summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2012-12-11 17:43:15 +0000
committerGerrit Code Review <review@openstack.org>2012-12-11 17:43:15 +0000
commitfa49ec0027e864bbe994818ddb0314e0412e3e58 (patch)
treee46e586e92d735dc32048092ae2b1fd47577120c /nova/api
parent06c50e0b42bc945d91f5695f3806d958a3e6add9 (diff)
parent1dc6c806b32044420bf17d3076dd712185b7ac07 (diff)
downloadnova-fa49ec0027e864bbe994818ddb0314e0412e3e58.tar.gz
nova-fa49ec0027e864bbe994818ddb0314e0412e3e58.tar.xz
nova-fa49ec0027e864bbe994818ddb0314e0412e3e58.zip
Merge "Fix handling of unimplemented host actions"
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/openstack/compute/contrib/hosts.py24
1 files changed, 14 insertions, 10 deletions
diff --git a/nova/api/openstack/compute/contrib/hosts.py b/nova/api/openstack/compute/contrib/hosts.py
index 0d2b68f11..7da596a78 100644
--- a/nova/api/openstack/compute/contrib/hosts.py
+++ b/nova/api/openstack/compute/contrib/hosts.py
@@ -176,9 +176,11 @@ class HostController(object):
context = req.environ['nova.context']
LOG.audit(_("Putting host %(host)s in maintenance "
"mode %(mode)s.") % locals())
- result = self.api.set_host_maintenance(context, host, mode)
- if result not in ("on_maintenance", "off_maintenance"):
- raise webob.exc.HTTPBadRequest(explanation=result)
+ try:
+ result = self.api.set_host_maintenance(context, host, mode)
+ except NotImplementedError:
+ msg = _("Virt driver does not implement host maintenance mode.")
+ raise webob.exc.HTTPNotImplemented(explanation=msg)
return {"host": host, "maintenance_mode": result}
def _set_enabled_status(self, req, host, enabled):
@@ -186,11 +188,12 @@ class HostController(object):
context = req.environ['nova.context']
state = "enabled" if enabled else "disabled"
LOG.audit(_("Setting host %(host)s to %(state)s.") % locals())
- result = self.api.set_host_enabled(context, host=host,
- enabled=enabled)
- if result not in ("enabled", "disabled"):
- # An error message was returned
- raise webob.exc.HTTPBadRequest(explanation=result)
+ try:
+ result = self.api.set_host_enabled(context, host=host,
+ enabled=enabled)
+ except NotImplementedError:
+ msg = _("Virt driver does not implement host disabled status.")
+ raise webob.exc.HTTPNotImplemented(explanation=msg)
return {"host": host, "status": result}
def _host_power_action(self, req, host, action):
@@ -200,8 +203,9 @@ class HostController(object):
try:
result = self.api.host_power_action(context, host=host,
action=action)
- except NotImplementedError as e:
- raise webob.exc.HTTPBadRequest(explanation=e.msg)
+ except NotImplementedError:
+ msg = _("Virt driver does not implement host power management.")
+ raise webob.exc.HTTPNotImplemented(explanation=msg)
return {"host": host, "power_action": result}
@wsgi.serializers(xml=HostActionTemplate)