summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorJohn Tran <jtran@attinteractive.com>2011-06-11 01:31:10 +0000
committerTarmac <>2011-06-11 01:31:10 +0000
commit91e34d37d2907295e892e96ca2c3039c7fbe14bf (patch)
tree0dfe08c722b60f4050762cff9f075ccf61d81f6b /nova/api
parent8e6fabd481520b46b47d2f9f9a9c9dfa200f5866 (diff)
parent05fecdf873a5c02dcb13c841304df872411d4183 (diff)
downloadnova-91e34d37d2907295e892e96ca2c3039c7fbe14bf.tar.gz
nova-91e34d37d2907295e892e96ca2c3039c7fbe14bf.tar.xz
nova-91e34d37d2907295e892e96ca2c3039c7fbe14bf.zip
ec2 api method allocate_address ; raises exception.NoFloatingIpsDefined instead of UnknownError when there aren't any floating ips available.
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/ec2/cloud.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py
index 316298c39..e1c65ae40 100644
--- a/nova/api/ec2/cloud.py
+++ b/nova/api/ec2/cloud.py
@@ -39,6 +39,7 @@ from nova import flags
from nova import ipv6
from nova import log as logging
from nova import network
+from nova import rpc
from nova import utils
from nova import volume
from nova.api.ec2 import ec2utils
@@ -872,8 +873,14 @@ class CloudController(object):
def allocate_address(self, context, **kwargs):
LOG.audit(_("Allocate address"), context=context)
- public_ip = self.network_api.allocate_floating_ip(context)
- return {'publicIp': public_ip}
+ try:
+ public_ip = self.network_api.allocate_floating_ip(context)
+ return {'publicIp': public_ip}
+ except rpc.RemoteError as ex:
+ if ex.exc_type == 'NoMoreAddresses':
+ raise exception.NoMoreFloatingIps()
+ else:
+ raise
def release_address(self, context, public_ip, **kwargs):
LOG.audit(_("Release address %s"), public_ip, context=context)