feat: edit nodes, delete, status as separate menu items
This commit is contained in:
parent
b981b82c5d
commit
1d4b6c9673
1 changed files with 43 additions and 20 deletions
|
|
@ -150,7 +150,9 @@ def main():
|
|||
n += 1
|
||||
|
||||
if deployed:
|
||||
print(f" [{n}] Manage nodes"); n += 1
|
||||
print(f" [{n}] Edit nodes"); n += 1
|
||||
print(f" [{n}] Delete a node"); n += 1
|
||||
print(f" [{n}] Status"); n += 1
|
||||
print(f" [{n}] Remote tunnel"); n += 1
|
||||
print(" [q] Quit")
|
||||
|
||||
|
|
@ -168,8 +170,12 @@ def main():
|
|||
str(nc.get("upstream_port","80")), "",
|
||||
nc.get("mode","monitoring"))
|
||||
deployed.add(name)
|
||||
elif c == str(n-2) and deployed:
|
||||
manage_nodes()
|
||||
elif c == str(n-4) and deployed:
|
||||
edit_nodes()
|
||||
elif c == str(n-3) and deployed:
|
||||
remove_menu()
|
||||
elif c == str(n-2):
|
||||
container_status()
|
||||
elif c == str(n-1):
|
||||
start_tunnel()
|
||||
elif c.lower() == "q":
|
||||
|
|
@ -274,22 +280,39 @@ def start_tunnel():
|
|||
except Exception as e:
|
||||
print(f"Tunnel failed: {e}")
|
||||
|
||||
def manage_nodes():
|
||||
def edit_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", [])
|
||||
print("\n─── Edit Node ───")
|
||||
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(" [b] Back")
|
||||
c = input("\nSelect node: ").strip()
|
||||
if c.lower() == 'b': return
|
||||
if not c.isdigit(): return
|
||||
idx = int(c) - 1
|
||||
if idx < 0 or idx >= len(s): return
|
||||
n = s[idx]
|
||||
print(f"\nEditing {n['name']}. Enter to keep current:")
|
||||
port = input(f"Port [{n.get('port','')}]: ").strip()
|
||||
upstream = input(f"Upstream [{n.get('upstream_ip','')}:{n.get('upstream_port','')}]: ").strip()
|
||||
if port: n['port'] = int(port)
|
||||
if ':' in upstream:
|
||||
ip, p = upstream.split(':')
|
||||
n['upstream_ip'] = ip; n['upstream_port'] = int(p)
|
||||
save_state({"nodes": s})
|
||||
print(f"✅ Updated. Restart to apply.")
|
||||
|
||||
def remove_menu():
|
||||
s = load_state().get("nodes", [])
|
||||
if not s: print("No nodes."); return
|
||||
print("\n─── Delete Node ───")
|
||||
for i, n in enumerate(s):
|
||||
print(f" [{i+1}] {n['name']} (port {n.get('port','')})")
|
||||
c = input("\nSelect: ").strip()
|
||||
if not c.isdigit(): return
|
||||
idx = int(c) - 1
|
||||
if 0 <= idx < len(s):
|
||||
remove_container(s[idx]["name"])
|
||||
|
|
|
|||
Loading…
Reference in a new issue