summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorEd Leafe <ed@leafe.com>2011-07-07 15:24:12 +0000
committerEd Leafe <ed@leafe.com>2011-07-07 15:24:12 +0000
commit6b83e1cd31f5e138af20fbd5c118d55da092eb35 (patch)
treee58c899c777f117a9c1415720f87973610b45502 /plugins
parent9d29dc60d904f2c5037d03cead71933dc62777ff (diff)
downloadnova-6b83e1cd31f5e138af20fbd5c118d55da092eb35.tar.gz
nova-6b83e1cd31f5e138af20fbd5c118d55da092eb35.tar.xz
nova-6b83e1cd31f5e138af20fbd5c118d55da092eb35.zip
Added API and supporting code for rebooting or shutting down XenServer hosts.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/xenserver/xenapi/etc/xapi.d/plugins/xenhost30
1 files changed, 29 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..0cf7de0ce 100644
--- a/plugins/xenserver/xenapi/etc/xapi.d/plugins/xenhost
+++ b/plugins/xenserver/xenapi/etc/xapi.d/plugins/xenhost
@@ -104,6 +104,33 @@ def set_host_enabled(self, arg_dict):
@jsonify
+def set_power_state(self, arg_dict):
+ """Reboots or powers off this host. Ideally, we would also like to be
+ able to power *on* a host, but right now this is not technically
+ feasible.
+ """
+ power_state = arg_dict.get("power_state")
+ if power_state is None:
+ raise pluginlib.PluginError(
+ _("Missing 'power_state' argument to set_power_state"))
+ # Host must be disabled first
+# result = _run_command("xe host-disable")
+# if result:
+# raise pluginlib.PluginError(result)
+# # All running VMs must be shutdown
+# result = _run_command("xe vm-shutdown --multiple power-state=running")
+# if result:
+# raise pluginlib.PluginError(result)
+# cmds = {"reboot": "xe host-reboot", "on": "xe host-power-on",
+# "off": "xe host-shutdown"}
+# result = _run_command(cmds[power_state])
+# # Should be empty string
+# if result:
+# raise pluginlib.PluginError(result)
+ return {"power_state": power_state}
+
+
+@jsonify
def host_data(self, arg_dict):
"""Runs the commands on the xenstore host to return the current status
information.
@@ -217,4 +244,5 @@ def cleanup(dct):
if __name__ == "__main__":
XenAPIPlugin.dispatch(
{"host_data": host_data,
- "set_host_enabled": set_host_enabled})
+ "set_host_enabled": set_host_enabled,
+ "set_power_state": set_power_state})