diff options
| author | Chris Yeoh <cyeoh@au1.ibm.com> | 2013-04-17 13:02:02 +0930 |
|---|---|---|
| committer | Chris Yeoh <cyeoh@au1.ibm.com> | 2013-04-18 16:30:33 +0930 |
| commit | f9be01a42a513d7d579cc2424a439ae800ec6df6 (patch) | |
| tree | 717397a267b61844e92f2650c7bee6c305f2d18a /nova/tests | |
| parent | 36b10384724fec9657784980cd2bd38e72b445bc (diff) | |
Translate NoMoreFloatingIps exception
When the pool of floating ips is exhausted the NoMoreFloatingIps exception
is raised but not handled properly in the floating ips extension resulting
in the exception propagating further up and causing a stack trace to be logged.
This change translates the exception explicitly into a HTTPNotFound, preserving the current
REST API behaviour. It fixes a bug where the pool name was not correctly inserted into
the message returned if allocation from a specific pool was requested.
Fixes bug 1169811
Part of blueprint no-stacktraces-in-logs
Change-Id: I8f35d25d065bb1fa709cff6f59841ac8c86658bd
Diffstat (limited to 'nova/tests')
| -rw-r--r-- | nova/tests/api/openstack/compute/contrib/test_floating_ips.py | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/nova/tests/api/openstack/compute/contrib/test_floating_ips.py b/nova/tests/api/openstack/compute/contrib/test_floating_ips.py index 00759a7ef..385d56939 100644 --- a/nova/tests/api/openstack/compute/contrib/test_floating_ips.py +++ b/nova/tests/api/openstack/compute/contrib/test_floating_ips.py @@ -17,6 +17,7 @@ import uuid from lxml import etree +import testtools import webob from nova.api.openstack.compute.contrib import floating_ips @@ -281,9 +282,21 @@ class FloatingIpTest(test.TestCase): self.stubs.Set(network.api.API, "allocate_floating_ip", fake_allocate) req = fakes.HTTPRequest.blank('/v2/fake/os-floating-ips') - self.assertRaises(exception.NoMoreFloatingIps, - self.controller.create, - req) + with testtools.ExpectedException(webob.exc.HTTPNotFound, + 'No more floating ips'): + self.controller.create(req) + + def test_floating_ip_allocate_no_free_ips_pool(self): + def fake_allocate(*args, **kwargs): + raise exception.NoMoreFloatingIps() + + self.stubs.Set(network.api.API, "allocate_floating_ip", fake_allocate) + + req = fakes.HTTPRequest.blank('/v2/fake/os-floating-ips') + with testtools.ExpectedException( + webob.exc.HTTPNotFound, + 'No more floating ips in pool non_existant_pool'): + self.controller.create(req, {'pool': 'non_existant_pool'}) def test_floating_ip_allocate(self): def fake1(*args, **kwargs): |
