Merge "Remove hints from schedule_router"
This commit is contained in:
commit
69e0d1f397
@ -43,8 +43,7 @@ class L3AgentNotifyAPI(n_rpc.RpcProxy):
|
||||
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(
|
||||
@ -92,7 +91,7 @@ class L3AgentNotifyAPI(n_rpc.RpcProxy):
|
||||
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)
|
||||
@ -104,9 +103,9 @@ class L3AgentNotifyAPI(n_rpc.RpcProxy):
|
||||
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,
|
||||
@ -136,7 +135,7 @@ class L3AgentNotifyAPI(n_rpc.RpcProxy):
|
||||
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,
|
||||
|
@ -448,15 +448,15 @@ class L3AgentSchedulerDbMixin(l3agentscheduler.L3AgentSchedulerPluginBase,
|
||||
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."""
|
||||
|
@ -271,11 +271,11 @@ class L3AgentSchedulerDbMixin(l3_agentschedulers_db.L3AgentSchedulerDbMixin):
|
||||
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)
|
||||
@ -289,7 +289,7 @@ class L3AgentSchedulerDbMixin(l3_agentschedulers_db.L3AgentSchedulerDbMixin):
|
||||
|
||||
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
|
||||
@ -300,7 +300,7 @@ class L3AgentNotifyAPI(l3_rpc_agent_api.L3AgentNotifyAPI):
|
||||
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):
|
||||
|
@ -197,15 +197,14 @@ class L3Scheduler(object):
|
||||
'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
|
||||
@ -238,9 +237,9 @@ class ChanceScheduler(L3Scheduler):
|
||||
"""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)
|
||||
@ -250,9 +249,9 @@ class LeastRoutersScheduler(L3Scheduler):
|
||||
"""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]
|
||||
|
@ -425,6 +425,8 @@ class L3SchedulerTestCase(l3_agentschedulers_db.L3AgentSchedulerDbMixin,
|
||||
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),
|
||||
|
Loading…
x
Reference in New Issue
Block a user