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:
- 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:
- 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:
- 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 ofstr
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:
- 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:
- 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:
- reboot() None [source]¶
Reboot a host via IPMI, either performing a power cycle or a power on based on the power status.
- Return type:
- 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:
- 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 betweenspicerack.ipmi.IPMI_PASSWORD_MIN_LEN
andspicerack.ipmi.IPMI_PASSWORD_MAX_LEN
bytes.
- Raises:
spicerack.ipmi.IpmiError -- if unable reset password or arguments invalid.
- Return type: