]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Divide _cleanup_namespaces for easy extensibility
authorJohn Schwarz <jschwarz@redhat.com>
Tue, 23 Sep 2014 12:24:47 +0000 (15:24 +0300)
committerJohn Schwarz <jschwarz@redhat.com>
Mon, 6 Oct 2014 09:18:55 +0000 (12:18 +0300)
This division of the function to 2 different functions allows for
easier overwriting in the l3 test agent used by the HA functional
tests, and later by the integration tests.

Related-bug: #1374947
Change-Id: I8f277759747c8a142f5c023aa3511b00a886348c

neutron/agent/l3_agent.py

index 4e73a0ee61edaef1d61d6af9a8dfa9e0004b87bb..59c68cf8de24842ed64fd5f4c9c55b197687e6de 100644 (file)
@@ -599,6 +599,12 @@ class L3NATAgent(firewall_l3_agent.FWaaSL3AgentRpcCallback,
                             'for namespace cleanup.'))
             return set()
 
+    def _get_routers_namespaces(self, router_ids):
+        namespaces = set(self._get_router_info(id, router=None).ns_name
+                         for id in router_ids)
+        namespaces.update(self.get_snat_ns_name(id) for id in router_ids)
+        return namespaces
+
     def _cleanup_namespaces(self, router_namespaces, router_ids):
         """Destroy stale router namespaces on host when L3 agent restarts
 
@@ -607,9 +613,9 @@ class L3NATAgent(firewall_l3_agent.FWaaSL3AgentRpcCallback,
         The argument router_namespaces is the list of all routers namespaces
         The argument router_ids is the list of ids for known routers.
         """
-        ns_to_ignore = set(self._get_router_info(id, router=None).ns_name
-                           for id in router_ids)
-        ns_to_ignore.update(self.get_snat_ns_name(id) for id in router_ids)
+        # Don't destroy namespaces of routers this agent handles.
+        ns_to_ignore = self._get_routers_namespaces(router_ids)
+
         ns_to_destroy = router_namespaces - ns_to_ignore
         self._destroy_stale_router_namespaces(ns_to_destroy)