diff options
-rw-r--r-- | lcm/lcm/nf/vnfs/tests/test_vnf_cancel.py | 2 | ||||
-rw-r--r-- | lcm/lcm/nf/vnfs/tests/test_vnf_create.py | 14 | ||||
-rw-r--r-- | lcm/lcm/nf/vnfs/vnf_cancel/term_vnf.py | 16 | ||||
-rw-r--r-- | lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py | 3 | ||||
-rw-r--r-- | lcm/lcm/pub/msapi/catalog.py | 4 | ||||
-rw-r--r-- | lcm/lcm/pub/msapi/nfvolcm.py | 14 |
6 files changed, 16 insertions, 37 deletions
diff --git a/lcm/lcm/nf/vnfs/tests/test_vnf_cancel.py b/lcm/lcm/nf/vnfs/tests/test_vnf_cancel.py index ceef5d9f..84411aef 100644 --- a/lcm/lcm/nf/vnfs/tests/test_vnf_cancel.py +++ b/lcm/lcm/nf/vnfs/tests/test_vnf_cancel.py @@ -20,7 +20,7 @@ from rest_framework import status from lcm.nf.vnfs.vnf_cancel.term_vnf import TermVnf from lcm.pub.database.models import NfInstModel, JobStatusModel, VmInstModel, NetworkInstModel, SubNetworkInstModel, \ - PortInstModel, NfvoRegInfoModel, FlavourInstModel, StorageInstModel + PortInstModel, FlavourInstModel, StorageInstModel from lcm.pub.utils import restcall from lcm.pub.utils.jobutil import JobUtil from lcm.pub.utils.timeutil import now_time diff --git a/lcm/lcm/nf/vnfs/tests/test_vnf_create.py b/lcm/lcm/nf/vnfs/tests/test_vnf_create.py index 92a85172..0961f64e 100644 --- a/lcm/lcm/nf/vnfs/tests/test_vnf_create.py +++ b/lcm/lcm/nf/vnfs/tests/test_vnf_create.py @@ -32,23 +32,9 @@ from lcm.pub.vimapi import api class TestNFInstantiate(TestCase): def setUp(self): self.client = Client() - # VmInstModel.objects.create(vmid="1", vimid="1", resouceid="11", insttype=0, instid="1", vmname="test_01", - # operationalstate=1) - # VmInstModel.objects.create(vmid="2", vimid="2", resouceid="22", insttype=0, instid="2", - # vmname="test_02", operationalstate=1) - # NetworkInstModel.objects.create(networkid='1', vimid='1', resouceid='1', name='pnet_network', - # tenant='admin', insttype=0, instid='1') - # SubNetworkInstModel.objects.create(subnetworkid='1', vimid='1', resouceid='1', networkid='1', - # name='sub_pnet', tenant='admin', insttype=0, instid='1') - # PortInstModel.objects.create(portid='1', networkid='1', subnetworkid='1', vimid='1', resouceid='1', - # name='aaa_pnet_cp', tenant='admin', insttype=0, instid='1') def tearDown(self): pass - # VmInstModel.objects.all().delete() - # NetworkInstModel.objects.all().delete() - # SubNetworkInstModel.objects.all().delete() - # PortInstModel.objects.all().delete() def assert_job_result(self, job_id, job_progress, job_detail): jobs = JobStatusModel.objects.filter( diff --git a/lcm/lcm/nf/vnfs/vnf_cancel/term_vnf.py b/lcm/lcm/nf/vnfs/vnf_cancel/term_vnf.py index b1e6ebfb..c9d1c12f 100644 --- a/lcm/lcm/nf/vnfs/vnf_cancel/term_vnf.py +++ b/lcm/lcm/nf/vnfs/vnf_cancel/term_vnf.py @@ -36,6 +36,8 @@ class TermVnf(Thread): self.job_id = job_id self.terminationType = ignore_case_get(self.data, "terminationType") self.gracefulTerminationTimeout = ignore_case_get(self.data, "gracefulTerminationTimeout") + self.apply_result = None + self.notify_data = None self.inst_resource = {'volumn': [], # [{"vim_id": ignore_case_get(ret, "vim_id")},{}] 'network': [], 'subnet': [], @@ -43,7 +45,6 @@ class TermVnf(Thread): 'flavor': [], 'vm': [], } - self.notify_data = None def run(self): try: @@ -57,7 +58,6 @@ class TermVnf(Thread): except NFLCMException as e: self.vnf_term_failed_handle(e.message) except: - logger.error(traceback.format_exc()) self.vnf_term_failed_handle(traceback.format_exc()) def term_pre(self): @@ -92,7 +92,6 @@ class TermVnf(Thread): logger.info('content_args=%s' % content_args) self.apply_result = apply_grant_to_nfvo(content_args) - vim_info = ignore_case_get(self.apply_result, "vim") logger.info("nf_cancel_task grant_resource end") JobUtil.add_job_status(self.job_id, 20, 'Nf terminating grant_resource finish') @@ -175,17 +174,17 @@ class TermVnf(Thread): affected_vnfc = [] vnfcs = VNFCInstModel.objects.filter(instid=self.nf_inst_id) for vnfc in vnfcs: - vmResource = {} + vm_resource = {} if vnfc.vmid: vm = VmInstModel.objects.filter(vmid=vnfc.vmid) if vm: - vmResource = {'vimId': vm[0].vimid, 'resourceId': vm[0].resouceid, - 'resourceName': vm[0].vmname, 'resourceType': 'vm'} + vm_resource = {'vimId': vm[0].vimid, 'resourceId': vm[0].resouceid, + 'resourceName': vm[0].vmname, 'resourceType': 'vm'} affected_vnfc.append( {'vnfcInstanceId': vnfc.vnfcinstanceid, 'vduId': vnfc.vduid, 'changeType': 'removed', - 'computeResource': vmResource}) + 'computeResource': vm_resource}) affected_vl = [] networks = NetworkInstModel.objects.filter(instid=self.nf_inst_id) for network in networks: @@ -253,6 +252,7 @@ class TermVnf(Thread): StorageInstModel.objects.filter(instid=self.nf_inst_id, resouceid=res_id).delete() def lcm_notify(self): + NfInstModel.objects.filter(nfinstid=self.nf_inst_id).update(status='NOT_INSTANTIATED', lastuptime=now_time()) logger.info('[NF termination] send notify request to nfvo end') resp = notify_lcm_to_nfvo(self.notify_data, self.nf_inst_id) logger.info('[NF termination] get lcm response %s' % resp) @@ -261,4 +261,4 @@ class TermVnf(Thread): def vnf_term_failed_handle(self, error_msg): logger.error('VNF termination failed, detail message: %s' % error_msg) NfInstModel.objects.filter(nfinstid=self.nf_inst_id).update(status='failed', lastuptime=now_time()) - JobUtil.add_job_status(self.job_id, 255, error_msg)
\ No newline at end of file + JobUtil.add_job_status(self.job_id, 255, error_msg) diff --git a/lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py b/lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py index 685decfa..cedc4a42 100644 --- a/lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py +++ b/lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py @@ -59,11 +59,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) diff --git a/lcm/lcm/pub/msapi/catalog.py b/lcm/lcm/pub/msapi/catalog.py index 39409aed..d62651a1 100644 --- a/lcm/lcm/pub/msapi/catalog.py +++ b/lcm/lcm/pub/msapi/catalog.py @@ -83,6 +83,7 @@ def get_process_id(name, srv_template_id): return item['processId'] raise NFLCMException('service[%s,%s] process id not exist' % (name, srv_template_id)) + def get_servicetemplate_id(nsd_id): ret = req_by_msb('/openoapi/catalog/v1/servicetemplates', 'GET') if ret[0] != 0: @@ -92,7 +93,8 @@ def get_servicetemplate_id(nsd_id): if stpl["id"] == nsd_id: return stpl["serviceTemplateId"] raise NFLCMException('servicetemplate(%s) does not exist.' % nsd_id) - + + def get_servicetemplate(nsd_id): ret = req_by_msb('/openoapi/catalog/v1/servicetemplates', 'GET') if ret[0] != 0: diff --git a/lcm/lcm/pub/msapi/nfvolcm.py b/lcm/lcm/pub/msapi/nfvolcm.py index dc310451..6ea8df1c 100644 --- a/lcm/lcm/pub/msapi/nfvolcm.py +++ b/lcm/lcm/pub/msapi/nfvolcm.py @@ -20,7 +20,6 @@ from lcm.pub.utils.restcall import req_by_msb logger = logging.getLogger(__name__) -#call gvnfm driver def get_packageinfo_by_vnfdid(vnfdid): ret = req_by_msb("openoapi/nslcm/v1/vnfs/%s" % vnfdid, "GET") if ret[0] != 0: @@ -28,23 +27,18 @@ def get_packageinfo_by_vnfdid(vnfdid): raise NFLCMException("Failed to query package_info of vnfdid(%s) from nslcm." % vnfdid) return json.JSONDecoder().decode(ret[1]) -#call gvnfm driver + def apply_grant_to_nfvo(data): - ret = req_by_msb("openoapi/nslcm/v1/grantvnf" , "POST", data) + ret = req_by_msb("openoapi/nslcm/v1/grantvnf", "POST", data) if ret[0] != 0: logger.error("Status code is %s, detail is %s.", ret[2], ret[1]) raise NFLCMException("Nf instancing apply grant exception") return json.JSONDecoder().decode(ret[1]) -#call gvnfm driver + def notify_lcm_to_nfvo(data, nf_inst_id): - ret = req_by_msb("openoapi/nslcm/v1/vnfs/%s/Notify"%nf_inst_id, "POST", data) + ret = req_by_msb("openoapi/nslcm/v1/vnfs/%s/Notify" % nf_inst_id, "POST", data) if ret[0] != 0: logger.error("Status code is %s, detail is %s.", ret[2], ret[1]) raise NFLCMException("Nf lcm notify exception") return json.JSONDecoder().decode(ret[1]) - -#call gvnfm driver -def apply_res_to_nfvo(data): - ret = req_by_msb("openoapi/nslcm/v1/res" , "POST", data) - return ret
\ No newline at end of file |