1 # Copyright 2019 ZTE Corporation.
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.change_vnf_flavour_request import ChangeVnfFlavourRequestSerializer
22 from lcm.nf.serializers.response import ProblemDetailsSerializer
23 from lcm.nf.const import VNF_STATUS
24 from lcm.nf.const import OPERATION_TYPE
25 from lcm.nf.biz.change_vnf_flavour import ChangeVnfFlavour
26 from .common import view_safe_call_with_log
27 from .common import deal_vnf_action
29 logger = logging.getLogger(__name__)
32 class ChangeVnfFlavourView(APIView):
34 request_body=ChangeVnfFlavourRequestSerializer(),
36 status.HTTP_202_ACCEPTED: "Empty",
37 status.HTTP_404_NOT_FOUND: ProblemDetailsSerializer(),
38 status.HTTP_409_CONFLICT: ProblemDetailsSerializer(),
39 status.HTTP_500_INTERNAL_SERVER_ERROR: ProblemDetailsSerializer()
42 @view_safe_call_with_log(logger=logger)
43 def post(self, request, instanceid):
44 return deal_vnf_action(
46 opt_type=OPERATION_TYPE.CHANGE_FLAVOUR,
47 opt_status=VNF_STATUS.UPDATING,
50 req_serializer=ChangeVnfFlavourRequestSerializer,
51 act_task=ChangeVnfFlavour