ipmi

IPMI module.

Todo

replace with pyghmi.

exception spicerack.ipmi.IpmiCheckError[source]

Bases: SpicerackCheckError

Custom exception class for check errors of the Ipmi class.

exception spicerack.ipmi.IpmiError[source]

Bases: SpicerackError

Custom exception class for errors of the Ipmi class.

class spicerack.ipmi.Ipmi(target: str, password: str, dry_run: bool = True) None[source]

Bases: object

Class to manage remote IPMI via ipmitool.

Initialize the instance.

Parameters:
  • target (str) -- the management console FQDN or IP to target.

  • password (str) -- the password to use to connect via IPMI.

  • dry_run (bool, default: True) -- whether this is a DRY-RUN.

check_bootparams() None[source]

Check if the BIOS boot parameters are back to normal values.

Raises:

spicerack.ipmi.IpmiCheckError -- if the BIOS boot parameters are incorrect.

Return type:

None

check_connection() None[source]

Ensure that remote IPMI is working for the management console.

Raises:

spicerack.ipmi.IpmiError -- if unable to connect or execute a test command.

Return type:

None

command(command_parts: list[str], is_safe: bool = False, hide_parts: tuple = ()) str[source]

Run an ipmitool command for a remote management console and return its output.

Parameters:
  • command_parts (list[str]) -- a list of str with the IPMI command components to execute.

  • is_safe (bool, default: False) -- if this is a safe command to run also in DRY RUN mode.

  • hide_parts (tuple, default: ()) -- tuple with indexes of the command_parts list that should be redacted in logs and outputs because contain sensitive data. For example setting it to (2, 4) would replace in logs and outputs the 3rd and 5th element of the command_parts list.

Raises:

spicerack.ipmi.IpmiError -- on failure.

Return type:

str

force_pxe() None[source]

Force PXE for the next boot and verify that the setting was applied.

Raises:

spicerack.ipmi.IpmiCheckError -- if unable to verify the PXE mode within the retries.

Return type:

None

power_status() str[source]

Get the current power status for the management console.

Raises:

spicerack.ipmi.IpmiError -- if unable to get the power status.

Return type:

str

reboot() None[source]

Reboot a host via IPMI, either performing a power cycle or a power on based on the power status.

Return type:

None

remove_boot_override() None[source]

Remove any boot override, if present for the next boot and verify that the change was applied.

Raises:

spicerack.ipmi.IpmiCheckError -- if unable to verify the boot mode.

Return type:

None

reset_password(username: str, password: str) None[source]

Reset the given usernames password to the one provided.

Parameters:
Raises:

spicerack.ipmi.IpmiError -- if unable reset password or arguments invalid.

Return type:

None

spicerack.ipmi.IPMI_PASSWORD_MAX_LEN: int = 20

The maximum length of the IPMI password.

spicerack.ipmi.IPMI_PASSWORD_MIN_LEN: int = 16

The minimum length of the IPMI password.

spicerack.ipmi.IPMI_SAFE_BOOT_PARAMS: tuple[str, ...] = ('0000000000', '8000000000', '8000020000')

The boot params returned by IPMI to consider valid for normal operations.