From c43a7be99e79743df5528b643eaed642d2e912e3 Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Tue, 14 Oct 2014 15:38:42 -0400 Subject: [PATCH] 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 --- awx/main/tasks.py | 4 ++++ awx/ui/static/js/forms/Source.js | 4 ++-- awx/ui/static/js/helpers/Groups.js | 6 +++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/awx/main/tasks.py b/awx/main/tasks.py index b81eb1242d..f406a001e6 100644 --- a/awx/main/tasks.py +++ b/awx/main/tasks.py @@ -1044,6 +1044,10 @@ class RunInventoryUpdate(BaseTask): elif inventory_update.source == 'file': # FIXME: Parse source_env to dict, update env. 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 def build_args(self, inventory_update, **kwargs): diff --git a/awx/ui/static/js/forms/Source.js b/awx/ui/static/js/forms/Source.js index ca4b225302..cd78c8c793 100644 --- a/awx/ui/static/js/forms/Source.js +++ b/awx/ui/static/js/forms/Source.js @@ -42,7 +42,7 @@ angular.module('SourceFormDefinition', []) credential: { label: 'Cloud Credential', type: 'lookup', - ngShow: "source && source.value !== ''", + ngShow: "source && source.value !== '' && source.value !== 'custom'", sourceModel: 'credential', sourceField: 'name', ngClick: 'lookUpCredential()', @@ -65,7 +65,7 @@ angular.module('SourceFormDefinition', []) }, source_vars: { label: 'Source Variables', - ngShow: "source && (source.value == 'file' || source.value == 'ec2')", + ngShow: "source && (source.value == 'file' || source.value == 'ec2' || source.value == 'custom')", type: 'textarea', addRequired: false, editRequird: false, diff --git a/awx/ui/static/js/helpers/Groups.js b/awx/ui/static/js/helpers/Groups.js index 4228ff8ead..0f72872710 100644 --- a/awx/ui/static/js/helpers/Groups.js +++ b/awx/ui/static/js/helpers/Groups.js @@ -268,7 +268,7 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', ' field: 'credential', 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'); }; Wait('start'); 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); } 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'); ParseTypeChange({ scope: sources_scope, variable: 'source_vars', parse_variable: SourceForm.fields.source_vars.parseTypeName, field_id: 'source_source_vars', onReady: waitStop }); @@ -1141,7 +1141,7 @@ function($compile, SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize, Sched } 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 data.source_vars = ToJSON(sources_scope.envParseType, sources_scope.source_vars, true); }