1 # Copyright 2017 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 rest_framework import status
18 from rest_framework.response import Response
19 from rest_framework.views import APIView
21 from lcm.nf.vnfs.vnf_create.create_vnf_identifier import CreateVnf
22 from lcm.pub.utils.jobutil import JobUtil
23 from lcm.pub.utils.values import ignore_case_get
25 logger = logging.getLogger(__name__)
28 class CreateVnfIdentifier(APIView):
29 def post(self, request):
30 logger.debug("CreateVnfIdentifier--post::> %s" % request.data)
32 data["vnfdId"] = ignore_case_get(request.data, "vnfdId")
33 data["vnfInstanceName"] = ignore_case_get(request.data, "vnfInstanceName")
34 data["vnfInstanceDescription"] = ignore_case_get(request.data, "vnfInstanceDescription")
36 self.nf_inst_id = CreateVnf(data).do_biz()
37 except Exception as e:
38 return Response(data={'error': '%s' % e.message}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
39 rsp = {"vnfInstanceId": self.nf_inst_id}
40 return Response(data=rsp, status=status.HTTP_201_CREATED)
43 class InstantiateVnf(APIView):
44 def post(self, request, instanceId):
45 logger.debug("InstantiateVnf--post::> %s" % request.data)
46 data = {'flavourId': ignore_case_get(request.data, 'flavourId'),
47 'instantiationLevelId': ignore_case_get(request.data, 'instantiationLevelId'),
48 'extVirtualLinks': ignore_case_get(request.data, 'extVirtualLinks'),
49 'localizationLanguage': ignore_case_get(request.data, 'localizationLanguage'),
50 'additionalParams': ignore_case_get(request.data, 'additionalParams')}
51 nf_inst_id = instanceId
52 job_id = JobUtil.create_job('NF', 'CREATE', nf_inst_id)
53 JobUtil.add_job_status(job_id, 0, "INST_VNF_READY")
55 # CreateVnfs(data, nf_inst_id, job_id).start()
56 rsp = {"jobId": job_id}
57 return Response(data=rsp, status=status.HTTP_202_ACCEPTED)
60 class DeleteVnfIdentifier(APIView):
61 def delete(self, request):
62 logger.debug("DeleteVnfIdentifier--delete::> %s" % request.data)
63 return Response(data='', status=status.HTTP_202_ACCEPTED)
66 class TerminateVnf(APIView):
67 def post(self, request):
68 logger.debug("TerminateVnf--post::> %s" % request.data)
69 return Response(data='', status=status.HTTP_202_ACCEPTED)
72 class QueryMultipleVnf(APIView):
73 def get(self, request):
74 logger.debug("QueryMultipleVnf--get::> %s" % request.data)
75 return Response(data='', status=status.HTTP_202_ACCEPTED)
78 class QuerySingleVnf(APIView):
79 def get(self, request):
80 logger.debug("QuerySingleVnf--get::> %s" % request.data)
81 return Response(data='', status=status.HTTP_202_ACCEPTED)
84 class GetOperationStatus(APIView):
85 def get(self, request):
86 logger.debug("GetOperationStatus--get::> %s" % request.data)
87 return Response(data='', status=status.HTTP_202_ACCEPTED)