diff options
| author | Eoghan Glynn <eglynn@redhat.com> | 2012-07-19 16:19:49 +0100 |
|---|---|---|
| committer | Eoghan Glynn <eglynn@redhat.com> | 2012-07-19 16:19:49 +0100 |
| commit | ebc05b803615b78a14008136bb549a41013e6cd1 (patch) | |
| tree | e0d13d2f57904fe6f4a65776ea03acccb5d840c4 /nova | |
| parent | 5f45eadbf2c1ea4a4cf6c9358aac269ca3f2cff6 (diff) | |
Allow NoMoreFloatingIps to bubble up to FaultWrapper
Fixes LP 1026167.
The fix for LP 1021721 caught the wrong exception in order to
address floating IP quota over-run. NoMoreFloatingIps is raised
when the floating range is exhausted, whereas FloatingIpLimitExceeded
is raised on over-quota.
Also the HTTPRequestEntityTooLarge exception raised is mapped
to 500 Server Error due to the required retry-after header being
left unset.
We now allow the NoMoreFloatingIps to bubble up to the FaultWrapper
middleware, where its mapped to a 404 status due to it extending
the NotFound exception.
Change-Id: Id35c487113059ec3053f2f9e9e7eca24854ac02c
Diffstat (limited to 'nova')
| -rw-r--r-- | nova/api/openstack/compute/contrib/floating_ips.py | 8 | ||||
| -rw-r--r-- | nova/exception.py | 1 | ||||
| -rw-r--r-- | nova/tests/api/openstack/compute/contrib/test_floating_ips.py | 2 |
3 files changed, 6 insertions, 5 deletions
diff --git a/nova/api/openstack/compute/contrib/floating_ips.py b/nova/api/openstack/compute/contrib/floating_ips.py index df25e4fd2..b6a6adc9e 100644 --- a/nova/api/openstack/compute/contrib/floating_ips.py +++ b/nova/api/openstack/compute/contrib/floating_ips.py @@ -169,12 +169,12 @@ class FloatingIPController(object): try: address = self.network_api.allocate_floating_ip(context, pool) ip = self.network_api.get_floating_ip_by_address(context, address) - except exception.NoMoreFloatingIps: + except exception.NoMoreFloatingIps, nmfi: if pool: - msg = _("No more floating ips in pool %s.") % pool + nmfi.message = _("No more floating ips in pool %s.") % pool else: - msg = _("No more floating ips available.") - raise webob.exc.HTTPRequestEntityTooLarge(explanation=msg) + nmfi.message = _("No more floating ips available.") + raise nmfi return _translate_floating_ip_view(ip) diff --git a/nova/exception.py b/nova/exception.py index f70cbe48e..c6f05e97e 100644 --- a/nova/exception.py +++ b/nova/exception.py @@ -651,6 +651,7 @@ class FloatingIpNotFoundForHost(FloatingIpNotFound): class NoMoreFloatingIps(FloatingIpNotFound): message = _("Zero floating ips available.") + safe = True class FloatingIpAssociated(NovaException): 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 e1a5593d3..bd752b6e5 100644 --- a/nova/tests/api/openstack/compute/contrib/test_floating_ips.py +++ b/nova/tests/api/openstack/compute/contrib/test_floating_ips.py @@ -228,7 +228,7 @@ class FloatingIpTest(test.TestCase): self.stubs.Set(rpc, "call", fake_call) req = fakes.HTTPRequest.blank('/v2/fake/os-floating-ips') - self.assertRaises(webob.exc.HTTPRequestEntityTooLarge, + self.assertRaises(exception.NoMoreFloatingIps, self.controller.create, req) |
