def _agent_notification(self, context, method, routers): """Notify l3 metering agents hosted by l3 agent hosts.""" adminContext = context if context.is_admin else context.elevated() plugin = manager.NeutronManager.get_service_plugins().get( service_constants.L3_ROUTER_NAT) l3_routers = {} state = agentschedulers_db.get_admin_state_up_filter() for router in routers: l3_agents = plugin.get_l3_agents_hosting_routers( adminContext, [router['id']], admin_state_up=state, active=True) for l3_agent in l3_agents: LOG.debug('Notify metering agent at %(topic)s.%(host)s ' 'the message %(method)s', {'topic': self.topic, 'host': l3_agent.host, 'method': method}) l3_router = l3_routers.get(l3_agent.host, []) l3_router.append(router) l3_routers[l3_agent.host] = l3_router for host, routers in l3_routers.iteritems(): cctxt = self.client.prepare(server=host) cctxt.cast(context, method, routers=routers)
def _agent_notification_arp(self, context, method, router_id, operation, data): """Notify arp details to l3 agents hosting router.""" if not router_id: return adminContext = (context.is_admin and context or context.elevated()) plugin = manager.NeutronManager.get_service_plugins().get( service_constants.L3_ROUTER_NAT) state = agentschedulers_db.get_admin_state_up_filter() l3_agents = (plugin. get_l3_agents_hosting_routers(adminContext, [router_id], admin_state_up=state, active=True)) # TODO(murali): replace cast with fanout to avoid performance # issues at greater scale. for l3_agent in l3_agents: log_topic = '%s.%s' % (l3_agent.topic, l3_agent.host) LOG.debug('Casting message %(method)s with topic %(topic)s', {'topic': log_topic, 'method': method}) dvr_arptable = {'router_id': router_id, 'arp_table': data} cctxt = self.client.prepare(topic=l3_agent.topic, server=l3_agent.host, version='1.2') cctxt.cast(context, method, payload=dvr_arptable)
def get_hosts_to_notify(self, context, router_id): """Returns all hosts to send notification about router update""" state = agentschedulers_db.get_admin_state_up_filter() agents = self.get_l3_agents_hosting_routers(context, [router_id], admin_state_up=state, active=True) return [a.host for a in agents]
def _agent_notification(self, context, method, routers): """Notify l3 metering agents hosted by l3 agent hosts.""" adminContext = context if context.is_admin else context.elevated() plugin = directory.get_plugin(plugin_constants.L3) l3_routers = {} state = agentschedulers_db.get_admin_state_up_filter() for router in routers: l3_agents = plugin.get_l3_agents_hosting_routers( adminContext, [router['id']], admin_state_up=state, active=True) for l3_agent in l3_agents: LOG.debug('Notify metering agent at %(topic)s.%(host)s ' 'the message %(method)s', {'topic': self.topic, 'host': l3_agent.host, 'method': method}) l3_router = l3_routers.get(l3_agent.host, []) l3_router.append(router) l3_routers[l3_agent.host] = l3_router for host, routers in l3_routers.items(): cctxt = self.client.prepare(server=host) cctxt.cast(context, method, routers=routers)
def get_hosts_to_notify(self, context, router_id): """Returns all hosts to send notification about router update""" hosts = super(L3_DVRsch_db_mixin, self).get_hosts_to_notify( context, router_id) router = self.get_router(context, router_id) if router.get('distributed', False): dvr_hosts = self._get_dvr_hosts_for_router(context, router_id) dvr_hosts = set(dvr_hosts) - set(hosts) state = agentschedulers_db.get_admin_state_up_filter() agents = self.get_l3_agents(context, active=state, filters={'host': dvr_hosts}) hosts += [a.host for a in agents] return hosts
def _agent_notification(self, context, method, router_ids, operation, shuffle_agents): """Notify changed routers to hosting l3 agents.""" adminContext = context if context.is_admin else context.elevated() plugin = manager.NeutronManager.get_service_plugins().get(service_constants.L3_ROUTER_NAT) state = agentschedulers_db.get_admin_state_up_filter() for router_id in router_ids: l3_agents = plugin.get_l3_agents_hosting_routers( adminContext, [router_id], admin_state_up=state, active=True ) if shuffle_agents: random.shuffle(l3_agents) for l3_agent in l3_agents: LOG.debug( "Notify agent at %(topic)s.%(host)s the message " "%(method)s", {"topic": l3_agent.topic, "host": l3_agent.host, "method": method}, ) cctxt = self.client.prepare(topic=l3_agent.topic, server=l3_agent.host, version="1.1") cctxt.cast(context, method, routers=[router_id])
def _agent_notification(self, context, method, router_ids, operation, shuffle_agents): """Notify changed routers to hosting l3 agents.""" adminContext = context if context.is_admin else context.elevated() plugin = manager.NeutronManager.get_service_plugins().get( service_constants.L3_ROUTER_NAT) state = agentschedulers_db.get_admin_state_up_filter() for router_id in router_ids: l3_agents = plugin.get_l3_agents_hosting_routers( adminContext, [router_id], admin_state_up=state, active=True) if shuffle_agents: random.shuffle(l3_agents) for l3_agent in l3_agents: LOG.debug('Notify agent at %(topic)s.%(host)s the message ' '%(method)s', {'topic': l3_agent.topic, 'host': l3_agent.host, 'method': method}) cctxt = self.client.prepare(topic=l3_agent.topic, server=l3_agent.host, version='1.1') cctxt.cast(context, method, routers=[router_id])
def get_dvr_snat_agent_list(self, context): agent_filters = {'agent_modes': [n_const.L3_AGENT_MODE_DVR_SNAT]} state = agentschedulers_db.get_admin_state_up_filter() return self.get_l3_agents(context, active=state, filters=agent_filters)
def get_hosts_to_notify(self, context, router_id): """Returns all hosts to send notification about router update""" state = agentschedulers_db.get_admin_state_up_filter() agents = self.get_l3_agents_hosting_routers( context, [router_id], admin_state_up=state, active=True) return [a.host for a in agents]