Fail on launch for scenario where job cannot run

This commit is contained in:
AlanCoding 2020-02-27 14:37:29 -05:00
parent 16ecf17c69
commit 07807c2dec
No known key found for this signature in database
GPG Key ID: FD2C3C012A72926B

View File

@ -4054,6 +4054,13 @@ class JobLaunchSerializer(BaseSerializer):
**attrs)
self._ignored_fields = rejected
# Basic validation - cannot run a playbook without a playbook
if not template.project:
errors['project'] = _("A project is required to run a job.")
elif template.project.status in ('error', 'failed'):
errors['playbook'] = _("Missing a revision to run due to failed project update.")
# cannot run a playbook without an inventory
if template.inventory and template.inventory.pending_deletion is True:
errors['inventory'] = _("The inventory associated with this Job Template is being deleted.")
elif 'inventory' in accepted and accepted['inventory'].pending_deletion: