From e14d7650416cba933041b94884ad6c1e27ae45e3 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Mon, 25 Jun 2018 13:44:41 -0400 Subject: [PATCH] GNU Screen integration stub --- libremanage.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/libremanage.py b/libremanage.py index 6ebf835..4f7b74b 100644 --- a/libremanage.py +++ b/libremanage.py @@ -34,6 +34,7 @@ Server names are defined in the accompanying config.py. Valid commands are as follows: - shutdown, reboot, poweron: Power management + - screen: Open TTY in GNU Screen """ def die_with_usage(message): @@ -52,9 +53,15 @@ def set_server_power(state, server): 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): @@ -62,8 +69,11 @@ 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]) -- 2.25.1