payload=payload),
topic='%s.%s' % (topics.L3_AGENT, host))
- def _agent_notification(self, context, method, router_ids,
- operation, data):
+ def _agent_notification(self, context, method, router_ids, operation):
"""Notify changed routers to hosting l3 agents."""
adminContext = context.is_admin and context or context.elevated()
plugin = manager.NeutronManager.get_service_plugins().get(
self.make_msg(method, payload=dvr_arptable),
topic=topic, version='1.2')
- def _notification(self, context, method, router_ids, operation, data):
+ def _notification(self, context, method, router_ids, operation):
"""Notify all the agents that are hosting the routers."""
plugin = manager.NeutronManager.get_service_plugins().get(
service_constants.L3_ROUTER_NAT)
plugin, constants.L3_AGENT_SCHEDULER_EXT_ALIAS):
adminContext = (context.is_admin and
context or context.elevated())
- plugin.schedule_routers(adminContext, router_ids, hints=data)
+ plugin.schedule_routers(adminContext, router_ids)
self._agent_notification(
- context, method, router_ids, operation, data)
+ context, method, router_ids, operation)
else:
self.fanout_cast(
context, self.make_msg(method,
def routers_updated(self, context, router_ids, operation=None, data=None):
if router_ids:
self._notification(context, 'routers_updated', router_ids,
- operation, data)
+ operation)
def add_arp_entry(self, context, router_id, arp_table, operation=None):
self._agent_notification_arp(context, 'add_arp_entry', router_id,
return self.router_scheduler.auto_schedule_routers(
self, context, host, router_ids)
- def schedule_router(self, context, router, candidates=None, hints=None):
+ def schedule_router(self, context, router, candidates=None):
if self.router_scheduler:
return self.router_scheduler.schedule(
- self, context, router, candidates=candidates, hints=hints)
+ self, context, router, candidates=candidates)
- def schedule_routers(self, context, routers, hints=None):
+ def schedule_routers(self, context, routers):
"""Schedule the routers to l3 agents."""
for router in routers:
- self.schedule_router(context, router, candidates=None, hints=hints)
+ self.schedule_router(context, router, candidates=None)
def get_l3_agent_with_min_routers(self, context, agent_ids):
"""Return l3 agent with the least number of routers."""
return super(L3AgentSchedulerDbMixin, self).auto_schedule_routers(
context, host, router_ids)
- def schedule_router(self, context, router, candidates=None, hints=None):
+ def schedule_router(self, context, router, candidates=None):
if (self._get_provider_by_router_id(context, router) ==
nconst.ROUTER_PROVIDER_L3AGENT):
return super(L3AgentSchedulerDbMixin, self).schedule_router(
- context, router, candidates=candidates, hints=hints)
+ context, router, candidates=candidates)
def add_router_to_l3_agent(self, context, id, router_id):
provider = self._get_provider_by_router_id(context, router_id)
class L3AgentNotifyAPI(l3_rpc_agent_api.L3AgentNotifyAPI):
- def _notification(self, context, method, router_ids, operation, data):
+ def _notification(self, context, method, router_ids, operation):
"""Notify all the agents that are hosting the routers.
_notification() is called in L3 db plugin for all routers regardless
router_ids = rdb.get_routers_by_provider(
context.session, nconst.ROUTER_PROVIDER_L3AGENT, router_ids)
super(L3AgentNotifyAPI, self)._notification(
- context, method, router_ids, operation, data)
+ context, method, router_ids, operation)
def load_driver(plugin, ofc_manager):
'agent_id': chosen_agent.id})
def _schedule_router(self, plugin, context, router_id,
- candidates=None, hints=None):
+ candidates=None):
sync_router = plugin.get_router(context, router_id)
router_distributed = sync_router.get('distributed', False)
if router_distributed:
# For Distributed routers check for SNAT Binding before
# calling the schedule_snat_router
snat_bindings = plugin.get_snat_bindings(context, [router_id])
- router_gw_exists = (hints and 'gw_exists' in hints
- and hints['gw_exists'])
+ router_gw_exists = sync_router.get('external_gateway_info', False)
if not snat_bindings and router_gw_exists:
# If GW exists for DVR routers and no SNAT binding
# call the schedule_snat_router
"""Randomly allocate an L3 agent for a router."""
def schedule(self, plugin, context, router_id,
- candidates=None, hints=None):
+ candidates=None):
return self._schedule_router(
- plugin, context, router_id, candidates=candidates, hints=hints)
+ plugin, context, router_id, candidates=candidates)
def _choose_router_agent(self, plugin, context, candidates):
return random.choice(candidates)
"""Allocate to an L3 agent with the least number of routers bound."""
def schedule(self, plugin, context, router_id,
- candidates=None, hints=None):
+ candidates=None):
return self._schedule_router(
- plugin, context, router_id, candidates=candidates, hints=hints)
+ plugin, context, router_id, candidates=candidates)
def _choose_router_agent(self, plugin, context, candidates):
candidate_ids = [candidate['id'] for candidate in candidates]
plugin, self.adminContext, 'foo_router_id', None)
expected_calls = [
mock.call.get_router(mock.ANY, 'foo_router_id'),
+ mock.call.schedule_snat_router(
+ mock.ANY, 'foo_router_id', sync_router),
mock.call.get_l3_agents_hosting_routers(
mock.ANY, ['foo_router_id'], admin_state_up=True),
mock.call.get_l3_agents(mock.ANY, active=True),