summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormingyan bao <bao.mingyan@hp.com>2013-02-04 15:52:33 -0700
committermingyan bao <bao.mingyan@hp.com>2013-02-08 13:06:04 -0700
commit12c73ee65372fd1b0a3d3417cd91e548fd7afd2b (patch)
tree68ed86c079143dded015a5f447c5cc1a514ba851
parent36fffe9bde1d353a418274a79e6f7abd0177d065 (diff)
downloadnova-12c73ee65372fd1b0a3d3417cd91e548fd7afd2b.tar.gz
nova-12c73ee65372fd1b0a3d3417cd91e548fd7afd2b.tar.xz
nova-12c73ee65372fd1b0a3d3417cd91e548fd7afd2b.zip
l3.py,add_floating_ip: setup NAT before binding
fix for bug 1100435 Change-Id: Iad022f61297fe26edb230ba7b9e31d73df99b5a5
-rw-r--r--nova/network/l3.py2
-rw-r--r--nova/tests/network/test_manager.py38
2 files changed, 38 insertions, 2 deletions
diff --git a/nova/network/l3.py b/nova/network/l3.py
index 14abf41eb..30a9f1ecd 100644
--- a/nova/network/l3.py
+++ b/nova/network/l3.py
@@ -101,9 +101,9 @@ class LinuxNetL3(L3Driver):
def add_floating_ip(self, floating_ip, fixed_ip, l3_interface_id,
network=None):
- linux_net.bind_floating_ip(floating_ip, l3_interface_id)
linux_net.ensure_floating_forward(floating_ip, fixed_ip,
l3_interface_id, network)
+ linux_net.bind_floating_ip(floating_ip, l3_interface_id)
def remove_floating_ip(self, floating_ip, fixed_ip, l3_interface_id,
network=None):
diff --git a/nova/tests/network/test_manager.py b/nova/tests/network/test_manager.py
index 0dcd02f78..c0a434e6c 100644
--- a/nova/tests/network/test_manager.py
+++ b/nova/tests/network/test_manager.py
@@ -726,7 +726,7 @@ class VlanNetworkTestCase(test.TestCase):
'floating_ip_fixed_ip_associate',
fake1)
self.stubs.Set(self.network.db, 'floating_ip_disassociate', fake1)
- self.stubs.Set(self.network.driver, 'bind_floating_ip', fake8)
+ self.stubs.Set(self.network.driver, 'ensure_floating_forward', fake8)
self.assertRaises(exception.NoFloatingIpInterface,
self.network._associate_floating_ip,
ctxt,
@@ -776,6 +776,42 @@ class VlanNetworkTestCase(test.TestCase):
mox.IgnoreArg())
self.assertTrue(self.local)
+ def test_add_floating_ip_nat_before_bind(self):
+ # Tried to verify order with documented mox record/verify
+ # functionality, but it doesn't seem to work since I can't make it
+ # fail. I'm using stubs and a flag for now, but if this mox feature
+ # can be made to work, it would be a better way to test this.
+ #
+ # self.mox.StubOutWithMock(self.network.driver,
+ # 'ensure_floating_forward')
+ # self.mox.StubOutWithMock(self.network.driver, 'bind_floating_ip')
+ #
+ # self.network.driver.ensure_floating_forward(mox.IgnoreArg(),
+ # mox.IgnoreArg(),
+ # mox.IgnoreArg(),
+ # mox.IgnoreArg())
+ # self.network.driver.bind_floating_ip(mox.IgnoreArg(),
+ # mox.IgnoreArg())
+ # self.mox.ReplayAll()
+
+ nat_called = [False]
+
+ def fake_nat(*args, **kwargs):
+ nat_called[0] = True
+
+ def fake_bind(*args, **kwargs):
+ self.assertTrue(nat_called[0])
+
+ self.stubs.Set(self.network.driver,
+ 'ensure_floating_forward',
+ fake_nat)
+ self.stubs.Set(self.network.driver, 'bind_floating_ip', fake_bind)
+
+ self.network.l3driver.add_floating_ip('fakefloat',
+ 'fakefixed',
+ 'fakeiface',
+ 'fakenet')
+
def test_floating_ip_init_host(self):
def get_all_by_host(_context, _host):