From: Michael Smith Date: Tue, 2 Sep 2014 17:08:06 +0000 (+0000) Subject: Remove hints from schedule_router X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=357404e73427aeb4a45c2b226706703f4f846dfc;p=openstack-build%2Fneutron-build.git Remove hints from schedule_router Partial-bug: #1353266 Partial-bug: #1356639 Co-Authored-By: Swaminathan Vasudevan Change-Id: Ie6b55e5d0d70be74b19c91994e52eb1719e32fef --- diff --git a/neutron/api/rpc/agentnotifiers/l3_rpc_agent_api.py b/neutron/api/rpc/agentnotifiers/l3_rpc_agent_api.py index d38e69b44..d06074e78 100644 --- a/neutron/api/rpc/agentnotifiers/l3_rpc_agent_api.py +++ b/neutron/api/rpc/agentnotifiers/l3_rpc_agent_api.py @@ -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, diff --git a/neutron/db/l3_agentschedulers_db.py b/neutron/db/l3_agentschedulers_db.py index d7342681f..3989500dc 100644 --- a/neutron/db/l3_agentschedulers_db.py +++ b/neutron/db/l3_agentschedulers_db.py @@ -442,15 +442,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.""" diff --git a/neutron/plugins/nec/nec_router.py b/neutron/plugins/nec/nec_router.py index 99f407667..9af75cbed 100644 --- a/neutron/plugins/nec/nec_router.py +++ b/neutron/plugins/nec/nec_router.py @@ -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): diff --git a/neutron/scheduler/l3_agent_scheduler.py b/neutron/scheduler/l3_agent_scheduler.py index f13ae8db3..6788ab248 100644 --- a/neutron/scheduler/l3_agent_scheduler.py +++ b/neutron/scheduler/l3_agent_scheduler.py @@ -198,15 +198,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 @@ -239,9 +238,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) @@ -251,9 +250,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] diff --git a/neutron/tests/unit/test_l3_schedulers.py b/neutron/tests/unit/test_l3_schedulers.py index 2a8890784..28d45e452 100644 --- a/neutron/tests/unit/test_l3_schedulers.py +++ b/neutron/tests/unit/test_l3_schedulers.py @@ -420,6 +420,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),