Skip to content

Instantly share code, notes, and snippets.

@signal-09
Last active May 25, 2025 10:48
Show Gist options
  • Save signal-09/235784e20647a6481921946e0884b45b to your computer and use it in GitHub Desktop.
Save signal-09/235784e20647a6481921946e0884b45b to your computer and use it in GitHub Desktop.
Allowed and default values for ironic.conf interfaces

List allowed and default values for ironic.conf interfaces:

> cat ironic-conf-entry.py

#!/usr/bin/env python

import sys

from importlib.metadata import entry_points
from ironic.conf.default import driver_opts


def list_entry_point(entry_point):
    """
    Lists the available values for entry point
    """

    values = []
    for entry in entry_points(group=entry_point):
        try:
            values.append(entry.name)
        except Exception as e:
            print(f"Error loading entry point {entry}: {e}", file=sys.stderr)
            exit(1)
    return values


def enumerate_entry_point(arg):
    """
    Print entry point with available values (*=default)
    """

    if arg.startswith('default_'):
        arg = arg.replace('default_', 'enabled_')

    opt = next((opt for opt in driver_opts if opt.name == arg), None)
    if not opt:
        print(f"Option {arg} not found", file=sys.stderr)
        exit(1)

    # Translate ironic.conf item into setup.cfg entry_point
    args = arg.split('_')
    if args[-1] == 'interfaces':
        args = ['hardware', 'interfaces', args[-2]]
    elif args[-1] == 'types':
        args = args[1:]
    entry_point = 'ironic.' + '.'.join(args)

    list_values = list_entry_point(entry_point)
    defaults = opt.default or []

    print(f"{entry_point}:")
    for value in list_values:
        item = "*" if value in defaults else "-"
        print(f"{item} {value}")


if __name__ == "__main__":
    for arg in sys.argv[1:]:
        enumerate_entry_point(arg)

> ./ironic-conf-entry.py enabled_inspect_interfaces default_storage_interfaces enabled_boot_interfaces

ironic.hardware.interfaces.inspect:
- agent
- fake
- idrac-redfish
- ilo
- inspector
- irmc
* no-inspect
* redfish
ironic.hardware.interfaces.storage:
* cinder
- external
- fake
* noop
ironic.hardware.interfaces.boot:
- fake
- http
- http-ipxe
- idrac-redfish-virtual-media
- ilo-ipxe
- ilo-pxe
- ilo-uefi-https
- ilo-virtual-media
* ipxe
- irmc-pxe
- irmc-virtual-media
* pxe
- redfish-https
* redfish-virtual-media

Running the script inside Kolla Ansible installation:

> docker exec -i ironic_conductor /usr/bin/env python3 - $(awk '/^enabled_/{ print $1}' /etc/kolla/config/ironic.conf) <ironic-conf-entry.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment