+ self.engine.del_item(
+ self.internal_session,
+ "nsrs",
+ _id=params["nsr_id"],
+ not_send_msg=msg_to_send,
+ )
+ self.logger.debug(
+ "ns={} deleted from database".format(params["nsr_id"])
+ )
+ # Check for nslcm notification
+ if isinstance(params, dict):
+ # Check availability of operationState and command
+ if (
+ (not params.get("operationState"))
+ or (not command)
+ or (not params.get("operationParams"))
+ ):
+ self.logger.debug(
+ "Message can not be used for notification of nslcm"
+ )
+ else:
+ nsd_id = params["operationParams"].get("nsdId")
+ ns_instance_id = params["operationParams"].get("nsInstanceId")
+ # Any one among nsd_id, ns_instance_id should be present.
+ if not (nsd_id or ns_instance_id):
+ self.logger.debug(
+ "Message can not be used for notification of nslcm"
+ )
+ else:
+ op_state = params["operationState"]
+ event_details = {
+ "topic": topic,
+ "command": command.upper(),
+ "params": params,
+ }
+ subscribers = self.nslcm.get_subscribers(
+ nsd_id,
+ ns_instance_id,
+ command.upper(),
+ op_state,
+ event_details,
+ )
+ # self.logger.debug("subscribers list: ")
+ # self.logger.debug(subscribers)
+ if subscribers:
+ asyncio.ensure_future(
+ self.nslcm.send_notifications(
+ subscribers, loop=self.loop
+ ),
+ loop=self.loop,
+ )
+ else:
+ self.logger.debug(
+ "Message can not be used for notification of nslcm"
+ )
+ elif topic == "vnf":
+ if isinstance(params, dict):
+ vnfd_id = params["vnfdId"]
+ vnf_instance_id = params["vnfInstanceId"]
+ if command == "create" or command == "delete":
+ op_state = command
+ else:
+ op_state = params["operationState"]
+ event_details = {
+ "topic": topic,
+ "command": command.upper(),
+ "params": params,
+ }
+ subscribers = self.vnflcm.get_subscribers(
+ vnfd_id,
+ vnf_instance_id,
+ command.upper(),
+ op_state,
+ event_details
+ )
+ if subscribers:
+ asyncio.ensure_future(
+ self.vnflcm.send_notifications(
+ subscribers, loop=self.loop
+ ),
+ loop=self.loop
+ )