From 28d6ca99277b5f8edf61d03af07da0658fee920e Mon Sep 17 00:00:00 2001 From: Nachi Ueno Date: Tue, 16 Jul 2013 21:54:11 -0700 Subject: [PATCH] Fixes argument mismatch in l3-agent Fixes bug 1202055 Also fixes deletion problem in snat rule Change-Id: I007a81003e343300836ad226c2dc64b95c5a3247 --- neutron/agent/l3_agent.py | 4 ++-- neutron/tests/unit/test_l3_agent.py | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/neutron/agent/l3_agent.py b/neutron/agent/l3_agent.py index 1f5105d1a..910034ed7 100644 --- a/neutron/agent/l3_agent.py +++ b/neutron/agent/l3_agent.py @@ -400,7 +400,7 @@ class L3NATAgent(manager.Manager): ri.iptables_manager.ipv4['nat'].empty_chain('POSTROUTING') ri.iptables_manager.ipv4['nat'].empty_chain('snat') # And add them back if the action if add_rules - if action == 'add_rules': + if action == 'add_rules' and ex_gw_port: # ex_gw_port should not be None in this case ex_gw_ip = ex_gw_port['fixed_ips'][0]['ip_address'] for rule in self.external_gateway_nat_rules(ex_gw_ip, @@ -691,7 +691,7 @@ class L3NATAgent(manager.Manager): def _process_router_delete(self): current_removed_routers = list(self.removed_routers) for router_id in current_removed_routers: - self._router_removed(context, router_id) + self._router_removed(router_id) self.removed_routers.remove(router_id) def _router_ids(self): diff --git a/neutron/tests/unit/test_l3_agent.py b/neutron/tests/unit/test_l3_agent.py index dc76926e4..d2da8979d 100644 --- a/neutron/tests/unit/test_l3_agent.py +++ b/neutron/tests/unit/test_l3_agent.py @@ -533,6 +533,24 @@ class TestBasicRouterOperations(base.BaseTestCase): # verify that will set fullsync self.assertTrue(FAKE_ID in agent.updated_routers) + def test_process_router_delete(self): + agent = l3_agent.L3NATAgent(HOSTNAME, self.conf) + ex_gw_port = {'id': _uuid(), + 'network_id': _uuid(), + 'fixed_ips': [{'ip_address': '19.4.4.4', + 'subnet_id': _uuid()}], + 'subnet': {'cidr': '19.4.4.0/24', + 'gateway_ip': '19.4.4.1'}} + router = { + 'id': _uuid(), + 'enable_snat': True, + 'routes': [], + 'gw_port': ex_gw_port} + agent._router_added(router['id'], router) + agent.router_deleted(None, router['id']) + agent._process_router_delete() + self.assertFalse(list(agent.removed_routers)) + def testDestroyNamespace(self): class FakeDev(object):