summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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):