Make it so that we take source_vars with the custom inventory script

when defining the inventory source.  Slight modification to the UI to
make that possible
This commit is contained in:
Matthew Jones
2014-10-14 15:38:42 -04:00
parent 8b8fb2403c
commit c43a7be99e
3 changed files with 9 additions and 5 deletions

View File

@@ -1044,6 +1044,10 @@ class RunInventoryUpdate(BaseTask):
elif inventory_update.source == 'file': elif inventory_update.source == 'file':
# FIXME: Parse source_env to dict, update env. # FIXME: Parse source_env to dict, update env.
pass pass
elif inventory_update.source == 'custom':
for env_k in inventory_update.source_vars_dict:
if env_k not in os.environ:
env[env_k] = inventory_update.source_vars_dict[env_k]
return env return env
def build_args(self, inventory_update, **kwargs): def build_args(self, inventory_update, **kwargs):

View File

@@ -42,7 +42,7 @@ angular.module('SourceFormDefinition', [])
credential: { credential: {
label: 'Cloud Credential', label: 'Cloud Credential',
type: 'lookup', type: 'lookup',
ngShow: "source && source.value !== ''", ngShow: "source && source.value !== '' && source.value !== 'custom'",
sourceModel: 'credential', sourceModel: 'credential',
sourceField: 'name', sourceField: 'name',
ngClick: 'lookUpCredential()', ngClick: 'lookUpCredential()',
@@ -65,7 +65,7 @@ angular.module('SourceFormDefinition', [])
}, },
source_vars: { source_vars: {
label: 'Source Variables', label: 'Source Variables',
ngShow: "source && (source.value == 'file' || source.value == 'ec2')", ngShow: "source && (source.value == 'file' || source.value == 'ec2' || source.value == 'custom')",
type: 'textarea', type: 'textarea',
addRequired: false, addRequired: false,
editRequird: false, editRequird: false,

View File

@@ -268,7 +268,7 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
field: 'credential', field: 'credential',
input_type: "radio" input_type: "radio"
}); });
if ($('#group_tabs .active a').text() === 'Source' && scope.source.value === 'ec2') { if ($('#group_tabs .active a').text() === 'Source' && (scope.source.value === 'ec2' || scope.source.value == 'custom')) {
callback = function(){ Wait('stop'); }; callback = function(){ Wait('stop'); };
Wait('start'); Wait('start');
scope.source_vars = (Empty(scope.source_vars)) ? "---" : scope.source_vars; scope.source_vars = (Empty(scope.source_vars)) ? "---" : scope.source_vars;
@@ -831,7 +831,7 @@ function($compile, SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize, Sched
setTimeout(function(){ textareaResize('group_variables'); }, 300); setTimeout(function(){ textareaResize('group_variables'); }, 300);
} }
else if ($(e.target).text() === 'Source') { else if ($(e.target).text() === 'Source') {
if (sources_scope.source && sources_scope.source.value === 'ec2') { if (sources_scope.source && (sources_scope.source.value === 'ec2' || sources_scope.source.value === 'custom')) {
Wait('start'); Wait('start');
ParseTypeChange({ scope: sources_scope, variable: 'source_vars', parse_variable: SourceForm.fields.source_vars.parseTypeName, ParseTypeChange({ scope: sources_scope, variable: 'source_vars', parse_variable: SourceForm.fields.source_vars.parseTypeName,
field_id: 'source_source_vars', onReady: waitStop }); field_id: 'source_source_vars', onReady: waitStop });
@@ -1141,7 +1141,7 @@ function($compile, SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize, Sched
} }
data.source_regions = r.join(); data.source_regions = r.join();
if (sources_scope.source && sources_scope.source.value === 'ec2') { if (sources_scope.source && (sources_scope.source.value === 'ec2' || sources_scope.source.value === 'custom')) {
// for ec2, validate variable data // for ec2, validate variable data
data.source_vars = ToJSON(sources_scope.envParseType, sources_scope.source_vars, true); data.source_vars = ToJSON(sources_scope.envParseType, sources_scope.source_vars, true);
} }