saltext.bmc.utils.redfish

Redfish HTTP transport for the saltext-bmc extension.

A small Redfish client built directly on requests. It exposes the minimum primitives the higher-level layers need:

The protocol-neutral operations (power / boot / inventory / sensors) are in saltext.bmc.utils.backend; raw passthrough lives in saltext.bmc.modules.bmc_redfish.

Configuration is read from Salt opts/pillar under saltext.bmc:

saltext.bmc:
  host: 192.168.1.100
  username: root
  password: calvin
  verify_ssl: false

Or, when multiple targets are managed by a single minion:

saltext.bmc:
  profiles:
    bmc-host-01:
      host: 10.0.0.5
      username: root
      password: calvin
      verify_ssl: false
    bmc-host-02:
      host: 10.0.0.6
      username: root
      password: calvin
      verify_ssl: false

Auth strategy: a session is opened against /redfish/v1/SessionService/Sessions to obtain an X-Auth-Token for subsequent requests, and DELETE’d on close. If session creation fails (older BMCs, or BMCs with the session service disabled), the client falls back to HTTP Basic for the request lifetime.

exception saltext.bmc.utils.redfish.RedfishError[source]

A Redfish API request failed.

exception saltext.bmc.utils.redfish.RedfishAuthError[source]

Authentication against the Redfish endpoint failed.

saltext.bmc.utils.redfish.get_config(opts: dict, profile: str | None = None) dict[source]

Extract BMC connection config from opts/pillar.

Searches in order:
  1. saltext.bmc:profiles:<profile> (when profile is given)

  2. saltext.bmc top-level keys (fallback / single-host config)

saltext.bmc.utils.redfish.resolve_conn(opts: dict, name: str | None = None, **overrides) dict[source]

Resolve a connection config from opts/pillar plus explicit kwargs.

Explicit kwargs (host=, username=, password=, verify_ssl=) take precedence over the resolved profile.

class saltext.bmc.utils.redfish.RedfishClient(host: str, username: str, password: str, *, verify_ssl: bool = True, timeout: int = 30)[source]

Thin Redfish HTTP client.

Use as a context manager:

with RedfishClient(host, user, password, verify_ssl=False) as c:
    data = c.get("/redfish/v1/Systems")
saltext.bmc.utils.redfish.get_system_path(client: RedfishClient) str[source]

Return the @odata.id of the (typically single) ComputerSystem.

Raises RedfishError if no system is exposed or multiple systems are present without an obvious default.

saltext.bmc.utils.redfish.get_reset_action(system: dict) tuple[str, list[str]][source]

Return (target_path, allowable_values) for ComputerSystem.Reset.

Parses the Actions block of a ComputerSystem resource to find the reset action target and the list of accepted ResetType values.

saltext.bmc.utils.redfish.open_client(opts: dict, name: str | None = None, **overrides) RedfishClient[source]

Build a RedfishClient from opts/pillar plus optional overrides.

Caller is responsible for using it as a context manager.