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
|
n += 1
|
||||||
|
|
||||||
if deployed:
|
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(f" [{n}] Remote tunnel"); n += 1
|
||||||
print(" [q] Quit")
|
print(" [q] Quit")
|
||||||
|
|
||||||
|
|
@ -168,8 +170,12 @@ 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-2) and deployed:
|
elif c == str(n-4) and deployed:
|
||||||
manage_nodes()
|
edit_nodes()
|
||||||
|
elif c == str(n-3) and deployed:
|
||||||
|
remove_menu()
|
||||||
|
elif c == str(n-2):
|
||||||
|
container_status()
|
||||||
elif c == str(n-1):
|
elif c == str(n-1):
|
||||||
start_tunnel()
|
start_tunnel()
|
||||||
elif c.lower() == "q":
|
elif c.lower() == "q":
|
||||||
|
|
@ -274,22 +280,39 @@ def start_tunnel():
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Tunnel failed: {e}")
|
print(f"Tunnel failed: {e}")
|
||||||
|
|
||||||
def manage_nodes():
|
def edit_nodes():
|
||||||
s = load_state().get("nodes", [])
|
s = load_state().get("nodes", [])
|
||||||
if not s: print("No nodes."); return
|
if not s: print("No nodes."); return
|
||||||
while True:
|
print("\n─── Edit Node ───")
|
||||||
print("\n─── Manage Nodes ───")
|
|
||||||
for i, n in enumerate(s):
|
for i, n in enumerate(s):
|
||||||
r = run(f"docker inspect -f '{{{{.State.Status}}}}' wallarm-{n['name']} 2>/dev/null")
|
r = run(f"docker inspect -f '{{{{.State.Status}}}}' wallarm-{n['name']} 2>/dev/null")
|
||||||
st = "●" if r.stdout.strip() == "running" else "○"
|
st = "●" if r.stdout.strip() == "running" else "○"
|
||||||
print(f" [{i+1}] {st} {n['name']} (port {n.get('port','')})")
|
print(f" [{i+1}] {st} {n['name']} (port {n.get('port','')})")
|
||||||
print(" [r] Restart [d] Delete [b] Back")
|
print(" [b] Back")
|
||||||
c = input("\nAction: ").strip()
|
c = input("\nSelect node: ").strip()
|
||||||
if c.lower() == 'b': break
|
if c.lower() == 'b': return
|
||||||
if c == 'r':
|
if not c.isdigit(): return
|
||||||
name = input("Node name: ").strip()
|
idx = int(c) - 1
|
||||||
if name: run(f"docker restart wallarm-{name} 2>/dev/null"); print(f"Restarted {name}")
|
if idx < 0 or idx >= len(s): return
|
||||||
elif c == 'd':
|
n = s[idx]
|
||||||
name = input("Node name: ").strip()
|
print(f"\nEditing {n['name']}. Enter to keep current:")
|
||||||
if name: remove_container(name)
|
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", [])
|
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