diff options
author | Fu Jinhua <fu.jinhua@zte.com.cn> | 2018-08-08 05:40:19 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2018-08-08 05:40:19 +0000 |
commit | f34bc365946d633a4f4802a7d7ffdd8e199623c4 (patch) | |
tree | 707cf951cb278ab45fc89399bf8c445cbcdd99ee | |
parent | 2b1d51f9b81ecd6318f61755f08bb8d2e3c8b1ff (diff) | |
parent | c0683afc58b07bba7f5105d9785e19adf84e9bdc (diff) |
Merge "CreateVnf and DeleteVnf"
-rw-r--r-- | lcm/lcm/nf/biz/create_vnf.py | 38 | ||||
-rw-r--r-- | lcm/lcm/nf/views/curd_vnf_views.py | 7 |
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) |