Make Inventory and Project required when initially launching.

This prevents the scenario where an inactive-but-present project or
inventory on a job template would carry on even when we wouldn't want
it to
This commit is contained in:
Matthew Jones
2015-01-21 11:05:14 -05:00
parent bb5f3243e3
commit 873afd64d2
2 changed files with 27 additions and 0 deletions

View File

@@ -1458,6 +1458,10 @@ class JobTemplateLaunch(GenericAPIView):
status=status.HTTP_400_BAD_REQUEST)
if obj.credential is None and ('credential' not in request.DATA and 'credential_id' not in request.DATA):
return Response(dict(errors="Credential not provided"), status=status.HTTP_400_BAD_REQUEST)
if obj.project is None or not obj.project.active:
return Response(dict(errors="Job Template Project is missing or undefined"), status=status.HTTP_400_BAD_REQUEST)
if obj.inventory is None or not obj.inventory.active:
return Response(dict(errors="Job Template Inventory is missing or undefined"), status=status.HTTP_400_BAD_REQUEST)
new_job = obj.create_unified_job(**request.DATA)
result = new_job.signal_start(**request.DATA)
if not result: