diff options
author | Jenkins <jenkins@review.openstack.org> | 2014-09-29 10:10:19 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2014-09-29 10:10:19 +0000 |
commit | 30b66a90a4f51a04d7f59b4196c4235484ade38d (patch) | |
tree | d2297effbbddee582352c67bc956734df4bcbf0f | |
parent | 2e9b49212f16f050b8c4c9df47057d7740805ed4 (diff) | |
parent | 00d8c334bbfaef3ffec4b04b494e609740b96253 (diff) | |
download | nova-30b66a90a4f51a04d7f59b4196c4235484ade38d.tar.gz |
Merge "Fixes missing ec2 api address disassociate error on failure"
-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): |