mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-5674: Fixed cloudstackConnection.py to return FAILED in case of well handled exceptions returning from server having jobresultcode as 530
This commit is contained in:
parent
be73571c74
commit
aaa2f5932b
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
'''
|
||||
|
|
|
|||
Loading…
Reference in New Issue