feat: individual node deploy options in menu
This commit is contained in:
parent
95e66f21c8
commit
c6e163a767
1 changed files with 27 additions and 22 deletions
|
|
@ -139,37 +139,42 @@ def main():
|
||||||
while True:
|
while True:
|
||||||
undeployed = [k for k in cfg if k not in deployed]
|
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 ───")
|
print("\n─── Menu ───")
|
||||||
if undeployed: print(f" Pending: {', '.join(undeployed)}")
|
print(" [1] Add a new node")
|
||||||
for label, key in opts:
|
|
||||||
print(f" [{key}] {label}")
|
# 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()
|
c = input("\nChoice: ").strip()
|
||||||
|
|
||||||
if c == "1" and undeployed:
|
if c == "1":
|
||||||
for name in undeployed:
|
add_node()
|
||||||
|
cfg = load_config()
|
||||||
|
deployed = {n["name"] for n in load_state().get("nodes", [])}
|
||||||
|
elif c in node_map:
|
||||||
|
name = node_map[c]
|
||||||
nc = cfg[name]
|
nc = cfg[name]
|
||||||
deploy_container(name, nc["token"], nc.get("cloud","EU"),
|
deploy_container(name, nc["token"], nc.get("cloud","EU"),
|
||||||
str(nc.get("port","8081")), nc.get("upstream_ip",""),
|
str(nc.get("port","8081")), nc.get("upstream_ip",""),
|
||||||
str(nc.get("upstream_port","80")), "",
|
str(nc.get("upstream_port","80")), "",
|
||||||
nc.get("mode","monitoring"))
|
nc.get("mode","monitoring"))
|
||||||
elif c == "2":
|
deployed.add(name)
|
||||||
add_node()
|
elif c == str(n-3) and deployed:
|
||||||
cfg = load_config()
|
|
||||||
deployed = {n["name"] for n in load_state().get("nodes", [])}
|
|
||||||
elif c == "3" and deployed:
|
|
||||||
container_status()
|
container_status()
|
||||||
elif c == "4" and deployed:
|
elif c == str(n-2) and deployed:
|
||||||
remove_menu()
|
remove_menu()
|
||||||
elif c == "5":
|
elif c == str(n-1):
|
||||||
start_tunnel()
|
start_tunnel()
|
||||||
elif c.lower() == "q":
|
elif c.lower() == "q":
|
||||||
break
|
break
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue