AC-503 Add inventory->groups update interval. Appears as a dropdown with a seemingly reasonable list of choices.

This commit is contained in:
chouseknecht
2013-10-08 17:54:35 -04:00
parent 8510ce6bdc
commit 78e0d4c0f5
2 changed files with 96 additions and 19 deletions

View File

@@ -41,7 +41,8 @@ angular.module('GroupFormDefinition', [])
'default': '---', 'default': '---',
dataTitle: 'Group Variables', dataTitle: 'Group Variables',
dataPlacement: 'left', dataPlacement: 'left',
awPopOver: "<p>Variables defined here apply to all child groups and hosts. Enter variables using either JSON or YAML syntax. Use the " + awPopOver: "<p>Variables defined here apply to all child groups and hosts.</p>" +
"<p>Enter variables using either JSON or YAML syntax. Use the " +
"radio button to toggle between the two.</p>" + "radio button to toggle between the two.</p>" +
"JSON:<br />\n" + "JSON:<br />\n" +
"<blockquote>{<br />\"somevar\": \"somevalue\",<br />\"password\": \"magic\"<br /> }</blockquote>\n" + "<blockquote>{<br />\"somevar\": \"somevalue\",<br />\"password\": \"magic\"<br /> }</blockquote>\n" +
@@ -104,7 +105,12 @@ angular.module('GroupFormDefinition', [])
type: 'text', type: 'text',
ngShow: "source.value == 'rackspace' || source.value == 'ec2'", ngShow: "source.value == 'rackspace' || source.value == 'ec2'",
addRequired: false, addRequired: false,
editRequired: false editRequired: false,
dataTitle: 'Source Regions',
dataPlacement: 'left',
awPopOver: "<p>Comma separated list of regions. Region names must match those defined at the inventory source (i.e. ec2 or rackspace). " +
"Only hosts associated with the list of regions will be included in the update process.</p>",
dataContainer: 'body'
}, },
source_tags: { source_tags: {
label: 'Tags', label: 'Tags',
@@ -112,7 +118,12 @@ angular.module('GroupFormDefinition', [])
type: 'text', type: 'text',
ngShow: "source.value == 'ec2'", ngShow: "source.value == 'ec2'",
addRequired: false, addRequired: false,
editRequired: false editRequired: false,
dataTitle: 'Source Regions',
dataPlacement: 'left',
awPopOver: "<p>Comma separated list of tags. Tag names must match those defined at the inventory source (i.e. ec2 or rackspace)." +
" Only hosts associated with the list of tags will be included in the update process.</p>",
dataContainer: 'body'
}, },
source_vars: { source_vars: {
label: 'Source Variables', label: 'Source Variables',
@@ -126,8 +137,8 @@ angular.module('GroupFormDefinition', [])
parseTypeName: 'envParseType', parseTypeName: 'envParseType',
dataTitle: 'Source Variables', dataTitle: 'Source Variables',
dataPlacement: 'left', dataPlacement: 'left',
awPopOver: "<p>Define additional variables here that will be referenced by the inventory script at runtime. " + awPopOver: "<p>Define additional variables here that will be referenced by the inventory script at runtime.</p> " +
"Enter variables using either JSON or YAML syntax. Use the radio button to toggle between the two.</p>" + "<p>Enter variables using either JSON or YAML syntax. Use the radio button to toggle between the two.</p>" +
"JSON:<br />\n" + "JSON:<br />\n" +
"<blockquote>{<br />\"somevar\": \"somevalue\",<br />\"password\": \"magic\"<br /> }</blockquote>\n" + "<blockquote>{<br />\"somevar\": \"somevalue\",<br />\"password\": \"magic\"<br /> }</blockquote>\n" +
"YAML:<br />\n" + "YAML:<br />\n" +
@@ -137,6 +148,21 @@ angular.module('GroupFormDefinition', [])
dataContainer: 'body', dataContainer: 'body',
awPopOverRight: true awPopOverRight: true
}, },
update_interval: {
label: 'Update Interval',
type: 'select',
ngOptions: 'interval.label for interval in update_interval_options',
ngShow: "source.value !== '' && source.value !== null",
editRequired: false,
addRequired: false,
default: { label: 'none', value: null },
dataTitle: 'Update Interval',
dataPlacement: 'left',
awPopOver: "<p>Instruct the AWX server to automatically run the inventory update process the selected number of minutes from " +
"the last run.</p><p>With a value set, task manager will periodically compare the amount of elapsed time from the last run. If enough time " +
"has elapsed, it will go ahead and start an inventory update process.</p>",
dataContainer: 'body',
},
checkbox_group: { checkbox_group: {
label: 'Update Options', label: 'Update Options',
type: 'checkbox_group', type: 'checkbox_group',
@@ -154,8 +180,7 @@ angular.module('GroupFormDefinition', [])
dataTitle: 'Overwrite Hosts', dataTitle: 'Overwrite Hosts',
dataContainer: 'body', dataContainer: 'body',
dataPlacement: 'left', dataPlacement: 'left',
labelClass: 'checkbox-options', labelClass: 'checkbox-options'
inline: false
}, },
{ {
name: 'overwrite_vars', name: 'overwrite_vars',
@@ -168,8 +193,7 @@ angular.module('GroupFormDefinition', [])
dataTitle: 'Overwrite Variables', dataTitle: 'Overwrite Variables',
dataContainer: 'body', dataContainer: 'body',
dataPlacement: 'left', dataPlacement: 'left',
labelClass: 'checkbox-options', labelClass: 'checkbox-options'
inline: false
}, },
{ {
name: 'update_on_launch', name: 'update_on_launch',
@@ -182,8 +206,7 @@ angular.module('GroupFormDefinition', [])
dataTitle: 'Update on Launch', dataTitle: 'Update on Launch',
dataContainer: 'body', dataContainer: 'body',
dataPlacement: 'left', dataPlacement: 'left',
labelClass: 'checkbox-options', labelClass: 'checkbox-options'
inline: false
} }
] ]
} }

