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 notify_lcm_to_nfvo, prepare_notification_data
+from lcm.pub.msapi.gvnfmdriver import prepare_notification_data
+# 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.notificationsutil import NotificationsUtil
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
-from lcm.nf.const import GRANT_TYPE
+from lcm.nf.const import CHANGE_TYPE, GRANT_TYPE, OPERATION_TYPE
logger = logging.getLogger(__name__)
logger.info("Create resource finish")
def lcm_notify(self):
- notification_content = prepare_notification_data(self.nf_inst_id, self.job_id, "ADDED")
+ notification_content = prepare_notification_data(self.nf_inst_id, self.job_id, CHANGE_TYPE.ADDED, OPERATION_TYPE.INSTANTIATE)
logger.info('Notify request data = %s' % notification_content)
- resp = notify_lcm_to_nfvo(json.dumps(notification_content))
- logger.info('Lcm notify end, response %s' % resp)
+ # resp = notify_lcm_to_nfvo(json.dumps(notification_content))
+ # logger.info('Lcm notify end, response %s' % resp)
+ NotificationsUtil().send_notification(notification_content)
def vnf_inst_failed_handle(self, error_msg):
logger.error('VNF instantiation failed, detail message: %s' % error_msg)
break
def set_location(self, apply_result):
+ vim_connections = ignore_case_get(apply_result, "vimConnections")
+ vnfid = ignore_case_get(apply_result, "vnfInstanceId")
+ directive = ignore_case_get(apply_result, "directive")
+ vim_assets = ignore_case_get(apply_result, "vimAssets")
+ access_info = ignore_case_get(vim_connections[0], "accessInfo")
+ tenant = ignore_case_get(access_info, "tenant")
+ vimid = ignore_case_get(vim_connections[0], "vimId")
+ cloud_owner, cloud_regionid = vimid.split("_")
+ vdu_info = []
+
+ for flavor in ignore_case_get(vim_assets, "vimComputeResourceFlavour"):
+ vdu_info.append({"vduName": flavor["resourceProviderId"],
+ "flavorName": flavor["vimFlavourId"],
+ "directive": directive})
+
for resource_type in ['vdus', 'vls']:
for resource in ignore_case_get(self.vnfd_info, resource_type):
if "location_info" in resource["properties"]:
- resource["properties"]["location_info"]["vimid"] = ignore_case_get(apply_result, "vimid")
- resource["properties"]["location_info"]["tenant"] = ignore_case_get(apply_result, "tenant")
+ resource["properties"]["location_info"]["vimid"] = vimid
+ resource["properties"]["location_info"]["tenant"] = tenant
+ resource["properties"]["location_info"]["vnfId"] = vnfid
+ resource["properties"]["location_info"]["cloudOwner"] = cloud_owner
+ resource["properties"]["location_info"]["cloudRegionId"] = cloud_regionid
+ resource["properties"]["location_info"]["vduInfo"] = vdu_info
else:
resource["properties"]["location_info"] = {
- "vimid": ignore_case_get(apply_result, "vimid"),
- "tenant": ignore_case_get(apply_result, "tenant")}
+ "vimid": vimid,
+ "tenant": tenant,
+ "vnfId": vnfid,
+ "cloudOwner": cloud_owner,
+ "cloudRegionId": cloud_regionid,
+ "vduInfo": vdu_info}
'''
def get_subnet_ids(self, ext_cp):