1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-31 23:51:09 +03:00

Support populating extra vars with post data when launching and

relaunching jobs
This commit is contained in:
Matthew Jones 2014-09-26 15:46:45 -04:00
parent d8fe8cc7ff
commit eabfbd572f
2 changed files with 10 additions and 0 deletions

View File

@ -444,6 +444,11 @@ class Job(UnifiedJob, JobOptions):
dependencies.append(source.create_inventory_update(launch_type='dependency'))
return dependencies
def handle_extra_data(self, extra_data):
evars = json.loads(self.extra_vars)
evars.update(extra_data)
self.update_fields(extra_vars=json.dumps(evars))
def copy(self):
presets = {}
for kw in self.job_template._get_unified_job_field_names():

View File

@ -567,6 +567,9 @@ class UnifiedJob(PolymorphicModel, PasswordFieldsModel, CommonModelNameNotUnique
def get_passwords_needed_to_start(self):
return []
def handle_extra_data(self, extra_data):
return
@property
def can_start(self):
return bool(self.status in ('new', 'waiting'))
@ -631,6 +634,8 @@ class UnifiedJob(PolymorphicModel, PasswordFieldsModel, CommonModelNameNotUnique
opts = dict([(field, kwargs.get(field, '')) for field in needed])
if not all(opts.values()):
return False
extra_data = dict([(field, kwargs[field]) for field in kwargs if field not in needed])
self.handle_extra_data(extra_data)
self.update_fields(start_args=json.dumps(kwargs), status='pending')
self.socketio_emit_status("pending")
task_type = get_type_for_model(self)