- def check_res_status(self, args):
- try:
- logger.info('check_res_status, args=%s' % args)
- # CheckResStatusTask(args).do_biz()
- return {'result': '100', 'msg': 'Nf instancing check resource status finish', 'context': {}}
- except Exception as e:
- logger.error('Nf instancing check resource status exception=%s' % e.message)
- logger.error(traceback.format_exc())
- return {'result': '255', 'msg': 'Nf instancing check resource status exception', 'context': {}}
+ vls = ignore_case_get(self.data, "vls")
+ # create_networks(vls)
+ JobUtil.add_job_status(self.job_id, 55, 'Nf instancing create resource(networks) finish')
+
+ vdus = ignore_case_get(self.data, "vdus")
+ # create_vdus(vdus)
+ JobUtil.add_job_status(self.job_id, 75, 'Nf instancing create resource(vms) finish')
+
+ logger.info("[NF instantiation] create resource end")
+
+ def check_res_status(self):
+ logger.info("[NF instantiation] confirm all vms are active start")
+ vnfcs = self.create_res_result['resource_result']['affectedvnfc']
+ for vnfc in vnfcs:
+ if 'success' != vnfc['status']:
+ logger.error("VNFC_STATUS_IS_NOT_ACTIVE[vduid=%s]" % vnfc['vduId'])
+ raise NFLCMException(msgid="VNFC_STATUS_IS_NOT_ACTIVE[vduid=%s]", args=vnfc['vduId'])
+
+ JobUtil.add_job_status(self.job_id, 80, 'SAVE_VNFC_TO_DB')
+ vls = self.create_res_result['resource_result']['affectedvirtuallink']
+ cps = self.create_res_result['resource_result']['affectedcp']
+
+ for vnfc in vnfcs:
+ if 'failed' == vnfc['status']:
+ continue
+ compute_resource = vnfc['computeresource']
+ vminst = VmInstModel.objects.filter(resouceid=compute_resource['resourceid']).first()
+ VNFCInstModel.objects.create(
+ vnfcinstanceid=vnfc['vnfcinstanceid'],
+ vduid=vnfc['vduid'],
+ vdutype=vnfc['vdutype'],
+ nfinstid=self.nf_inst_id,
+ vmid=vminst.vmid)
+ # for vl in vls:
+ # if 'failed' == vl['status']:
+ # continue
+ # network_resource = vl['networkresource']
+ # subnet_resource = vl['subnetworkresource']
+ # networkinst = NetworkInstModel.objects.filter(resouceid=network_resource['resourceid']).first()
+ # subnetinst = SubNetworkInstModel.objects.filter(resouceid=subnet_resource['resourceid']).first()
+ # VLInstModel.objects.create(
+ # vlinstanceid=vl['virtuallinkinstanceid'],
+ # vldid=vl['virtuallinkdescid'],
+ # ownertype='0', # VNF
+ # ownerid=self.nf_inst_id,
+ # relatednetworkid=networkinst.networkid,
+ # relatedsubnetworkid=subnetinst.subnetworkid)
+ # # for vs in vss:
+ # for cp in cps:
+ # if 'failed' == cp['status']:
+ # continue
+ # port_resource = cp['portresource']
+ # portinst = PortInstModel.objects.filter(resouceid=port_resource['resourceid']).first()
+ # CPInstModel.objects.create(
+ # cpinstanceid=cp['cpinstanceid'],
+ # cpdid=cp['cpdid'],
+ # relatedtype='2', # port
+ # relatedport=portinst.portid,
+ # ownertype=cp['ownertype'],
+ # ownerid=cp['ownerid'],
+ # vlinstanceid=cp['virtuallinkinstanceid'])
+ # self.add_job(43, 'INST_DPLY_VM_PRGS')
+ logger.info("[NF instantiation] confirm all vms are active end")