feat(power): reboot_host and shutdown_host on FreeBSD and OpenBSD (NetOrk/netork#2841) #36

Merged
christianmanivong merged 1 commits from feature/host-shutdown-2841 into main 2026-11-29 21:58:22 +00:00
Owner

The BSD drivers could not restart at all. reboot_host() and shutdown_host() on BsdDriver: /sbin/shutdown -r now / /sbin/shutdown -p now (the same on both BSDs; -p powers off after rc's clean shutdown), detached like the linux driver, through run_command(..., privileged=True). A non-zero exit raises RuntimeError with the host's answer.

No version bump: this repo collects features under [Unreleased]; the entry is there. Tests: TestHostPower (14 cases) in tests/test_drivers.py, including the real sudo line through sh -n; full suite 219 passed.

Part of NetOrk/netork#2841: the device header gets Restart and Shut down for hardware devices. netOrk offers each button where the driver has the method (callable(getattr(driver, "reboot_host" / "shutdown_host", None))), so defining it is what switches the button on. The contracts are HostRebootMixin / HostShutdownMixin in napalm-device-types, already mixed in through DeviceTypeDriver; the minimum napalm-device-types version needs no change.

netOrk's feature/host-shutdown-2841 pins this branch's commit for now; once this is merged, the pin moves to the merge commit.

The BSD drivers could not restart at all. `reboot_host()` and `shutdown_host()` on `BsdDriver`: `/sbin/shutdown -r now` / `/sbin/shutdown -p now` (the same on both BSDs; `-p` powers off after rc's clean shutdown), detached like the linux driver, through `run_command(..., privileged=True)`. A non-zero exit raises `RuntimeError` with the host's answer. No version bump: this repo collects features under [Unreleased]; the entry is there. Tests: `TestHostPower` (14 cases) in `tests/test_drivers.py`, including the real sudo line through `sh -n`; full suite 219 passed. Part of NetOrk/netork#2841: the device header gets Restart and Shut down for hardware devices. netOrk offers each button where the driver has the method (`callable(getattr(driver, "reboot_host" / "shutdown_host", None))`), so defining it is what switches the button on. The contracts are `HostRebootMixin` / `HostShutdownMixin` in napalm-device-types, already mixed in through `DeviceTypeDriver`; the minimum napalm-device-types version needs no change. netOrk's `feature/host-shutdown-2841` pins this branch's commit for now; once this is merged, the pin moves to the merge commit.
christianmanivong added 1 commit 2026-11-29 21:53:24 +00:00
feat(power): reboot_host and shutdown_host on FreeBSD and OpenBSD (NetOrk/netork#2841)
driver / lint (pull_request) Successful in 12s
driver / standard (pull_request) Successful in 14s
driver / lowest (pull_request) Successful in 28s
driver / test (3.12) (pull_request) Successful in 54s
driver / types (pull_request) Successful in 57s
driver / test (3.13) (pull_request) Successful in 54s
driver / build (pull_request) Successful in 25s
driver / security (pull_request) Successful in 54s
CI / driver (pull_request) Successful in 1m59s
driver / publish (pull_request) Skipped
4532c0ea1c
The host's restart and its clean shutdown, through napalm-device-types'
HostRebootMixin and HostShutdownMixin: shutdown -r now and shutdown -p now
as root, through the driver's sudo, detached and two seconds late, so the
exit status comes back before the session drops and closing the session
cannot take the command with it. A refusal raises RuntimeError with what
the host said.
christianmanivong merged commit bc93153ea0 into main 2026-11-29 21:58:22 +00:00
christianmanivong deleted branch feature/host-shutdown-2841 2026-11-29 21:58:22 +00:00
Sign in to join this conversation.