Add thread in waiting delete vnf 05/94805/3
authorhewei-cmss <hewei@cmss.chinamobile.com>
Tue, 3 Sep 2019 08:14:58 +0000 (16:14 +0800)
committerhewei-cmss <hewei@cmss.chinamobile.com>
Tue, 3 Sep 2019 08:58:51 +0000 (16:58 +0800)
Issue-ID: VFC-1504

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

lcm/ns/biz/ns_terminate.py

index 30fbd4c..6bb444c 100644 (file)
@@ -133,17 +133,24 @@ class TerminateNsService(threading.Thread):
             JobUtil.add_job_status(self.job_id, cur_progress, job_msg)
             vnf_jobs.append((vnfinst.nfinstid, vnf_job_id))
 
+        thread = threading.Thread(
+            target=self.wait_delete_vnfs,
+            args=(vnf_jobs, cur_progress, step_progress,))
+        thread.start()
+
+    def wait_delete_vnfs(self, vnf_jobs, cur_progress, step_progress):
         for vnfinstid, vnfjobid in vnf_jobs:
             try:
                 cur_progress += step_progress
                 if not vnfjobid:
                     continue
                 is_job_ok = self.wait_delete_vnf_job_finish(vnfjobid)
-                msg = "%s to delete VNF(%s)" % ("Succeed" if is_job_ok else "Failed", vnfinstid)
+                msg = "%s to delete VNF(%s)" %\
+                      ("Succeed" if is_job_ok else "Failed", vnfinstid)
                 logger.debug(msg)
                 JobUtil.add_job_status(self.job_id, cur_progress, msg)
             except Exception as e:
-                msg = "Exception occurs when delete VNF(%s)" % vnfinstid
+                msg = "Exception occurs(%s) when delete VNF(%s)" % (e, vnfinstid)
                 logger.debug(msg)
                 JobUtil.add_job_status(self.job_id, cur_progress, msg)