From 6ff7f4029551093b6c02b675b442f8fc190c27f3 Mon Sep 17 00:00:00 2001 From: Peng Yong Date: Mon, 30 Apr 2012 23:24:55 +0800 Subject: fix bug 992008, we should config public interface on compute Change-Id: I35a7d63c9613161f9fea052edf39759e4e2c6227 --- nova/network/manager.py | 8 ++++---- nova/tests/network/test_manager.py | 13 +++++++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) (limited to 'nova') diff --git a/nova/network/manager.py b/nova/network/manager.py index e37d2649c..3c3ff93a8 100644 --- a/nova/network/manager.py +++ b/nova/network/manager.py @@ -292,10 +292,10 @@ class FloatingIP(object): LOG.debug(msg) continue fixed_address = fixed_ip_ref['address'] - interface = floating_ip['interface'] + interface = FLAGS.public_interface or floating_ip['interface'] try: self.l3driver.add_floating_ip(floating_ip['address'], - fixed_address, floating_ip['interface']) + fixed_address, interface) except exception.ProcessExecutionError: LOG.debug(_('Interface %(interface)s not found'), locals()) raise exception.NoFloatingIpInterface(interface=interface) @@ -462,7 +462,7 @@ class FloatingIP(object): else: host = network['host'] - interface = floating_ip['interface'] + interface = FLAGS.public_interface or floating_ip['interface'] if host == self.host: # i'm the correct host self._associate_floating_ip(context, floating_address, @@ -527,7 +527,7 @@ class FloatingIP(object): else: host = network['host'] - interface = floating_ip['interface'] + interface = FLAGS.public_interface or floating_ip['interface'] if host == self.host: # i'm the correct host self._disassociate_floating_ip(context, address, interface) diff --git a/nova/tests/network/test_manager.py b/nova/tests/network/test_manager.py index c8d1851d6..577b7a086 100644 --- a/nova/tests/network/test_manager.py +++ b/nova/tests/network/test_manager.py @@ -715,11 +715,24 @@ class VlanNetworkTestCase(test.TestCase): self.stubs.Set(self.network.db, 'fixed_ip_get', fixed_ip_get) self.mox.StubOutWithMock(self.network.l3driver, 'add_floating_ip') + self.flags(public_interface=False) self.network.l3driver.add_floating_ip('fakefloat', 'fakefixed', 'fakeiface') self.mox.ReplayAll() self.network.init_host_floating_ips() + self.mox.UnsetStubs() + self.mox.VerifyAll() + + self.mox.StubOutWithMock(self.network.l3driver, 'add_floating_ip') + self.flags(public_interface='fooiface') + self.network.l3driver.add_floating_ip('fakefloat', + 'fakefixed', + 'fooiface') + self.mox.ReplayAll() + self.network.init_host_floating_ips() + self.mox.UnsetStubs() + self.mox.VerifyAll() def test_disassociate_floating_ip(self): ctxt = context.RequestContext('testuser', 'testproject', -- cgit