From d786517ad1dbd4e59382de241074c5dc454bd365 Mon Sep 17 00:00:00 2001 From: Hans Lindgren Date: Tue, 12 Mar 2013 15:30:53 +0100 Subject: Fix: improve API error responses from os-hosts extension Modify responses to include the actual host instead of %(host)s. Resolves bug 1154117. Change-Id: Ic680403bdf1cb1fc1ac184352f486390fb04a195 --- nova/api/openstack/compute/contrib/hosts.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'nova/api') diff --git a/nova/api/openstack/compute/contrib/hosts.py b/nova/api/openstack/compute/contrib/hosts.py index 3ecfb9965..409603691 100644 --- a/nova/api/openstack/compute/contrib/hosts.py +++ b/nova/api/openstack/compute/contrib/hosts.py @@ -200,7 +200,7 @@ class HostController(object): msg = _("Virt driver does not implement host maintenance mode.") raise webob.exc.HTTPNotImplemented(explanation=msg) except exception.NotFound as e: - raise webob.exc.HTTPNotFound(explanation=e.message) + raise webob.exc.HTTPNotFound(explanation=unicode(e)) if result not in ("on_maintenance", "off_maintenance"): raise webob.exc.HTTPBadRequest(explanation=result) return result @@ -220,7 +220,7 @@ class HostController(object): msg = _("Virt driver does not implement host disabled status.") raise webob.exc.HTTPNotImplemented(explanation=msg) except exception.NotFound as e: - raise webob.exc.HTTPNotFound(explanation=e.message) + raise webob.exc.HTTPNotFound(explanation=unicode(e)) if result not in ("enabled", "disabled"): raise webob.exc.HTTPBadRequest(explanation=result) return result @@ -236,7 +236,7 @@ class HostController(object): msg = _("Virt driver does not implement host power management.") raise webob.exc.HTTPNotImplemented(explanation=msg) except exception.NotFound as e: - raise webob.exc.HTTPNotFound(explanation=e.message) + raise webob.exc.HTTPNotFound(explanation=unicode(e)) return {"host": host_name, "power_action": result} @wsgi.serializers(xml=HostActionTemplate) @@ -317,7 +317,7 @@ class HostController(object): try: service = self.api.service_get_by_compute_host(context, host_name) except exception.NotFound as e: - raise webob.exc.HTTPNotFound(explanation=e.message) + raise webob.exc.HTTPNotFound(explanation=unicode(e)) except exception.AdminRequired: msg = _("Describe-resource is admin only functionality") raise webob.exc.HTTPForbidden(explanation=msg) -- cgit