ironic.common.redfish.client module

Async Redfish client - main entry point.

class ironic.common.redfish.client.AsyncRedfishClient(base_url, username=None, password=None, verify=True, auth_type='auto', root_prefix=None, default_request_timeout=60, response_callback=None, server_side_retries=3, server_side_retries_delay=2, connect_timeout=None)[source]

Bases: object

Async Redfish client.

Main entry point for async Redfish BMC communication. Provides async methods to fetch and interact with Redfish resources.

This client uses httpx for async HTTP operations and the lightweight AsyncResource class for dynamic resource access.

Usage:

async with AsyncRedfishClient(
    'https://bmc.example.com',
    username='admin',
    password='password',
    verify=True,
    auth_type='auto'
) as client:
    # Get collections
    systems = await client.collection('Systems')
    for system in await systems.get_all():
        print(system.field('Name'))

    # Get the only system of a single-node server
    system = await systems.one()
    print(system.field('Manufacturer'))
    print(system.field('PowerState'))

    # Get resources by name
    update_service = await client.resource('UpdateService')
    session_service = await client.resource('SessionService')

    # Get resources by absolute path
    system = await client.resource('/redfish/v1/Systems/1')
    bios = await client.resource('/redfish/v1/Systems/1/Bios')
async close()[source]

Close the client and clean up resources.

Closes the authentication session and HTTP connection.

async collection(name)[source]

Get a Redfish collection by name.

Parameters:

name – Collection name (e.g., ‘Systems’, ‘Managers’, ‘Chassis’).

Returns:

AsyncResourceCollection with all members.

Raises:

ConnectionError on HTTP failures.

Raises:

ResourceNotFoundError if collection not found.

async get_task_monitor(task_monitor_uri)[source]

Pick an operation back up from its task monitor URI.

This is how an operation outlives the process that started it: the URI is all that has to be kept, and polling resumes from here. The monitor is refreshed before it is returned, so its state reflects the BMC rather than an assumption. Mirrors sushy.Sushy.get_task_monitor.

Parameters:

task_monitor_uri – URI of the task monitor, as recorded when the operation was started.

Returns:

an AsyncTaskMonitor reflecting the current state.

Raises:

ConnectionError on request failures.

Raises:

RuntimeError if client is not initialized.

property redfish_version

Get the Redfish version.

DSP0266 requires the service root to carry RedfishVersion, but a BMC that leaves it out gets None here rather than an error, which is what sushy does as well: everything else about such a BMC usually works, and refusing to talk to it over a missing version string would be a steep price. Callers that branch on the version have to cope with not knowing it.

Returns:

Redfish version string, or None if the service root does not report one.

Raises:

RuntimeError if client is not initialized.

async resource(name)[source]

Get a Redfish resource by name or path.

Parameters:

name – Resource name (e.g., ‘UpdateService’, ‘SessionService’) or absolute path (e.g., ‘/redfish/v1/Systems/1’).

Returns:

AsyncResource for the requested resource.

Raises:

ResourceNotFoundError if resource not found.

Raises:

ConnectionError on HTTP failures.

property root

Get the root service resource.

Returns:

AsyncResource for the root service.

Raises:

RuntimeError if client is not initialized.

async task_monitor(response, target_uri)[source]

Build a task monitor for an operation that answered 202.

The monitor polls over this client’s connector, so it keeps the session, timeouts and retry settings the operation itself ran with. Without this, a caller would have to reach for the client’s private connector to build one.

Parameters:
  • response – the httpx.Response the operation returned.

  • target_uri – URI the asynchronous operation was sent to, used to resolve a relative task URI in the response body.

Returns:

an AsyncTaskMonitor for the operation.

Raises:

MissingHeaderError if the response carries neither a Location header nor a task URI in its body.

Raises:

RuntimeError if client is not initialized.