diff options
author | ying.yunlong <ying.yunlong@zte.com.cn> | 2018-01-31 10:51:00 +0800 |
---|---|---|
committer | ying.yunlong <ying.yunlong@zte.com.cn> | 2018-01-31 10:51:00 +0800 |
commit | 607b3528fc1fae6517c875b3de9ef70250e31275 (patch) | |
tree | 84d3b44ca6666ee17771843eb2633db9997788ba | |
parent | 44dcff6aec926b143c4de59f77e4de37540299e9 (diff) |
Add vfc-vnflcm getVnf auto-swagger
Change-Id: I76ad78e1cf7157d2606debc6dd39e7f6de43b4e5
Issue-ID: VFC-682
Signed-off-by: ying.yunlong <ying.yunlong@zte.com.cn>
-rw-r--r-- | lcm/lcm/nf/vnfs/serializers.py | 2 | ||||
-rw-r--r-- | lcm/lcm/nf/vnfs/views.py | 17 |
2 files changed, 15 insertions, 4 deletions
diff --git a/lcm/lcm/nf/vnfs/serializers.py b/lcm/lcm/nf/vnfs/serializers.py index d1f462a2..2516bc9d 100644 --- a/lcm/lcm/nf/vnfs/serializers.py +++ b/lcm/lcm/nf/vnfs/serializers.py @@ -244,7 +244,7 @@ class AdditionalParamsSerializer(serializers.Serializer): inputs = serializers.DictField( help_text="inputs", child=serializers.CharField( - help_text="but i needed to test these 2 fields somehow", + help_text="custom key-value", allow_blank=True), required=False, allow_null=True) diff --git a/lcm/lcm/nf/vnfs/views.py b/lcm/lcm/nf/vnfs/views.py index c8f6b1b7..b114ee58 100644 --- a/lcm/lcm/nf/vnfs/views.py +++ b/lcm/lcm/nf/vnfs/views.py @@ -21,7 +21,7 @@ from rest_framework.response import Response from rest_framework.views import APIView from lcm.nf.vnfs.serializers import CreateVnfReqSerializer, CreateVnfRespSerializer, VnfsInfoSerializer, \ - InstantiateVnfResponseSerializer, InstantiateVnfRequestSerializer + InstantiateVnfResponseSerializer, InstantiateVnfRequestSerializer, VnfInfoSerializer 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 @@ -35,7 +35,6 @@ 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" @@ -127,10 +126,23 @@ class InstantiateVnf(APIView): class DeleteVnfAndQueryVnf(APIView): + @swagger_auto_schema( + responses={ + status.HTTP_200_OK: VnfInfoSerializer(), + status.HTTP_500_INTERNAL_SERVER_ERROR: "Internal error" + } + ) def get(self, request, instanceid): logger.debug("QuerySingleVnf--get::> %s" % request.data) try: resp_data = QueryVnf(request.data, instanceid).query_single_vnf() + + vnfInfoSerializer = VnfInfoSerializer(data=resp_data) + resp_isValid = vnfInfoSerializer.is_valid() + if not resp_isValid: + raise NFLCMException(vnfInfoSerializer.errors) + + return Response(data=vnfInfoSerializer.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) @@ -139,7 +151,6 @@ class DeleteVnfAndQueryVnf(APIView): 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_200_OK) def delete(self, request, instanceid): logger.debug("DeleteVnfIdentifier--delete::> %s" % request.data) |