summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFu Jinhua <fu.jinhua@zte.com.cn>2018-11-26 02:21:36 +0000
committerGerrit Code Review <gerrit@onap.org>2018-11-26 02:21:36 +0000
commitec1fd594dc2f08b7107e7965b39da3b589b4e0fa (patch)
tree7f343a6f4ccdd349ba5538bc53eca513972c3cf6
parentf23897f17f2c4a65c09f3d697292dc40d8fe54cc (diff)
parent1f6a8972256f31809cee9514abca4215d96152bd (diff)
Merge "fix VNF query result none exception"
-rw-r--r--lcm/lcm/nf/biz/query_vnf.py9
-rw-r--r--lcm/lcm/nf/tests/test_query_vnf.py3
-rw-r--r--lcm/lcm/nf/views/curd_vnf_views.py3
3 files changed, 8 insertions, 7 deletions
diff --git a/lcm/lcm/nf/biz/query_vnf.py b/lcm/lcm/nf/biz/query_vnf.py
index c735e0b7..1dd7c2d1 100644
--- a/lcm/lcm/nf/biz/query_vnf.py
+++ b/lcm/lcm/nf/biz/query_vnf.py
@@ -35,11 +35,12 @@ class QueryVnf:
def query_multi_vnf(self):
vnf_insts = NfInstModel.objects.all()
- if not vnf_insts:
- raise NFLCMException('VnfInsts does not exist.')
+ # if not vnf_insts:
+ # raise NFLCMException('VnfInsts does not exist.')
resp_data = []
- for vnf_inst in vnf_insts:
- resp_data.append(self.fill_resp_data(vnf_inst))
+ if vnf_insts:
+ for vnf_inst in vnf_insts:
+ resp_data.append(self.fill_resp_data(vnf_inst))
return resp_data
def fill_resp_data(self, vnf):
diff --git a/lcm/lcm/nf/tests/test_query_vnf.py b/lcm/lcm/nf/tests/test_query_vnf.py
index 1fbe9c7c..25824239 100644
--- a/lcm/lcm/nf/tests/test_query_vnf.py
+++ b/lcm/lcm/nf/tests/test_query_vnf.py
@@ -169,5 +169,4 @@ class ResourceTest(TestCase):
def test_get_vnfs_not_exist(self):
response = self.client.get("/api/vnflcm/v1/vnf_instances", format='json')
- self.assertEqual(response.status_code, status.HTTP_500_INTERNAL_SERVER_ERROR)
- self.assertEqual({'error': 'VnfInsts does not exist.'}, response.data)
+ self.assertEqual(response.status_code, status.HTTP_200_OK)
diff --git a/lcm/lcm/nf/views/curd_vnf_views.py b/lcm/lcm/nf/views/curd_vnf_views.py
index ae8a211a..25a98af8 100644
--- a/lcm/lcm/nf/views/curd_vnf_views.py
+++ b/lcm/lcm/nf/views/curd_vnf_views.py
@@ -42,7 +42,8 @@ class CreateVnfAndQueryVnfs(APIView):
logger.debug("QueryMultiVnf--get::> %s" % request.data)
try:
resp_data = QueryVnf(request.data).query_multi_vnf()
-
+ if len(resp_data) == 0:
+ return Response(data=[], status=status.HTTP_200_OK)
vnf_instances_serializer = VnfInstancesSerializer(data=resp_data)
if not vnf_instances_serializer.is_valid():
raise NFLCMException(vnf_instances_serializer.errors)