summaryrefslogtreecommitdiffstats
path: root/lcm
diff options
context:
space:
mode:
authorbiancunkang <bian.cunkang@zte.com.cn>2018-08-08 11:56:47 +0800
committerbiancunkang <bian.cunkang@zte.com.cn>2018-08-08 12:10:18 +0800
commitc0683afc58b07bba7f5105d9785e19adf84e9bdc (patch)
tree63f688425bcc9bc0045e51b45a7dc1dd41a2ced7 /lcm
parentf3d40972231fa66d4574dbbb92b3fe8e6b9db385 (diff)
CreateVnf and DeleteVnf
Modify create_vnf.py and curd_vnf_views.py Change-Id: I424380bff3c049ad1723efefa8f837284b85e50f Issue-ID: VFC-1015 Signed-off-by: biancunkang <bian.cunkang@zte.com.cn>
Diffstat (limited to 'lcm')
-rw-r--r--lcm/lcm/nf/biz/create_vnf.py38
-rw-r--r--lcm/lcm/nf/views/curd_vnf_views.py7
2 files changed, 6 insertions, 39 deletions
diff --git a/lcm/lcm/nf/biz/create_vnf.py b/lcm/lcm/nf/biz/create_vnf.py
index 34329a52..cf5435ad 100644
--- a/lcm/lcm/nf/biz/create_vnf.py
+++ b/lcm/lcm/nf/biz/create_vnf.py
@@ -13,7 +13,6 @@
# limitations under the License.
import json
import logging
-import traceback
import uuid
from lcm.pub.database.models import NfInstModel
@@ -34,41 +33,10 @@ class CreateVnf:
def do_biz(self):
self.nf_inst_id = str(uuid.uuid4())
- try:
- self.check_valid()
- self.save_db()
- except NFLCMException as e:
- logger.debug('Create VNF instance[%s]: %s', self.nf_inst_id, e.message)
- raise NFLCMException(e.message)
- except Exception as e:
- logger.error(e.message)
- logger.error(traceback.format_exc())
- NfInstModel.objects.create(nfinstid=self.nf_inst_id,
- nf_name=self.vnf_instance_mame,
- package_id='',
- version='',
- vendor='',
- netype='',
- vnfd_model='',
- status='NOT_INSTANTIATED',
- nf_desc=self.description,
- vnfdid=self.csar_id,
- vnfSoftwareVersion='',
- create_time=now_time())
+ self.check_valid()
+ self.save_db()
vnf_inst = NfInstModel.objects.get(nfinstid=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
+ return vnf_inst
def check_valid(self):
is_exist = NfInstModel.objects.filter(nf_name=self.vnf_instance_mame).exists()
diff --git a/lcm/lcm/nf/views/curd_vnf_views.py b/lcm/lcm/nf/views/curd_vnf_views.py
index 16d082c6..33f32a10 100644
--- a/lcm/lcm/nf/views/curd_vnf_views.py
+++ b/lcm/lcm/nf/views/curd_vnf_views.py
@@ -23,8 +23,9 @@ from rest_framework.views import APIView
from lcm.nf.biz.create_vnf import CreateVnf
from lcm.nf.biz.query_vnf import QueryVnf
-from lcm.nf.serializers.serializers import CreateVnfReqSerializer, CreateVnfRespSerializer, VnfsInfoSerializer, \
+from lcm.nf.serializers.serializers import CreateVnfRespSerializer, VnfsInfoSerializer, \
VnfInfoSerializer
+from lcm.nf.serializers.create_vnf_req import CreateVnfReqSerializer
from lcm.pub.exceptions import NFLCMException
logger = logging.getLogger(__name__)
@@ -69,9 +70,7 @@ class CreateVnfAndQueryVnfs(APIView):
if not req_serializer.is_valid():
raise NFLCMException(req_serializer.errors)
- resp = CreateVnf(req_serializer.data).do_biz()
- nf_inst_id = resp.get('id', 'undefined')
-
+ nf_inst_id = CreateVnf(req_serializer.data).do_biz().nfinstid
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)