Modify toscalutil of gvnfm vnflcm
[vfc/gvnfm/vnflcm.git] / lcm / lcm / nf / vnfs / vnf_create / inst_vnf.py
index 9760381..d6e06a5 100644 (file)
@@ -38,6 +38,7 @@ class InstVnf(Thread):
         self.data = data
         self.nf_inst_id = nf_inst_id
         self.job_id = job_id
+        self.vnfd_id = ''
         self.nfvo_inst_id = ''
         self.vnfm_inst_id = ''
         self.csar_id = ''
@@ -59,11 +60,8 @@ class InstVnf(Thread):
             JobUtil.add_job_status(self.job_id, 100, "Instantiate Vnf success.")
         except NFLCMException as e:
             self.vnf_inst_failed_handle(e.message)
-            # self.rollback(e.message)
         except:
             self.vnf_inst_failed_handle('unexpected exception')
-            logger.error(traceback.format_exc())
-            # self.rollback('unexpected exception')
 
     def inst_pre(self):
         vnf_insts = NfInstModel.objects.filter(nfinstid=self.nf_inst_id)
@@ -76,9 +74,13 @@ class InstVnf(Thread):
 
         JobUtil.add_job_status(self.job_id, 5, 'Get packageinfo by vnfd_id')
         # get csar_id from nslcm by vnfd_id
-        self.package_info = get_packageinfo_by_vnfdid(vnf_insts[0].vnfdid)
-        self.package_id = ignore_case_get(self.package_info, "package_id")
-        self.csar_id = ignore_case_get(self.package_info, "csar_id")
+        self.vnfd_id = vnf_insts[0].vnfdid
+        self.package_info = get_packageinfo_by_vnfdid(self.vnfd_id)
+        for val in self.package_info:
+            if self.vnfd_id == ignore_case_get(val, "vnfd_id"):
+                self.package_id = ignore_case_get(val, "package_id")
+                self.csar_id = ignore_case_get(val, "csar_id")
+                break
 
         JobUtil.add_job_status(self.job_id, 10, 'Get rawdata from catalog by csar_id')
         # get rawdata from catalog by csar_id
@@ -208,11 +210,8 @@ class InstVnf(Thread):
             }
         logger.info('content_args=%s' % content_args)
         # call rest api
-        resp = notify_lcm_to_nfvo(content_args, self.nf_inst_id)
+        resp = notify_lcm_to_nfvo(content_args)
         logger.info('[NF instantiation] get lcm response %s' % resp)
-        if resp[0] != 0:
-            logger.error("notify lifecycle to nfvo failed.[%s]" % resp[1])
-            raise NFLCMException("send notify request to nfvo failed")
         logger.info('[NF instantiation] send notify request to nfvo end')
 
     # def load_nfvo_config(self):