]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Fixes argument mismatch in l3-agent
authorNachi Ueno <nachi@ntti3.com>
Wed, 17 Jul 2013 04:54:11 +0000 (21:54 -0700)
committerNachi Ueno <nachi@ntti3.com>
Wed, 17 Jul 2013 06:34:24 +0000 (23:34 -0700)
Fixes bug 1202055
Also fixes deletion problem in snat rule

Change-Id: I007a81003e343300836ad226c2dc64b95c5a3247

neutron/agent/l3_agent.py
neutron/tests/unit/test_l3_agent.py

index 1f5105d1aa0c11817da1c554752f3cce26492ca3..910034ed7177114e604bc7657aeefba8a1467d27 100644 (file)
@@ -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):
index dc76926e48f2d111e927fe78bdda5aaad6bdb522..d2da8979d9b782f38dbbd58981c272212bfadaec 100644 (file)
@@ -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):