ironic.common.driver_factory module

class ironic.common.driver_factory.BaseDriverFactory[source]

Bases: object

Discover, load and manage the drivers available.

This is subclassed to load both main drivers and extra interfaces.

get_driver(name)[source]
items()[source]

Iterator over pairs (name, instance).

property names

The list of driver names available.

class ironic.common.driver_factory.HardwareTypesFactory[source]

Bases: BaseDriverFactory

class ironic.common.driver_factory.InterfaceFactory[source]

Bases: BaseDriverFactory

class ironic.common.driver_factory.NetworkInterfaceFactory

Bases: InterfaceFactory

class ironic.common.driver_factory.StorageInterfaceFactory

Bases: InterfaceFactory

ironic.common.driver_factory.all_interfaces()[source]

Get all interfaces for all interface types.

Returns:

Dictionary mapping interface type to dictionary mapping interface name to interface object.

ironic.common.driver_factory.build_driver_for_task(task)[source]

Builds a composable driver for a given task.

Starts with a BareDriver object, and attaches implementations of the various driver interfaces to it. They come from separate driver factories and are configurable via the database.

Parameters:

task – The task containing the node to build a driver for.

Returns:

A driver object for the task.

Raises:

DriverNotFound if node.driver could not be found in the “ironic.hardware.types” namespaces.

Raises:

InterfaceNotFoundInEntrypoint if some node interfaces are set to invalid or unsupported values.

Raises:

IncompatibleInterface the requested implementation is not compatible with it with the hardware type.

ironic.common.driver_factory.check_and_update_node_interfaces(node, hw_type=None)[source]

Ensure that node interfaces (e.g. for creation or updating) are valid.

Updates (but doesn’t save to the database) hardware interfaces with calculated defaults, if they are not provided.

This function is run on node updating and creation, as well as each time a driver instance is built for a node.

Parameters:
  • node – node object to check and potentially update

  • hw_type – hardware type instance object; will be detected from node.driver if missing

Returns:

True if any changes were made to the node, otherwise False

Raises:

InterfaceNotFoundInEntrypoint on validation failure

Raises:

NoValidDefaultForInterface if the default value cannot be calculated and is not provided in the configuration

Raises:

DriverNotFound if the node’s hardware type is not found

ironic.common.driver_factory.default_interface(hw_type, interface_type, driver_name=None, node=None)[source]

Calculate and return the default interface implementation.

Finds the first implementation that is supported by the hardware type and is enabled in the configuration.

Parameters:
  • hw_type – hardware type instance object.

  • interface_type – type of the interface (e.g. ‘boot’).

  • driver_name – entrypoint name of the hw_type object. Is used for exception message.

  • node – the identifier of a node. If specified, is used for exception message.

Returns:

an entrypoint name of the calculated default implementation.

Raises:

InterfaceNotFoundInEntrypoint if the entry point was not found.

Raises:

NoValidDefaultForInterface if no default interface can be found.

ironic.common.driver_factory.enabled_supported_interfaces(hardware_type)[source]

Get usable interfaces for a given hardware type.

For a given hardware type, find the intersection of enabled and supported interfaces for each interface type. This is the set of interfaces that are usable for this hardware type.

Parameters:

hardware_type – The hardware type object to search.

Returns:

a dict mapping interface types to a list of enabled and supported interface names.

ironic.common.driver_factory.get_hardware_type(hardware_type)[source]

Get a hardware type instance by name.

Parameters:

hardware_type – the name of the hardware type to find

Returns:

An instance of ironic.drivers.hardware_type.AbstractHardwareType

Raises:

DriverNotFound if requested hardware type cannot be found

ironic.common.driver_factory.get_interface(hw_type, interface_type, interface_name)[source]

Get interface implementation instance.

For hardware types also validates compatibility.

Parameters:
  • hw_type – a hardware type instance.

  • interface_type – name of the interface type (e.g. ‘boot’).

  • interface_name – name of the interface implementation from an appropriate entry point (ironic.hardware.interfaces.<interface type>).

Returns:

instance of the requested interface implementation.

Raises:

InterfaceNotFoundInEntrypoint if the entry point was not found.

Raises:

IncompatibleInterface if hw_type is a hardware type and the requested implementation is not compatible with it.

ironic.common.driver_factory.hardware_types()[source]

Get all hardware types.

Returns:

Dictionary mapping hardware type name to hardware type object.

ironic.common.driver_factory.interfaces(interface_type)[source]

Get all interfaces for a given interface type.

Parameters:

interface_type – String, type of interface to fetch for.

Returns:

Dictionary mapping interface name to interface object.