summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormaopengzhang <zhang.maopeng1@zte.com.cn>2018-11-13 23:16:51 +0800
committermaopengzhang <zhang.maopeng1@zte.com.cn>2018-11-13 23:16:51 +0800
commit83e33d9dd6608024dbf92cfde8daf51a298b5f54 (patch)
tree7d6ae4f8e6aafb2aeef73cfe174a79742c8c8f10
parent5efbf8748ca225b26e909cef06e2314746fb3e1b (diff)
fix storage query error
fix storage query error in query VNF Change-Id: Ic2adbd57eb2bea2ed31132e37c808728a3f00625 Issue-ID: VFC-1184 Signed-off-by: maopengzhang <zhang.maopeng1@zte.com.cn>
-rw-r--r--lcm/lcm/nf/biz/query_vnf.py8
-rw-r--r--lcm/lcm/nf/biz/terminate_vnf.py2
-rw-r--r--lcm/lcm/nf/tests/test_query_vnf.py1
3 files changed, 5 insertions, 6 deletions
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):