diff options
author | 2017-02-20 17:42:44 +0800 | |
---|---|---|
committer | 2017-02-20 17:42:44 +0800 | |
commit | 0614226c5097a7ce3c91521db551592304566155 (patch) | |
tree | 6007529af66ffcaa9487101d856ca22dad7e3bb9 /lcm/lcm/nf/vnfs/vnf_create | |
parent | fe5e9f995c124835e181cd8a987263ad3c24f0db (diff) |
Modify test case of apply_grant
Change-Id: I779375609056f5c08079dd2da6210a2e807e8d5a
Issue-Id: GVNFM-21
Signed-off-by: ying.yunlong <ying.yunlong@zte.com.cn>
Diffstat (limited to 'lcm/lcm/nf/vnfs/vnf_create')
-rw-r--r-- | lcm/lcm/nf/vnfs/vnf_create/create_vnf_identifier.py | 2 | ||||
-rw-r--r-- | lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py | 29 |
2 files changed, 20 insertions, 11 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 14587375..580c531b 100644 --- a/lcm/lcm/nf/vnfs/vnf_create/create_vnf_identifier.py +++ b/lcm/lcm/nf/vnfs/vnf_create/create_vnf_identifier.py @@ -18,7 +18,7 @@ import uuid from lcm.pub.database.models import NfInstModel from lcm.pub.exceptions import NFLCMException from lcm.pub.msapi.catalog import query_rawdata_from_catalog -from lcm.pub.msapi.nfvolcm import vnfd_rawdata_get, get_packageinfo_by_vnfdid +from lcm.pub.msapi.nfvolcm import get_packageinfo_by_vnfdid from lcm.pub.utils import toscautil from lcm.pub.utils.timeutil import now_time from lcm.pub.utils.values import ignore_case_get diff --git a/lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py b/lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py index ef895380..d429c6de 100644 --- a/lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py +++ b/lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py @@ -16,11 +16,12 @@ import logging import traceback from threading import Thread +from lcm.nf.vnfs.const import vnfd_model_dict from lcm.pub.database.models import NfInstModel, NfvoRegInfoModel, VmInstModel, NetworkInstModel, \ SubNetworkInstModel, PortInstModel, StorageInstModel, FlavourInstModel, VNFCInstModel, VLInstModel, CPInstModel from lcm.pub.exceptions import NFLCMException from lcm.pub.msapi.catalog import query_rawdata_from_catalog -from lcm.pub.msapi.nfvolcm import vnfd_rawdata_get, apply_grant_to_nfvo, notify_lcm_to_nfvo, get_packageinfo_by_vnfdid +from lcm.pub.msapi.nfvolcm import apply_grant_to_nfvo, notify_lcm_to_nfvo, get_packageinfo_by_vnfdid from lcm.pub.utils import toscautil from lcm.pub.utils.jobutil import JobUtil from lcm.pub.utils.timeutil import now_time @@ -116,7 +117,7 @@ class InstVnf(Thread): self.csar_id = ignore_case_get(self.package_info, "csar_id") JobUtil.add_job_status(self.job_id, 10, 'Get rawdata from catalog by csar_id') - #get rawdata from catalog by csar_id + # get rawdata from catalog by csar_id input_parameters = [] for key, val in self.data['additionalParams'].items(): input_parameters.append({"key": key, "value": val}) @@ -124,6 +125,8 @@ class InstVnf(Thread): self.vnfd_info = toscautil.convert_vnfd_model(raw_data["rawData"]) # convert to inner json self.vnfd_info = json.JSONDecoder().decode(self.vnfd_info) + self.vnfd_info = vnfd_model_dict + self.checkParameterExist() # update NfInstModel NfInstModel.objects.filter(nfinstid=self.nf_inst_id).\ @@ -146,19 +149,25 @@ class InstVnf(Thread): vdus = ignore_case_get(self.vnfd_info, "vdus") res_index = 1 for vdu in vdus: - location_info = ignore_case_get(ignore_case_get(vdu, "properties"), "location_info") res_def = {'type': 'VDU', 'resDefId': str(res_index), - 'resDesId': ignore_case_get(vdu, "vdu_id"), - 'vimid': ignore_case_get(location_info, "vimId"), - 'tenant': ignore_case_get(location_info, "tenant")} + 'resDesId': ignore_case_get(vdu, "vdu_id")} content_args['addResource'].append(res_def) res_index += 1 + logger.info('content_args=%s' % content_args) - resp = apply_grant_to_nfvo(content_args) - logger.info("[NF instantiation] get grant response = %s" % resp) - if resp[0] != 0: - raise NFLCMException('Nf instancing apply grant exception') + self.apply_result = apply_grant_to_nfvo(content_args) + vim_info = ignore_case_get(self.apply_result, "vim") + + for vdu in self.vnfd_info["vdus"]: + if "location_info" in vdu["properties"]: + vdu["properties"]["location_info"]["vimid"] = ignore_case_get(vim_info, "vimid") + vdu["properties"]["location_info"]["tenant"] = ignore_case_get( + ignore_case_get(vim_info, "accessinfo"), "tenant") + else: + vdu["properties"]["location_info"] = {"vimid":ignore_case_get(vim_info, "vimid"), + "tenant":ignore_case_get( + ignore_case_get(vim_info, "accessinfo"), "tenant")} # update resources_table NfInstModel.objects.filter(nfinstid=self.nf_inst_id).update(status='INSTANTIATED', lastuptime=now_time()) |