From 318da8522fe176496c7ac7da7d708054858d3485 Mon Sep 17 00:00:00 2001 From: Jared Tabor Date: Wed, 17 Dec 2014 17:27:48 -0500 Subject: [PATCH] Passing vars to API via extra_vars in job launch We changed this at one point to have all vars passed on the root level, but for uniformity we have changed it back to using the extra_vars object --- awx/ui/static/js/helpers/JobSubmission.js | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/awx/ui/static/js/helpers/JobSubmission.js b/awx/ui/static/js/helpers/JobSubmission.js index 51c4b6121c..47ee634a0d 100644 --- a/awx/ui/static/js/helpers/JobSubmission.js +++ b/awx/ui/static/js/helpers/JobSubmission.js @@ -25,25 +25,28 @@ angular.module('JobSubmissionHelper', [ 'RestServices', 'Utilities', 'Credential extra_vars; - if(!Empty(scope.passwords_needed_to_start) && scope.passwords_needed_to_start .length>0){ + if(!Empty(scope.passwords_needed_to_start) && scope.passwords_needed_to_start.length>0){ scope.passwords.forEach(function(password) { job_launch_data[password] = scope[password]; + scope.passwords_needed_to_start.push(password+'_confirm'); // i'm pushing these values into this array for use during the survey taker parsing }); } if(scope.prompt_for_vars===true){ extra_vars = ToJSON(scope.parseType, scope.extra_vars, false); - $.each(extra_vars, function(key,value){ - job_launch_data[key] = value; - }); + // $.each(extra_vars, function(key,value){ + // job_launch_data[key] = value; + // }); + job_launch_data.extra_vars = (extra_vars===null) ? {} : extra_vars; } if(scope.survey_enabled===true){ + job_launch_data.extra_vars = (!job_launch_data.extra_vars || job_launch_data.extra_vars===null) ? {} : job_launch_data.extra_vars; for (fld in scope.job_launch_form){ - if(scope[fld] || scope[fld] === 0){ - job_launch_data[fld] = scope[fld]; + if((scope[fld] || scope[fld] === 0) && scope.passwords_needed_to_start.indexOf(fld) === -1){ + job_launch_data.extra_vars[fld] = scope[fld]; } } } - delete(job_launch_data.extra_vars); + // delete(job_launch_data.extra_vars); if(!Empty(scope.credential)){ job_launch_data.credential_id = scope.credential; } @@ -754,7 +757,7 @@ function($location, Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialLi Rest.setUrl(GetBasePath('credentials')+credential); Rest.get() .success(function (data) { - if(data.ssh_key_unlock === "ASK"){ + if((data.kind === "ssh" && data.password === "ASK" ) || data.ssh_key_unlock === "ASK"){ passwords.push("ssh_password"); } if(data.sudo_password === "ASK"){ @@ -767,6 +770,7 @@ function($location, Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialLi passwords.push("vault_password"); } if(passwords.length>0){ + scope.passwords_needed_to_start = passwords; scope.$emit('PromptForPasswords', passwords, html, url); } else if (scope.ask_variables_on_launch){ @@ -796,7 +800,7 @@ function($location, Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialLi scope.prompt_for_vars = data.ask_variables_on_launch; scope.survey_enabled = data.survey_enabled; scope.ask_variables_on_launch = data.ask_variables_on_launch; - + scope.variables_needed_to_start = data.variables_needed_to_start; html = '
'; if(data.credential_needed_to_start === true){