From f9be01a42a513d7d579cc2424a439ae800ec6df6 Mon Sep 17 00:00:00 2001 From: Chris Yeoh Date: Wed, 17 Apr 2013 13:02:02 +0930 Subject: 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 --- nova/api/openstack/compute/contrib/floating_ips.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'nova/api') diff --git a/nova/api/openstack/compute/contrib/floating_ips.py b/nova/api/openstack/compute/contrib/floating_ips.py index bf1246ccb..7be479e5a 100644 --- a/nova/api/openstack/compute/contrib/floating_ips.py +++ b/nova/api/openstack/compute/contrib/floating_ips.py @@ -160,12 +160,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, nmfi: + except exception.NoMoreFloatingIps: if pool: - nmfi.message = _("No more floating ips in pool %s.") % pool + msg = _("No more floating ips in pool %s.") % pool else: - nmfi.message = _("No more floating ips available.") - raise + msg = _("No more floating ips available.") + raise webob.exc.HTTPNotFound(explanation=msg) return _translate_floating_ip_view(ip) -- cgit