summaryrefslogtreecommitdiffstats
path: root/lcm
diff options
context:
space:
mode:
authorying.yunlong <ying.yunlong@zte.com.cn>2017-02-24 14:43:07 +0800
committerying.yunlong <ying.yunlong@zte.com.cn>2017-02-24 14:43:07 +0800
commit4571e2dd027035cca42d27dc0f8f0c2c94a3e019 (patch)
treec94727a8f9ac0f1698020347a1ce6e0fa8159333 /lcm
parent3282ed39a71c360abb21f06636ab58b22c47b5ec (diff)
Optimized code and testcase of query vnf
Change-Id: I3c02f90d33a4274fb2fe30fdd17fc50bb289cbc0 Issue-Id: GVNFM-12 Signed-off-by: ying.yunlong <ying.yunlong@zte.com.cn>
Diffstat (limited to 'lcm')
-rw-r--r--lcm/lcm/nf/vnfs/tests/test_vnf_query.py113
-rw-r--r--lcm/lcm/nf/vnfs/urls.py8
-rw-r--r--lcm/lcm/nf/vnfs/views.py22
3 files changed, 57 insertions, 86 deletions
diff --git a/lcm/lcm/nf/vnfs/tests/test_vnf_query.py b/lcm/lcm/nf/vnfs/tests/test_vnf_query.py
index bc88b95c..599372ef 100644
--- a/lcm/lcm/nf/vnfs/tests/test_vnf_query.py
+++ b/lcm/lcm/nf/vnfs/tests/test_vnf_query.py
@@ -50,61 +50,61 @@ class ResourceTest(TestCase):
"onboardedVnfPkgInfoId": None
}
self.test_data_multi_vnf = [
- {
- "vnfInstanceId": "1",
- "vnfInstanceName": "VNF1",
- "vnfProvider": None,
- "instantiatedVnfInfo": {
- "vnfState": None,
- "extCpInfo": [],
- "virtualStorageResourceInfo": [
- {
- "virtualStorageInstanceId": "s01",
- "storageResource": {
- "resourceId": "resource01",
- "vimId": "vim01"
+ {
+ "vnfInstanceId": "1",
+ "vnfInstanceName": "VNF1",
+ "vnfProvider": None,
+ "instantiatedVnfInfo": {
+ "vnfState": None,
+ "extCpInfo": [],
+ "virtualStorageResourceInfo": [
+ {
+ "virtualStorageInstanceId": "s01",
+ "storageResource": {
+ "resourceId": "resource01",
+ "vimId": "vim01"
+ }
}
- }
- ],
- "extVirtualLink": [],
- "vnfcResourceInfo": [],
- "monitoringParameters": {},
- "vimInfo": [],
- "flavourId": None,
- "virtualLinkResourceInfo": [],
- "scaleStatus": []
+ ],
+ "extVirtualLink": [],
+ "vnfcResourceInfo": [],
+ "monitoringParameters": {},
+ "vimInfo": [],
+ "flavourId": None,
+ "virtualLinkResourceInfo": [],
+ "scaleStatus": []
+ },
+ "vnfdVersion": None,
+ "onboardedVnfPkgInfoId": None
},
- "vnfdVersion": None,
- "onboardedVnfPkgInfoId": None
- },
- {
- "vnfInstanceId": "2",
- "vnfInstanceName": "VNF2",
- "vnfProvider": None,
- "instantiatedVnfInfo": {
- "vnfState": None,
- "extCpInfo": [],
- "virtualStorageResourceInfo": [
- {
- "virtualStorageInstanceId": "s02",
- "storageResource": {
- "resourceId": "resource02",
- "vimId": "vim02"
+ {
+ "vnfInstanceId": "2",
+ "vnfInstanceName": "VNF2",
+ "vnfProvider": None,
+ "instantiatedVnfInfo": {
+ "vnfState": None,
+ "extCpInfo": [],
+ "virtualStorageResourceInfo": [
+ {
+ "virtualStorageInstanceId": "s02",
+ "storageResource": {
+ "resourceId": "resource02",
+ "vimId": "vim02"
+ }
}
- }
- ],
- "extVirtualLink": [],
- "vnfcResourceInfo": [],
- "monitoringParameters": {},
- "vimInfo": [],
- "flavourId": None,
- "virtualLinkResourceInfo": [],
- "scaleStatus": []
- },
- "vnfdVersion": None,
- "onboardedVnfPkgInfoId": None
- }
- ]
+ ],
+ "extVirtualLink": [],
+ "vnfcResourceInfo": [],
+ "monitoringParameters": {},
+ "vimInfo": [],
+ "flavourId": None,
+ "virtualLinkResourceInfo": [],
+ "scaleStatus": []
+ },
+ "vnfdVersion": None,
+ "onboardedVnfPkgInfoId": None
+ }
+ ]
def tearDown(self):
pass
@@ -112,17 +112,16 @@ class ResourceTest(TestCase):
def test_get_vnf(self):
vnf_inst_id = "1"
NfInstModel(nfinstid=vnf_inst_id, nf_name='VNF1').save()
- StorageInstModel(storageid='s02', vimid='vim01', resouceid='resource01', insttype=1, \
- instid=vnf_inst_id).save()
+ StorageInstModel(storageid='s02', vimid='vim01', resouceid='resource01', insttype=1, instid=vnf_inst_id).save()
response = self.client.get("/openoapi/vnflcm/v1/vnf_instances/%s" % vnf_inst_id, format='json')
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(self.test_data_single_vnf, response.data)
def test_get_vnfs(self):
- for i in range(1,3):
+ for i in range(1, 3):
NfInstModel(nfinstid='%s' % i, nf_name='VNF%s' % i).save()
StorageInstModel(storageid='s0%s' % i, vimid='vim0%s' % i, resouceid='resource0%s' % i,
insttype=1, instid='%s' % i).save()
- response = self.client.get("/openoapi/vnflcm/v1/vnf_instances")
+ response = self.client.get("/openoapi/vnflcm/v1/vnf_instances", format='json')
self.failUnlessEqual(status.HTTP_200_OK, response.status_code)
- self.assertEqual(self.test_data_multi_vnf, response.data) \ No newline at end of file
+ self.assertEqual(self.test_data_multi_vnf, response.data)
diff --git a/lcm/lcm/nf/vnfs/urls.py b/lcm/lcm/nf/vnfs/urls.py
index 4857f429..b40190d2 100644
--- a/lcm/lcm/nf/vnfs/urls.py
+++ b/lcm/lcm/nf/vnfs/urls.py
@@ -15,8 +15,7 @@
from django.conf.urls import patterns, url
from rest_framework.urlpatterns import format_suffix_patterns
-from lcm.nf.vnfs.views import InstantiateVnf, QueryMultipleVnf,\
- TerminateVnf, SwaggerJsonView, DeleteVnfAndQueryVnf, CreateVnfAndQueryVnfs
+from lcm.nf.vnfs.views import InstantiateVnf, TerminateVnf, SwaggerJsonView, DeleteVnfAndQueryVnf, CreateVnfAndQueryVnfs
urlpatterns = patterns('',
url(r'^openoapi/vnflcm/v1/vnf_instances$', CreateVnfAndQueryVnfs.as_view()),
@@ -26,11 +25,6 @@ urlpatterns = patterns('',
DeleteVnfAndQueryVnf.as_view()),
url(r'^openoapi/vnflcm/v1/vnf_instances/(?P<instanceid>[0-9a-zA-Z_-]+)/terminate$',
TerminateVnf.as_view()),
- # url(r'^openoapi/vnflcm/v1/vnf_instances$', QueryMultipleVnf.as_view()),
- # url(r'^openoapi/vnflcm/v1/vnf_instances/(?P<instanceid>[0-9a-zA-Z_-]+)$',
- # QuerySingleVnf.as_view()),
- # url(r'^openoapi/vnflcm/v1/vnf_lc_ops/(?P<vnfLcOpId>[0-9a-zA-Z_-]+)&'
- # r'responseId=(?P<responseId>[0-9a-zA-Z_-]+)$', GetOperationStatus.as_view()),
url(r'^openoapi/vnflcm/v1/swagger.json$', SwaggerJsonView.as_view()),
)
diff --git a/lcm/lcm/nf/vnfs/views.py b/lcm/lcm/nf/vnfs/views.py
index a97c6169..ef997f05 100644
--- a/lcm/lcm/nf/vnfs/views.py
+++ b/lcm/lcm/nf/vnfs/views.py
@@ -27,7 +27,6 @@ from lcm.nf.vnfs.vnf_create.inst_vnf import InstVnf
from lcm.nf.vnfs.vnf_query.query_vnf import QueryVnf
from lcm.pub.exceptions import NFLCMException
from lcm.pub.utils.jobutil import JobUtil
-from lcm.pub.utils.values import ignore_case_get
logger = logging.getLogger(__name__)
@@ -42,7 +41,6 @@ class CreateVnfAndQueryVnfs(APIView):
return Response(data={'error': '%s' % e.message}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
except:
logger.error(traceback.format_exc())
- tt = traceback.format_exc()
return Response(data={'error': 'Failed to get Vnfs'},
status=status.HTTP_500_INTERNAL_SERVER_ERROR)
return Response(data=resp_data, status=status.HTTP_200_OK)
@@ -120,26 +118,6 @@ class QueryMultipleVnf(APIView):
logger.debug("QueryMultipleVnf--get::> %s" % request.data)
return Response(data='', status=status.HTTP_202_ACCEPTED)
-# class QuerySingleVnf(APIView):
-# def get(self, request, instanceid):
-# logger.debug("QuerySingleVnf--get::> %s" % request.data)
-# try:
-# resp_data = QueryVnf(request.data, instanceid).query_single_vnf(instanceid)
-# except NFLCMException as e:
-# logger.error(e.message)
-# return Response(data={'error': '%s' % e.message}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
-# except:
-# logger.error(traceback.format_exc())
-# return Response(data={'error': 'Failed to get Vnf(%s)' % instanceid},
-# status=status.HTTP_500_INTERNAL_SERVER_ERROR)
-# return Response(data=resp_data, status=status.HTTP_202_ACCEPTED)
-
-
-# class GetOperationStatus(APIView):
-# def get(self, request):
-# logger.debug("GetOperationStatus--get::> %s" % request.data)
-# return Response(data='', status=status.HTTP_202_ACCEPTED)
-
class SwaggerJsonView(APIView):
def get(self, request):