summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Tran <jtran@attinteractive.com>2011-06-08 15:23:33 -0700
committerJohn Tran <jtran@attinteractive.com>2011-06-08 15:23:33 -0700
commit70e4d73778d448cb7f122bc0a2a0c43a78fff46a (patch)
tree62ef2040dbaa8948ffc027b46257153e925d8ec6
parent8ff87c649e13e21ba968ec85a1158230e8cf118d (diff)
downloadnova-70e4d73778d448cb7f122bc0a2a0c43a78fff46a.tar.gz
nova-70e4d73778d448cb7f122bc0a2a0c43a78fff46a.tar.xz
nova-70e4d73778d448cb7f122bc0a2a0c43a78fff46a.zip
added a test for allocate_address & added error handling for api instead of returning 'UnknownError', will give information 'AllocateAddressError: NoMoreAddresses
-rw-r--r--nova/api/ec2/__init__.py6
-rw-r--r--nova/tests/test_cloud.py10
2 files changed, 16 insertions, 0 deletions
diff --git a/nova/api/ec2/__init__.py b/nova/api/ec2/__init__.py
index 1915d007d..459ecb442 100644
--- a/nova/api/ec2/__init__.py
+++ b/nova/api/ec2/__init__.py
@@ -348,6 +348,12 @@ class Executor(wsgi.Application):
LOG.debug(_('KeyPairExists raised: %s'), unicode(ex),
context=context)
return self._error(req, context, type(ex).__name__, unicode(ex))
+ except rpc.RemoteError as ex:
+ LOG.debug(_('RemoteError raised: %s'), ex.exc_type,
+ context=context)
+ if ex.exc_type == 'NoMoreAddresses':
+ return self._error(req, context, 'AllocateAddressError',
+ ex.exc_type)
except Exception as ex:
extra = {'environment': req.environ}
LOG.exception(_('Unexpected error raised: %s'), unicode(ex),
diff --git a/nova/tests/test_cloud.py b/nova/tests/test_cloud.py
index ba133c860..d6d90e873 100644
--- a/nova/tests/test_cloud.py
+++ b/nova/tests/test_cloud.py
@@ -115,6 +115,16 @@ class CloudTestCase(test.TestCase):
public_ip=address)
db.floating_ip_destroy(self.context, address)
+ def test_allocate_address(self):
+ address = "10.10.10.10"
+ allocate = self.cloud.allocate_address
+ db.floating_ip_create(self.context,
+ {'address': address,
+ 'host': self.network.host})
+ self.assertEqual(allocate(self.context)['publicIp'], address)
+ db.floating_ip_destroy(self.context, address)
+ self.assertRaises(rpc.RemoteError, allocate, self.context)
+
def test_associate_disassociate_address(self):
"""Verifies associate runs cleanly without raising an exception"""
address = "10.10.10.10"