feat: shutdown_host and begin_stop_vm, shutting down without waiting #55

Open
christianmanivong wants to merge 1 commits from feat/shutdown-requests into main
pull from: feat/shutdown-requests
Owner

Summary

Two declared contracts for netOrk's graph workflows, which switch a hypervisor off when CI has nothing for it (NetOrk/netork#1636, epic NetOrk/netork#1633).

Changes

  • HostShutdownMixin.shutdown_host() (host_shutdown.py), mixed into DeviceTypeDriver like HostRebootMixin. The device shuts itself down cleanly through its own means. It is declared under TYPE_CHECKING, so hasattr tells a caller whether a driver can. There is no forced variant: cutting the power is the BMC's business.
  • VmStopRequestMixin.begin_stop_vm(name) (vm_stop_request.py) asks for a VM's clean shutdown and returns at once. stop_vm blocks within a driver's own limit (120 s in napalm-proxmox), while a guest with down=300 may take longer. A caller with timer-based waits asks with this and reads get_vm_status. No role base carries it, so VMware owes nothing.
  • README and CHANGELOG (Unreleased).

Testing

  • tests/test_host_shutdown.py and tests/test_vm_stop_request.py: declared, not implemented; documented; on the right bases.
  • Full suite: 861 passed. Coverage 95 %, the new modules 100 %. ruff, format and mypy --strict are clean.
  • One change outside the new code: the type: ignore[misc] on DeviceTypeDriver moved to the NetworkDriver base, because the class header now spans lines.
## Summary Two declared contracts for netOrk's graph workflows, which switch a hypervisor off when CI has nothing for it (NetOrk/netork#1636, epic NetOrk/netork#1633). ## Changes - `HostShutdownMixin.shutdown_host()` (`host_shutdown.py`), mixed into `DeviceTypeDriver` like `HostRebootMixin`. The device shuts itself down cleanly through its own means. It is declared under `TYPE_CHECKING`, so `hasattr` tells a caller whether a driver can. There is no forced variant: cutting the power is the BMC's business. - `VmStopRequestMixin.begin_stop_vm(name)` (`vm_stop_request.py`) asks for a VM's clean shutdown and returns at once. `stop_vm` blocks within a driver's own limit (120 s in napalm-proxmox), while a guest with `down=300` may take longer. A caller with timer-based waits asks with this and reads `get_vm_status`. No role base carries it, so VMware owes nothing. - README and CHANGELOG (Unreleased). ## Testing - `tests/test_host_shutdown.py` and `tests/test_vm_stop_request.py`: declared, not implemented; documented; on the right bases. - Full suite: 861 passed. Coverage 95 %, the new modules 100 %. ruff, format and `mypy --strict` are clean. - One change outside the new code: the `type: ignore[misc]` on `DeviceTypeDriver` moved to the `NetworkDriver` base, because the class header now spans lines.
christianmanivong added 1 commit 2026-10-26 23:37:06 +00:00
feat: shutdown_host and begin_stop_vm, shutting down without waiting
driver / lint (pull_request) Successful in 18s
driver / standard (pull_request) Successful in 20s
driver / test (3.10) (pull_request) Failing after 6s
driver / types (pull_request) Successful in 1m4s
driver / test (3.12) (pull_request) Successful in 1m8s
driver / test (3.11) (pull_request) Successful in 1m13s
driver / test (3.13) (pull_request) Successful in 1m1s
driver / lowest (pull_request) Successful in 43s
driver / build (pull_request) Successful in 29s
driver / security (pull_request) Successful in 1m8s
CI / driver (pull_request) Failing after 2m41s
driver / publish (pull_request) Skipped
4d3574cd60
HostShutdownMixin.shutdown_host(), on DeviceTypeDriver: a device shuts
itself down cleanly through its own means; declared, so hasattr says
whether a driver can. There is no forced variant.

VmStopRequestMixin.begin_stop_vm(name): ask for a VM's clean shutdown
and return at once, for a caller that waits on a timer and reads
get_vm_status instead of blocking in stop_vm. No role demands it.

For netOrk's graph workflows, which switch a hypervisor off when CI has
nothing for it (NetOrk/netork#1636).
Some required checks failed
driver / lint (pull_request) Successful in 18s
driver / standard (pull_request) Successful in 20s
driver / test (3.10) (pull_request) Failing after 6s
driver / types (pull_request) Successful in 1m4s
driver / test (3.12) (pull_request) Successful in 1m8s
driver / test (3.11) (pull_request) Successful in 1m13s
driver / test (3.13) (pull_request) Successful in 1m1s
driver / lowest (pull_request) Successful in 43s
driver / build (pull_request) Successful in 29s
driver / security (pull_request) Successful in 1m8s
CI / driver (pull_request) Failing after 2m41s
driver / publish (pull_request) Skipped
You are not authorized to merge this pull request.
This pull request can be merged automatically.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin feat/shutdown-requests:feat/shutdown-requests
git checkout feat/shutdown-requests
Sign in to join this conversation.