def update_pool_stats(self, context, notification_data): notification = notification_data['notification'][0] request_info = notification_data.get('info') request_context = request_info.get('context') logging_context = request_context.get('logging_context') nfp_logging.store_logging_context(**logging_context) resource_data = notification['data'] pool_id = resource_data['pool_id'] stats = resource_data['stats'] host = resource_data['host'] msg = ("NCO received LB's update_pool_stats API, making an " "update_pool_stats RPC cast to plugin for updating" "pool: %s stats" % (pool_id)) LOG.info(msg) # RPC cast to plugin to update stats of pool rpcClient = transport.RPCClient(a_topics.LB_NFP_PLUGIN_TOPIC) rpcClient.cctxt = rpcClient.client.prepare( version=const.LOADBALANCER_RPC_API_VERSION) rpcClient.cctxt.cast(context, 'update_pool_stats', pool_id=pool_id, stats=stats, host=host) nfp_logging.clear_logging_context()
def set_firewall_status(self, context, notification_data): notification = notification_data['notification'][0] request_info = notification_data.get('info') request_context = request_info.get('context') logging_context = request_context.get('logging_context') nfp_logging.store_logging_context(**logging_context) resource_data = notification['data'] firewall_id = resource_data['firewall_id'] status = resource_data['status'] msg = ("Config Orchestrator received " "firewall_configuration_create_complete API, making an " "set_firewall_status RPC call for firewall: %s & status " " %s" % (firewall_id, status)) LOG.info(msg) # RPC call to plugin to set firewall status rpcClient = transport.RPCClient(a_topics.FW_NFP_PLUGIN_TOPIC) rpcClient.cctxt.cast(context, 'set_firewall_status', host=resource_data['host'], firewall_id=firewall_id, status=status) nfp_logging.clear_logging_context()
def get_network_function_map(context, network_function_id): request_data = None try: rpc_nso_client = transport.RPCClient(a_topics.NFP_NSO_TOPIC) nf_context = rpc_nso_client.cctxt.call( context, 'get_network_function_context', network_function_id=network_function_id) network_function_details = nf_context['network_function_details'] ports_info = nf_context['ports_info'] mngmt_port_info = nf_context['mngmt_port_info'] monitor_port_info = nf_context['monitor_port_info'] request_data = _prepare_structure(network_function_details, ports_info, mngmt_port_info, monitor_port_info) msg = (" %s " % (request_data)) LOG.debug(msg) return request_data except Exception as e: LOG.error( _LE("Failed to get network function map of " "network_function_id %(network_function_id)s : %(ex)s "), { 'ex': e, 'network_function_id': network_function_id }) return request_data
def update_status(self, context, notification_data): notification = notification_data['notification'][0] request_info = notification_data.get('info') request_context = request_info.get('context') logging_context = request_context.get('logging_context') nfp_logging.store_logging_context(**logging_context) resource_data = notification['data'] obj_type = resource_data['obj_type'] obj_id = resource_data['obj_id'] status = resource_data['status'] msg = ("NCO received LB's update_status API, making an update_status" "RPC call to plugin for %s: %s with status %s" % ( obj_type, obj_id, status)) LOG.info(msg) nfp_logging.clear_logging_context() # RPC call to plugin to update status of the resource rpcClient = transport.RPCClient(a_topics.LB_NFP_PLUGIN_TOPIC) rpcClient.cctxt = rpcClient.client.prepare( version=const.LOADBALANCER_RPC_API_VERSION) rpcClient.cctxt.cast(context, 'update_status', obj_type=obj_type, obj_id=obj_id, status=status)
def set_firewall_status(self, context, notification_data): nfp_context = module_context.init() notification = notification_data['notification'][0] request_info = notification_data.get('info') request_context = request_info.get('context') logging_context = request_context.get('logging_context', {}) nfp_context['log_context'] = logging_context resource_data = notification['data'] firewall_id = resource_data['firewall_id'] status = resource_data['status'] LOG.info( "Received firewall configuration create complete API, " "making an RPC call set firewall status for " "firewall:%(firewall)s and status: %(status)s", { 'firewall': firewall_id, 'status': status }) # RPC call to plugin to set firewall status rpcClient = transport.RPCClient(a_topics.FW_NFP_PLUGIN_TOPIC) rpcClient.cctxt.cast(context, 'set_firewall_status', host=resource_data['host'], firewall_id=firewall_id, status=status)
def update_status(self, context, notification_data): nfp_context = module_context.init() notification = notification_data['notification'][0] request_info = notification_data.get('info') request_context = request_info.get('context') logging_context = request_context.get('logging_context', {}) nfp_context['log_context'] = logging_context resource_data = notification['data'] obj_type = resource_data['obj_type'] obj_id = resource_data['obj_id'] rpcClient = transport.RPCClient(a_topics.LBV2_NFP_PLUGIN_TOPIC) rpcClient.cctxt = rpcClient.client.prepare( version=const.LOADBALANCERV2_RPC_API_VERSION) lb_p_status = const.ACTIVE lb_o_status = None obj_p_status = resource_data['provisioning_status'] obj_o_status = resource_data['operating_status'] LOG.info( "Received LB's update_status API. Making an " "update_status RPC call to plugin for %(obj_type)s:" "%(obj_id)s with status: %(status)s", { 'obj_type': obj_type, 'obj_id': obj_id, 'status': obj_p_status }) if obj_type == 'healthmonitor': obj_o_status = None if obj_type != 'loadbalancer': rpcClient.cctxt.cast(context, 'update_status', obj_type=obj_type, obj_id=obj_id, provisioning_status=obj_p_status, operating_status=obj_o_status) else: lb_o_status = lbv2_const.ONLINE if obj_p_status == const.ERROR: lb_p_status = const.ERROR lb_o_status = lbv2_const.OFFLINE rpcClient.cctxt.cast(context, 'update_status', obj_type='loadbalancer', obj_id=resource_data['root_lb_id'], provisioning_status=lb_p_status, operating_status=lb_o_status)
def _method_handler(self, notification): # Method handles notification as per resource, resource_type and method try: requester = notification['info']['context']['requester'] topic = ResourceMap[requester] context = notification['info']['context']['neutron_context'] rpcClient = transport.RPCClient(topic) rpc_ctx = n_context.Context.from_dict(context) rpcClient.cctxt.cast(rpc_ctx, 'network_function_notification', notification_data=notification) except Exception as e: raise Exception(e)
def get_network_function_details(context, network_function_id): network_function_details = None try: rpc_nso_client = transport.RPCClient(a_topics.NFP_NSO_TOPIC) network_function_details = rpc_nso_client.cctxt.call( context, 'get_network_function_details', network_function_id=network_function_id) msg = (" %s " % (network_function_details)) LOG.info(msg) return network_function_details['network_function'] except Exception as e: msg = (" %s " % (e)) LOG.info(msg)
def update_status(self, context, notification_data): nfp_context = module_context.init() resource_data = notification_data['notification'][0]['data'] request_info = notification_data.get('info') request_context = request_info.get('context') logging_context = request_context.get('logging_context', {}) nfp_context['log_context'] = logging_context status = resource_data['status'] LOG.info( "Received VPN's update_status API. " "Making an update_status RPC cast to plugin for object" "with status: %(status)s", {'status': status}) rpcClient = transport.RPCClient(a_topics.VPN_NFP_PLUGIN_TOPIC) rpcClient.cctxt.cast(context, 'update_status', status=status)
def get_network_function_details(context, network_function_id): network_function_details = None try: rpc_nso_client = transport.RPCClient(a_topics.NFP_NSO_TOPIC) network_function_details = rpc_nso_client.cctxt.call( context, 'get_network_function_details', network_function_id=network_function_id) msg = (" %s " % (network_function_details)) LOG.debug(msg) return network_function_details['network_function'] except Exception as e: LOG.error("Failed to get network function details of " "network_function_id %(network_function_id)s : %(ex)s ", {'ex': e, 'network_function_id': network_function_id})
def update_status(self, context, notification_data): notification = notification_data['notification'][0] request_info = notification_data.get('info') request_context = request_info.get('context') logging_context = request_context.get('logging_context') nfp_logging.store_logging_context(**logging_context) resource_data = notification['data'] obj_type = resource_data['obj_type'] obj_id = resource_data['obj_id'] rpcClient = transport.RPCClient(a_topics.LBV2_NFP_PLUGIN_TOPIC) rpcClient.cctxt = rpcClient.client.prepare( version=const.LOADBALANCERV2_RPC_API_VERSION) lb_p_status = const.ACTIVE lb_o_status = None obj_p_status = resource_data['provisioning_status'] obj_o_status = resource_data['operating_status'] msg = ("NCO received LB's update_status API, making an update_status " "RPC call to plugin for %s: %s with status %s" % ( obj_type, obj_id, obj_p_status)) LOG.info(msg) if obj_type == 'healthmonitor': obj_o_status = None if obj_type != 'loadbalancer': rpcClient.cctxt.cast(context, 'update_status', obj_type=obj_type, obj_id=obj_id, provisioning_status=obj_p_status, operating_status=obj_o_status) else: lb_o_status = lbv2_const.ONLINE if obj_p_status == const.ERROR: lb_p_status = const.ERROR lb_o_status = lbv2_const.OFFLINE rpcClient.cctxt.cast(context, 'update_status', obj_type='loadbalancer', obj_id=resource_data['root_lb_id'], provisioning_status=lb_p_status, operating_status=lb_o_status) nfp_logging.clear_logging_context()
def update_status(self, context, notification_data): resource_data = notification_data['notification'][0]['data'] request_info = notification_data.get('info') request_context = request_info.get('context') logging_context = request_context.get('logging_context') nfp_logging.store_logging_context(**logging_context) status = resource_data['status'] msg = ("NCO received VPN's update_status API," "making an update_status RPC cast to plugin for object" "with status %s" % (status)) LOG.info(msg) rpcClient = transport.RPCClient(a_topics.VPN_NFP_PLUGIN_TOPIC) rpcClient.cctxt.cast(context, 'update_status', status=status) nfp_logging.clear_logging_context()
def _method_handler(self, notification): # Method handles notification as per resource, resource_type and method try: requester = notification['info']['context']['requester'] if requester in ResourceMap: topic = ResourceMap[requester] context = notification['info']['context']['neutron_context'] rpc_ctx = n_context.Context.from_dict(context) else: topic = requester.lower() + '_notifications' rpc_ctx = n_context.get_admin_context() rpcClient = transport.RPCClient(topic) rpcClient.cctxt.cast(rpc_ctx, 'network_function_notification', notification_data=notification) except Exception as e: msg = "Exception while calling notification: %s" % (e) LOG.error(msg) raise Exception(e)
def firewall_deleted(self, context, notification_data): nfp_context = module_context.init() notification = notification_data['notification'][0] request_info = notification_data.get('info') request_context = request_info.get('context') logging_context = request_context.get('logging_context', {}) nfp_context['log_context'] = logging_context resource_data = notification['data'] firewall_id = resource_data['firewall_id'] LOG.info( "Received firewall_configuration_delete_complete API, " "making an RPC call firewall_deleted for firewall:" "%(firewall)s ", {'firewall': firewall_id}) # RPC call to plugin to update firewall deleted rpcClient = transport.RPCClient(a_topics.FW_NFP_PLUGIN_TOPIC) rpcClient.cctxt.cast(context, 'firewall_deleted', host=resource_data['host'], firewall_id=firewall_id)
def get_network_function_map(context, network_function_id): request_data = None try: rpc_nso_client = transport.RPCClient(a_topics.NFP_NSO_TOPIC) nf_context = rpc_nso_client.cctxt.call( context, 'get_network_function_context', network_function_id=network_function_id) network_function_details = nf_context['network_function_details'] ports_info = nf_context['ports_info'] mngmt_port_info = nf_context['mngmt_port_info'] monitor_port_info = nf_context['monitor_port_info'] request_data = _prepare_structure(network_function_details, ports_info, mngmt_port_info, monitor_port_info) msg = (" %s " % (request_data)) LOG.info(msg) return request_data except Exception as e: msg = (" %s " % (e)) LOG.info(msg) return request_data