Rm port inst data from db when terminate vnf
[vfc/nfvo/lcm.git] / lcm / ns_vnfs / biz / terminate_nfs.py
index 8f9f5ec..397460e 100644 (file)
@@ -18,7 +18,7 @@ import threading
 import traceback
 
 from lcm.pub.config.config import REPORT_TO_AAI
-from lcm.pub.database.models import NfInstModel, VmInstModel, OOFDataModel
+from lcm.pub.database.models import NfInstModel, VmInstModel, OOFDataModel, PortInstModel
 from lcm.pub.exceptions import NSLCMException
 from lcm.pub.msapi import resmgr
 from lcm.pub.msapi.aai import query_vnf_aai, delete_vnf_aai, query_vserver_aai, delete_vserver_aai
@@ -92,6 +92,7 @@ class TerminateVnfs(threading.Thread):
         vnf_inst_info = self.get_vnf_inst()
         if not vnf_inst_info:
             self.add_progress(100, "TERM_VNF_NOT_EXIST_SUCCESS", "finished")
+            return None
         self.add_progress(2, "GET_VNF_INST_SUCCESS")
         self.vnfm_inst_id = vnf_inst_info.vnfm_inst_id
         self.vnf_uuid = vnf_inst_info.mnfinstid
@@ -139,11 +140,12 @@ class TerminateVnfs(threading.Thread):
 
     def delete_subscription(self):
         try:
-            SubscriptionDeletion(self.vnfm_inst_id, self.vnf_inst_id).do_biz()
+            SubscriptionDeletion(self.vnfm_inst_id, self.vnf_uuid).do_biz()
         except Exception as e:
             logger.error("delete_subscription failed: %s", e.args[0])
 
     def delete_data_from_db(self):
+        PortInstModel.objects.filter(instid=self.vnf_inst_id).delete()
         NfInstModel.objects.filter(nfinstid=self.vnf_inst_id).delete()
         VmInstModel.objects.filter(instid=self.vnf_inst_id).delete()
         OOFDataModel.objects.filter(service_resource_id=self.vnf_inst_id).delete()