diff options
author | fujinhua <fu.jinhua@zte.com.cn> | 2019-04-23 12:03:46 +0800 |
---|---|---|
committer | fujinhua <fu.jinhua@zte.com.cn> | 2019-04-23 12:12:18 +0800 |
commit | aacae59d128707dea731664f4c164ef92330c4a9 (patch) | |
tree | 832375247d26745495fba1045a091e19e2ab3ca8 | |
parent | 0b6a4c7cb7244eb895ac45b59d6b8bc8721a5b27 (diff) |
Refactor codes for pnf descriptor
Change-Id: I78f1a4de70c31db64e5306024f06acaee5958a8e
Issue-ID: VFC-1306
Signed-off-by: fujinhua <fu.jinhua@zte.com.cn>
-rw-r--r-- | catalog/packages/views/pnf_descriptor_views.py | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/catalog/packages/views/pnf_descriptor_views.py b/catalog/packages/views/pnf_descriptor_views.py index 897644d5..2b99fd93 100644 --- a/catalog/packages/views/pnf_descriptor_views.py +++ b/catalog/packages/views/pnf_descriptor_views.py @@ -25,10 +25,10 @@ from catalog.packages.serializers.create_pnfd_info_request import CreatePnfdInfo from catalog.packages.serializers.pnfd_info import PnfdInfoSerializer from catalog.packages.serializers.pnfd_infos import PnfdInfosSerializer from catalog.packages.views.common import validate_data -from catalog.pub.exceptions import CatalogException from catalog.packages.serializers.catalog_serializers import ParseModelRequestSerializer from catalog.packages.serializers.catalog_serializers import ParseModelResponseSerializer from catalog.packages.serializers.catalog_serializers import InternalErrorRequestSerializer +from catalog.packages.serializers.response import ProblemDetailsSerializer from catalog.pub.utils.syscomm import fun_name from catalog.pub.utils.values import ignore_case_get from .common import view_safe_call_with_log @@ -42,8 +42,8 @@ logger = logging.getLogger(__name__) request_body=no_body, responses={ status.HTTP_200_OK: PnfdInfoSerializer(), - status.HTTP_404_NOT_FOUND: "PNFD does not exist", - status.HTTP_500_INTERNAL_SERVER_ERROR: "Internal error" + status.HTTP_404_NOT_FOUND: ProblemDetailsSerializer(), + status.HTTP_500_INTERNAL_SERVER_ERROR: ProblemDetailsSerializer() } ) @swagger_auto_schema( @@ -52,7 +52,7 @@ logger = logging.getLogger(__name__) request_body=no_body, responses={ status.HTTP_204_NO_CONTENT: "No content", - status.HTTP_500_INTERNAL_SERVER_ERROR: "Internal error" + status.HTTP_500_INTERNAL_SERVER_ERROR: ProblemDetailsSerializer() } ) @api_view(http_method_names=['GET', 'DELETE']) @@ -77,7 +77,7 @@ def pnfd_info_rd(request, **kwargs): # TODO request_body=CreatePnfdInfoRequestSerializer(), responses={ status.HTTP_201_CREATED: PnfdInfoSerializer(), - status.HTTP_500_INTERNAL_SERVER_ERROR: "Internal error" + status.HTTP_500_INTERNAL_SERVER_ERROR: ProblemDetailsSerializer() } ) @swagger_auto_schema( @@ -86,7 +86,7 @@ def pnfd_info_rd(request, **kwargs): # TODO request_body=no_body, responses={ status.HTTP_200_OK: PnfdInfosSerializer(), - status.HTTP_500_INTERNAL_SERVER_ERROR: "Internal error" + status.HTTP_500_INTERNAL_SERVER_ERROR: ProblemDetailsSerializer() } ) @api_view(http_method_names=['POST', 'GET']) @@ -114,7 +114,7 @@ def pnf_descriptors_rc(request): request_body=no_body, responses={ status.HTTP_204_NO_CONTENT: "No content", - status.HTTP_500_INTERNAL_SERVER_ERROR: "Internal error" + status.HTTP_500_INTERNAL_SERVER_ERROR: ProblemDetailsSerializer() } ) @swagger_auto_schema( @@ -123,8 +123,8 @@ def pnf_descriptors_rc(request): request_body=no_body, responses={ status.HTTP_204_NO_CONTENT: 'PNFD file', - status.HTTP_404_NOT_FOUND: "PNFD does not exist", - status.HTTP_500_INTERNAL_SERVER_ERROR: "Internal error" + status.HTTP_404_NOT_FOUND: ProblemDetailsSerializer(), + status.HTTP_500_INTERNAL_SERVER_ERROR: ProblemDetailsSerializer() } ) @api_view(http_method_names=['PUT', 'GET']) @@ -137,9 +137,6 @@ def pnfd_content_ru(request, **kwargs): local_file_name = PnfDescriptor().upload(files[0], pnfd_info_id) PnfDescriptor().parse_pnfd_and_save(pnfd_info_id, local_file_name) return Response(data=None, status=status.HTTP_204_NO_CONTENT) - except CatalogException as e: - PnfDescriptor().handle_upload_failed(pnfd_info_id) - raise e except Exception as e: PnfDescriptor().handle_upload_failed(pnfd_info_id) raise e |