1 # Copyright 2017 ZTE Corporation.
\r
3 # Licensed under the Apache License, Version 2.0 (the "License");
\r
4 # you may not use this file except in compliance with the License.
\r
5 # You may obtain a copy of the License at
\r
7 # http://www.apache.org/licenses/LICENSE-2.0
\r
9 # Unless required by applicable law or agreed to in writing, software
\r
10 # distributed under the License is distributed on an "AS IS" BASIS,
\r
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
12 # See the License for the specific language governing permissions and
\r
13 # limitations under the License.
\r
17 from drf_yasg.utils import swagger_auto_schema
\r
18 from rest_framework import status
\r
19 from rest_framework.views import APIView
\r
21 from lcm.nf.serializers.instantiate_vnf_request import InstantiateVnfRequestSerializer
\r
22 from lcm.nf.serializers.job_identifier import JobIdentifierSerializer
\r
23 from lcm.nf.biz.instantiate_vnf import InstantiateVnf
\r
24 from lcm.nf.const import VNF_STATUS
\r
25 from lcm.nf.const import OPERATION_TYPE
\r
26 from .common import view_safe_call_with_log
\r
27 from .common import deal_vnf_action
\r
29 logger = logging.getLogger(__name__)
\r
32 class InstantiateVnfView(APIView):
\r
33 @swagger_auto_schema(
\r
34 request_body=InstantiateVnfRequestSerializer(),
\r
36 status.HTTP_202_ACCEPTED: JobIdentifierSerializer(),
\r
37 status.HTTP_500_INTERNAL_SERVER_ERROR: "Internal error"
\r
40 @view_safe_call_with_log(logger=logger)
\r
41 def post(self, request, instanceid):
\r
42 return deal_vnf_action(
\r
44 opt_type=OPERATION_TYPE.INSTANTIATE,
\r
45 opt_status=VNF_STATUS.INSTANTIATING,
\r
48 req_serializer=InstantiateVnfRequestSerializer,
\r
49 act_task=InstantiateVnf
\r