def delete_pool(self, context, pool): # Fetch nf_id from description of the resource nf_id = self._fetch_nf_from_resource_desc(pool["description"]) nfp_logging.store_logging_context(meta_id=nf_id) nf = common.get_network_function_details(context, nf_id) self._delete(context, pool['tenant_id'], 'pool', nf, pool=pool) 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 delete_vip(self, context, vip): # Fetch nf_id from description of the resource nf_id = self._fetch_nf_from_resource_desc(vip["description"]) nfp_logging.store_logging_context(meta_id=nf_id) nf = common.get_network_function_details(context, nf_id) self._delete(context, vip['tenant_id'], 'vip', nf, vip=vip) nfp_logging.clear_logging_context()
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 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 log_dispatch(self, handler, event, *args): try: event.context['namespace'] = event.desc.target nfp_logging.store_logging_context(**(event.context)) finally: handler(event, *args) nfp_logging.clear_logging_context()
def update_network_function_config(self, context, request_data): """RPC method to update of configuration in a network service. Updates configuration of a network service. This RPC method is invoked by the configurator REST server. It updates configuration of a network service based on the configuration request specified in the request_data argument. :param context: RPC context instance :param request_data: RPC data Returns: None """ try: log_info = request_data.get('info') logging_context = log_info['context']['logging_context'] nfp_logging.store_logging_context(**logging_context) self._invoke_service_agent('update', request_data) except Exception as err: msg = ("Failed to update network service configuration. %s" % str(err).capitalize()) LOG.error(msg) nfp_logging.clear_logging_context()
def log_dispatch(self, handler, event, *args): try: nfp_logging.store_logging_context(**(event.context)) handler(event, *args) nfp_logging.clear_logging_context() except Exception as e: message = "%r" % e LOG.error(message) handler(event, *args)
def delete_member(self, context, member): loadbalancer = member['pool']['loadbalancer'] # Fetch nf_id from description of the resource nf_id = self._fetch_nf_from_resource_desc(loadbalancer["description"]) nfp_logging.store_logging_context(meta_id=nf_id) nf = common.get_network_function_details(context, nf_id) self._update_tls_cert('member', member) self._delete(context, member['tenant_id'], 'member', nf, member=member) nfp_logging.clear_logging_context()
def create_pool(self, context, pool): loadbalancer = pool['loadbalancer'] # Fetch nf_id from description of the resource nf_id = self._fetch_nf_from_resource_desc(loadbalancer["description"]) nfp_logging.store_logging_context(meta_id=nf_id) nf = common.get_network_function_details(context, nf_id) self._update_tls_cert('pool', pool) self._post(context, pool['tenant_id'], 'pool', nf, pool=pool) nfp_logging.clear_logging_context()
def delete_member(self, context, member): # Fetch pool from pool_id pool = self._get_pool(context, member['pool_id']) # Fetch nf_id from description of the resource nf_id = self._fetch_nf_from_resource_desc(pool["description"]) nfp_logging.store_logging_context(meta_id=nf_id) nf = common.get_network_function_details(context, nf_id) self._delete(context, member['tenant_id'], 'member', nf, member=member) nfp_logging.clear_logging_context()
def delete_firewall(self, context, firewall, host): # Fetch nf_id from description of the resource nf_id = self._fetch_nf_from_resource_desc(firewall["description"]) nfp_logging.store_logging_context(meta_id=nf_id) nf = common.get_network_function_details(context, nf_id) body = self._data_wrapper(context, firewall, host, nf, 'DELETE') transport.send_request_to_configurator(self._conf, context, body, "DELETE") nfp_logging.clear_logging_context()
def delete_healthmonitor(self, context, healthmonitor): loadbalancer = healthmonitor['pool']['loadbalancer'] # Fetch nf_id from description of the resource nf_id = self._fetch_nf_from_resource_desc(loadbalancer["description"]) nfp_logging.store_logging_context(meta_id=nf_id) nf = common.get_network_function_details(context, nf_id) self._delete( context, healthmonitor['tenant_id'], 'healthmonitor', nf, healthmonitor=healthmonitor) nfp_logging.clear_logging_context()
def create_listener(self, context, listener): loadbalancer = listener['loadbalancer'] # Fetch nf_id from description of the resource nf_id = self._fetch_nf_from_resource_desc(loadbalancer["description"]) nfp_logging.store_logging_context(meta_id=nf_id) nf = common.get_network_function_details(context, nf_id) self._post( context, listener['tenant_id'], 'listener', nf, listener=listener) nfp_logging.clear_logging_context()
def delete_loadbalancer(self, context, loadbalancer, delete_vip_port=True): # Fetch nf_id from description of the resource nf_id = self._fetch_nf_from_resource_desc(loadbalancer["description"]) nfp_logging.store_logging_context(meta_id=nf_id) nf = common.get_network_function_details(context, nf_id) self._delete( context, loadbalancer['tenant_id'], 'loadbalancer', nf, loadbalancer=loadbalancer) nfp_logging.clear_logging_context()
def delete_pool_health_monitor(self, context, health_monitor, pool_id): # Fetch pool from pool_id pool = self._get_pool(context, pool_id) # Fetch nf_id from description of the resource nf_id = self._fetch_nf_from_resource_desc(pool["description"]) nfp_logging.store_logging_context(meta_id=nf_id) nf = common.get_network_function_details(context, nf_id) self._delete( context, health_monitor['tenant_id'], 'pool_health_monitor', nf, health_monitor=health_monitor, pool_id=pool_id) nfp_logging.clear_logging_context()
def create_loadbalancer(self, context, loadbalancer, driver_name, allocate_vip=True): # Fetch nf_id from description of the resource nf_id = self._fetch_nf_from_resource_desc(loadbalancer["description"]) nfp_logging.store_logging_context(meta_id=nf_id) nf = common.get_network_function_details(context, nf_id) self._post( context, loadbalancer['tenant_id'], 'loadbalancer', nf, loadbalancer=loadbalancer, driver_name=driver_name) nfp_logging.clear_logging_context()
def vpnservice_updated(self, context, **kwargs): # Fetch nf_id from description of the resource nf_id = self._fetch_nf_from_resource_desc( kwargs['resource']['description']) nfp_logging.store_logging_context(meta_id=nf_id) nf = common.get_network_function_details(context, nf_id) reason = kwargs['reason'] body = self._data_wrapper(context, kwargs['resource']['tenant_id'], nf, **kwargs) transport.send_request_to_configurator(self._conf, context, body, reason) nfp_logging.clear_logging_context()
def update_loadbalancer(self, context, old_loadbalancer, loadbalancer): # Fetch nf_id from description of the resource nf_id = self._fetch_nf_from_resource_desc(loadbalancer["description"]) nfp_logging.store_logging_context(meta_id=nf_id) nf = common.get_network_function_details(context, nf_id) self._update_tls_cert('loadbalancer', loadbalancer) self._put(context, loadbalancer['tenant_id'], 'loadbalancer', nf, old_loadbalancer=old_loadbalancer, loadbalancer=loadbalancer) nfp_logging.clear_logging_context()
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()