summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorEd Leafe <ed@leafe.com>2011-07-06 16:53:08 +0000
committerEd Leafe <ed@leafe.com>2011-07-06 16:53:08 +0000
commit6435ba27edea7e525305d349cafea3d08f5db2c6 (patch)
treefa2dfd9d8717c535634a5a08550108c3c1b91b16 /nova/api
parentb02b1d78245634f81a27d0ba0a6e29024495c162 (diff)
downloadnova-6435ba27edea7e525305d349cafea3d08f5db2c6.tar.gz
nova-6435ba27edea7e525305d349cafea3d08f5db2c6.tar.xz
nova-6435ba27edea7e525305d349cafea3d08f5db2c6.zip
Changed the exception type for invalid requests to webob.exc.HTTPBadRequest.
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/openstack/contrib/hosts.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/nova/api/openstack/contrib/hosts.py b/nova/api/openstack/contrib/hosts.py
index 40a260c20..55e57e1a4 100644
--- a/nova/api/openstack/contrib/hosts.py
+++ b/nova/api/openstack/contrib/hosts.py
@@ -15,7 +15,7 @@
"""The hosts admin extension."""
-from webob import exc
+import webob.exc
from nova import compute
from nova import exception
@@ -72,13 +72,15 @@ class HostController(object):
# NOTE: (dabo) Right now only 'status' can be set, but other
# actions may follow.
if key == "status":
- if val in ("enable", "disable"):
+ if val[:6] in ("enable", "disabl"):
return self._set_enabled_status(req, id,
- enabled=(val == "enable"))
+ enabled=(val.startswith("enable")))
else:
- raise ValueError(_("Invalid status: '%s'") % raw_val)
+ explanation = _("Invalid status: '%s'") % raw_val
+ raise webob.exc.HTTPBadRequest(explanation=explanation)
else:
- raise ValueError(_("Invalid update setting: '%s'") % raw_key)
+ explanation = _("Invalid update setting: '%s'") % raw_key
+ raise webob.exc.HTTPBadRequest(explanation=explanation)
def _set_enabled_status(self, req, host, enabled):
"""Sets the specified host's ability to accept new instances."""