Valid commands are as follows:
- shutdown, reboot, poweron: Power management
+ - screen: Open TTY in GNU Screen
"""
def die_with_usage(message):
print("Setting server " + server + " to power state " + str(state))
COMMANDS = {
- "shutdown": functools.partial(set_server_power, 0),
- "poweron": functools.partial(set_server_power, 1),
- "reboot": lambda s: (set_server_power(0, s), set_server_power(1, s))
+ # Power managemment
+
+ "shutdown": (False, functools.partial(set_server_power, 0)),
+ "poweron": (False, functools.partial(set_server_power, 1)),
+ "reboot": (False, lambda s: (set_server_power(0, s), set_server_power(1, s))),
+
+ # TTY access (or keyboard if wired as such)
+
+ "screen": (True, lambda s: print("Screening on " + s))
}
def issue_command(server_name, command):
print(server_name, command)
try:
- COMMANDS[command](server_name)
+ (visible_shell, callback) = COMMANDS[command]
except KeyError:
die_with_usage("Invalid command supplied")
+ print("Shell visible? " + str(visible_shell))
+ callback(server_name)
+
issue_command(sys.argv[1], sys.argv[2])