redfish¶
Redfish module.
- exception spicerack.redfish.RedfishError[source]¶
Bases:
spicerack.exceptions.SpicerackError
General errors raised by this module.
- exception spicerack.redfish.RedfishTaskNotCompletedError[source]¶
Bases:
spicerack.redfish.RedfishError
Raised when a Redfish task is not found on the server.
- class spicerack.redfish.ChassisResetPolicy(value)[source]¶
Bases:
enum.Enum
Subset of available Chassis.Reset policies compatible with all supported vendors (at this moment only Dell).
- class spicerack.redfish.DellSCP(config: Dict, target: spicerack.redfish.DellSCPTargetPolicy)[source]¶
Bases:
object
Reprenset a Dell System Configuration Profile configuration as returned by Redfish API.
Parse the Redfish API response.
- Parameters
config (dict) -- the configuration as returned by Redfish API.
target (spicerack.redfish.DellSCPTargetPolicy) -- describe which sections of the configuration are represented in the loaded configuration.
- set(component_name: str, attribute_name: str, attribute_value: str) None [source]¶
Update the current configuration setting to the new value for the given key in the given component.
Notes
This updates only the instance representation of the instance. To push and apply the changes to the server see
spicerack.redfish.RedfishDell.scp_push()
.- Parameters
- Raises
spicerack.redfish.RedfishError -- if unable to find the given component or attribute.
- update(changes: Dict[str, Dict[str, str]]) None [source]¶
Bulk update the current configuration with the set of changes provided.
Notes
This updates only the instance representation of the instance. To push and apply the changes to the server see
spicerack.redfish.RedfishDell.scp_push()
.- Parameters
changes (dict) -- a dictionary of changes to apply in the same format of the one returned by
spicerack.redfish.DellSCP.components()
.- Raises
spicerack.redfish.RedfishError -- if unable to apply all the changes.
- property components: Dict[str, Dict[str, str]]¶
Getter for the components present in the configuration in a simplified view.
The returned dictionary where all the keys are recursively sorted and has the following format:
{ '<component name>': { 'key1': 'value1', 'key2': 'value2', }, }
- property config: Dict¶
Getter for the whole configuration in Dell's format.
- property target: spicerack.redfish.DellSCPTargetPolicy¶
Getter for the target that the current configuration represents.
- property timestamp: datetime.datetime¶
Getter for the timestamp when the configuration dump was generated.
- class spicerack.redfish.DellSCPPowerStatePolicy(value)[source]¶
Bases:
enum.Enum
Available Dell SCP (Server Configuration Profiles) final power state after an operation policies.
- class spicerack.redfish.DellSCPRebootPolicy(value)[source]¶
Bases:
enum.Enum
Available Dell SCP (Server Configuration Profiles) reboot policies.
- class spicerack.redfish.DellSCPTargetPolicy(value)[source]¶
Bases:
enum.Enum
Available sections of the Dell SCP (Server Configuration Profiles) to target.
- ALL = 'ALL'¶
All settings.
- BIOS = 'BIOS'¶
Only BIOS settings.
- IDRAC = 'IDRAC'¶
Only iDRAC settings.
- NIC = 'NIC'¶
Only network interfaces settings.
- RAID = 'RAID'¶
Only RAID controller settings.
- class spicerack.redfish.Redfish(fqdn: str, username: str, password: str, *, dry_run: bool = True)[source]¶
Bases:
object
Manage Redfish operations on a specific device.
Initialize the instance.
- Parameters
- change_user_password(username: str, password: str) None [source]¶
Change the password for the account with the given username.
If the username matches the one used by the instance to connect to the API, automatically updates the instance value so that the instance will keep working.
- Parameters
- Raises
spicerack.redfish.RedfishError -- if unable to find the user or update its password.
- chassis_reset(action: spicerack.redfish.ChassisResetPolicy) None [source]¶
Perform a reset of the chassis power status.
- Parameters
action (spicerack.redfish.ChassisResetPolicy) -- the reset policy to use.
- Raises
spicerack.redfish.RedfishError -- if unable to perform the reset.
- check_connection() None [source]¶
Check the connection with the Redfish API.
- Raises
spicerack.redfish.RedfishError -- if unable to connect to Redfish API.
- find_account(username: str) Tuple[str, str] [source]¶
Find the account for the given username and return its URI.
- Parameters
username (str) -- the username to search for.
- Returns
a 2-element tuple with the the URI for the account and the ETag header value of the GET response.
- Return type
- Raises
spicerack.redfish.RedfishError -- if unable to find the account.
- get_power_state() str [source]¶
Return the current power state of the device.
- Returns
the power state.
- Return type
- poll_task(uri: str) Dict [source]¶
Poll a Redfish task until the results are available.
- Parameters
uri (str) -- the URI of the task, usually returned as Location header by the originating API call.
- Returns
the task results.
- Return type
- Raises
RedfishError -- if the response from the server is outside the expected values of HTTP 200 or 202.
RedfishTaskNotCompletedError -- if the task is not yet completed.
- request(method: str, uri: str, *, data: Optional[Dict] = None, headers: Optional[Dict] = None) requests.models.Response [source]¶
Perform a request against the target Redfish instance with the provided HTTP method and data.
- Parameters
- Returns
the response.
- Return type
requests.models.Response
- Raises
RedfishError -- if the response status code is between 400 and 600 or if the given uri does not start with
a slash (/) --
- submit_task(uri: str, data: Optional[Dict] = None) str [source]¶
Submit a request that generates a task, return the URI of the submitted task.
- Parameters
- Returns
the URI of the task ID to poll the results.
- Return type
- Raises
spicerack.redfish.RedfishError -- if the response status code is not 202 or there is no Location header.
- class spicerack.redfish.RedfishDell(fqdn: str, username: str, password: str, *, dry_run: bool = True)[source]¶
Bases:
spicerack.redfish.Redfish
Dell specific Redfish support.
Initialize the instance.
- Parameters
- scp_dump(target: spicerack.redfish.DellSCPTargetPolicy = DellSCPTargetPolicy.ALL) spicerack.redfish.DellSCP [source]¶
Dump and return the SCP (Server Configuration Profiles) configuration.
- Parameters
target (spicerack.redfish.DellSCPTargetPolicy, optional) -- choose which sections to dump.
- Returns
the server's configuration.
- Return type
- Raises
spicerack.redfish.RedfishError -- if the API call fail.
spicerack.redfish.RedfishTaskNotCompletedError -- if unable to fetch the dumped results.
- scp_push(scp: spicerack.redfish.DellSCP, *, reboot: spicerack.redfish.DellSCPRebootPolicy = DellSCPRebootPolicy.NO_REBOOT, power_state: spicerack.redfish.DellSCPPowerStatePolicy = DellSCPPowerStatePolicy.ON, preview: bool = True) Dict [source]¶
Push the SCP (Server Configuration Profiles) configuration.
- Parameters
scp (spicerack.redfish.DellSCP) -- the configuration that will pushed to the server.
reboot (spicerack.redfish.DellSCPRebootPolicy, optional) -- which reboot policy to use to apply the changes.
power_state (spicerack.redfish.DellSCPPowerStatePolicy, optional) -- which final power state policy to use to apply to the host after the changes have been applied.
preview (bool, optional) -- if
True
perform a test push of the SCP data. This will tell if the file parses correctly and would not result in any writes. The comments will tell if the new configuration would not produce any changes. Forces the reboot parameter to bespicerack.redfish.DellSCPRebootPolicy.NO_REBOOT
.
- Returns
the results of the push operation.
- Return type
- Raises
spicerack.redfish.RedfishError -- if the API call fail.
spicerack.redfish.RedfishTaskNotCompletedError -- if unable to fetch the dumped results.