ironic.drivers.modules.redfish.utils module¶
- ironic.drivers.modules.redfish.utils.BIOS = 'bios'¶
BIOS Firmware Component
- ironic.drivers.modules.redfish.utils.BMC = 'bmc'¶
BMC Firmware Component
- class ironic.drivers.modules.redfish.utils.BootProgressStatus(*values)[source]¶
Bases:
EnumOutcome of checking a node’s BootProgress against target states.
- PASSED = 'passed'¶
The node has booted far enough for the current step.
- UNAVAILABLE = 'unavailable'¶
The node does not report BootProgress.
- WAITING = 'waiting'¶
The node has not been seen to boot far enough yet.
- ironic.drivers.modules.redfish.utils.FIRMWARE_COMPONENTS = ['bios', 'bmc']¶
Firmware Components available to update
- ironic.drivers.modules.redfish.utils.NIC = 'nic'¶
NIC Firmware Component type
- ironic.drivers.modules.redfish.utils.NIC_COMPONENT_PREFIX = 'nic:'¶
Prefix for NIC Firmware Components
- class ironic.drivers.modules.redfish.utils.SessionCache(driver_info)[source]¶
Bases:
objectCache of HTTP sessions credentials
- AUTH_CLASSES = {'auto': <class 'sushy.auth.SessionOrBasicAuth'>, 'basic': <class 'sushy.auth.BasicAuth'>, 'session': <class 'sushy.auth.SessionAuth'>}¶
- ironic.drivers.modules.redfish.utils.async_session(driver_info)[source]¶
Yield an async Redfish client, closing it when the block ends.
Each call opens its own session on the BMC and releases it on the way out with an HTTP DELETE. Nothing is cached between calls.
Caching these clients is not as simple as keeping them in a dict. The sensor collection periodic task drives them from a fresh
asyncio.run()on every tick, and anhttpx.AsyncClientbinds its pooled connections to the loop that opened them, so a client held across ticks fails with “Event loop is closed” as soon as a kept-alive connection is reused. Reinstating a cache means solving that first, which is deliberately left to a later change rather than carried here half-done.Not caching costs a session setup and teardown per node per call. Callers that collect from many nodes should bound how many run at once, since BMCs cap the number of sessions open at a time.
- Parameters:
driver_info – dict with Redfish connection parameters as returned by
parse_driver_info.- Returns:
an async context manager yielding an initialized
AsyncRedfishClient.
- ironic.drivers.modules.redfish.utils.boot_changed_since(before, current)[source]¶
Check whether the host has reset since an earlier observation.
A reboot request does not reset BootProgress: until the host actually resets, the BMC keeps reporting the state the previous boot reached. The host has reset if
LastStatehas changed to one ofBOOT_PROGRESS_RESET_STATES, which are only reported while the host is down or early in POST, or fromOSRunningtoOEM: a boot that has reached the OS cannot move on toOEMwithout a new boot, and Dell iDRAC may reportOEMfor most of the boot after a reboot. Any other change proves nothing, as the boot in progress before the reboot may simply have moved on, nor does a state missing from either observation.- Parameters:
before – an observation from
get_boot_observation()taken before the reboot was requested, or None if it could not be read.current – an observation taken since.
- Returns:
True if the host has reset since
before, False if nothing shows that it has.
- ironic.drivers.modules.redfish.utils.check_boot_progress(node, system, target_states)[source]¶
Check a node’s Redfish BootProgress against the target states.
A target state read after a reboot request may still describe the previous boot; callers decide whether to trust it, see
boot_changed_since().- Parameters:
node – an ironic node object, used for logging only.
system – an already-fetched sushy System object. Callers are responsible for fetching it; this function performs no I/O.
target_states – an iterable of
sushy.BootProgressStatesmembers that satisfy the gate.
- Returns:
a tuple of (status, last_state) where status is a BootProgressStatus, and last_state is the
sushy.BootProgressStatesvalue observed, or None.- Raises:
sushy.exceptions.SushyError when the BootProgress resource cannot be read; callers should retry on the next poll.
- ironic.drivers.modules.redfish.utils.get_boot_observation(system)[source]¶
Read the markers of a system that change when its host resets.
LastResetTimeis not used: Dell iDRAC, the only BMC known to report it on the System, recalculates it on every read, keeps the old value for some time after a reset and then reports values that are not valid date-times.- Parameters:
system – an already-fetched sushy System object. Callers are responsible for fetching it; this function performs no I/O.
- Returns:
a dict that can be stored in
driver_internal_info, with the keystate(BootProgressLastState) as a string, or None where the BMC does not report it.
- ironic.drivers.modules.redfish.utils.get_boot_progress_targets(node)[source]¶
Get the BootProgress target states for the node’s current step.
- Parameters:
node – an ironic node object.
- Returns:
a frozenset of
sushy.BootProgressStatesmembers that satisfy the BootProgress gate for the step currently running on the node.- Raises:
IronicException if no clean, deploy or service step is running on the node.
- ironic.drivers.modules.redfish.utils.get_chassis(node, system)[source]¶
Get a Redfish Chassis associated with a System of a node
- Parameters:
node – an Ironic node object
system – the Sushy System object
- Raises:
RedfishConnectionError when it fails to connect to Redfish
- Raises:
RedfishError if there is no Chassis registered
- ironic.drivers.modules.redfish.utils.get_component_type(component)[source]¶
Determine the type of firmware component.
Note: This helper exists primarily to handle NIC components which use a prefix pattern (e.g., ‘nic:BCM57414’, ‘nic:adapter1’) rather than exact string matches. This centralizes the component type detection logic that is used in multiple places (update initiation, task monitoring, completion handling) and provides a single source of truth for component type classification.
- Parameters:
component – The component name from settings
- Returns:
One of ‘bios’, ‘bmc’, ‘nic’, or None
- ironic.drivers.modules.redfish.utils.get_enabled_macs(task, system)[source]¶
Get information on MAC addresses of enabled ports using Redfish.
- Parameters:
task – a TaskManager instance containing the node to act on.
system – a Redfish System object
- Returns:
a dictionary containing MAC addresses of enabled interfaces in a {‘mac’: <state>} format, where <state> is a sushy constant
- ironic.drivers.modules.redfish.utils.get_event_service(node)[source]¶
Get a node’s event service.
- Parameters:
node – an Ironic node object.
- Raises:
RedfishConnectionError when it fails to connect to Redfish
- Raises:
RedfishError when the EventService is not registered in Redfish
- ironic.drivers.modules.redfish.utils.get_first_controller(storage)[source]¶
Get the first storage controller from a storage object.
- Parameters:
storage – a storage object
- Returns:
the first storage controller or None
- ironic.drivers.modules.redfish.utils.get_manager(node, system, manager_id=None)[source]¶
Get a node’s manager.
- Parameters:
system – a Sushy system object
manager_id – the id of the manager
- Returns:
a sushy Manager
- Raises:
RedfishError when the System doesn’t have Managers associated
- ironic.drivers.modules.redfish.utils.get_root_vendor(node)[source]¶
Get the BMC vendor from the Redfish Service Root.
- Parameters:
node – an Ironic node object
- Returns:
The Vendor string from the ServiceRoot, or None
- ironic.drivers.modules.redfish.utils.get_system(node)[source]¶
Get a Redfish System that represents a node.
- Parameters:
node – an Ironic node object
- Raises:
RedfishConnectionError when it fails to connect to Redfish
- Raises:
RedfishError if the System is not registered in Redfish
- ironic.drivers.modules.redfish.utils.get_system_collection(node)[source]¶
Get a Redfish System Collection that includes the node
- Parameters:
node – an Ironic node object
- Raises:
RedfishConnectionError when it fails to connect to Redfish
- Raises:
RedfishResourceNotFound if the Systems collection is not available in Redfish
- ironic.drivers.modules.redfish.utils.get_task_monitor(node, uri)[source]¶
Get a TaskMonitor for a node.
- Parameters:
node – an Ironic node object
uri – the URI of a TaskMonitor
- Raises:
RedfishConnectionError when it fails to connect to Redfish
- Raises:
RedfishResourceNotFound when the TaskMonitor is not available in Redfish
- Raises:
RedfishError on other Redfish errors
- ironic.drivers.modules.redfish.utils.get_update_service(node)[source]¶
Get a node’s update service.
- Parameters:
node – an Ironic node object
- Raises:
RedfishConnectionError when it fails to connect to Redfish
- Raises:
RedfishError when the UpdateService is not registered in Redfish
- ironic.drivers.modules.redfish.utils.parse_driver_info(node)[source]¶
Parse the information required for Ironic to connect to Redfish.
- Parameters:
node – an Ironic node object, or its dict representation as returned by
Node.as_dict(). Asynchronous callers have to pass the dict, since ORM objects are not safe to touch from an event loop.- Returns:
dictionary of parameters
- Raises:
InvalidParameterValue on malformed parameter(s)
- Raises:
MissingParameterValue on missing parameter(s)