Modify table module and related code
[vfc/gvnfm/vnflcm.git] / lcm / lcm / nf / vnfs / vnf_create / inst_vnf.py
index 17b45ba..b9bc15a 100644 (file)
@@ -85,12 +85,10 @@ class InstVnf(Thread):
             self.inst_pre()
             self.apply_grant()
             self.create_res()
-            # self.check_res_status()
-            # self.wait_inst_finish(args)
             self.lcm_notify()
             JobUtil.add_job_status(self.job_id, 100, "Instantiate Vnf success.")
-            is_exist = JobStatusModel.objects.filter(jobid=self.job_id).exists()
-            logger.debug("check_ns_inst_name_exist::is_exist=%s" % is_exist)
+            is_exist = JobStatusModel.objects.filter(jobid=self.job_id).exists()
+            logger.debug("check_ns_inst_name_exist::is_exist=%s" % is_exist)
         except NFLCMException as e:
             self.vnf_inst_failed_handle(e.message)
             # self.rollback(e.message)
@@ -105,7 +103,7 @@ class InstVnf(Thread):
             raise NFLCMException('VNF nf_inst_id is not exist.')
 
         # self.vnfm_inst_id = vnf_insts[0].vnfm_inst_id
-        if vnf_insts[0].instantiationState != 'NOT_INSTANTIATED':
+        if vnf_insts[0].status != 'NOT_INSTANTIATED':
             raise NFLCMException('VNF instantiationState is not NOT_INSTANTIATED.')
 
         # get rawdata by vnfd_id
@@ -228,16 +226,6 @@ class InstVnf(Thread):
     #     # self.add_job(43, 'INST_DPLY_VM_PRGS')
     #     logger.info("[NF instantiation] confirm all vms are active end")
 
-    # def wait_inst_finish(self, args):
-    #     try:
-    #         logger.info('wait_inst_finish, args=%s' % args)
-    #         # WaitInstFinishTask(args).do_biz()
-    #         return {'result': '100', 'msg': 'Nf instancing wait finish', 'context': {}}
-    #     except Exception as e:
-    #         logger.error('Nf instancing wait exception=%s' % e.message)
-    #         logger.error(traceback.format_exc())
-    #         return {'result': '255', 'msg': 'Nf instancing wait exception', 'context': {}}
-
     def lcm_notify(self):
         logger.info('[NF instantiation] send notify request to nfvo start')
         reg_info = NfvoRegInfoModel.objects.filter(vnfminstid=self.vnfm_inst_id).first()
@@ -345,16 +333,6 @@ class InstVnf(Thread):
             raise NFLCMException("send notify request to nfvo failed")
         logger.info('[NF instantiation] send notify request to nfvo end')
 
-    # def rollback(self, args):
-    #     try:
-    #         logger.info('inst_exception, args=%s' % args)
-    #         # InstExceptionTask(args).do_biz()
-    #         return {'result': '100', 'msg': 'Nf instancing exception process finish', 'context': {}}
-    #     except Exception as e:
-    #         logger.error('Nf instancing exception process exception=%s' % e.message)
-    #         logger.error(traceback.format_exc())
-    #         return {'result': '255', 'msg': 'Nf instancing exception process exception', 'context': {}}
-
     def load_nfvo_config(self):
         logger.info("[NF instantiation]get nfvo connection info start")
         reg_info = NfvoRegInfoModel.objects.filter(vnfminstid='vnfm111').first()
@@ -387,6 +365,7 @@ class InstVnf(Thread):
                 name='40G',
                 tenant='admin',
                 insttype=0,
+                is_predefined=ret["returnCode"],
                 instid=self.nf_inst_id)
         elif res_type == adaptor.OPT_CREATE_NETWORK:
             logger.info('Create networks!')
@@ -402,6 +381,7 @@ class InstVnf(Thread):
                 name='pnet_network',
                 tenant='admin',
                 insttype=0,
+                is_predefined=ret["returnCode"],
                 instid=self.nf_inst_id)
         elif res_type == adaptor.OPT_CREATE_SUBNET:
             logger.info('Create subnets!')
@@ -418,6 +398,7 @@ class InstVnf(Thread):
                 name='sub_pnet',
                 tenant='admin',
                 insttype=0,
+                is_predefined=ret["returnCode"],
                 instid=self.nf_inst_id)
         elif res_type == adaptor.OPT_CREATE_PORT:
             logger.info('Create ports!')
@@ -435,6 +416,7 @@ class InstVnf(Thread):
                 name='aaa_pnet_cp',
                 tenant='admin',
                 insttype=0,
+                is_predefined=ret["returnCode"],
                 instid=self.nf_inst_id)
         elif res_type == adaptor.OPT_CREATE_FLAVOR:
             logger.info('Create flavors!')
@@ -448,6 +430,7 @@ class InstVnf(Thread):
                 name='1',
                 vcpu='1',
                 extraspecs='1',
+                is_predefined=ret["returnCode"],
                 instid=self.nf_inst_id)
         elif res_type == adaptor.OPT_CREATE_VM:
             logger.info('Create vms!')
@@ -463,6 +446,7 @@ class InstVnf(Thread):
                 insttype=0,
                 instid=self.nf_inst_id,
                 vmname="test_01",
+                is_predefined=ret["returnCode"],
                 operationalstate=1)
 
     def do_rollback(self, args_=None):