1 # Copyright (C) 2019 ZTE. All Rights Reserved.
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
17 from drf_yasg.utils import swagger_auto_schema
18 from rest_framework import status
19 from rest_framework.views import APIView
21 from lcm.nf.serializers.scale_vnf_request import ScaleVnfRequestSerializer
22 from lcm.nf.serializers.response import ProblemDetailsSerializer
23 from lcm.nf.biz.scale_vnf import ScaleVnf
24 from lcm.nf.const import VNF_STATUS
25 from lcm.nf.const import OPERATION_TYPE
26 from .common import view_safe_call_with_log
27 from .common import deal_vnf_action
29 logger = logging.getLogger(__name__)
32 class ScaleVnfView(APIView):
34 request_body=ScaleVnfRequestSerializer(),
36 status.HTTP_202_ACCEPTED: "Success",
37 status.HTTP_404_NOT_FOUND: ProblemDetailsSerializer(),
38 status.HTTP_409_CONFLICT: ProblemDetailsSerializer(),
39 status.HTTP_500_INTERNAL_SERVER_ERROR: "Internal error"
42 @view_safe_call_with_log(logger=logger)
43 def post(self, request, instanceid):
44 return deal_vnf_action(
46 opt_type=OPERATION_TYPE.SCALE,
47 opt_status=VNF_STATUS.SCALING,
50 req_serializer=ScaleVnfRequestSerializer,