tools.bmc_vendor_tools module
Vendor BMC tools: Redfish/HTTPS, Dell racadm, Supermicro SMCIPMITool.
Security: all handlers require UNSANDBOXED_EXEC. No shell; argv lists only
for subprocess tools. Redfish uses enum actions mapped to fixed paths.
Remote HPE iLO is accessed via Redfish (not hponcfg, which is local OS only).
- async tools.bmc_vendor_tools.run_bmc_redfish(host, user, password, action, ctx=None, *, credential_profile='', system_id='', chassis_id='', manager_id='', reset_type='ForceRestart', boot_override_enabled='Once', boot_override_target='Pxe', verify_ssl=False, port=None, timeout=120.0)[source]
Perform one allowlisted Redfish operation over HTTPS against a BMC.
Backing implementation of the
bmc_redfishtool, covering HPE iLO, Dell iDRAC (Redfish mode), Lenovo XCC, and many Supermicro/Cisco controllers. Dispatches onaction— an enum drawn from_REDFISH_ACTIONS— to a fixed Redfish path (service root, systems/chassis/managers inventory, thermal and power readings, log services and entries, firmware/software inventory, virtual-media listing, boot properties, a boot-override PATCH, or a ComputerSystem.Reset POST). Member ids are auto-discovered when not supplied. Only enum actions reach fixed paths; arbitrary URLs are never issued.When
credential_profileis set it loads saved connection fields viatools._credential_profile_store.load_profile()(aliased_cred_load) and merges them with_cred_mergebefore validating the host, user, password, and port with_host_ok(),_user_ok(),_bad_pw(), and_port_ok(). RequiresUNSANDBOXED_EXECviatools.ipmi_tools._check_priv(). Builds the base URL with_bmc_base_url(), opens an SSRF-guarded client fromtools._safe_http.safe_httpx_client()carryinghttpx.BasicAuth, resolves ids through_resolve_system_id(),_resolve_chassis_id(), and_resolve_manager_id(), issues each request via_redfish_json(), and bounds every response with_truncate_payload(). Side effects: outbound HTTPS to the BMC management network, and (forboot_override/system_reset) a state change on the target server. Errors are returned as JSON, not raised.Called by the
tool_loaderdispatcher as the registeredhandlerfor thebmc_redfishentry inTOOLS(and directly intests/test_credential_profile_merges.py).- Parameters:
host (
str) – BMC hostname or IP, optionally with anhttp(s)://scheme.user (
str) – BMC username for BasicAuth.password (
str) – BMC password for BasicAuth.action (
str) – Redfish operation to perform; must be in_REDFISH_ACTIONS.ctx (
Any) – Tool context providingredis/user_idfor the privilege and credential lookups; required.credential_profile (
str) – Optional saved profile name supplying host, user, password, and TLS options.system_id (
str) – Redfish Systems member id; empty auto-detects the first.chassis_id (
str) – Chassis member id; empty auto-detects the first.manager_id (
str) – Managers member id; empty auto-detects the first.reset_type (
str) – ResetType forsystem_reset(must be in_RESET_TYPES; default"ForceRestart").boot_override_enabled (
str) – BootSourceOverrideEnabled forboot_override(default"Once").boot_override_target (
str) – BootSourceOverrideTarget forboot_override(default"Pxe").verify_ssl (
bool) – Whether to verify the BMC’s TLS certificate (defaultFalsefor self-signed BMC certs).port (
int|None) – Optional HTTPS port when not 443 and not embedded inhost.timeout (
float) – HTTP timeout in seconds (default 120).
- Returns:
A JSON object carrying
success,http_status,action, the resolved id(s), and the truncateddata(or per-action payload keys), or{"success": False, "error": ...}on a validation, auth, or request failure.- Return type:
- async tools.bmc_vendor_tools.run_idrac_racadm(host, user, password, action, ctx=None, *, credential_profile='', timeout=180.0)[source]
Run one allowlisted Dell iDRAC racadm action against a remote BMC.
Backing implementation of the
idrac_racadmtool. It invokes the localracadmbinary in remote mode (racadm -rhost,-uuser,-ppassword, then the action tail) with a fixed, pre-vetted subcommand tail chosen from_RACADM_ACTIONS— read and power actions plus storagegetviews. Because only constant argv tails (resolved by_racadm_tail()) are appended and no shell is used, no user-controlled token can reach the subcommand; firmware flash and destructive RAID actions are not exposed.When
credential_profileis set it loads and merges saved fields via_cred_load/_cred_merge. RequiresUNSANDBOXED_EXECviatools.ipmi_tools._check_priv(); checks the binary with_racadm_available()and validates host/user/password with_host_ok()and_user_ok(); then runs the argv through_run_subprocess()(no shell, bounded output, timeout-killed). Side effect: spawns theracadmprocess, which reaches out to the iDRAC over the network (and may change power state forserveraction_*). Errors are returned as JSON, not raised.Called by the
tool_loaderdispatcher as the registeredhandlerfor theidrac_racadmentry inTOOLS; no internal callers in this module.- Parameters:
host (
str) – iDRAC IP or hostname.user (
str) – iDRAC username.password (
str) – iDRAC password.action (
str) – Action name; must be in_RACADM_ACTIONSand map to a tail.ctx (
Any) – Tool context providingredis/user_id; required.credential_profile (
str) – Optional saved profile supplying host, user, password, and timeout.timeout (
float) – Subprocess wall-clock timeout in seconds (default 180).
- Returns:
A JSON object with
success(true on exit code 0),action,exit_code, and the capturedstdout/stderr, or{"success": False, "error": ...}on a missing binary, validation, or auth failure.- Return type:
- async tools.bmc_vendor_tools.run_smc_supermicro(host, user, password, action, ctx=None, *, credential_profile='', timeout=180.0)[source]
Run one allowlisted Supermicro SMCIPMITool action against a BMC.
Backing implementation of the
smc_supermicrotool. It invokes the Supermicro CLI in remote IP mode (the resolved binary followed by host, user, password, then theipmisubcommand tokens) with a fixed subcommand tail chosen from_SMC_ACTIONS— power, sensor, FRU, LAN, and SEL reads. Only the constant tails resolved by_smc_tail()are appended and no shell is used, so user input cannot reach the subcommand.When
credential_profileis set it loads and merges saved fields via_cred_load/_cred_merge. RequiresUNSANDBOXED_EXECviatools.ipmi_tools._check_priv(); locates the binary with_smc_bin()and validates host/user/password with_host_ok()and_user_ok(); then runs the argv through_run_subprocess()(no shell, bounded output, timeout-killed). Side effect: spawns the SMCIPMITool process, which contacts the BMC over the network (and may change power state for theipmi_power_*actions). Errors are returned as JSON, not raised.Called by the
tool_loaderdispatcher as the registeredhandlerfor thesmc_supermicroentry inTOOLS; no internal callers in this module.- Parameters:
host (
str) – BMC IP address.user (
str) – BMC username.password (
str) – BMC password.action (
str) – Action name; must be in_SMC_ACTIONSand map to a tail.ctx (
Any) – Tool context providingredis/user_id; required.credential_profile (
str) – Optional saved profile supplying host, user, password, and timeout.timeout (
float) – Subprocess wall-clock timeout in seconds (default 180).
- Returns:
A JSON object with
success(true on exit code 0),action,exit_code, and the capturedstdout/stderr, or{"success": False, "error": ...}on a missing binary, validation, or auth failure.- Return type:
- async tools.bmc_vendor_tools.bmc_redfish_save_credentials(host, user, password, profile='default', ctx=None, *, verify_ssl=False, port=None, timeout=120.0)[source]
Encrypt and persist a reusable Redfish BMC credential profile.
Bundles the connection fields (host, user, password,
verify_ssl, port, timeout) so a laterrun_bmc_redfish()call can load them by name viacredential_profileinstead of re-supplying secrets each time.Requires the
UNSANDBOXED_EXECprivilege, enforced viatools.ipmi_tools._check_priv(). Delegates storage totools._credential_profile_store.save_profile()(aliased_cred_save) under prefixbmc_redfish, which encrypts the JSON with the per-user key and writes it to the user’s Redis hashstargazer:bmc_redfish_credentials:{user_id}(field = profile name). This is a tool handler registered inTOOLSand is invoked by the tool dispatcher rather than by other functions in this module.- Parameters:
host (
str) – BMC hostname or IP (whitespace-stripped before saving).user (
str) – BMC username to store.password (
str) – BMC password to store (encrypted at rest).profile (
str) – Profile name to save under; defaults to"default".ctx (
Any) – Tool context providingredisanduser_id; required.verify_ssl (
bool) – Whether saved sessions should verify TLS certs.timeout (
float) – HTTP timeout in seconds to remember.
- Returns:
A JSON result string
{"success": ...}from the credential store (or an error envelope whenctxis missing or the privilege check fails).- Return type:
- async tools.bmc_vendor_tools.bmc_redfish_list_credentials(ctx=None)[source]
List the saved Redfish BMC credential profile names for the user.
Returns only the profile names, never the decrypted secrets. Requires
UNSANDBOXED_EXECvia_check_priv(), then delegates totools._credential_profile_store.list_profile_names()(_cred_list), which reads the keys of the Redis hashstargazer:bmc_redfish_credentials:{user_id}. Registered inTOOLSand called by the tool dispatcher.
- async tools.bmc_vendor_tools.bmc_redfish_delete_credentials(profile='default', ctx=None)[source]
Delete one saved Redfish BMC credential profile for the user.
Requires
UNSANDBOXED_EXECvia_check_priv(), then delegates totools._credential_profile_store.delete_profile()(_cred_delete), which removes theprofilefield from the Redis hashstargazer:bmc_redfish_credentials:{user_id}. Registered inTOOLSand invoked by the tool dispatcher.
- async tools.bmc_vendor_tools.idrac_racadm_save_credentials(host, user, password, profile='default', ctx=None, *, timeout=180.0)[source]
Encrypt and persist a reusable Dell iDRAC racadm credential profile.
Stores host, user, password, and subprocess timeout so a later
run_idrac_racadm()call can load them bycredential_profilename. RequiresUNSANDBOXED_EXECvia_check_priv(), then delegates totools._credential_profile_store.save_profile()(_cred_save) under prefixidrac_racadm, encrypting the JSON to the user’s Redis hashstargazer:idrac_racadm_credentials:{user_id}. Registered inTOOLSand invoked by the tool dispatcher.- Parameters:
host (
str) – iDRAC IP or hostname (whitespace-stripped before saving).user (
str) – iDRAC username.password (
str) – iDRAC password (encrypted at rest).profile (
str) – Profile name to save under; defaults to"default".ctx (
Any) – Tool context providingredisanduser_id; required.timeout (
float) – Subprocess timeout in seconds to remember.
- Returns:
JSON result string from the credential store, or an error envelope when
ctxis missing or unprivileged.- Return type:
- async tools.bmc_vendor_tools.idrac_racadm_list_credentials(ctx=None)[source]
List the saved iDRAC racadm credential profile names for the user.
Returns names only, no secrets. Requires
UNSANDBOXED_EXECvia_check_priv(), then delegates totools._credential_profile_store.list_profile_names()(_cred_list) reading the Redis hashstargazer:idrac_racadm_credentials:{user_id}. Registered inTOOLSand invoked by the tool dispatcher.
- async tools.bmc_vendor_tools.idrac_racadm_delete_credentials(profile='default', ctx=None)[source]
Delete one saved iDRAC racadm credential profile for the user.
Requires
UNSANDBOXED_EXECvia_check_priv(), then delegates totools._credential_profile_store.delete_profile()(_cred_delete), removing theprofilefield from the Redis hashstargazer:idrac_racadm_credentials:{user_id}. Registered inTOOLSand invoked by the tool dispatcher.
- async tools.bmc_vendor_tools.smc_supermicro_save_credentials(host, user, password, profile='default', ctx=None, *, timeout=180.0)[source]
Encrypt and persist a reusable Supermicro SMCIPMITool credential profile.
Stores host, user, password, and subprocess timeout so a later
run_smc_supermicro()call can load them bycredential_profilename. RequiresUNSANDBOXED_EXECvia_check_priv(), then delegates totools._credential_profile_store.save_profile()(_cred_save) under prefixsmc_supermicro, encrypting the JSON to the user’s Redis hashstargazer:smc_supermicro_credentials:{user_id}. Registered inTOOLSand invoked by the tool dispatcher.- Parameters:
host (
str) – BMC IP address (whitespace-stripped before saving).user (
str) – BMC username.password (
str) – BMC password (encrypted at rest).profile (
str) – Profile name to save under; defaults to"default".ctx (
Any) – Tool context providingredisanduser_id; required.timeout (
float) – Subprocess timeout in seconds to remember.
- Returns:
JSON result string from the credential store, or an error envelope when
ctxis missing or unprivileged.- Return type:
- async tools.bmc_vendor_tools.smc_supermicro_list_credentials(ctx=None)[source]
List the saved Supermicro SMCIPMITool credential profile names.
Returns names only, no secrets. Requires
UNSANDBOXED_EXECvia_check_priv(), then delegates totools._credential_profile_store.list_profile_names()(_cred_list) reading the Redis hashstargazer:smc_supermicro_credentials:{user_id}. Registered inTOOLSand invoked by the tool dispatcher.
- async tools.bmc_vendor_tools.smc_supermicro_delete_credentials(profile='default', ctx=None)[source]
Delete one saved Supermicro SMCIPMITool credential profile.
Requires
UNSANDBOXED_EXECvia_check_priv(), then delegates totools._credential_profile_store.delete_profile()(_cred_delete), removing theprofilefield from the Redis hashstargazer:smc_supermicro_credentials:{user_id}. Registered inTOOLSand invoked by the tool dispatcher.