]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Remove hints from schedule_router
authorMichael Smith <michael.smith6@hp.com>
Tue, 2 Sep 2014 17:08:06 +0000 (17:08 +0000)
committerCarl Baldwin <carl.baldwin@hp.com>
Mon, 8 Sep 2014 23:41:55 +0000 (23:41 +0000)
Partial-bug: #1353266
Partial-bug: #1356639
Co-Authored-By: Swaminathan Vasudevan <swaminathan.vasudevan@hp.com>
Change-Id: Ie6b55e5d0d70be74b19c91994e52eb1719e32fef

neutron/api/rpc/agentnotifiers/l3_rpc_agent_api.py
neutron/db/l3_agentschedulers_db.py
neutron/plugins/nec/nec_router.py
neutron/scheduler/l3_agent_scheduler.py
neutron/tests/unit/test_l3_schedulers.py

index d38e69b44408394286a113038d29e322f2625726..d06074e78e0929a8857a841de49abce9ce6646b6 100644 (file)
@@ -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,
index d7342681faef6cb89d654979e80fab4907a74a76..3989500dcb5be034b6bcbb8568f2f70724ec5ba1 100644 (file)
@@ -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."""
index 99f407667344d92c576094dffbf428a0baf6a5e2..9af75cbeda279c27bf92218e66242577c0e2cc8a 100644 (file)
@@ -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):
index f13ae8db333133ec4978ed8e092114b55d3acad6..6788ab2484af22338184d434b5eaf4e5a4fa2e1e 100644 (file)
@@ -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]
index 2a8890784bdbd5b1ba35e2672f143ecd0eaa621f..28d45e452303de606d19944155d8df901ce22fec 100644 (file)
@@ -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),