feat: shutdown_host and begin_stop_vm through the API #34

Merged
christianmanivong merged 1 commits from feat/shutdown-requests into main 2026-10-27 07:41:24 +00:00
Owner

Summary

shutdown_host() and begin_stop_vm(name) for netOrk's graph workflows, which shut pve-dual down when CI has nothing for build-01 (NetOrk/netork#1636, epic NetOrk/netork#1633). They implement the contracts of NAPALM/napalm-device-types#55.

Changes

  • shutdown_host(): POST /nodes/{node}/status with command=shutdown, next to reboot_host(). A refusal is a RuntimeError.
  • begin_stop_vm(name): POST …/status/shutdown for a VM or container, found by vmid or name. It returns once Proxmox took the request and does not wait for the task. stop_vm waits at most 120 s, and a guest with down=300 can take longer. An unknown guest is a ValueError, a refusal a RuntimeError.
  • The driver does not import the new mixins yet, because napalm_device_types>=4.22.0 does not have them; netOrk asks with hasattr. Mixing them in can come with the next device-types release.
  • CHANGELOG (Unreleased).

Testing

  • tests/test_shutdown_requests.py (7): the request sent, no task waited for, VM and container, by name and by vmid, unknown guest, refusal.
  • Full suite: 350 passed (with device-types from #55 on the path). ruff, format and mypy are clean.
## Summary `shutdown_host()` and `begin_stop_vm(name)` for netOrk's graph workflows, which shut pve-dual down when CI has nothing for build-01 (NetOrk/netork#1636, epic NetOrk/netork#1633). They implement the contracts of NAPALM/napalm-device-types#55. ## Changes - `shutdown_host()`: `POST /nodes/{node}/status` with `command=shutdown`, next to `reboot_host()`. A refusal is a `RuntimeError`. - `begin_stop_vm(name)`: `POST …/status/shutdown` for a VM or container, found by vmid or name. It returns once Proxmox took the request and does not wait for the task. `stop_vm` waits at most 120 s, and a guest with `down=300` can take longer. An unknown guest is a `ValueError`, a refusal a `RuntimeError`. - The driver does not import the new mixins yet, because `napalm_device_types>=4.22.0` does not have them; netOrk asks with `hasattr`. Mixing them in can come with the next device-types release. - CHANGELOG (Unreleased). ## Testing - `tests/test_shutdown_requests.py` (7): the request sent, no task waited for, VM and container, by name and by vmid, unknown guest, refusal. - Full suite: 350 passed (with device-types from #55 on the path). ruff, format and mypy are clean.
christianmanivong added 1 commit 2026-10-27 00:07:26 +00:00
feat: shutdown_host and begin_stop_vm through the API
driver / standard (pull_request) Successful in 14s
driver / lint (pull_request) Successful in 11s
driver / types (pull_request) Successful in 1m2s
driver / test (3.10) (pull_request) Successful in 1m9s
driver / test (3.11) (pull_request) Successful in 1m8s
driver / lowest (pull_request) Successful in 34s
driver / test (3.12) (pull_request) Successful in 1m3s
driver / test (3.13) (pull_request) Successful in 1m0s
driver / build (pull_request) Successful in 26s
driver / security (pull_request) Successful in 1m1s
CI / driver (pull_request) Successful in 3m17s
driver / publish (pull_request) Skipped
16f1b87392
shutdown_host() posts command=shutdown to the node itself; its guests
stop as on any shutdown. begin_stop_vm(name) asks a guest for its clean
shutdown and returns once Proxmox took it, without waiting for the
task: the caller reads get_vm_status until it stopped. Both raise
RuntimeError when Proxmox refuses; an unknown guest is a ValueError.

The contracts HostShutdownMixin and VmStopRequestMixin of
napalm-device-types (NAPALM/napalm-device-types#55); for netOrk's graph
workflows (NetOrk/netork#1636).
christianmanivong merged commit 8205829437 into main 2026-10-27 07:41:24 +00:00
christianmanivong deleted branch feat/shutdown-requests 2026-10-27 07:41:24 +00:00
Sign in to join this conversation.