From dea795263eb2968519d4235a8de98329c329e0e8 Mon Sep 17 00:00:00 2001 From: John Schwarz Date: Tue, 23 Sep 2014 15:24:47 +0300 Subject: [PATCH] Divide _cleanup_namespaces for easy extensibility 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 | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/neutron/agent/l3_agent.py b/neutron/agent/l3_agent.py index 4e73a0ee6..59c68cf8d 100644 --- a/neutron/agent/l3_agent.py +++ b/neutron/agent/l3_agent.py @@ -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) -- 2.45.2