mirror of
https://github.com/ansible/awx.git
synced 2026-05-17 14:27:42 -02:30
Make credential required when launching job template if it isn't
provided on the job template
This commit is contained in:
@@ -1480,11 +1480,13 @@ class JobTemplateLaunch(GenericAPIView):
|
|||||||
if validation_errors:
|
if validation_errors:
|
||||||
return Response(dict(errors=validation_errors),
|
return Response(dict(errors=validation_errors),
|
||||||
status=status.HTTP_400_BAD_REQUEST)
|
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)
|
||||||
new_job = obj.create_unified_job(**request.DATA)
|
new_job = obj.create_unified_job(**request.DATA)
|
||||||
result = new_job.signal_start(**request.DATA)
|
result = new_job.signal_start(**request.DATA)
|
||||||
if not result:
|
if not result:
|
||||||
data = dict(passwords_needed_to_start=new_job.passwords_needed_to_start)
|
data = dict(passwords_needed_to_start=new_job.passwords_needed_to_start)
|
||||||
# TODO, this scenario leaves an orphaned "new" job. Should we delete it?
|
new_job.delete()
|
||||||
return Response(data, status=status.HTTP_400_BAD_REQUEST)
|
return Response(data, status=status.HTTP_400_BAD_REQUEST)
|
||||||
else:
|
else:
|
||||||
data = dict(job=new_job.id)
|
data = dict(job=new_job.id)
|
||||||
|
|||||||
Reference in New Issue
Block a user