The ironic_inspector.node_cache Module

Cache for nodes currently under introspection.

class ironic_inspector.node_cache.NodeInfo(uuid, started_at=None, finished_at=None, error=None, node=None, ports=None, ironic=None, lock=None)[source]

Bases: object

Record about a node in the cache.

This class optionally allows to acquire a lock on a node. Note that the class instance itself is NOT thread-safe, you need to create a new instance for every thread.


Acquire a lock on the associated node.

Exits with success if a lock is already acquired using this NodeInfo object.

Parameters:blocking – if True, wait for lock to be acquired, otherwise return immediately.
Returns:boolean value, whether lock was acquired successfully
add_attribute(name, value, session=None)[source]

Store look up attribute for a node in the database.

  • name – attribute name
  • value – attribute value or list of possible values
  • session – optional existing database session

Error if attributes values are already in database


Node look up attributes as a dict.


Create one or several ports for this node.

A warning is issued if port already exists on a node.


Delete port.

Parameters:port – port object or its MAC

Record status for this node.

Also deletes look up attributes from the cache.

Parameters:error – error message
classmethod from_row(row, ironic=None, lock=None)[source]

Construct NodeInfo from a database row.


Get field value by ironic-style path (e.g. /extra/foo).

Parameters:path – path to a field
Returns:field value
Raises:KeyError if field was not found

Clear all cached info, so that it’s reloaded next time.


Ironic client instance.


Get Ironic node object associated with the cached node record.


Node introspection options as a dict.


Apply JSON patches to a node.

Refreshes cached node instance.

Parameters:patches – JSON patches to apply
Raises:ironicclient exceptions
patch_port(port, patches)[source]

Apply JSON patches to a port.

  • port – port object or its MAC
  • patches – JSON patches to apply

Get Ironic port objects associated with the cached node record.

This value is cached as well, use invalidate_cache() to clean.

Returns:dict MAC -> port object

Release a lock on a node.

Does nothing if lock was not acquired using this NodeInfo object.

replace_field(path, func, **kwargs)[source]

Replace a field on ironic node.

  • path – path to a field as used by the ironic client
  • func – function accepting an old value and returning a new one
  • kwargs – if ‘default’ value is passed here, it will be used when no existing value is found.

KeyError if value is not found and default is not set


everything that patch() may raise

set_option(name, value)[source]

Set an option for a node.


Update capabilities on a node.

Parameters:props – capabilities to update

Update properties on a node.

Parameters:props – properties to update

List all MAC’s that are on introspection right now.

ironic_inspector.node_cache.add_node(uuid, **attributes)[source]

Store information about a node under introspection.

All existing information about this node is dropped. Empty values are skipped.

  • uuid – Ironic node UUID
  • attributes – attributes known about this node (like macs, BMC etc); also ironic client instance may be passed under ‘ironic’



Clean up the cache.

  • Finish introspection for timed out nodes.
  • Drop outdated node status information.
Returns:list of timed out node UUID’s
ironic_inspector.node_cache.create_node(driver, ironic=None, **attributes)[source]

Create ironic node and cache it.

  • Create new node in ironic.
  • Cache it in inspector.
  • driver – driver for Ironic node.
  • ironic – ronic client instance.
  • attributes – dict, additional keyword arguments to pass to the ironic client on node creation.

NodeInfo, or None in case error happened.


Delete nodes which don’t exist in Ironic node UUIDs.

Parameters:uuids – Ironic node UUIDs

Find node in cache.

This function acquires a lock on a node.

Parameters:attributes – attributes known about this node (like macs, BMC etc) also ironic client instance may be passed under ‘ironic’
Returns:structure NodeInfo with attributes uuid and created_at
Raises:Error if node is not found
ironic_inspector.node_cache.get_node(uuid, ironic=None, locked=False)[source]

Get node from cache by it’s UUID.

  • uuid – node UUID.
  • ironic – optional ironic client instance
  • locked – if True, get a lock on node before fetching its data

structure NodeInfo.


Check if introspection is active for at least one node.

Previous topic

The ironic_inspector.main Module

Next topic

The ironic_inspector.plugins.base Module

Project Source

This Page