feat: add Pimox out-of-band helpers
This commit is contained in:
parent
2629a26068
commit
c25a8a84e0
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
4
jeannie
4
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
|
||||
;;
|
||||
|
|
|
|||
|
|
@ -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}"
|
||||
|
|
|
|||
|
|
@ -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
|
||||
Loading…
Reference in New Issue