diff --git a/nova/network/manager.py b/nova/network/manager.py index 0e652c6107e7..621744f6c73c 100644 --- a/nova/network/manager.py +++ b/nova/network/manager.py @@ -293,10 +293,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) @@ -476,7 +476,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, @@ -547,7 +547,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 de8779be1d17..da892eddda2e 100644 --- a/nova/tests/network/test_manager.py +++ b/nova/tests/network/test_manager.py @@ -716,11 +716,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',