NetVM: netvm-accounts.sh operator view + fleet accounts

This commit is contained in:
Antigravity Agent
2026-10-03 01:24:11 -04:00
parent d82eb3984a
commit 835ed3cbe9
2 changed files with 35 additions and 1 deletions
+30
View File
@@ -0,0 +1,30 @@
#!/usr/bin/env bash
# netvm-accounts.sh — operator view: login registry joined with live node state.
# Secret-free: reads ACCOUNTS.md (structure) + live topology (state).
set -euo pipefail
NETVM_BIN="$(cd "$(dirname "$0")" && pwd)"
REPO="$(dirname "$NETVM_BIN")"
. "$NETVM_BIN/netvm-names.sh"
# registry rows: only the table under "## Registry", skip header/separator
registry() {
awk '/^## Registry/{f=1;next} f && /^\|/ && !/profile\/node/ && !/---/' "$REPO/ACCOUNTS.md"
}
live() { # <node> -> "up <egress>" or "down"
local out
out=$(sudo -n "$NETVM_BIN/netvm-topology.sh" 2>/dev/null | grep "^node=${1} " || true)
if [ -z "$out" ]; then echo "down"
else echo "up $(echo "$out" | grep -oP 'egress=\K[^ ]*')"; fi
}
registry | while IFS='|' read -r _ login _ profile purpose auth rest; do
login=$(echo "$login" | xargs); profile=$(echo "$profile" | xargs)
auth=$(echo "$auth" | xargs); purpose=$(echo "$purpose" | xargs)
[ -n "$profile" ] && [ "$profile" != "—" ] || continue
netvm_names "$profile"
st=$(live "$profile")
printf '%-8s login=%-8s auth=%-16s %-22s cdp=http://%s:%s\n' \
"$profile" "$login" "$auth" "($purpose)" "$PEER_IP" "$CDP_PORT"
printf '%-8s node state: %s\n' "" "$st"
done
+5 -1
View File
@@ -38,7 +38,7 @@ run_on() { # <node> <remote-command...>
ssh -o BatchMode=yes -o ConnectTimeout=15 "${OPERATOR_USER}@${ip}" "$@" ssh -o BatchMode=yes -o ConnectTimeout=15 "${OPERATOR_USER}@${ip}" "$@"
} }
cmd="${1:?usage: netvm-fleet.sh topology|up <node>|down <node>|ssh <node>|exec <node> -- <cmd>|cdp <node>}" cmd="${1:?usage: netvm-fleet.sh topology|up <node>|down <node>|ssh <node>|exec <node> -- <cmd>|cdp <node>|accounts <node>}"
case "$cmd" in case "$cmd" in
topology) topology)
for n in $(nodes); do for n in $(nodes); do
@@ -65,5 +65,9 @@ case "$cmd" in
node="${2:?usage: netvm-fleet.sh cdp <node>}" node="${2:?usage: netvm-fleet.sh cdp <node>}"
run_on "$node" "\$HOME/Projects/NetVM/bin/netvm-cdp.sh ${node}" run_on "$node" "\$HOME/Projects/NetVM/bin/netvm-cdp.sh ${node}"
;; ;;
accounts)
node="${2:?usage: netvm-fleet.sh accounts <node>}"
run_on "$node" "\$HOME/Projects/NetVM/bin/netvm-accounts.sh"
;;
*) echo "unknown command: $cmd"; exit 1 ;; *) echo "unknown command: $cmd"; exit 1 ;;
esac esac