ipmi

IPMI module.

Todo

replace with pyghmi.

exception spicerack.ipmi.IpmiCheckError[source]

Bases: spicerack.exceptions.SpicerackCheckError

Custom exception class for check errors of the Ipmi class.

exception spicerack.ipmi.IpmiError[source]

Bases: spicerack.exceptions.SpicerackError

Custom exception class for errors of the Ipmi class.

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

Bases: object

Class to manage remote IPMI via ipmitool.

Initialize the instance.

Parameters
  • mgmt_fqdn (str) -- the management console FQDN to target.

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

  • dry_run (bool, optional) -- 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.

check_connection() None[source]

Ensure that remote IPMI is working for the management console FQDN.

Raises

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

command(command_parts: List[str], is_safe: bool = False, hide_parts: Tuple = ()) str[source]

Run an ipmitool command for a remote management console FQDN.

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

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

  • hide_parts (tuple, optional) -- 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.

Returns

the output of the ipmitool command.

Return type

str

Raises

spicerack.ipmi.IpmiError -- on failure.

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.

power_status() str[source]

Get the current power status for the management console FQDN.

Raises

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

reboot() None[source]

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

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

Reset the given usernames password to the one provided.

Parameters
  • username (str) -- The username who's password will be reset must not be empty

  • password (str) -- The new password, length between spicerack.ipmi.IPMI_PASSWORD_MIN_LEN and spicerack.ipmi.IPMI_PASSWORD_MAX_LEN bytes

Raises

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