summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorEd Leafe <ed@leafe.com>2011-08-08 14:07:03 +0000
committerEd Leafe <ed@leafe.com>2011-08-08 14:07:03 +0000
commit10ab2e76b1ea8bbbb6bff4ccaf506bfdd5b57388 (patch)
treec61d801ff6e5754e0994fadd8d4db0f3661f4c53 /plugins
parentf1f86d229cff084a3f6257565a991c7ffe010907 (diff)
parentdcac4bc6c7be9832704e37cca7ce815e083974f5 (diff)
downloadnova-10ab2e76b1ea8bbbb6bff4ccaf506bfdd5b57388.tar.gz
nova-10ab2e76b1ea8bbbb6bff4ccaf506bfdd5b57388.tar.xz
nova-10ab2e76b1ea8bbbb6bff4ccaf506bfdd5b57388.zip
Updated with code changes on LP
Diffstat (limited to 'plugins')
-rwxr-xr-xplugins/xenserver/xenapi/etc/xapi.d/plugins/xenhost39
1 files changed, 6 insertions, 33 deletions
diff --git a/plugins/xenserver/xenapi/etc/xapi.d/plugins/xenhost b/plugins/xenserver/xenapi/etc/xapi.d/plugins/xenhost
index 5169aeb12..f6a9ac8d8 100755
--- a/plugins/xenserver/xenapi/etc/xapi.d/plugins/xenhost
+++ b/plugins/xenserver/xenapi/etc/xapi.d/plugins/xenhost
@@ -103,7 +103,7 @@ def set_host_enabled(self, arg_dict):
return {"status": status}
-def _powerstate(state):
+def _power_action(action):
host_uuid = _get_host_uuid()
# Host must be disabled first
result = _run_command("xe host-disable")
@@ -115,23 +115,23 @@ def _powerstate(state):
raise pluginlib.PluginError(result)
cmds = {"reboot": "xe host-reboot", "startup": "xe host-power-on",
"shutdown": "xe host-shutdown"}
- result = _run_command(cmds[state])
+ result = _run_command(cmds[action])
# Should be empty string
if result:
raise pluginlib.PluginError(result)
- return {"powerstate": state}
+ return {"power_action": action}
@jsonify
def host_reboot(self, arg_dict):
"""Reboots the host."""
- return _powerstate("reboot")
+ return _power_action("reboot")
@jsonify
def host_shutdown(self, arg_dict):
"""Reboots the host."""
- return _powerstate("shutdown")
+ return _power_action("shutdown")
@jsonify
@@ -139,34 +139,7 @@ def host_start(self, arg_dict):
"""Starts the host. NOTE: Currently not feasible, since the host
runs on the same machine as Xen.
"""
- return _powerstate("startup")
-
-
-@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}
+ return _power_action("startup")
@jsonify