OpenStack Ironic Client Library

6.0.0 · active · verified Thu Apr 16

python-ironicclient is the official Python client library for the OpenStack Ironic API, which provides bare metal provisioning services. It offers a Python API for programmatic interaction and integrates with the `openstack baremetal` command-line interface. The current stable version is 6.0.0, actively maintained within the OpenStack project, with releases generally aligned with the OpenStack release cycle (typically every six months).

Common errors

Warnings

Install

Imports

Quickstart

Initializes the Ironic client using an authentication token and the Ironic API endpoint, then attempts to list all bare metal nodes. Environment variables are used for sensitive credentials.

import os
from ironicclient import client

# Configure with actual Ironic API endpoint and Keystone authentication token
IRONIC_URL = os.environ.get('IRONIC_URL', 'http://localhost:6385/')
OS_AUTH_TOKEN = os.environ.get('OS_AUTH_TOKEN', 'YOUR_AUTH_TOKEN_HERE')

if not OS_AUTH_TOKEN or 'YOUR_AUTH_TOKEN_HERE' in OS_AUTH_TOKEN:
    print("Warning: OS_AUTH_TOKEN not set or is a placeholder. API calls may fail.")

kwargs = {
    'os_auth_token': OS_AUTH_TOKEN,
    'ironic_url': IRONIC_URL
}

try:
    # API version 1 is common, newer microversions can be specified if needed
    ironic = client.get_client(1, **kwargs)
    nodes = ironic.node.list()
    print(f"Successfully connected to Ironic. Found {len(nodes)} nodes.")
    for node in nodes:
        print(f" - Node UUID: {node.uuid}, Name: {node.name}")
except Exception as e:
    print(f"Error connecting to Ironic or listing nodes: {e}")
    print("Please ensure IRONIC_URL and OS_AUTH_TOKEN are correctly configured and Ironic API is reachable.")

view raw JSON →