def open_ssh(config):
subprocess.run(["ssh", config["username"] + "@" + config["host"], "-p", str(config["port"])])
-open_ssh(CONFIG["managers"]["myboard"])
-print(CONFIG)
-
def die_with_usage(message):
print(message)
print(USAGE)
die_with_usage("Incorrect number of arguments")
def get_server_handle(name):
- # TODO: resolve based on config, SSH in, give self-contained handle?
- return name
+ server = CONFIG["servers"][name]
+ server["ssh"] = CONFIG["managers"][server["manager"]]
+ return server
def set_server_power(state, server):
print("Setting server " + server + " to power state " + str(state))
"tty": (True, lambda s: print("Screening on " + s)),
# SSH sanity test
- "console": (True, lambda s: open_ssh(CONFIG["managers"]["myboard"])),
+
+ "console": (True, lambda s: open_ssh(s["ssh"])),
}
def issue_command(server_name, command):
die_with_usage("Invalid command supplied")
print("Shell visible? " + str(visible_shell))
- callback(server_name)
+ callback(server)
issue_command(sys.argv[1], sys.argv[2])