GNU Screen integration stub
authorAlyssa Rosenzweig <alyssa@rosenzweig.io>
Mon, 25 Jun 2018 17:44:41 +0000 (13:44 -0400)
committerAlyssa Rosenzweig <alyssa@rosenzweig.io>
Mon, 25 Jun 2018 17:44:41 +0000 (13:44 -0400)
libremanage.py

index 6ebf835282569f8c0d5eb3f251a393d8c3dad628..4f7b74bd893a629011147512910135982ce89e3d 100644 (file)
@@ -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])