mirror of
https://github.com/ansible/awx.git
synced 2026-02-28 08:18:43 -03:30
Basic support for job start/cancel via REST API with supporting tests.
This commit is contained in:
@@ -115,7 +115,7 @@ class JobAdminForm(JobTemplateAdminForm):
|
||||
if self.instance.pk and self.instance.status != 'new':
|
||||
self.fields.pop('playbook', None)
|
||||
if (not self.data or self.data.get('start_job', '')) and \
|
||||
self.instance.credential and self.instance.status == 'new':
|
||||
self.instance.credential and self.instance.can_start:
|
||||
for field in self.instance.get_passwords_needed_to_start():
|
||||
if field not in self.fields:
|
||||
continue
|
||||
@@ -128,7 +128,7 @@ class JobAdminForm(JobTemplateAdminForm):
|
||||
return self.cleaned_data.get('cancel_job', False)
|
||||
|
||||
def clean(self):
|
||||
if self.instance.credential and self.instance.status == 'new':
|
||||
if self.instance.credential and self.instance.can_start:
|
||||
for field in self.instance.get_passwords_needed_to_start():
|
||||
if field in self.fields:
|
||||
self.fields[field].required = True
|
||||
@@ -138,7 +138,7 @@ class JobAdminForm(JobTemplateAdminForm):
|
||||
instance = super(JobAdminForm, self).save(commit)
|
||||
save_m2m = getattr(self, 'save_m2m', lambda: None)
|
||||
should_start = bool(self.cleaned_data.get('start_job', '') and
|
||||
instance.status == 'new')
|
||||
instance.can_start)
|
||||
start_opts = {}
|
||||
for field in ('ssh_password', 'sudo_password', 'ssh_key_unlock'):
|
||||
value = self.cleaned_data.get(field, '')
|
||||
@@ -146,7 +146,7 @@ class JobAdminForm(JobTemplateAdminForm):
|
||||
start_opts[field] = value
|
||||
#print 'should_start', should_start
|
||||
should_cancel = bool(self.cleaned_data.get('cancel_job', '') and
|
||||
instance.status in ('new', 'pending'))
|
||||
instance.can_cancel)
|
||||
def new_save_m2m():
|
||||
save_m2m()
|
||||
if should_start:
|
||||
|
||||
Reference in New Issue
Block a user