View File

@@ -12,12 +12,53 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
'InventoryHelper', 'SelectionHelper', 'JobSubmissionHelper', 'RefreshHelper' 'InventoryHelper', 'SelectionHelper', 'JobSubmissionHelper', 'RefreshHelper'
]) ])
.factory('getSourceTypeOptions', [ function() { .factory('GetSourceTypeOptions', [ function() {
return function() { return function() {
return [ return [
{ label: 'Manual', value: null }, { label: 'none', value: null },
{ label: 'Amazon EC2', value: 'ec2' }, { label: 'ec2', value: 'ec2' },
{ label: 'Rackspace', value: 'rackspace' } { label: 'rackspace', value: 'rackspace' }
];
}
}])
.factory('GetUpdateIntervalOptions', [ function() {
return function() {
return [
{ label: 'none', value: null },
{ label: '5 minutes', value: 5 },
{ label: '10 minutes', value: 10 },
{ label: '15 minutes', value: 15 },
{ label: '30 minutes', value: 30 },
{ label: '45 minutes', value: 45 },
{ label: '1 hour', value: 60 },
{ label: '2 hours', value: 120 },
{ label: '3 hours', value: 180 },
{ label: '4 hours', value: 240 },
{ label: '5 hours', value: 300 },
{ label: '6 hours', value: 360 },
{ label: '7 hours', value: 420 },
{ label: '8 hours', value: 480 },
{ label: '9 hours', value: 540 },
{ label: '10 hours', value: 600 },
{ label: '11 hours', value: 660 },
{ label: '12 hours', value: 720 },
{ label: '13 hours', value: 780 },
{ label: '14 hours', value: 840 },
{ label: '15 hours', value: 900 },
{ label: '16 hours', value: 960 },
{ label: '17 hours', value: 1020 },
{ label: '18 hours', value: 1080 },
{ label: '19 hours', value: 1140},
{ label: '20 hours', value: 1200 },
{ label: '21 hours', value: 1260 },
{ label: '22 hours', value: 1320 },
{ label: '23 hours', value: 1380 },
{ label: '24 hours', value: 1440 },
{ label: '48 hours', value: 1880 },
{ label: '72 hours', value: 4320 },
{ label: 'weekly (every 7 days)', value: 10080 },
{ label: 'monthly (every 30 days)', value: 43200 }
]; ];
} }
}]) }])
@@ -425,9 +466,10 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
}]) }])
.factory('GroupsEdit', ['$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'GroupForm', 'GenerateForm', .factory('GroupsEdit', ['$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'GroupForm', 'GenerateForm',
'Prompt', 'ProcessErrors', 'GetBasePath', 'RefreshGroupName', 'ParseTypeChange', 'getSourceTypeOptions', 'InventoryUpdate', 'Prompt', 'ProcessErrors', 'GetBasePath', 'RefreshGroupName', 'ParseTypeChange', 'GetSourceTypeOptions', 'InventoryUpdate',
'GetUpdateIntervalOptions',
function($rootScope, $location, $log, $routeParams, Rest, Alert, GroupForm, GenerateForm, Prompt, ProcessErrors, function($rootScope, $location, $log, $routeParams, Rest, Alert, GroupForm, GenerateForm, Prompt, ProcessErrors,
GetBasePath, RefreshGroupName, ParseTypeChange, getSourceTypeOptions, InventoryUpdate) { GetBasePath, RefreshGroupName, ParseTypeChange, GetSourceTypeOptions, InventoryUpdate, GetUpdateIntervalOptions) {
return function(params) { return function(params) {
var group_id = params.group_id; var group_id = params.group_id;
@@ -443,7 +485,8 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
var master = {}; var master = {};
var relatedSets = {}; var relatedSets = {};
scope.source_type_options = getSourceTypeOptions(); scope.source_type_options = GetSourceTypeOptions();
scope.update_interval_options = GetUpdateIntervalOptions();
scope.parseType = 'yaml'; scope.parseType = 'yaml';
scope[form.fields['source_vars'].parseTypeName] = 'yaml'; scope[form.fields['source_vars'].parseTypeName] = 'yaml';
scope.sourcePasswordRequired = false; scope.sourcePasswordRequired = false;
@@ -524,6 +567,16 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
} }
master['source'] = scope['source']; master['source'] = scope['source'];
} }
else if (fld == 'update_interval') {
if (data['update_interval'] == '') {
data['update_interval'] = null;
}
for (var i=0; i < scope.update_interval_options.length; i++) {
if (scope.update_interval_options[i].value == data['update_interval']) {
scope['update_interval'] = scope.update_interval_options[i];
}
}
}
else if (fld == 'source_vars') { else if (fld == 'source_vars') {
// Parse source_vars, converting to YAML. // Parse source_vars, converting to YAML.
if ($.isEmptyObject(data.source_vars) || data.source_vars == "\{\}" || if ($.isEmptyObject(data.source_vars) || data.source_vars == "\{\}" ||
@@ -598,7 +651,8 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
source_tags: scope['source_tags'], source_tags: scope['source_tags'],
overwrite: scope['overwrite'], overwrite: scope['overwrite'],
overwrite_vars: scope['overwrite_vars'], overwrite_vars: scope['overwrite_vars'],
update_on_launch: scope['update_on_launch'] update_on_launch: scope['update_on_launch'],
update_interval: scope['update_interval'].value
}; };
if (scope['source'].value == 'ec2') { if (scope['source'].value == 'ec2') {