From c6e163a767f868b02fc4d1a3adbdef8fa2108989 Mon Sep 17 00:00:00 2001 From: admin Date: Mon, 3 Aug 2026 15:38:42 +0000 Subject: [PATCH] feat: individual node deploy options in menu --- sources/python/main.py | 49 +++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/sources/python/main.py b/sources/python/main.py index c116f52..2aabb63 100644 --- a/sources/python/main.py +++ b/sources/python/main.py @@ -139,37 +139,42 @@ def main(): while True: undeployed = [k for k in cfg if k not in deployed] - opts = [] - if undeployed: opts.append(("Deploy pending", '1')) - opts.append(("Add a new node", '2')) - if deployed: opts.append(("Show status", '3')) - if deployed: opts.append(("Remove a node", '4')) - opts.append(("Remote tunnel", '5')) - opts.append(("Quit", 'q')) - print("\n─── Menu ───") - if undeployed: print(f" Pending: {', '.join(undeployed)}") - for label, key in opts: - print(f" [{key}] {label}") + print(" [1] Add a new node") + + # List undeployed nodes as individual options + n = 2 + node_map = {} + for name in undeployed: + print(f" [{n}] Deploy {name} (port {cfg[name].get('port','?')})") + node_map[str(n)] = name + n += 1 + + if deployed: + print(f" [{n}] Show status"); n += 1 + print(f" [{n}] Remove a node"); n += 1 + print(f" [{n}] Remote tunnel"); n += 1 + print(" [q] Quit") c = input("\nChoice: ").strip() - if c == "1" and undeployed: - for name in undeployed: - nc = cfg[name] - deploy_container(name, nc["token"], nc.get("cloud","EU"), - str(nc.get("port","8081")), nc.get("upstream_ip",""), - str(nc.get("upstream_port","80")), "", - nc.get("mode","monitoring")) - elif c == "2": + if c == "1": add_node() cfg = load_config() deployed = {n["name"] for n in load_state().get("nodes", [])} - elif c == "3" and deployed: + elif c in node_map: + name = node_map[c] + nc = cfg[name] + deploy_container(name, nc["token"], nc.get("cloud","EU"), + str(nc.get("port","8081")), nc.get("upstream_ip",""), + str(nc.get("upstream_port","80")), "", + nc.get("mode","monitoring")) + deployed.add(name) + elif c == str(n-3) and deployed: container_status() - elif c == "4" and deployed: + elif c == str(n-2) and deployed: remove_menu() - elif c == "5": + elif c == str(n-1): start_tunnel() elif c.lower() == "q": break