]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Move DVR related method to proper class
authorOleg Bondarev <obondarev@mirantis.com>
Tue, 7 Jul 2015 10:39:21 +0000 (13:39 +0300)
committerOleg Bondarev <obondarev@mirantis.com>
Thu, 9 Jul 2015 16:48:24 +0000 (19:48 +0300)
get_snat_candidates() is about DVR routers scheduling and hence
should be a method of L3_DVRsch_db_mixin.
This commit does not modify anything, just moves.

Change-Id: Ib610e589befae55c6fe827f5ee8c3d6a596b86e1

neutron/db/l3_agentschedulers_db.py
neutron/db/l3_dvrscheduler_db.py

index cb4c638cff6cb4c0577fd748e6e6721897535a25..83d404d525301a839f3c3754237ec1ebff7745af 100644 (file)
@@ -408,41 +408,6 @@ class L3AgentSchedulerDbMixin(l3agentscheduler.L3AgentSchedulerPluginBase,
 
         return False
 
-    def get_snat_candidates(self, sync_router, l3_agents):
-        """Get the valid snat enabled l3 agents for the distributed router."""
-        candidates = []
-        is_router_distributed = sync_router.get('distributed', False)
-        if not is_router_distributed:
-            return candidates
-        for l3_agent in l3_agents:
-            if not l3_agent.admin_state_up:
-                continue
-
-            agent_conf = self.get_configuration_dict(l3_agent)
-            agent_mode = agent_conf.get(constants.L3_AGENT_MODE,
-                                        constants.L3_AGENT_MODE_LEGACY)
-            if agent_mode != constants.L3_AGENT_MODE_DVR_SNAT:
-                continue
-
-            router_id = agent_conf.get('router_id', None)
-            use_namespaces = agent_conf.get('use_namespaces', True)
-            if not use_namespaces and router_id != sync_router['id']:
-                continue
-
-            handle_internal_only_routers = agent_conf.get(
-                'handle_internal_only_routers', True)
-            gateway_external_network_id = agent_conf.get(
-                'gateway_external_network_id', None)
-            ex_net_id = (sync_router['external_gateway_info'] or {}).get(
-                'network_id')
-            if ((not ex_net_id and not handle_internal_only_routers) or
-                (ex_net_id and gateway_external_network_id and
-                 ex_net_id != gateway_external_network_id)):
-                continue
-
-            candidates.append(l3_agent)
-        return candidates
-
     def get_l3_agent_candidates(self, context, sync_router, l3_agents,
                                 ignore_admin_state=False):
         """Get the valid l3 agents for the router from a list of l3_agents."""
index b170cfbf09ac9335acf3f6e631a53bafa4cda2ed..605a9356352665d0ff53006240a6ae171b25ac83 100644 (file)
@@ -299,6 +299,41 @@ class L3_DVRsch_db_mixin(l3agent_sch_db.L3AgentSchedulerDbMixin):
             CentralizedSnatL3AgentBinding.router_id.in_(router_ids))
         return query.all()
 
+    def get_snat_candidates(self, sync_router, l3_agents):
+        """Get the valid snat enabled l3 agents for the distributed router."""
+        candidates = []
+        is_router_distributed = sync_router.get('distributed', False)
+        if not is_router_distributed:
+            return candidates
+        for l3_agent in l3_agents:
+            if not l3_agent.admin_state_up:
+                continue
+
+            agent_conf = self.get_configuration_dict(l3_agent)
+            agent_mode = agent_conf.get(n_const.L3_AGENT_MODE,
+                                        n_const.L3_AGENT_MODE_LEGACY)
+            if agent_mode != n_const.L3_AGENT_MODE_DVR_SNAT:
+                continue
+
+            router_id = agent_conf.get('router_id', None)
+            use_namespaces = agent_conf.get('use_namespaces', True)
+            if not use_namespaces and router_id != sync_router['id']:
+                continue
+
+            handle_internal_only_routers = agent_conf.get(
+                'handle_internal_only_routers', True)
+            gateway_external_network_id = agent_conf.get(
+                'gateway_external_network_id', None)
+            ex_net_id = (sync_router['external_gateway_info'] or {}).get(
+                'network_id')
+            if ((not ex_net_id and not handle_internal_only_routers) or
+                (ex_net_id and gateway_external_network_id and
+                 ex_net_id != gateway_external_network_id)):
+                continue
+
+            candidates.append(l3_agent)
+        return candidates
+
     def schedule_snat_router(self, context, router_id, sync_router):
         """Schedule the snat router on l3 service agent."""
         active_l3_agents = self.get_l3_agents(context, active=True)