Merge "l3.py,add_floating_ip: setup NAT before binding"
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user