feat: manage nodes submenu with restart/delete

This commit is contained in:
admin 2026-08-03 15:40:20 +00:00
parent c6e163a767
commit b981b82c5d

View file

@ -142,7 +142,6 @@ def main():
print("\n─── Menu ───") print("\n─── Menu ───")
print(" [1] Add a new node") print(" [1] Add a new node")
# List undeployed nodes as individual options
n = 2 n = 2
node_map = {} node_map = {}
for name in undeployed: for name in undeployed:
@ -151,8 +150,7 @@ def main():
n += 1 n += 1
if deployed: if deployed:
print(f" [{n}] Show status"); n += 1 print(f" [{n}] Manage nodes"); n += 1
print(f" [{n}] Remove a node"); n += 1
print(f" [{n}] Remote tunnel"); n += 1 print(f" [{n}] Remote tunnel"); n += 1
print(" [q] Quit") print(" [q] Quit")
@ -170,10 +168,8 @@ def main():
str(nc.get("upstream_port","80")), "", str(nc.get("upstream_port","80")), "",
nc.get("mode","monitoring")) nc.get("mode","monitoring"))
deployed.add(name) deployed.add(name)
elif c == str(n-3) and deployed:
container_status()
elif c == str(n-2) and deployed: elif c == str(n-2) and deployed:
remove_menu() manage_nodes()
elif c == str(n-1): elif c == str(n-1):
start_tunnel() start_tunnel()
elif c.lower() == "q": elif c.lower() == "q":
@ -277,3 +273,23 @@ def start_tunnel():
print("Install paramiko: pip3 install paramiko") print("Install paramiko: pip3 install paramiko")
except Exception as e: except Exception as e:
print(f"Tunnel failed: {e}") print(f"Tunnel failed: {e}")
def manage_nodes():
s = load_state().get("nodes", [])
if not s: print("No nodes."); return
while True:
print("\n─── Manage Nodes ───")
for i, n in enumerate(s):
r = run(f"docker inspect -f '{{{{.State.Status}}}}' wallarm-{n['name']} 2>/dev/null")
st = "" if r.stdout.strip() == "running" else ""
print(f" [{i+1}] {st} {n['name']} (port {n.get('port','')})")
print(" [r] Restart [d] Delete [b] Back")
c = input("\nAction: ").strip()
if c.lower() == 'b': break
if c == 'r':
name = input("Node name: ").strip()
if name: run(f"docker restart wallarm-{name} 2>/dev/null"); print(f"Restarted {name}")
elif c == 'd':
name = input("Node name: ").strip()
if name: remove_container(name)
s = load_state().get("nodes", [])