summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lcm/lcm/nf/vnfs/serializers.py20
-rw-r--r--lcm/lcm/nf/vnfs/views.py26
2 files changed, 33 insertions, 13 deletions
diff --git a/lcm/lcm/nf/vnfs/serializers.py b/lcm/lcm/nf/vnfs/serializers.py
index 2ec38b29..ae2866aa 100644
--- a/lcm/lcm/nf/vnfs/serializers.py
+++ b/lcm/lcm/nf/vnfs/serializers.py
@@ -25,8 +25,14 @@ class CreateVnfRespSerializer(serializers.Serializer):
vnfInstanceId = serializers.CharField(help_text="vnf Instance Id", required=True)
+class StorageResourceSerializer(serializers.Serializer):
+ resourceId = serializers.CharField(help_text="resourceId", required=True)
+ vimId = serializers.CharField(help_text="vimId", required=True)
+
+
class virtualStorageResourceInfoSerializer(serializers.Serializer):
- pass
+ virtualStorageInstanceId = serializers.CharField(help_text="virtualStorageInstanceId", required=True)
+ storageResource = StorageResourceSerializer(help_text="storageResource", required=True)
class virtualLinkResourceInfoSerializer(serializers.Serializer):
@@ -101,12 +107,12 @@ class ScaleInfoSerializer(serializers.Serializer):
class instantiatedVnfInfoSerializer(serializers.Serializer):
- flavourId = serializers.CharField(help_text="flavour Id", required=True)
- vnfState = serializers.ChoiceField(help_text="vnf State", choices=['STARTED', 'STOPPED'], required=True)
+ flavourId = serializers.CharField(help_text="flavour Id", required=True, allow_null=True)
+ vnfState = serializers.ChoiceField(help_text="vnf State", choices=['STARTED', 'STOPPED'], required=True, allow_null=True)
scaleStatus = ScaleInfoSerializer(help_text="scaleStatus", many=True)
extCpInfo = extCpInfoSerializer(help_text="extCpInfo", many=True)
extVirtualLink = ExtVirtualLinkInfoSerializer(help_text="extVirtualLink", many=True)
- monitoringParameters = monitoringParametersSerializer(help_text="monitoringParameters", many=True, allow_null=True)
+ monitoringParameters = monitoringParametersSerializer(help_text="monitoringParameters", allow_null=True)
vimInfo = vimInfoSerializer(help_text="vimInfo", many=True)
vnfcResourceInfo = vnfcResourceInfoSerializer(help_text="vnfcResourceInfo", many=True)
virtualLinkResourceInfo = virtualLinkResourceInfoSerializer(help_text="virtualLinkResourceInfo", many=True)
@@ -114,7 +120,7 @@ class instantiatedVnfInfoSerializer(serializers.Serializer):
pass
-class VnfsInfoSerializer(serializers.ListSerializer):
+class VnfInfoSerializer(serializers.Serializer):
vnfInstanceId = serializers.CharField(help_text="vnf Instance Id", required=True)
vnfInstanceName = serializers.CharField(help_text="vnf Instance Name", required=True)
onboardedVnfPkgInfoId = serializers.CharField(help_text="onboarded Vnf Pkg Info Id", required=False,
@@ -122,3 +128,7 @@ class VnfsInfoSerializer(serializers.ListSerializer):
vnfdVersion = serializers.CharField(help_text="vnfd Version", required=False, allow_null=True)
vnfProvider = serializers.CharField(help_text="vnf Provider", required=False, allow_null=True)
instantiatedVnfInfo = instantiatedVnfInfoSerializer(help_text="instantiatedVnfInfo", required=True)
+
+
+class VnfsInfoSerializer(serializers.ListSerializer):
+ child = VnfInfoSerializer()
diff --git a/lcm/lcm/nf/vnfs/views.py b/lcm/lcm/nf/vnfs/views.py
index 1980fd48..171de9ce 100644
--- a/lcm/lcm/nf/vnfs/views.py
+++ b/lcm/lcm/nf/vnfs/views.py
@@ -20,7 +20,7 @@ from rest_framework import status
from rest_framework.response import Response
from rest_framework.views import APIView
-from lcm.nf.vnfs.serializers import CreateVnfReqSerializer, CreateVnfRespSerializer
+from lcm.nf.vnfs.serializers import CreateVnfReqSerializer, CreateVnfRespSerializer, VnfsInfoSerializer
from lcm.nf.vnfs.vnf_cancel.delete_vnf_identifier import DeleteVnf
from lcm.nf.vnfs.vnf_cancel.term_vnf import TermVnf
from lcm.nf.vnfs.vnf_create.create_vnf_identifier import CreateVnf
@@ -33,19 +33,31 @@ logger = logging.getLogger(__name__)
class CreateVnfAndQueryVnfs(APIView):
+ @swagger_auto_schema(
+ request_body=None,
+ responses={
+ status.HTTP_200_OK: VnfsInfoSerializer(),
+ status.HTTP_500_INTERNAL_SERVER_ERROR: "Internal error"
+ }
+ )
def get(self, request):
logger.debug("QueryMultiVnf--get::> %s" % request.data)
try:
resp_data = QueryVnf(request.data).query_multi_vnf()
+
+ vnfsInfoSerializer = VnfsInfoSerializer(data=resp_data)
+ resp_isValid = vnfsInfoSerializer.is_valid()
+ if not resp_isValid:
+ raise NFLCMException(vnfsInfoSerializer.errors)
+
+ return Response(data=vnfsInfoSerializer.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)
except Exception as e:
logger.error(e.message)
logger.error(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)
+ return Response(data={'error': 'Failed to get Vnfs'}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
@swagger_auto_schema(
request_body=CreateVnfReqSerializer(),
@@ -63,10 +75,8 @@ class CreateVnfAndQueryVnfs(APIView):
raise NFLCMException(req_serializer.errors)
nf_inst_id = CreateVnf(req_serializer.data).do_biz()
- rsp = {
- "vnfInstanceId": nf_inst_id
- }
- resp_serializer = CreateVnfRespSerializer(data=rsp)
+
+ resp_serializer = CreateVnfRespSerializer(data={"vnfInstanceId": nf_inst_id})
resp_isValid = resp_serializer.is_valid()
if not resp_isValid:
raise NFLCMException(resp_serializer.errors)