summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlaili <lai.li@zte.com.cn>2018-08-08 16:08:41 +0800
committerlaili <lai.li@zte.com.cn>2018-08-08 16:26:53 +0800
commitf5a6d2a97522298a1a20e5f2d0d5f5c14f90ef96 (patch)
tree2729cfb3841205ee1e0555c8a0758ed0726ec05e
parenta672b1602052e32c80c8cb08296880df4a2a220f (diff)
Modify vnf query related stuffs in vnflcm.
Modify biz/query_vnf.py and views/curd_vnf_views.py to implement query vnf interface. Modify tests/test_query_vnf.py. Change-Id: I3842764c027b43f8e059fe70fc0fd5dc4628c43a Issue-ID: VFC-1016 Signed-off-by: laili <lai.li@zte.com.cn>
-rw-r--r--lcm/lcm/nf/biz/query_vnf.py45
-rw-r--r--lcm/lcm/nf/tests/test_query_vnf.py39
-rw-r--r--lcm/lcm/nf/views/curd_vnf_views.py26
3 files changed, 41 insertions, 69 deletions
diff --git a/lcm/lcm/nf/biz/query_vnf.py b/lcm/lcm/nf/biz/query_vnf.py
index 1a6bdd90..f3b2997e 100644
--- a/lcm/lcm/nf/biz/query_vnf.py
+++ b/lcm/lcm/nf/biz/query_vnf.py
@@ -48,9 +48,9 @@ class QueryVnf:
arr = []
for s in storage_inst:
storage = {
- "virtualStorageInstanceId": s.storageid,
+ "id": s.storageid,
"storageResource": {
- "vimId": s.vimid,
+ "vimConnectionId": s.vimid,
"resourceId": s.resouceid
}
}
@@ -63,10 +63,10 @@ class QueryVnf:
if not net:
raise NFLCMException('NetworkInst(%s) does not exist.' % v.relatednetworkid)
v_dic = {
- "virtualLinkInstanceId": v.vlinstanceid,
+ "id": v.vlinstanceid,
"virtualLinkDescId": v.vldid,
"networkResource": {
- "vimId": net[0].vimid,
+ "vimConnectionId": net[0].vimid,
"resourceId": net[0].resouceid
}
}
@@ -82,45 +82,21 @@ class QueryVnf:
if not storage:
raise NFLCMException('StorageInst(%s) does not exist.' % vm[0].vmid)
vnfc_dic = {
- "vnfcInstanceId": vnfc.vnfcinstanceid,
+ "id": vnfc.vnfcinstanceid,
"vduId": vnfc.vduid,
"computeResource": {
- "vimId": vm[0].vimid,
+ "vimConnectionId": vm[0].vimid,
"resourceId": vm[0].resouceid
},
"storageResourceIds": [s.storageid for s in storage]
}
vnfc_arr.append(vnfc_dic)
logger.info('Get vms')
- vms = VmInstModel.objects.filter(instid=vnf.nfinstid)
- vm_arr = []
- for vm in vms:
- vm_dic = {
- "vmid": vm.vmid,
- "vimid": vm.vimid,
- "tenant": vm.tenant,
- "resouceid": vm.resouceid,
- "vmname": vm.vmname,
- "nic_array": vm.nic_array,
- "metadata": vm.metadata,
- "volume_array": vm.volume_array,
- "server_group": vm.server_group,
- "availability_zone": vm.availability_zone,
- "flavor_id": vm.flavor_id,
- "security_groups": vm.security_groups,
- "operationalstate": vm.operationalstate,
- "insttype": vm.insttype,
- "is_predefined": vm.is_predefined,
- "create_time": vm.create_time,
- "instid": vm.instid,
- "nodeId": vm.nodeId
- }
- vm_arr.append(vm_dic)
resp_data = {
- "vnfInstanceId": vnf.nfinstid,
+ "id": vnf.nfinstid,
"vnfInstanceName": vnf.nf_name,
- "onboardedVnfPkgInfoId": vnf.package_id,
+ "vnfPkgId": vnf.package_id,
"vnfdVersion": vnf.version,
"vnfProvider": vnf.vendor,
"instantiatedVnfInfo": {
@@ -128,11 +104,10 @@ class QueryVnf:
"vnfState": vnf.status,
"scaleStatus": [],
"extCpInfo": [],
- "extVirtualLink": [],
+ "extVirtualLinkInfo": [],
"monitoringParameters": {},
- "vimInfo": vm_arr,
"vnfcResourceInfo": vnfc_arr,
- "virtualLinkResourceInfo": vl_arr,
+ "vnfVirtualLinkResourceInfo": vl_arr,
"virtualStorageResourceInfo": arr
}
}
diff --git a/lcm/lcm/nf/tests/test_query_vnf.py b/lcm/lcm/nf/tests/test_query_vnf.py
index 991583e7..e092223b 100644
--- a/lcm/lcm/nf/tests/test_query_vnf.py
+++ b/lcm/lcm/nf/tests/test_query_vnf.py
@@ -24,7 +24,7 @@ class ResourceTest(TestCase):
self.nf_inst_id = "01"
NfInstModel.objects.all().delete()
self.test_data_single_vnf = {
- "vnfInstanceId": "1",
+ "id": "1",
"vnfInstanceName": "VNF1",
"vnfProvider": None,
"instantiatedVnfInfo": {
@@ -32,27 +32,26 @@ class ResourceTest(TestCase):
"extCpInfo": [],
"virtualStorageResourceInfo": [
{
- "virtualStorageInstanceId": "s02",
+ "id": "s02",
"storageResource": {
"resourceId": "resource01",
- "vimId": "vim01"
+ "vimConnectionId": "vim01"
}
}
],
- "extVirtualLink": [],
+ "extVirtualLinkInfo": [],
"vnfcResourceInfo": [],
"monitoringParameters": {},
- "vimInfo": [],
"flavourId": None,
- "virtualLinkResourceInfo": [],
+ "vnfVirtualLinkResourceInfo": [],
"scaleStatus": []
},
"vnfdVersion": None,
- "onboardedVnfPkgInfoId": None
+ "vnfPkgId": None
}
self.test_data_multi_vnf = [
{
- "vnfInstanceId": "1",
+ "id": "1",
"vnfInstanceName": "VNF1",
"vnfProvider": None,
"instantiatedVnfInfo": {
@@ -60,26 +59,25 @@ class ResourceTest(TestCase):
"extCpInfo": [],
"virtualStorageResourceInfo": [
{
- "virtualStorageInstanceId": "s01",
+ "id": "s01",
"storageResource": {
"resourceId": "resource01",
- "vimId": "vim01"
+ "vimConnectionId": "vim01"
}
}
],
- "extVirtualLink": [],
+ "extVirtualLinkInfo": [],
"vnfcResourceInfo": [],
"monitoringParameters": {},
- "vimInfo": [],
"flavourId": None,
- "virtualLinkResourceInfo": [],
+ "vnfVirtualLinkResourceInfo": [],
"scaleStatus": []
},
"vnfdVersion": None,
- "onboardedVnfPkgInfoId": None
+ "vnfPkgId": None
},
{
- "vnfInstanceId": "2",
+ "id": "2",
"vnfInstanceName": "VNF2",
"vnfProvider": None,
"instantiatedVnfInfo": {
@@ -87,23 +85,22 @@ class ResourceTest(TestCase):
"extCpInfo": [],
"virtualStorageResourceInfo": [
{
- "virtualStorageInstanceId": "s02",
+ "id": "s02",
"storageResource": {
"resourceId": "resource02",
- "vimId": "vim02"
+ "vimConnectionId": "vim02"
}
}
],
- "extVirtualLink": [],
+ "extVirtualLinkInfo": [],
"vnfcResourceInfo": [],
"monitoringParameters": {},
- "vimInfo": [],
"flavourId": None,
- "virtualLinkResourceInfo": [],
+ "vnfVirtualLinkResourceInfo": [],
"scaleStatus": []
},
"vnfdVersion": None,
- "onboardedVnfPkgInfoId": None
+ "vnfPkgId": None
}
]
diff --git a/lcm/lcm/nf/views/curd_vnf_views.py b/lcm/lcm/nf/views/curd_vnf_views.py
index 0d3b5ff5..7419e69f 100644
--- a/lcm/lcm/nf/views/curd_vnf_views.py
+++ b/lcm/lcm/nf/views/curd_vnf_views.py
@@ -23,9 +23,9 @@ from rest_framework.views import APIView
from lcm.nf.biz.create_vnf import CreateVnf
from lcm.nf.biz.query_vnf import QueryVnf
-from lcm.nf.serializers.serializers import CreateVnfRespSerializer, VnfsInfoSerializer, \
- VnfInfoSerializer
-from lcm.nf.serializers.create_vnf_req import CreateVnfReqSerializer
+from lcm.nf.serializers.serializers import CreateVnfReqSerializer, CreateVnfRespSerializer
+from lcm.nf.serializers.vnf_instance import VnfInstanceSerializer
+from lcm.nf.serializers.vnf_instances import VnfInstancesSerializer
from lcm.pub.exceptions import NFLCMException
logger = logging.getLogger(__name__)
@@ -34,7 +34,7 @@ logger = logging.getLogger(__name__)
class CreateVnfAndQueryVnfs(APIView):
@swagger_auto_schema(
responses={
- status.HTTP_200_OK: VnfsInfoSerializer(),
+ status.HTTP_200_OK: VnfInstancesSerializer(),
status.HTTP_500_INTERNAL_SERVER_ERROR: "Internal error"
}
)
@@ -43,11 +43,11 @@ class CreateVnfAndQueryVnfs(APIView):
try:
resp_data = QueryVnf(request.data).query_multi_vnf()
- vnfs_info_serializer = VnfsInfoSerializer(data=resp_data)
- if not vnfs_info_serializer.is_valid():
- raise NFLCMException(vnfs_info_serializer.errors)
+ vnf_instances_serializer = VnfInstancesSerializer(data=resp_data)
+ if not vnf_instances_serializer.is_valid():
+ raise NFLCMException(vnf_instances_serializer.errors)
- return Response(data=vnfs_info_serializer.data, status=status.HTTP_200_OK)
+ return Response(data=vnf_instances_serializer.data, status=status.HTTP_200_OK)
except NFLCMException as e:
logger.error(e.message)
return Response(data={'error': '%s' % e.message}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
@@ -87,7 +87,7 @@ class CreateVnfAndQueryVnfs(APIView):
class DeleteVnfAndQueryVnf(APIView):
@swagger_auto_schema(
responses={
- status.HTTP_200_OK: VnfInfoSerializer(),
+ status.HTTP_200_OK: VnfInstanceSerializer(),
status.HTTP_500_INTERNAL_SERVER_ERROR: "Internal error"
}
)
@@ -96,11 +96,11 @@ class DeleteVnfAndQueryVnf(APIView):
try:
resp_data = QueryVnf(request.data, instanceid).query_single_vnf()
- vnf_info_serializer = VnfInfoSerializer(data=resp_data)
- if not vnf_info_serializer.is_valid():
- raise NFLCMException(vnf_info_serializer.errors)
+ vnfs_instance_serializer = VnfInstanceSerializer(data=resp_data)
+ if not vnfs_instance_serializer.is_valid():
+ raise NFLCMException(vnfs_instance_serializer.errors)
- return Response(data=vnf_info_serializer.data, status=status.HTTP_200_OK)
+ return Response(data=vnfs_instance_serializer.data, status=status.HTTP_200_OK)
except NFLCMException as e:
logger.error(e.message)
return Response(data={'error': '%s' % e.message}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)