feat(power): restart and shut the host down with Restart-/Stop-Computer (NetOrk/netork#2841) #11

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

The Windows driver could not restart. reboot_host() and shutdown_host() over the driver's PowerShell Remoting: Restart-Computer / Stop-Computer -Confirm:$false -ErrorAction Stop, without -Force, so Windows asks programs to close and refuses while other users are logged on (a disconnected RDP session included); that refusal is raised as RuntimeError with the host's message. PsrpTransport.run_last() treats a connection that breaks during the call as accepted.

No version bump: features collect under [Unreleased]. Tests: TestHostPower (10) and TestRunLast (8); full suite 269 passed. Not tried against a real Windows host.

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 Windows driver could not restart. `reboot_host()` and `shutdown_host()` over the driver's PowerShell Remoting: `Restart-Computer` / `Stop-Computer -Confirm:$false -ErrorAction Stop`, without `-Force`, so Windows asks programs to close and refuses while other users are logged on (a disconnected RDP session included); that refusal is raised as `RuntimeError` with the host's message. `PsrpTransport.run_last()` treats a connection that breaks during the call as accepted. No version bump: features collect under [Unreleased]. Tests: `TestHostPower` (10) and `TestRunLast` (8); full suite 269 passed. Not tried against a real Windows host. 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:25 +00:00
feat(power): restart and shut the host down with Restart-/Stop-Computer (NetOrk/netork#2841)
driver / standard (pull_request) Successful in 16s
driver / lint (pull_request) Successful in 13s
driver / test (3.13) (pull_request) Successful in 43s
driver / types (pull_request) Successful in 56s
driver / lowest (pull_request) Successful in 25s
driver / test (3.12) (pull_request) Successful in 55s
driver / build (pull_request) Successful in 29s
driver / security (pull_request) Successful in 56s
CI / driver (pull_request) Successful in 2m2s
driver / publish (pull_request) Skipped
d7511efd43
reboot_host() and shutdown_host() run Restart-Computer and Stop-Computer
without -Force over the PSRP connection: Windows asks running programs
to close and refuses while other users are logged on. A refusal raises
RuntimeError with the host's answer; a connection the host drops before
answering counts as accepted, which PsrpTransport.run_last() reports.
christianmanivong merged commit 977ddbd904 into main 2026-11-29 21:58:23 +00:00
christianmanivong deleted branch feature/host-shutdown-2841 2026-11-29 21:58:23 +00:00
Sign in to join this conversation.