summaryrefslogtreecommitdiffstats
path: root/plugins/xenserver
diff options
context:
space:
mode:
authorEd Leafe <ed@leafe.com>2011-08-01 21:06:47 +0000
committerEd Leafe <ed@leafe.com>2011-08-01 21:06:47 +0000
commit85795ff1f8b6a0ff3de634828208d6debd91692f (patch)
treefb25bb919bfefafca361f1a01f336e3cd935785c /plugins/xenserver
parentbdcfaa5b927a096f507fb0f7e2d81989173957f8 (diff)
downloadnova-85795ff1f8b6a0ff3de634828208d6debd91692f.tar.gz
nova-85795ff1f8b6a0ff3de634828208d6debd91692f.tar.xz
nova-85795ff1f8b6a0ff3de634828208d6debd91692f.zip
Added option for rebooting or shutting down a host.
Diffstat (limited to 'plugins/xenserver')
-rwxr-xr-xplugins/xenserver/xenapi/etc/xapi.d/plugins/xenhost25
1 files changed, 24 insertions, 1 deletions
diff --git a/plugins/xenserver/xenapi/etc/xapi.d/plugins/xenhost b/plugins/xenserver/xenapi/etc/xapi.d/plugins/xenhost
index 292bbce12..5a5122b4a 100755
--- a/plugins/xenserver/xenapi/etc/xapi.d/plugins/xenhost
+++ b/plugins/xenserver/xenapi/etc/xapi.d/plugins/xenhost
@@ -103,6 +103,27 @@ def set_host_enabled(self, arg_dict):
return {"status": status}
+def _powerstate(state):
+ host_uuid = _get_host_uuid()
+ cmd = "xe host-disable uuid=%(host_uuid)s" % locals()
+ _run_command(cmd)
+ cmd = "xe host-%(state)s uuid=%(host_uuid)s" % locals()
+ _run_command(cmd)
+ return {"powerstate": state}
+
+
+@jsonify
+def host_reboot(self, arg_dict):
+ """Reboots the host."""
+ return _powerstate("reboot")
+
+
+@jsonify
+def host_shutdown(self, arg_dict):
+ """Reboots the host."""
+ return _powerstate("shutdown")
+
+
@jsonify
def host_data(self, arg_dict):
"""Runs the commands on the xenstore host to return the current status
@@ -217,4 +238,6 @@ def cleanup(dct):
if __name__ == "__main__":
XenAPIPlugin.dispatch(
{"host_data": host_data,
- "set_host_enabled": set_host_enabled})
+ "set_host_enabled": set_host_enabled,
+ "host_shutdown": host_shutdown,
+ "host_reboot": host_reboot})