summaryrefslogtreecommitdiffstats
path: root/lcm
diff options
context:
space:
mode:
Diffstat (limited to 'lcm')
-rw-r--r--lcm/lcm/nf/views.py3
-rw-r--r--lcm/lcm/nf/vnf_create/create_vnf_identifier.py14
-rw-r--r--lcm/lcm/v2/views.py12
3 files changed, 21 insertions, 8 deletions
diff --git a/lcm/lcm/nf/views.py b/lcm/lcm/nf/views.py
index 94860d79..0db9d5fa 100644
--- a/lcm/lcm/nf/views.py
+++ b/lcm/lcm/nf/views.py
@@ -72,7 +72,8 @@ class CreateVnfAndQueryVnfs(APIView):
if not req_serializer.is_valid():
raise NFLCMException(req_serializer.errors)
- nf_inst_id = CreateVnf(req_serializer.data).do_biz()
+ resp = CreateVnf(req_serializer.data).do_biz()
+ nf_inst_id = resp.get('id', 'undefined')
create_vnf_resp_serializer = CreateVnfRespSerializer(data={"vnfInstanceId": nf_inst_id})
if not create_vnf_resp_serializer.is_valid():
diff --git a/lcm/lcm/nf/vnf_create/create_vnf_identifier.py b/lcm/lcm/nf/vnf_create/create_vnf_identifier.py
index 12f540da..62571a1b 100644
--- a/lcm/lcm/nf/vnf_create/create_vnf_identifier.py
+++ b/lcm/lcm/nf/vnf_create/create_vnf_identifier.py
@@ -63,7 +63,19 @@ class CreateVnf:
'description is [%s],create_time is [%s]' %
(vnf_inst.nfinstid, vnf_inst.nf_name, vnf_inst.vnfdid,
vnf_inst.vnfd_model, vnf_inst.nf_desc, vnf_inst.create_time))
- return self.nf_inst_id
+ resp = {
+ 'id': vnf_inst.nfinstid,
+ 'vnfInstanceName': vnf_inst.nf_name,
+ 'vnfInstanceDescription': 'Human-readable description of the VNF instance.',
+ 'vnfdId': vnf_inst.vnfdid,
+ 'vnfProvider': vnf_inst.vendor,
+ 'vnfProductName': vnf_inst.nf_name,
+ 'vnfSoftwareVersion': vnf_inst.vnfSoftwareVersion,
+ 'vnfdVersion': vnf_inst.version,
+ 'vnfPkgId': vnf_inst.package_id,
+ 'vnfConfigurableProperties': []
+ }
+ return resp
def check_valid(self):
logger.debug("CreateVnf--check_valid::> %s" % self.data)
diff --git a/lcm/lcm/v2/views.py b/lcm/lcm/v2/views.py
index 1c66c1c0..8fdb8e63 100644
--- a/lcm/lcm/v2/views.py
+++ b/lcm/lcm/v2/views.py
@@ -20,7 +20,7 @@ from rest_framework import status
from rest_framework.response import Response
from rest_framework.views import APIView
-from lcm.nf.serializers import CreateVnfReqSerializer, CreateVnfRespSerializer
+from lcm.nf.serializers import CreateVnfReqSerializer
from lcm.nf.vnf_create.create_vnf_identifier import CreateVnf
from lcm.pub.exceptions import NFLCMException
from lcm.v2.serializers import VnfInstanceSerializer
@@ -43,12 +43,12 @@ class CreateVnfAndQueryVnfs(APIView):
if not req_serializer.is_valid():
raise NFLCMException(req_serializer.errors)
- nf_inst_id = CreateVnf(req_serializer.data).do_biz()
+ resp = CreateVnf(req_serializer.data).do_biz()
- create_vnf_resp_serializer = CreateVnfRespSerializer(data={"vnfInstanceId": nf_inst_id})
- if not create_vnf_resp_serializer.is_valid():
- raise NFLCMException(create_vnf_resp_serializer.errors)
- return Response(data=create_vnf_resp_serializer.data, status=status.HTTP_201_CREATED)
+ vnfInstanceSerializer = VnfInstanceSerializer(data=resp)
+ if not vnfInstanceSerializer.is_valid():
+ raise NFLCMException(vnfInstanceSerializer.errors)
+ return Response(data=vnfInstanceSerializer.data, status=status.HTTP_201_CREATED)
except NFLCMException as e:
logger.error(e.message)
return Response(data={'error': '%s' % e.message}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)