diff options
Diffstat (limited to 'lcm/ns/biz/ns_heal.py')
-rw-r--r-- | lcm/ns/biz/ns_heal.py | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/lcm/ns/biz/ns_heal.py b/lcm/ns/biz/ns_heal.py index 096561e0..19994dfa 100644 --- a/lcm/ns/biz/ns_heal.py +++ b/lcm/ns/biz/ns_heal.py @@ -21,12 +21,12 @@ import traceback from lcm.ns.enum import NS_INST_STATUS from lcm.pub.database.models import JobModel, NSInstModel, NfInstModel, VNFCInstModel, VmInstModel from lcm.pub.exceptions import NSLCMException -from lcm.pub.utils.jobutil import JobUtil, JOB_MODEL_STATUS +from lcm.pub.utils.jobutil import JobUtil +from lcm.pub.enum import JOB_MODEL_STATUS, JOB_PROGRESS from lcm.pub.utils.values import ignore_case_get from lcm.ns_vnfs.biz.heal_vnfs import NFHealService from lcm.ns.biz.ns_lcm_op_occ import NsLcmOpOcc -JOB_ERROR = 255 logger = logging.getLogger(__name__) @@ -44,11 +44,11 @@ class NSHealService(threading.Thread): try: self.do_biz() except NSLCMException as e: - JobUtil.add_job_status(self.job_id, JOB_ERROR, e.message) + JobUtil.add_job_status(self.job_id, JOB_PROGRESS.ERROR, e.message) NsLcmOpOcc.update(self.occ_id, operationState="FAILED", error=e.message) except Exception as e: logger.error(traceback.format_exc()) - JobUtil.add_job_status(self.job_id, JOB_ERROR, 'ns heal fail') + JobUtil.add_job_status(self.job_id, JOB_PROGRESS.ERROR, 'ns heal fail') NsLcmOpOcc.update(self.occ_id, operationState="FAILED", error=e.message) def do_biz(self): @@ -64,7 +64,6 @@ class NSHealService(threading.Thread): ns_info = NSInstModel.objects.filter(id=self.ns_instance_id) if not ns_info: errmsg = 'NS [id=%s] does not exist' % self.ns_instance_id - logger.error(errmsg) raise NSLCMException(errmsg) self.heal_ns_data = ignore_case_get(self.request_data, 'healNsData') @@ -77,7 +76,6 @@ class NSHealService(threading.Thread): if not self.heal_ns_data and not self.heal_vnf_data: errmsg = 'healNsData and healVnfData parameters does not exist or value is incorrect.' - logger.error(errmsg) raise NSLCMException(errmsg) def do_heal(self): @@ -89,7 +87,6 @@ class NSHealService(threading.Thread): self.update_job(90, desc='nf[%s] heal handle end' % vnf_heal_params.get('vnfInstanceId')) else: errmsg = 'nf heal failed' - logger.error(errmsg) raise NSLCMException(errmsg) else: ns_heal_params = self.prepare_ns_heal_params(self.heal_ns_data) @@ -194,9 +191,9 @@ class NSHealService(threading.Thread): job_result = JobModel.objects.get(jobid=sub_job_id) time.sleep(query_interval) end_time = datetime.datetime.now() - if job_result.progress == 100: + if job_result.progress == JOB_PROGRESS.FINISHED: return JOB_MODEL_STATUS.FINISHED - elif job_result.progress > 100: + elif job_result.progress > JOB_PROGRESS.FINISHED: return JOB_MODEL_STATUS.ERROR else: continue |