diff options
| author | Ed Leafe <ed@leafe.com> | 2011-08-01 21:06:47 +0000 |
|---|---|---|
| committer | Ed Leafe <ed@leafe.com> | 2011-08-01 21:06:47 +0000 |
| commit | 85795ff1f8b6a0ff3de634828208d6debd91692f (patch) | |
| tree | fb25bb919bfefafca361f1a01f336e3cd935785c /nova/api | |
| parent | bdcfaa5b927a096f507fb0f7e2d81989173957f8 (diff) | |
Added option for rebooting or shutting down a host.
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/openstack/contrib/hosts.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/nova/api/openstack/contrib/hosts.py b/nova/api/openstack/contrib/hosts.py index 55e57e1a4..b6a4bdb77 100644 --- a/nova/api/openstack/contrib/hosts.py +++ b/nova/api/openstack/contrib/hosts.py @@ -78,6 +78,12 @@ class HostController(object): else: explanation = _("Invalid status: '%s'") % raw_val raise webob.exc.HTTPBadRequest(explanation=explanation) + elif key == "powerstate": + if val in ("reboot", "shutdown"): + return self._set_powerstate(req, id, val) + else: + explanation = _("Invalid powerstate: '%s'") % raw_val + raise webob.exc.HTTPBadRequest(explanation=explanation) else: explanation = _("Invalid update setting: '%s'") % raw_key raise webob.exc.HTTPBadRequest(explanation=explanation) @@ -91,6 +97,15 @@ class HostController(object): enabled=enabled) return {"host": host, "status": result} + def _set_powerstate(self, req, host, state): + """Reboots or shuts down the host.""" + context = req.environ['nova.context'] + LOG.audit(_("Changing powerstate of host %(host)s to %(state)s.") + % locals()) + result = self.compute_api.set_host_powerstate(context, host=host, + state=state) + return {"host": host, "powerstate": result} + class Hosts(extensions.ExtensionDescriptor): def get_name(self): |
