-
- JobUtil.add_job_status(self.job_id, 2, 'GET_NFVO_CONNECTION_INFO')
- self.load_global_config()
-
- JobUtil.add_job_status(self.job_id, 100, "Instantiate Vnf success.")
- is_exist = JobStatusModel.objects.filter(jobid=self.job_id).exists()
- logger.debug("check_ns_inst_name_exist::is_exist=%s" % is_exist)
-
- def apply_grant(self, args):
- try:
- logger.info('apply_grant, args=%s' % args)
- # ApplyGrantTask(args).do_biz()
- return {'result': '100', 'msg': 'Nf instancing apply grant finish', 'context': {}}
- except Exception as e:
- logger.error('Nf instancing apply grant exception=%s' % e.message)
- logger.error(traceback.format_exc())
- return {'result': '255', 'msg': 'Nf instancing apply grant exception', 'context': {}}
+ #get nfvo info
+ JobUtil.add_job_status(self.job_id, 5, 'GET_NFVO_CONNECTION_INFO')
+ self.load_nfvo_config()
+
+ def apply_grant(self):
+ logger.info('[NF instantiation] send resource grand request to nfvo start')
+ #self.check_vm_capacity()
+ content_args = {'nfvoInstanceId': self.nfvo_inst_id, 'vnfmInstanceId': self.vnfm_inst_id,
+ 'nfInstanceId': self.nf_inst_id, 'nfDescriptorId': '',
+ 'lifecycleOperation': 'Instantiate', 'jobId': self.job_id, 'addResource': [],
+ 'removeResource': [], 'placementConstraint': [], 'exVimIdList': [], 'additionalParam': {}}
+
+ vdus = self.vnfd_info['vdus']
+ res_index = 1
+ for vdu in vdus:
+ res_def = {'type': 'VDU', 'resourceDefinitionId': str(res_index), 'vduId': vdu['vdu_id'],
+ 'vimid': '', 'tenant': ''}
+ if self.vnfd_info['metadata']['cross_dc']:
+ res_def['vimid'] = vdu['properties']['location_info']['vimId']
+ res_def['tenant'] = vdu['properties']['location_info']['tenant']
+ 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:
+ err_msg = str(resp[1])
+ logger.error("Nf instancing apply grant exception.[%s]" % err_msg)
+ JobUtil.add_job_status(self.job_id, 255, 'Nf instancing apply grant exception')
+ raise NFLCMException('Nf instancing apply grant exception')
+
+ #update_resources_table()
+ JobUtil.add_job_status(self.job_id, 15, 'Nf instancing apply grant finish')
+ logger.info("Nf instancing apply grant finish")