Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce sdcommands option and shutdown.default INSTCMD to all drivers #2686

Open
wants to merge 87 commits into
base: master
Choose a base branch
from

Conversation

jimklimov
Copy link
Member

Closes: #2670

Started from discussion in the issue linked above, about drivers hard-coding some operations as their late-shutdown implementation -- which may not be the best fit for a particular supported device model.

This PR aims to allow one to configure (a generally comma-separated list of) sdcommands option with arbitrary INSTCMD values supported by the device-specific part of driver code (if any). In testing e.g. beeper commands can be used instead of powering off the load.

It also aliases the call to upsdrv_shutdown() as a shutdown.default for good measure (similar to driver.killpower but without a failsafe flag, and not necessarily exiting the driver).

Shutdown implementations of some drivers got reshuffled into newly supported standard instant commands like shutdown.return or shutdown.stayoff - sometimes guessing the name (testing wanted). For others, the method code remains unique (e.g. when return/stayoff is chosen based on OL/OB status).

…rom upsdrv_shutdown() to upscmd("shutdown.stayoff") [networkupstools#2670]

Signed-off-by: Jim Klimov <[email protected]>
…rv_shutdown() to upscmd("shutdown.return") [networkupstools#2670]

Signed-off-by: Jim Klimov <[email protected]>
…sdrv_shutdown() to upscmd("shutdown.return"); newly support INSTCMD at all [networkupstools#2670]

Signed-off-by: Jim Klimov <[email protected]>
…m upsdrv_shutdown() to upscmd("shutdown.return") [networkupstools#2670]

Signed-off-by: Jim Klimov <[email protected]>
…m upsdrv_shutdown() to upscmd("shutdown.return"); newly support INSTCMD at all [networkupstools#2670]

Signed-off-by: Jim Klimov <[email protected]>
…rv_shutdown() to upscmd("shutdown.return") [networkupstools#2670]

Signed-off-by: Jim Klimov <[email protected]>
…upsdrv_shutdown() to upscmd("shutdown.return"); newly support INSTCMD at all [networkupstools#2670]

Signed-off-by: Jim Klimov <[email protected]>
…rom upsdrv_shutdown() to upscmd("shutdown.stayoff") [networkupstools#2670]

Signed-off-by: Jim Klimov <[email protected]>
…er), by default chain the originally used sequence in upsdrv_shutdown() [networkupstools#2670]

Signed-off-by: Jim Klimov <[email protected]>
…XIT_FAILURE and EF_EXIT_SUCCESS for set_exit_flag(int) methods [networkupstools#2670]

Signed-off-by: Jim Klimov <[email protected]>
…rv_shutdown flag to exit or not after upsdrv_shutdown() and individual power-state related INSTCMDs [networkupstools#2670]

Signed-off-by: Jim Klimov <[email protected]>
…t and upsdrv_shutdown_default() shared method [networkupstools#2670]

Signed-off-by: Jim Klimov <[email protected]>
…wn_sdcommands_or_default() less ambiguously [networkupstools#2670]

Signed-off-by: Jim Klimov <[email protected]>
…default upsdrv_shutdown() as the implementation of forceshutdown() and "driver.killpower" INSTCMD (e.g. via `drivername -k`) [networkupstools#2670]

Signed-off-by: Jim Klimov <[email protected]>
…() so drivers might implement their own "shutdown.default" at will [networkupstools#2670]

Signed-off-by: Jim Klimov <[email protected]>
…tinfo() where we register INSTCMD handlers [networkupstools#2670]

Signed-off-by: Jim Klimov <[email protected]>
…fallback() so drivers might implement their own "shutdown.default" at will [networkupstools#2670]"

This reverts commit 25250b0:
too messy in logs where driver.instcmd() think they are last in stack.

Signed-off-by: Jim Klimov <[email protected]>
…" as upsdrv_shutdown() in main loop too [networkupstools#2670]

Signed-off-by: Jim Klimov <[email protected]>
@jimklimov jimklimov added feature need testing Code looks reasonable, but the feature would better be tested against hardware or OSes service/daemon start/stop General subject for starting and stopping NUT daemons (drivers, server, monitor); also BG/FG/Debug Shutdowns and overrides and battery level triggers Issues and PRs about system shutdown, especially if battery charge/runtime remaining is involved labels Nov 19, 2024
@jimklimov jimklimov added this to the 2.8.3 milestone Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature need testing Code looks reasonable, but the feature would better be tested against hardware or OSes service/daemon start/stop General subject for starting and stopping NUT daemons (drivers, server, monitor); also BG/FG/Debug Shutdowns and overrides and battery level triggers Issues and PRs about system shutdown, especially if battery charge/runtime remaining is involved
Projects
None yet
Development

Successfully merging this pull request may close these issues.

USB HID UPS / APC HID UPS shutdown command attempted order
1 participant