Merge "Cleanup floatingips also on router delete"

This commit is contained in:
Jenkins 2014-09-15 07:23:40 +00:00 committed by Gerrit Code Review
commit d44d3d880c
2 changed files with 12 additions and 2 deletions

View File

@ -948,7 +948,7 @@ class L3NATAgent(firewall_l3_agent.FWaaSL3AgentRpcCallback,
# Process SNAT/DNAT rules for floating IPs
fip_statuses = {}
try:
if ex_gw_port:
if ex_gw_port or ri.ex_gw_port:
existing_floating_ips = ri.floating_ips
self.process_router_floating_ip_nat_rules(ri)
ri.iptables_manager.defer_apply_off()
@ -962,7 +962,7 @@ class L3NATAgent(firewall_l3_agent.FWaaSL3AgentRpcCallback,
for fip in ri.router.get(l3_constants.FLOATINGIP_KEY, []):
fip_statuses[fip['id']] = l3_constants.FLOATINGIP_STATUS_ERROR
if ex_gw_port:
if ex_gw_port or ri.ex_gw_port:
# Identify floating IPs which were disabled
ri.floating_ips = set(fip_statuses.keys())
for fip_id in existing_floating_ips - ri.floating_ips:

View File

@ -988,7 +988,17 @@ class TestBasicRouterOperations(base.BaseTestCase):
del router[l3_constants.INTERFACE_KEY]
del router['gw_port']
agent.process_router(ri)
ex_gw_port = agent._get_ex_gw_port(ri)
self.assertEqual(self.send_arp.call_count, 1)
agent.process_router_floating_ip_addresses.assert_called_with(
ri, ex_gw_port)
agent.process_router_floating_ip_addresses.reset_mock()
agent.process_router_floating_ip_nat_rules.assert_called_with(ri)
agent.process_router_floating_ip_nat_rules.reset_mock()
# now no ports no gateway, test state tear down
ri.ex_gw_port = None
agent.process_router(ri)
self.assertFalse(agent.process_router_floating_ip_addresses.called)
self.assertFalse(agent.process_router_floating_ip_nat_rules.called)