diff --git a/tools/marvin/marvin/cloudstackConnection.py b/tools/marvin/marvin/cloudstackConnection.py index 8044da7ec66..1ff8381a431 100644 --- a/tools/marvin/marvin/cloudstackConnection.py +++ b/tools/marvin/marvin/cloudstackConnection.py @@ -21,26 +21,18 @@ import base64 import hmac import hashlib import time -from cloudstackAPI import * +from cloudstackAPI import queryAsyncJobResult import jsonHelper from marvin.codes import ( FAILED, - INVALID_RESPONSE, - INVALID_INPUT, JOB_FAILED, - JOB_INPROGRESS, JOB_CANCELLED, - JOB_SUCCEEDED + JOB_SUCCEEDED, + JOB_NO_EXCEPTION, + JOB_EXCEPTION_OCCURED ) -from requests import ( - ConnectionError, - HTTPError, - Timeout, - RequestException -) -from marvin.cloudstackException import ( - InvalidParameterException, - GetDetailExceptionInfo) +from marvin.cloudstackException import (GetDetailExceptionInfo, + InvalidParameterException) class CSConnection(object): @@ -100,6 +92,7 @@ class CSConnection(object): start_time = time.time() end_time = time.time() async_response = FAILED + jobresultcode = JOB_NO_EXCEPTION self.logger.debug("=== Jobid: %s Started ===" % (str(jobid))) while timeout > 0: async_response = self.\ @@ -109,6 +102,7 @@ class CSConnection(object): if job_status in [JOB_FAILED, JOB_CANCELLED, JOB_SUCCEEDED]: + jobresultcode = async_response.jobresultcode break time.sleep(5) timeout -= 5 @@ -122,6 +116,8 @@ class CSConnection(object): "TotalTime:%s===" % (str(jobid), str(time.ctime(start_time)), str(time.ctime(end_time)), str(tot_time))) + if jobresultcode == JOB_EXCEPTION_OCCURED: + async_response = FAILED return async_response except Exception as e: self.__lastError = e diff --git a/tools/marvin/marvin/codes.py b/tools/marvin/marvin/codes.py index ef49c0c3c8f..0619374bf72 100644 --- a/tools/marvin/marvin/codes.py +++ b/tools/marvin/marvin/codes.py @@ -60,6 +60,8 @@ JOB_INPROGRESS = 0 JOB_SUCCEEDED = 1 JOB_FAILED = 2 JOB_CANCELLED = 3 +JOB_EXCEPTION_OCCURED = 530 +JOB_NO_EXCEPTION = 0 ''' User Related Codes '''