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
This commit is contained in:
John Schwarz 2014-09-23 15:24:47 +03:00
parent 467bd9476d
commit dea795263e
1 changed files with 9 additions and 3 deletions

View 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)