diff options
author | fujinhua <fu.jinhua@zte.com.cn> | 2018-09-19 09:46:38 +0800 |
---|---|---|
committer | fujinhua <fu.jinhua@zte.com.cn> | 2018-09-19 09:46:38 +0800 |
commit | b03a30d541b972ac034baf4bd0e08d339ed3e78d (patch) | |
tree | 6357c1c6188c2df834ccbef8ddfaffe060cdb160 | |
parent | 7da623c2e406835765f7082f541df6f8dab174c2 (diff) |
Move inst ns view as single
Change-Id: Ifa460ec9260226bfb29df73a5a7b153f45e486c0
Issue-ID: VFC-1009
Signed-off-by: fujinhua <fu.jinhua@zte.com.cn>
-rw-r--r-- | lcm/ns/urls.py | 3 | ||||
-rw-r--r-- | lcm/ns/views/inst_ns_view.py | 49 | ||||
-rw-r--r-- | lcm/ns/views/views.py | 26 |
3 files changed, 51 insertions, 27 deletions
diff --git a/lcm/ns/urls.py b/lcm/ns/urls.py index d2d35b55..94070146 100644 --- a/lcm/ns/urls.py +++ b/lcm/ns/urls.py @@ -15,7 +15,8 @@ from django.conf.urls import url from rest_framework.urlpatterns import format_suffix_patterns from lcm.ns.views.create_ns_view import CreateNSView -from lcm.ns.views.views import NSInstView, TerminateNSView, NSDetailView, NSInstPostDealView, \ +from lcm.ns.views.inst_ns_view import NSInstView +from lcm.ns.views.views import TerminateNSView, NSDetailView, NSInstPostDealView, \ NSManualScaleView, NSHealView urlpatterns = [ diff --git a/lcm/ns/views/inst_ns_view.py b/lcm/ns/views/inst_ns_view.py new file mode 100644 index 00000000..0f54429e --- /dev/null +++ b/lcm/ns/views/inst_ns_view.py @@ -0,0 +1,49 @@ +# Copyright 2016-2017 ZTE Corporation. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +import logging + +from rest_framework import status +from rest_framework.response import Response +from rest_framework.views import APIView +from drf_yasg.utils import swagger_auto_schema + +from lcm.ns.biz.ns_instant import InstantNSService +from lcm.ns.serializers.ns_serializers import InstantNsReqSerializer +from lcm.ns.serializers.ns_serializers import NsOperateJobSerializer + +logger = logging.getLogger(__name__) + + +class NSInstView(APIView): + @swagger_auto_schema( + request_body=InstantNsReqSerializer(), + responses={ + status.HTTP_200_OK: NsOperateJobSerializer(), + status.HTTP_500_INTERNAL_SERVER_ERROR: "Inner error" + } + ) + def post(self, request, ns_instance_id): + logger.debug("Enter NSInstView::post::ns_instance_id=%s", ns_instance_id) + logger.debug("request.data=%s", request.data) + req_serializer = InstantNsReqSerializer(data=request.data) + if not req_serializer.is_valid(): + return Response({'error': req_serializer.errors}, + status=status.HTTP_500_INTERNAL_SERVER_ERROR) + ack = InstantNSService(ns_instance_id, request.data).do_biz() + resp_serializer = NsOperateJobSerializer(data=ack['data']) + if not resp_serializer.is_valid(): + return Response({'error': resp_serializer.errors}, + status=status.HTTP_500_INTERNAL_SERVER_ERROR) + logger.debug("Leave NSInstView::post::ack=%s", ack) + return Response(data=resp_serializer.data, status=ack['status']) diff --git a/lcm/ns/views/views.py b/lcm/ns/views/views.py index eae489b9..19ff8c01 100644 --- a/lcm/ns/views/views.py +++ b/lcm/ns/views/views.py @@ -18,7 +18,6 @@ import traceback from drf_yasg.utils import swagger_auto_schema from lcm.ns.biz.ns_get import GetNSInfoService from lcm.ns.biz.ns_heal import NSHealService -from lcm.ns.biz.ns_instant import InstantNSService from lcm.ns.biz.ns_manual_scale import NSManualScaleService from lcm.ns.biz.ns_terminate import TerminateNsService from rest_framework import status @@ -28,7 +27,6 @@ from rest_framework.views import APIView from lcm.ns.biz.ns_delete import DeleteNsService from lcm.ns.serializers.ns_serializers import HealNsReqSerializer from lcm.ns.serializers.ns_serializers import InstNsPostDealReqSerializer -from lcm.ns.serializers.ns_serializers import InstantNsReqSerializer from lcm.ns.serializers.ns_serializers import ManualScaleNsReqSerializer from lcm.ns.serializers.ns_serializers import NsOperateJobSerializer from lcm.ns.serializers.ns_serializers import QueryNsRespSerializer @@ -42,30 +40,6 @@ from lcm.pub.utils.values import ignore_case_get logger = logging.getLogger(__name__) -class NSInstView(APIView): - @swagger_auto_schema( - request_body=InstantNsReqSerializer(), - responses={ - status.HTTP_200_OK: NsOperateJobSerializer(), - status.HTTP_500_INTERNAL_SERVER_ERROR: "Inner error" - } - ) - def post(self, request, ns_instance_id): - logger.debug("Enter NSInstView::post::ns_instance_id=%s", ns_instance_id) - logger.debug("request.data=%s", request.data) - req_serializer = InstantNsReqSerializer(data=request.data) - if not req_serializer.is_valid(): - return Response({'error': req_serializer.errors}, - status=status.HTTP_500_INTERNAL_SERVER_ERROR) - ack = InstantNSService(ns_instance_id, request.data).do_biz() - resp_serializer = NsOperateJobSerializer(data=ack['data']) - if not resp_serializer.is_valid(): - return Response({'error': resp_serializer.errors}, - status=status.HTTP_500_INTERNAL_SERVER_ERROR) - logger.debug("Leave NSInstView::post::ack=%s", ack) - return Response(data=resp_serializer.data, status=ack['status']) - - class TerminateNSView(APIView): @swagger_auto_schema( request_body=TerminateNsReqSerializer(), |