summaryrefslogtreecommitdiffstats
path: root/nova
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2013-01-02 14:29:03 +0000
committerGerrit Code Review <review@openstack.org>2013-01-02 14:29:03 +0000
commit3a642467c8604e185d38ebaa8adc990cf415ff7f (patch)
treefadd18c2a6f28ad558562f2335d3db2b4acfe937 /nova
parentfc3a938804866b269ca864e177e80381f1ce7062 (diff)
parent3b9f08072abe9f92d292e9fa5998c62a766b01f3 (diff)
downloadnova-3a642467c8604e185d38ebaa8adc990cf415ff7f.tar.gz
nova-3a642467c8604e185d38ebaa8adc990cf415ff7f.tar.xz
nova-3a642467c8604e185d38ebaa8adc990cf415ff7f.zip
Merge "Ignore double messages to associate the same ip"
Diffstat (limited to 'nova')
-rw-r--r--nova/network/manager.py3
-rw-r--r--nova/tests/network/test_manager.py8
2 files changed, 9 insertions, 2 deletions
diff --git a/nova/network/manager.py b/nova/network/manager.py
index 97d4fa10d..5189b40c7 100644
--- a/nova/network/manager.py
+++ b/nova/network/manager.py
@@ -543,6 +543,9 @@ class FloatingIP(object):
# find previously associated instance
fixed_ip = self.db.fixed_ip_get(context,
floating_ip['fixed_ip_id'])
+ if fixed_ip['address'] == fixed_address:
+ # NOTE(vish): already associated to this address
+ return
orig_instance_uuid = fixed_ip['instance_uuid']
self.disassociate_floating_ip(context, floating_address)
diff --git a/nova/tests/network/test_manager.py b/nova/tests/network/test_manager.py
index 0e441eef8..c2aa1dbbb 100644
--- a/nova/tests/network/test_manager.py
+++ b/nova/tests/network/test_manager.py
@@ -740,15 +740,19 @@ class VlanNetworkTestCase(test.TestCase):
self.stubs.Set(self.network, 'disassociate_floating_ip', fake9)
def fake_fixed_ip_get(context, fixed_ip_id):
- return {'instance_uuid': 'fake_uuid'}
+ return {'address': 'old', 'instance_uuid': 'fake_uuid'}
self.stubs.Set(self.network.db, 'fixed_ip_get', fake_fixed_ip_get)
+ # doesn't raise because we exit early if the address is the same
+ self.network.associate_floating_ip(ctxt, mox.IgnoreArg(), 'old')
+
+ # raises because we call disassociate which is mocked
self.assertRaises(test.TestingException,
self.network.associate_floating_ip,
ctxt,
mox.IgnoreArg(),
- mox.IgnoreArg())
+ 'new')
self.stubs.Set(self.network.db, 'floating_ip_get_by_address', fake3)