diff options
author | Chris Yeoh <cyeoh@au1.ibm.com> | 2014-09-26 16:56:07 +0930 |
---|---|---|
committer | Chris Yeoh <cyeoh@au1.ibm.com> | 2014-09-26 16:56:07 +0930 |
commit | 00d8c334bbfaef3ffec4b04b494e609740b96253 (patch) | |
tree | ffa817bbf5a1ea75e5438b3fb59772d61c952b02 | |
parent | e771813c6edb83afa3d517630c27ef0863b331f1 (diff) | |
download | nova-00d8c334bbfaef3ffec4b04b494e609740b96253.tar.gz |
Fixes missing ec2 api address disassociate error on failure
Fixes ec2 api address disassociate so that the ec2 error
InvalidAssociationID.NotFound is returned when it is passed an
invalid association rather than returning success. Note this is
slightly different than the original bug report but the type
of failure has changed since the bug was originally filed.
Change-Id: I10034a2fed62d4e93bc384aef3ff594b66e285f2
Closes-Bug: 1179816
-rw-r--r-- | nova/api/ec2/cloud.py | 3 | ||||
-rw-r--r-- | nova/exception.py | 5 | ||||
-rw-r--r-- | nova/tests/api/ec2/test_cloud.py | 6 |
3 files changed, 11 insertions, 3 deletions
diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py index 1abb4524e5..5ed36b7fc6 100644 --- a/nova/api/ec2/cloud.py +++ b/nova/api/ec2/cloud.py @@ -1323,6 +1323,9 @@ class CloudController(object): LOG.audit(_("Disassociate address %s"), public_ip, context=context) self.network_api.disassociate_floating_ip(context, instance, address=public_ip) + else: + msg = _('Floating ip is not associated.') + raise exception.InvalidAssociation(message=msg) return {'return': "true"} def run_instances(self, context, **kwargs): diff --git a/nova/exception.py b/nova/exception.py index efc5492529..bfeae94457 100644 --- a/nova/exception.py +++ b/nova/exception.py @@ -1293,6 +1293,11 @@ class InstanceInfoCacheNotFound(NotFound): "found.") +class InvalidAssociation(NotFound): + ec2_code = 'InvalidAssociationID.NotFound' + msg_fmt = _("Invalid association.") + + class NodeNotFound(NotFound): msg_fmt = _("Node %(node_id)s could not be found.") diff --git a/nova/tests/api/ec2/test_cloud.py b/nova/tests/api/ec2/test_cloud.py index e5ab8da522..ccea951835 100644 --- a/nova/tests/api/ec2/test_cloud.py +++ b/nova/tests/api/ec2/test_cloud.py @@ -389,9 +389,9 @@ class CloudTestCase(test.TestCase): 'pool': 'nova'}) self.cloud.allocate_address(self.context) self.cloud.describe_addresses(self.context) - result = self.cloud.disassociate_address(self.context, - public_ip=address) - self.assertEqual(result['return'], 'true') + self.assertRaises(exception.InvalidAssociation, + self.cloud.disassociate_address, + self.context, public_ip=address) db.floating_ip_destroy(self.context, address) def test_describe_security_groups(self): |