diff options
Diffstat (limited to 'lcm')
-rw-r--r-- | lcm/lcm/nf/biz/grant_vnf.py | 12 | ||||
-rw-r--r-- | lcm/lcm/nf/biz/instantiate_vnf.py | 40 |
2 files changed, 11 insertions, 41 deletions
diff --git a/lcm/lcm/nf/biz/grant_vnf.py b/lcm/lcm/nf/biz/grant_vnf.py index 268e8e4f..1997e0c0 100644 --- a/lcm/lcm/nf/biz/grant_vnf.py +++ b/lcm/lcm/nf/biz/grant_vnf.py @@ -26,7 +26,7 @@ def grant_resource(data, nf_inst_id, job_id, grant_type, vdus): logger.info("Grant resource begin") if grant_type == "Terminate": lifecycleOperration = "Terminate" - elif grant_type == "instantiate": + elif grant_type == "Instantiate": lifecycleOperration = "Instantiate" content_args = { @@ -36,8 +36,8 @@ def grant_resource(data, nf_inst_id, job_id, grant_type, vdus): 'vnfLcmOpOccId': job_id, 'addResources': [], 'removeResources': [], - 'placementConstraint': [], - 'additionalParam': {} + 'placementConstraints': [], + 'additionalParams': {} } if grant_type == "Terminate": @@ -49,7 +49,7 @@ def grant_resource(data, nf_inst_id, job_id, grant_type, vdus): 'resDesId': vdu.resouceid} content_args['removeResources'].append(res_def) res_index += 1 - content_args['additionalParam']['vimid'] = vdus[0].vimid + content_args['additionalParams']['vimid'] = vdus[0].vimid elif grant_type == "Instantiate": vim_id = ignore_case_get(ignore_case_get(data, "additionalParams"), "vimId") res_index = 1 @@ -61,10 +61,10 @@ def grant_resource(data, nf_inst_id, job_id, grant_type, vdus): } content_args['addResources'].append(res_def) res_index += 1 - content_args['additionalParam']['vimid'] = vim_id + content_args['additionalParams']['vimid'] = vim_id vnfInsts = NfInstModel.objects.filter(nfinstid=nf_inst_id) - content_args['additionalParam']['vnfmid'] = vnfInsts[0].vnfminstid + content_args['additionalParams']['vnfmid'] = vnfInsts[0].vnfminstid logger.info('Grant request data=%s' % content_args) apply_result = apply_grant_to_nfvo(json.dumps(content_args)) return apply_result diff --git a/lcm/lcm/nf/biz/instantiate_vnf.py b/lcm/lcm/nf/biz/instantiate_vnf.py index 01f1ef7e..9b89c26d 100644 --- a/lcm/lcm/nf/biz/instantiate_vnf.py +++ b/lcm/lcm/nf/biz/instantiate_vnf.py @@ -21,12 +21,13 @@ from threading import Thread from lcm.pub.database.models import NfInstModel, VmInstModel, NetworkInstModel, \ SubNetworkInstModel, PortInstModel, StorageInstModel, FlavourInstModel, VNFCInstModel from lcm.pub.exceptions import NFLCMException -from lcm.pub.msapi.gvnfmdriver import apply_grant_to_nfvo, notify_lcm_to_nfvo +from lcm.pub.msapi.gvnfmdriver import notify_lcm_to_nfvo from lcm.pub.msapi.sdc_run_catalog import query_vnfpackage_by_id from lcm.pub.utils.jobutil import JobUtil from lcm.pub.utils.timeutil import now_time from lcm.pub.utils.values import ignore_case_get, get_none, get_boolean, get_integer from lcm.pub.vimapi import adaptor +from lcm.nf.biz.grant_vnf import grant_resource logger = logging.getLogger(__name__) @@ -38,6 +39,7 @@ class InstantiateVnf(Thread): self.nf_inst_id = nf_inst_id self.job_id = job_id self.vim_id = ignore_case_get(ignore_case_get(self.data, "additionalParams"), "vimId") + self.grant_type = "Instantiate" def run(self): try: @@ -108,41 +110,9 @@ class InstantiateVnf(Thread): logger.info("Nf instancing pre-check finish") def apply_grant(self): - logger.info('Send resource grand request to nfvo') - content_args = { - 'vnfInstanceId': self.nf_inst_id, - 'vnfDescriptorId': '', - 'lifecycleOperation': 'Instantiate', - 'jobId': self.job_id, - 'addResource': [], - 'removeResource': [], - 'placementConstraint': [], - 'additionalParam': {} - } - vdus = ignore_case_get(self.vnfd_info, "vdus") - res_index = 1 - for vdu in vdus: - res_def = { - 'type': 'VDU', - 'resDefId': str(res_index), - 'resDesId': ignore_case_get(vdu, "vdu_id") - } - content_args['addResource'].append(res_def) - res_index += 1 - - logger.debug("VnfInst = %s", self.nf_inst_id) - ''' - vnfmInfo = NfvoRegInfoModel.objects.filter(nfvoid=self.nf_inst_id) - if len(vnfmInfo) == 0: - raise NFLCMException('VnfInst(%s) does not exist' % self.nf_inst_id) - ''' - nfInsts = NfInstModel.objects.filter(nfinstid=self.nf_inst_id) - content_args['additionalParam']['vnfmid'] = nfInsts[0].vnfminstid - content_args['additionalParam']['vimid'] = self.vim_id - logger.info('Grant request data = %s', content_args) - - apply_result = apply_grant_to_nfvo(json.dumps(content_args)) + apply_result = grant_resource(data=self.data, nf_inst_id=self.nf_inst_id, job_id=self.job_id, + grant_type=self.grant_type, vdus=vdus) self.set_location(apply_result) logger.info('VnfdInfo = %s' % self.vnfd_info) |