Commit 0a26b149 by Rene Moser Committed by James Cammarata

cloudstack: add error result handling in async job

parent f5b00084
......@@ -185,8 +185,10 @@ class AnsibleCloudStack:
if 'jobid' in job:
while True:
res = self.cs.queryAsyncJobResult(jobid=job['jobid'])
if res['jobstatus'] != 0:
if 'jobresult' in res and key is not None and key in res['jobresult']:
if res['jobstatus'] != 0 and 'jobresult' in res:
if 'errortext' in res['jobresult']:
self.module.fail_json(msg="Failed: '%s'" % res['jobresult']['errortext'])
if key and key in res['jobresult']:
job = res['jobresult'][key]
break
time.sleep(2)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment