shutdown_host() next to reboot_host(): /sbin/poweroff, detached (sh -c '(trap "" HUP; sleep 2; /sbin/poweroff) …&') through the privileged path, so the call returns before the session drops. Same error contract as the reboot: a non-zero or missing status raises RuntimeError with the host's output (plus the sudo hint when sudo wants a password). poweroff rather than shutdown -h now: systemd, sysvinit and BusyBox all ship it, and sysvinit's -h may only halt.
Version 0.25.0 with its CHANGELOG entry. Tests: TestShutdownHost (5) in tests/test_linux.py, and shutdown_host in the sudo-line check; full suite 480 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.
`shutdown_host()` next to `reboot_host()`: `/sbin/poweroff`, detached (`sh -c '(trap "" HUP; sleep 2; /sbin/poweroff) …&'`) through the privileged path, so the call returns before the session drops. Same error contract as the reboot: a non-zero or missing status raises `RuntimeError` with the host's output (plus the sudo hint when sudo wants a password). `poweroff` rather than `shutdown -h now`: systemd, sysvinit and BusyBox all ship it, and sysvinit's `-h` may only halt.
Version 0.25.0 with its CHANGELOG entry. Tests: `TestShutdownHost` (5) in `tests/test_linux.py`, and `shutdown_host` in the sudo-line check; full suite 480 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 host's clean shutdown next to reboot_host: /sbin/poweroff as root,
detached and two seconds late like the restart, so the exit status comes
back before the session drops. A refusal raises RuntimeError with what
the host said, plus the sudo password hint where sudo wanted one.
poweroff rather than shutdown -h now: systemd links it to systemctl
poweroff, sysvinit and BusyBox ship it themselves, while BusyBox has no
shutdown and sysvinit's -h may only halt.
linux.py must not grow (python_file_lines, 1990): the power methods,
their detached commands and _launch_detached move to _host_power.py
(LinuxHostPowerMixin), and linux.py shrinks to 1972 lines, recorded in
the baseline. Behaviour unchanged; the 480 tests pass as they were.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
shutdown_host()next toreboot_host():/sbin/poweroff, detached (sh -c '(trap "" HUP; sleep 2; /sbin/poweroff) …&') through the privileged path, so the call returns before the session drops. Same error contract as the reboot: a non-zero or missing status raisesRuntimeErrorwith the host's output (plus the sudo hint when sudo wants a password).poweroffrather thanshutdown -h now: systemd, sysvinit and BusyBox all ship it, and sysvinit's-hmay only halt.Version 0.25.0 with its CHANGELOG entry. Tests:
TestShutdownHost(5) intests/test_linux.py, andshutdown_hostin the sudo-line check; full suite 480 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 areHostRebootMixin/HostShutdownMixinin napalm-device-types, already mixed in throughDeviceTypeDriver; the minimum napalm-device-types version needs no change.netOrk's
feature/host-shutdown-2841pins this branch's commit for now; once this is merged, the pin moves to the merge commit.