Fixes argument mismatch in l3-agent

Fixes bug 1202055
Also fixes deletion problem in snat rule

Change-Id: I007a81003e343300836ad226c2dc64b95c5a3247
This commit is contained in:
Nachi Ueno 2013-07-16 21:54:11 -07:00
parent 88f6d5ec7c
commit 28d6ca9927
2 changed files with 20 additions and 2 deletions

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

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