Merge "Fixes missing ec2 api address disassociate error on failure"

This commit is contained in:
Jenkins 2014-09-29 10:10:19 +00:00 committed by Gerrit Code Review
commit 30b66a90a4
3 changed files with 11 additions and 3 deletions

View File

@ -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):

View File

@ -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.")

View File

@ -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):