diff --git a/bin/netvm-accounts.sh b/bin/netvm-accounts.sh new file mode 100755 index 0000000..9145eea --- /dev/null +++ b/bin/netvm-accounts.sh @@ -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() { # -> "up " 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 diff --git a/bin/netvm-fleet.sh b/bin/netvm-fleet.sh index ae4f9a1..8805cf5 100755 --- a/bin/netvm-fleet.sh +++ b/bin/netvm-fleet.sh @@ -38,7 +38,7 @@ run_on() { # ssh -o BatchMode=yes -o ConnectTimeout=15 "${OPERATOR_USER}@${ip}" "$@" } -cmd="${1:?usage: netvm-fleet.sh topology|up |down |ssh |exec -- |cdp }" +cmd="${1:?usage: netvm-fleet.sh topology|up |down |ssh |exec -- |cdp |accounts }" case "$cmd" in topology) for n in $(nodes); do @@ -65,5 +65,9 @@ case "$cmd" in node="${2:?usage: netvm-fleet.sh cdp }" run_on "$node" "\$HOME/Projects/NetVM/bin/netvm-cdp.sh ${node}" ;; + accounts) + node="${2:?usage: netvm-fleet.sh accounts }" + run_on "$node" "\$HOME/Projects/NetVM/bin/netvm-accounts.sh" + ;; *) echo "unknown command: $cmd"; exit 1 ;; esac