modify ns terminate 17/97017/1
authorhewei-cmss <hewei@cmss.chinamobile.com>
Mon, 14 Oct 2019 01:35:48 +0000 (09:35 +0800)
committerhewei-cmss <hewei@cmss.chinamobile.com>
Mon, 14 Oct 2019 01:35:48 +0000 (09:35 +0800)
Issue-ID: VFC-1504

Signed-off-by: hewei-cmss <hewei@cmss.chinamobile.com>
Change-Id: I029e720ec6a984d976cc3bd17b7e5257e4ea407b

lcm/ns/biz/ns_terminate.py

index 6bb444c..06e84b7 100644 (file)
@@ -28,6 +28,8 @@ from lcm.ns.enum import OWNER_TYPE
 from lcm.pub.database.models import PNFInstModel
 from lcm.ns.biz.ns_lcm_op_occ import NsLcmOpOcc
 from lcm.jobs.enum import JOB_PROGRESS
+from lcm.ns.enum import NS_INST_STATUS
+from lcm.workflows import build_in
 
 logger = logging.getLogger(__name__)
 
@@ -48,6 +50,7 @@ class TerminateNsService(threading.Thread):
                 NsLcmOpOcc.update(self.occ_id, "COMPLETED")
                 return
             JobUtil.add_job_status(self.job_id, 10, "Starting terminate...", '')
+            NSInstModel.objects.filter(id=self.ns_inst_id).update(status=NS_INST_STATUS.TERMINATING)
 
             self.cancel_sfc_list()
             self.cancel_vnf_list()
@@ -60,11 +63,13 @@ class TerminateNsService(threading.Thread):
         except NSLCMException as e:
             JobUtil.add_job_status(self.job_id, JOB_PROGRESS.ERROR, e.args[0])
             NsLcmOpOcc.update(self.occ_id, operationState="FAILED", error=e.args[0])
+            build_in.post_deal(self.ns_inst_id, "false")
         except Exception as e:
             logger.error(e.args[0])
             logger.error(traceback.format_exc())
             JobUtil.add_job_status(self.job_id, JOB_PROGRESS.ERROR, "ns terminate fail.")
             NsLcmOpOcc.update(self.occ_id, operationState="FAILED", error=e.args[0])
+            build_in.post_deal(self.ns_inst_id, "false")
 
     def cancel_vl_list(self):
         array_vlinst = VLInstModel.objects.filter(ownertype=OWNER_TYPE.NS, ownerid=self.ns_inst_id)