diff options
| author | John Tran <jhtran@att.com> | 2012-07-09 16:26:55 -0700 |
|---|---|---|
| committer | John Tran <jhtran@att.com> | 2012-07-10 08:03:30 -0700 |
| commit | bed296b17ded5012d6651957df387336c10dd002 (patch) | |
| tree | 112e43f85b2f9b0484d3064735a353b46ee73990 | |
| parent | bda7c3e0b6863473a0202905cb5b41a7d33d2143 (diff) | |
| download | nova-bed296b17ded5012d6651957df387336c10dd002.tar.gz nova-bed296b17ded5012d6651957df387336c10dd002.tar.xz nova-bed296b17ded5012d6651957df387336c10dd002.zip | |
associate_floating_ip an ip already in use
Fixes bug 10014860 to be compliant w/ AWS EC2 spec
instead of return exception.FloatingIpAssociated,
disassociate from old fixed_ip and associate to
new fixed_ip.
Change-Id: I54ab3492092940dbb01f2787cc329a0162698568
| -rw-r--r-- | nova/network/manager.py | 4 | ||||
| -rw-r--r-- | nova/tests/network/test_manager.py | 6 |
2 files changed, 7 insertions, 3 deletions
diff --git a/nova/network/manager.py b/nova/network/manager.py index d4937d90b..00bb15346 100644 --- a/nova/network/manager.py +++ b/nova/network/manager.py @@ -493,9 +493,9 @@ class FloatingIP(object): # make sure project ownz this floating ip (allocated) self._floating_ip_owned_by_project(context, floating_ip) - # make sure floating ip isn't already associated + # disassociate any already associated if floating_ip['fixed_ip_id']: - raise exception.FloatingIpAssociated(address=floating_address) + self.disassociate_floating_ip(context, floating_address) fixed_ip = self.db.fixed_ip_get_by_address(context, fixed_address) diff --git a/nova/tests/network/test_manager.py b/nova/tests/network/test_manager.py index b3a5ef0ea..a5a6b9548 100644 --- a/nova/tests/network/test_manager.py +++ b/nova/tests/network/test_manager.py @@ -670,6 +670,9 @@ class VlanNetworkTestCase(test.TestCase): raise exception.ProcessExecutionError('', 'Cannot find device "em0"\n') + def fake9(*args, **kwargs): + raise test.TestingException() + # raises because interface doesn't exist self.stubs.Set(self.network.db, 'floating_ip_fixed_ip_associate', @@ -687,7 +690,8 @@ class VlanNetworkTestCase(test.TestCase): # raises because floating_ip is already associated to a fixed_ip self.stubs.Set(self.network.db, 'floating_ip_get_by_address', fake2) - self.assertRaises(exception.FloatingIpAssociated, + self.stubs.Set(self.network, 'disassociate_floating_ip', fake9) + self.assertRaises(test.TestingException, self.network.associate_floating_ip, ctxt, mox.IgnoreArg(), |
