From 8b597f76f980769e83a36111ca8fcd8b988d236c Mon Sep 17 00:00:00 2001 From: Chuck Short Date: Mon, 30 Apr 2012 21:36:06 -0400 Subject: Make allocation failure a bit more friendly If the user allocates the wrong address display a message about incorrect address rather than a traceback. Fixes LP: #957707 Change-Id: I8ccd3056f755afb9f873a25fd494428e481ff3a2 Signed-off-by: Chuck Short --- nova/api/ec2/cloud.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'nova/api') diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py index dcc0d17b9..70933d2bc 100644 --- a/nova/api/ec2/cloud.py +++ b/nova/api/ec2/cloud.py @@ -1282,18 +1282,24 @@ class CloudController(object): def release_address(self, context, public_ip, **kwargs): LOG.audit(_("Release address %s"), public_ip, context=context) - self.network_api.release_floating_ip(context, address=public_ip) - return {'return': "true"} + try: + self.network_api.release_floating_ip(context, address=public_ip) + return {'return': "true"} + except exception.FloatingIpNotFound: + raise exception.EC2APIError(_('Unable to release IP Address.')) def associate_address(self, context, instance_id, public_ip, **kwargs): LOG.audit(_("Associate address %(public_ip)s to" " instance %(instance_id)s") % locals(), context=context) instance_id = ec2utils.ec2_id_to_id(instance_id) instance = self.compute_api.get(context, instance_id) - self.compute_api.associate_floating_ip(context, - instance, - address=public_ip) - return {'return': "true"} + try: + self.compute_api.associate_floating_ip(context, + instance, + address=public_ip) + return {'return': "true"} + except exception.FloatingIpNotFound: + raise exception.EC2APIError(_('Unable to associate IP Address.')) def disassociate_address(self, context, public_ip, **kwargs): LOG.audit(_("Disassociate address %s"), public_ip, context=context) -- cgit