cloudstack: add error result handling in async job

This commit is contained in:
Rene Moser 2015-04-02 00:41:07 +02:00 committed by James Cammarata
parent f5b00084e1
commit 0a26b149fc

View file

@ -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)