summaryrefslogtreecommitdiffstats
path: root/plugins/xenserver
diff options
context:
space:
mode:
authorEd Leafe <ed@leafe.com>2011-08-02 02:19:31 +0000
committerEd Leafe <ed@leafe.com>2011-08-02 02:19:31 +0000
commit07d89c29389fe8f2b9f3a398ab99566d151e8e92 (patch)
tree92ae33e26522a4d20be287575f196cd18ca98068 /plugins/xenserver
parent85795ff1f8b6a0ff3de634828208d6debd91692f (diff)
downloadnova-07d89c29389fe8f2b9f3a398ab99566d151e8e92.tar.gz
nova-07d89c29389fe8f2b9f3a398ab99566d151e8e92.tar.xz
nova-07d89c29389fe8f2b9f3a398ab99566d151e8e92.zip
Added host shutdown/reboot conditioning.
Diffstat (limited to 'plugins/xenserver')
-rwxr-xr-xplugins/xenserver/xenapi/etc/xapi.d/plugins/xenhost27
1 files changed, 22 insertions, 5 deletions
diff --git a/plugins/xenserver/xenapi/etc/xapi.d/plugins/xenhost b/plugins/xenserver/xenapi/etc/xapi.d/plugins/xenhost
index 5a5122b4a..873b4c58d 100755
--- a/plugins/xenserver/xenapi/etc/xapi.d/plugins/xenhost
+++ b/plugins/xenserver/xenapi/etc/xapi.d/plugins/xenhost
@@ -105,10 +105,20 @@ def set_host_enabled(self, arg_dict):
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)
+ # 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", "startup": "xe host-power-on",
+ "shutdown": "xe host-shutdown"}
+ result = _run_command(cmds[state])
+ # Should be empty string
+ if result:
+ raise pluginlib.PluginError(result)
return {"powerstate": state}
@@ -125,6 +135,12 @@ def host_shutdown(self, arg_dict):
@jsonify
+def host_start(self, arg_dict):
+ """Starts the host."""
+ return _powerstate("startup")
+
+
+@jsonify
def host_data(self, arg_dict):
"""Runs the commands on the xenstore host to return the current status
information.
@@ -240,4 +256,5 @@ if __name__ == "__main__":
{"host_data": host_data,
"set_host_enabled": set_host_enabled,
"host_shutdown": host_shutdown,
- "host_reboot": host_reboot})
+ "host_reboot": host_reboot,
+ "host_start": host_start})