tools.ipmi_tools module
IPMI / BMC control via the system ipmitool binary.
Uses -I lanplus over the network. Requires ipmitool installed on the bot host.
Security: requires UNSANDBOXED_EXEC — bare-metal power and sensor access.
Commands are built as argv lists (no shell) to avoid injection.
- async tools.ipmi_tools.run(host, user, password, action, ctx=None, *, credential_profile='')[source]
Execute an IPMI power or sensor action against a BMC and return its result.
Handler for the
ipmi_controltool — the main entry point of this module. It performs the privileged, real-world side effect of talking to bare-metal hardware: querying or changing a host’s power state, or reading its full sensor list, over the network via the system ipmitool binary.The flow gates on
_check_priv()(UNSANDBOXED_EXECrequired), then — whencredential_profileis given — loads a saved encrypted bundle with_cred_loadand overlays explicit args via_cred_mergeso stored host/user/password can fill in the blanks. It confirms ipmitool is installed (_ipmitool_available()), validates the action against_VALID_ACTIONS, and validates the host/user/password with_host_ok()/_user_ok(). It then builds the argv with_build_cmd()and runs it through_run_ipmitool()(no shell). Forsensor_readit additionally parses the pipe-delimited sensor table into structured rows. Dispatched by the tool runtime as theipmi_controlhandler (registered inTOOLS); no direct internal callers were found.- Parameters:
host (
str) – BMC IP address or hostname (may be supplied by the profile).user (
str) – IPMI username (may be supplied by the profile).password (
str) – IPMI password (may be supplied by the profile).action (
str) – One of_VALID_ACTIONS— a power verb orsensor_read.ctx (
Any) – TheToolContextfor the privilege check and credential store;Nonefails the call.credential_profile (
str) – Optional saved profile name whose host/user/password are merged in (explicit args take precedence).
- Returns:
A JSON string with
success,action,exit_code,stdoutandstderr(plus parsedsensors/sensor_countfor a successfulsensor_read), or{"success": False, "error": ...}on a privilege, validation, or environment failure.- Return type: