X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=lcm%2Flcm%2Fnf%2Fbiz%2Fupdate_vnf.py;h=0dfaa7555ea1b9731ac63aa4761436e794180918;hb=46ad7c172411214c5432ed93fda4271288077447;hp=bc9ee0f28d822a862005fe690eb5bb646e040ee8;hpb=e0904a046f222082399d5d5e5518fe7aa297cb53;p=vfc%2Fgvnfm%2Fvnflcm.git diff --git a/lcm/lcm/nf/biz/update_vnf.py b/lcm/lcm/nf/biz/update_vnf.py index bc9ee0f2..0dfaa755 100644 --- a/lcm/lcm/nf/biz/update_vnf.py +++ b/lcm/lcm/nf/biz/update_vnf.py @@ -19,10 +19,12 @@ from lcm.pub.database.models import NfInstModel from lcm.pub.exceptions import NFLCMException from lcm.nf.const import OPERATION_STATE_TYPE from lcm.nf.const import OPERATION_TYPE +from lcm.nf.const import OPERATION_TASK from lcm.pub.utils.notificationsutil import NotificationsUtil from lcm.pub.utils.notificationsutil import prepare_notification from lcm.pub.utils.jobutil import JobUtil from lcm.pub.utils.timeutil import now_time +from .operate_vnf_lcm_op_occ import VnfLcmOpOcc logger = logging.getLogger(__name__) @@ -34,11 +36,18 @@ class UpdateVnf(Thread): self.nf_inst_id = instanceid self.job_id = job_id self.vnf_insts = NfInstModel.objects.filter(nfinstid=instanceid) + self.lcm_op_occ = VnfLcmOpOcc( + vnf_inst_id=instanceid, + lcm_op_id=job_id, + operation=OPERATION_TYPE.MODIFY_INFO, + task=OPERATION_TASK.MODIFY + ) def run(self): logger.debug("start update for vnf %s", self.nf_inst_id) key = "vnfInstanceName" try: + self.lcm_op_occ.notify_lcm(OPERATION_STATE_TYPE.PROCESSING) JobUtil.add_job_status(self.job_id, 50, "Start updating VNF.") if key in self.data and self.data[key] is not None: @@ -60,12 +69,14 @@ class UpdateVnf(Thread): JobUtil.add_job_status(self.job_id, 100, "Update VNF success.") except NFLCMException as e: - logger.error(e.message) - JobUtil.add_job_status(self.job_id, 255, e.message) + logger.error(e.args[0]) + self.lcm_op_occ.notify_lcm(OPERATION_STATE_TYPE.FAILED, e.args[0]) + JobUtil.add_job_status(self.job_id, 255, e.args[0]) except Exception as e: - logger.error(e.message) + logger.error(e.args[0]) logger.error(traceback.format_exc()) - JobUtil.add_job_status(self.job_id, 255, e.message) + self.lcm_op_occ.notify_lcm(OPERATION_STATE_TYPE.FAILED, e.args[0]) + JobUtil.add_job_status(self.job_id, 255, e.args[0]) def send_notification(self): notify_data = prepare_notification(nfinstid=self.nf_inst_id,