From 5b38c5c6fe57f7b0d3e36a5d0206488fa01106c0 Mon Sep 17 00:00:00 2001 From: Wangpan Date: Tue, 19 Feb 2013 13:14:06 +0800 Subject: Return proper error messages while disassociating floating IP Currently, when a floating IP is not associated with an instance, and if we try to disassociate it, a response likes "HTTP/1.1 404 Not Found" will be returned, it is not proper, so change it to "HTTP/1.1 422 Unprocessable Entity" with body likes '{"computeFault": {"message": "Floating ip 172.24.4.225 is not associated with instance a33857af-b18b-4b88-a5cc-7d84c7fd41c8.", "code": 422}}'. Fixes bug: #1129719 Change-Id: I18194ccf59edb5eb2bcd52a65f38d5632fef95d3 --- nova/api/openstack/compute/contrib/floating_ips.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (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 2f3c56199..bf1246ccb 100644 --- a/nova/api/openstack/compute/contrib/floating_ips.py +++ b/nova/api/openstack/compute/contrib/floating_ips.py @@ -294,7 +294,9 @@ class FloatingIPActionController(wsgi.Controller): disassociate_floating_ip(self, context, instance, address) return webob.Response(status_int=202) else: - return webob.Response(status_int=404) + msg = _("Floating ip %(address)s is not associated with instance " + "%(id)s.") % locals() + raise webob.exc.HTTPUnprocessableEntity(explanation=msg) class Floating_ips(extensions.ExtensionDescriptor): -- cgit