diff options
author | 2017-02-21 14:35:00 +0800 | |
---|---|---|
committer | 2017-02-21 14:35:00 +0800 | |
commit | b6987c5ad68ba3211b65967ca727d2f7e144fff1 (patch) | |
tree | 09722e8a2169b763ed5a563c2959e6a0d4440668 | |
parent | b73b78bb2f65c89b5506b8450388ad6cb982b887 (diff) |
Modify code of Create VNF Identifier
Change-Id: Ib96ec86612e33adf9018f6b99affaff03365abab
Issue-Id: GVNFM-12
Signed-off-by: ying.yunlong <ying.yunlong@zte.com.cn>
-rw-r--r-- | lcm/lcm/nf/vnfs/vnf_create/create_vnf_identifier.py | 48 |
1 files changed, 27 insertions, 21 deletions
diff --git a/lcm/lcm/nf/vnfs/vnf_create/create_vnf_identifier.py b/lcm/lcm/nf/vnfs/vnf_create/create_vnf_identifier.py index 580c531b..ceda2249 100644 --- a/lcm/lcm/nf/vnfs/vnf_create/create_vnf_identifier.py +++ b/lcm/lcm/nf/vnfs/vnf_create/create_vnf_identifier.py @@ -43,29 +43,35 @@ class CreateVnf: if is_exist: raise NFLCMException('VNF is already exist.') - # get package_info from nslcm by vnfd_id - self.package_info = get_packageinfo_by_vnfdid(self.vnfd_id) - self.package_id = ignore_case_get(self.package_info, "package_id") - self.csar_id = ignore_case_get(self.package_info, "csar_id") + nf_inst_id = str(uuid.uuid4()) + try: + # get package_info from nslcm by vnfd_id + self.package_info = get_packageinfo_by_vnfdid(self.vnfd_id) + self.package_id = ignore_case_get(self.package_info, "package_id") + self.csar_id = ignore_case_get(self.package_info, "csar_id") - # get rawdata from catalog by csar_id - raw_data = query_rawdata_from_catalog(self.csar_id, self.data) - self.vnfd = toscautil.convert_vnfd_model(raw_data["rawData"]) # convert to inner json - self.vnfd = json.JSONDecoder().decode(self.vnfd) + # get rawdata from catalog by csar_id + raw_data = query_rawdata_from_catalog(self.csar_id, self.data) + self.vnfd = toscautil.convert_vnfd_model(raw_data["rawData"]) # convert to inner json + self.vnfd = json.JSONDecoder().decode(self.vnfd) - metadata = ignore_case_get(self.vnfd, "metadata") - version = ignore_case_get(metadata, "vnfd_version") - vendor = ignore_case_get(metadata, "vendor") - netype = ignore_case_get(metadata, "vnf_type") - vnfsoftwareversion = ignore_case_get(metadata, "version") - vnfd_model = self.vnfd + metadata = ignore_case_get(self.vnfd, "metadata") + version = ignore_case_get(metadata, "vnfd_version") + vendor = ignore_case_get(metadata, "vendor") + netype = ignore_case_get(metadata, "vnf_type") + vnfsoftwareversion = ignore_case_get(metadata, "version") + vnfd_model = self.vnfd + NfInstModel.objects.create(nfinstid=nf_inst_id, nf_name=self.vnf_instance_mame, package_id=self.package_id, + version=version, vendor=vendor, netype=netype, vnfd_model=vnfd_model, + status='NOT_INSTANTIATED', nf_desc=self.description, vnfdid=self.vnfd_id, + vnfSoftwareVersion=vnfsoftwareversion, create_time=now_time()) + except: + NfInstModel.objects.create(nfinstid=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.vnfd_id, + vnfSoftwareVersion='', create_time=now_time()) - nf_inst_id = str(uuid.uuid4()) - NfInstModel.objects.create(nfinstid=nf_inst_id, nf_name=self.vnf_instance_mame, package_id=self.package_id, - version=version, vendor=vendor, netype=netype, vnfd_model=vnfd_model, - status='NOT_INSTANTIATED', nf_desc=self.description, vnfdid=self.vnfd_id, - vnfSoftwareVersion=vnfsoftwareversion, create_time=now_time()) vnf_inst = NfInstModel.objects.get(nfinstid=nf_inst_id) - logger.debug('id is [%s],name is [%s],vnfd_id is [%s],description is [%s],create_time is [%s]' % - (vnf_inst.nfinstid, vnf_inst.nf_name, vnf_inst.vnfdid, vnf_inst.nf_desc, vnf_inst.create_time)) + logger.debug('id is [%s],name is [%s],vnfd_id is [%s],vnfd_model is [%s],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 nf_inst_id |