From c25a8a84e0ec44fadb97a2b08c30f479b1d36815 Mon Sep 17 00:00:00 2001 From: "juvenal.diaz" Date: Thu, 22 Oct 2026 20:22:24 -0600 Subject: [PATCH] feat: add Pimox out-of-band helpers --- cmd/jeannie-server/main.go | 1 + cmd/jeannie-server/main_test.go | 6 ++++ jeannie | 4 +++ lib/jeannie/commands.sh | 5 ++++ scripts/pimox-oob | 53 +++++++++++++++++++++++++++++++++ 5 files changed, 69 insertions(+) create mode 100755 scripts/pimox-oob diff --git a/cmd/jeannie-server/main.go b/cmd/jeannie-server/main.go index c50d8eb..80d0b5c 100644 --- a/cmd/jeannie-server/main.go +++ b/cmd/jeannie-server/main.go @@ -62,6 +62,7 @@ var allowedCommands = map[string]bool{ "preflight": true, "doctor-preapply": true, "inventory-check": true, "state-backup": true, "fix-debian-docker-root": true, "state": true, + "pimox": true, "secrets-init": true, "secrets-check": true, "tailnet-policy-check": true, "secrets": true, "ai-index": true, "ai-check": true, "ask": true, "ai-evals": true, diff --git a/cmd/jeannie-server/main_test.go b/cmd/jeannie-server/main_test.go index abd7cbd..9b33a85 100644 --- a/cmd/jeannie-server/main_test.go +++ b/cmd/jeannie-server/main_test.go @@ -135,3 +135,9 @@ func TestSecretsCommandIsRemotelyEnabled(t *testing.T) { t.Fatal("secrets must be exposed through the remote API") } } + +func TestPimoxCommandIsRemotelyEnabled(t *testing.T) { + if !allowedCommands["pimox"] { + t.Fatal("pimox must be exposed through the remote API") + } +} diff --git a/jeannie b/jeannie index 7a42ad3..7d1d6a5 100755 --- a/jeannie +++ b/jeannie @@ -141,6 +141,7 @@ Recovery And State drill-pihole-restore Run the Pi-hole restore drill. state-backup Back up local OpenTofu state files. state status [STACK] [--json] Inspect OpenTofu locks and drift without changing state. + pimox {status [VMID]|console VMID} Inspect Pimox VMs or open a serial emergency console. Focused Doctors doctor-edge [--all|--details|--verbose|--json] @@ -516,6 +517,9 @@ case "${1:-}" in fi state_status "${@:3}" ;; + pimox) + pimox_oob "${@:2}" + ;; fix-debian-docker-root) fix_debian_docker_root ;; diff --git a/lib/jeannie/commands.sh b/lib/jeannie/commands.sh index 5f23d64..3f0bb27 100644 --- a/lib/jeannie/commands.sh +++ b/lib/jeannie/commands.sh @@ -3281,6 +3281,11 @@ state_status() { "${REPO_ROOT}/scripts/state-status" "$@" } +pimox_oob() { + require_debian_server "pimox" + "${REPO_ROOT}/scripts/pimox-oob" "$@" +} + storage_status() { require_debian_server "storage" local kubeconfig="${KUBECONFIG_PATH}" diff --git a/scripts/pimox-oob b/scripts/pimox-oob new file mode 100755 index 0000000..747579b --- /dev/null +++ b/scripts/pimox-oob @@ -0,0 +1,53 @@ +#!/usr/bin/env bash +set -euo pipefail + +PIMOX_HOST="${LAB_PIMOX_HOST:-${LAB_CLUSTER_PIMOX_HOST:-192.168.100.80}}" +PIMOX_USER="${LAB_PIMOX_USER:-${LAB_CLUSTER_PIMOX_USER:-jv}}" +PIMOX_KEY="${LAB_PIMOX_SSH_KEY_PATH:-${LAB_CLUSTER_PIMOX_SSH_KEY_PATH:-${HOME}/.ssh/id_ed25519}}" + +usage() { + echo "Usage: ./jeannie pimox {status [VMID]|console VMID}" >&2 + exit 2 +} + +valid_vmid() { + [[ "${1:-}" =~ ^[0-9]+$ ]] && ((10#$1 > 0)) +} + +pimox_ssh() { + ssh -i "${PIMOX_KEY}" -o BatchMode=yes -o ConnectTimeout=10 \ + -o StrictHostKeyChecking=accept-new "${PIMOX_USER}@${PIMOX_HOST}" "$@" +} + +status_vm() { + local vmid="$1" + if ! valid_vmid "${vmid}"; then + echo "VMID must be numeric: ${vmid}" >&2 + return 2 + fi + pimox_ssh "sudo qm status ${vmid}; echo '--- config ---'; sudo qm config ${vmid} | grep -E '^(name|cores|sockets|memory|cpu|agent|serial[0-9]*):' || true; echo '--- guest agent ---'; sudo qm agent ${vmid} ping 2>&1 || true" +} + +case "${1:-}" in + status) + if [[ -n "${2:-}" ]]; then + status_vm "$2" + else + echo "Pimox host: ${PIMOX_USER}@${PIMOX_HOST}" + pimox_ssh "sudo qm list" + fi + ;; + console) + if [[ "${JEANNIE_REMOTE_SERVER:-false}" == true ]]; then + echo "Interactive Pimox console cannot run through the remote API; SSH to Debian and run ./jeannie pimox console VMID." >&2 + exit 2 + fi + valid_vmid "${2:-}" || usage + exec ssh -tt -i "${PIMOX_KEY}" -o ConnectTimeout=10 \ + -o StrictHostKeyChecking=accept-new "${PIMOX_USER}@${PIMOX_HOST}" \ + "sudo qm terminal $2" + ;; + *) + usage + ;; +esac