From 83e33d9dd6608024dbf92cfde8daf51a298b5f54 Mon Sep 17 00:00:00 2001 From: maopengzhang Date: Tue, 13 Nov 2018 23:16:51 +0800 Subject: fix storage query error fix storage query error in query VNF Change-Id: Ic2adbd57eb2bea2ed31132e37c808728a3f00625 Issue-ID: VFC-1184 Signed-off-by: maopengzhang --- lcm/lcm/nf/biz/query_vnf.py | 8 ++++---- lcm/lcm/nf/biz/terminate_vnf.py | 2 +- lcm/lcm/nf/tests/test_query_vnf.py | 1 - 3 files changed, 5 insertions(+), 6 deletions(-) (limited to 'lcm') diff --git a/lcm/lcm/nf/biz/query_vnf.py b/lcm/lcm/nf/biz/query_vnf.py index 380d455a..c735e0b7 100644 --- a/lcm/lcm/nf/biz/query_vnf.py +++ b/lcm/lcm/nf/biz/query_vnf.py @@ -78,10 +78,10 @@ class QueryVnf: vm = VmInstModel.objects.filter(vmid=vnfc.vmid) if not vm: raise NFLCMException('VmInst(%s) does not exist.' % vnfc.vmid) - storage = StorageInstModel.objects.filter(vimid=vm[0].vmid) - # TODO: previously, ownerid=vm[0].vmid, but ownerid is not a field of StorageInstModel. - if not storage: - raise NFLCMException('StorageInst(%s) does not exist.' % vm[0].vmid) + if vm[0].volume_array: + storage = StorageInstModel.objects.filter(resourceid__in=vm[0].volume_array) + else: + storage = [] vnfc_dic = { "id": vnfc.vnfcinstanceid, "vduId": vnfc.vduid, diff --git a/lcm/lcm/nf/biz/terminate_vnf.py b/lcm/lcm/nf/biz/terminate_vnf.py index bcaf6433..250ce7fa 100644 --- a/lcm/lcm/nf/biz/terminate_vnf.py +++ b/lcm/lcm/nf/biz/terminate_vnf.py @@ -128,5 +128,5 @@ class TerminateVnf(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()) + NfInstModel.objects.filter(nfinstid=self.nf_inst_id).update(lastuptime=now_time()) JobUtil.add_job_status(self.job_id, 255, error_msg) diff --git a/lcm/lcm/nf/tests/test_query_vnf.py b/lcm/lcm/nf/tests/test_query_vnf.py index e0ecddb5..1fbe9c7c 100644 --- a/lcm/lcm/nf/tests/test_query_vnf.py +++ b/lcm/lcm/nf/tests/test_query_vnf.py @@ -152,7 +152,6 @@ class ResourceTest(TestCase): VmInstModel(vmid='x', insttype='0').save() response = self.client.get("/api/vnflcm/v1/vnf_instances/%s" % vnf_inst_id, format='json') self.assertEqual(response.status_code, status.HTTP_500_INTERNAL_SERVER_ERROR) - self.assertEqual({'error': 'StorageInst(x) does not exist.'}, response.data) def test_get_vnfs(self): for i in range(1, 3): -- cgit 1.2.3-korg