ironic_inspector.utils module

class ironic_inspector.utils.DeferredBasicAuthMiddleware(app, auth_file)[source]

Bases: object

Middleware which sets X-Identity-Status header based on authentication

exception ironic_inspector.utils.Error(msg, code=400, log_level='error', **kwargs)[source]

Bases: Exception

Inspector exception.

exception ironic_inspector.utils.IntrospectionDataNotFound(msg, code=404, **kwargs)[source]

Bases: NotFoundInCacheError

Introspection data not found.

exception ironic_inspector.utils.IntrospectionDataStoreDisabled(msg, code=400, log_level='error', **kwargs)[source]

Bases: Error

Introspection data store is disabled.

exception ironic_inspector.utils.NoAvailableConductor(msg, **kwargs)[source]

Bases: Error

No available conductor in the service group.

exception ironic_inspector.utils.NodeNotFoundInDBError(**kwargs)[source]

Bases: Error

The node was not found in the database.

exception ironic_inspector.utils.NodeStateInvalidEvent(msg, code=400, log_level='error', **kwargs)[source]

Bases: Error

Invalid event attempted.

exception ironic_inspector.utils.NodeStateRaceCondition(*args, **kwargs)[source]

Bases: Error

State mismatch between the DB and a node_info.

exception ironic_inspector.utils.NotFoundInCacheError(msg, code=404, **kwargs)[source]

Bases: Error

Exception when node was not found in cache during processing.

class ironic_inspector.utils.ProcessingLoggerAdapter(logger, extra=None)[source]

Bases: KeywordArgumentAdapter

process(msg, kwargs)[source]

Process the logging message and keyword arguments passed in to a logging call to insert contextual information. You can either manipulate the message itself, the keyword args or both. Return the message and kwargs modified (or not) to suit your needs.

Normally, you’ll only need to override this one method in a LoggerAdapter subclass for your specific needs.

exception ironic_inspector.utils.RuleNotFoundError(uuid, *args, **kwargs)[source]

Bases: Error

The requested rule was not found.

exception ironic_inspector.utils.RuleUUIDExistError(uuid, *args, **kwargs)[source]

Bases: Error

Rule requested already exists in the database.

ironic_inspector.utils.add_auth_middleware(app)[source]

Add authentication middleware to Flask application.

Parameters:

app – application.

ironic_inspector.utils.add_basic_auth_middleware(app)[source]

Add HTTP Basic authentication middleware to Flask application.

Parameters:

app – application.

ironic_inspector.utils.add_cors_middleware(app)[source]

Create a CORS wrapper

Attach ironic-inspector-specific defaults that must be included in all CORS responses.

Parameters:

app – application

ironic_inspector.utils.add_healthcheck_middleware(app)[source]

Add healthcheck middleware

Parameters:

app – application

ironic_inspector.utils.check_auth(request, rule=None, target=None)[source]

Check authentication on request.

Parameters:
  • request – Flask request

  • rule – policy rule to check the request against

  • target – dict-like structure to check rule against

Raises:

utils.Error if access is denied

ironic_inspector.utils.executor()[source]

Return the current futures executor.

ironic_inspector.utils.getProcessingLogger(name)[source]
ironic_inspector.utils.get_inventory(data, node_info=None)[source]

Get and validate the hardware inventory from introspection data.

ironic_inspector.utils.get_ipmi_address_from_data(introspection_data)[source]
ironic_inspector.utils.get_ipmi_v6address_from_data(introspection_data)[source]
ironic_inspector.utils.get_pxe_mac(introspection_data)[source]
ironic_inspector.utils.get_valid_macs(data)[source]

Get a list of valid MAC’s from the introspection data.

ironic_inspector.utils.iso_timestamp(timestamp=None, tz=datetime.timezone.utc)[source]

Return an ISO8601-formatted timestamp (tz: UTC) or None.

Parameters:
  • timestamp – such as time.time() or None

  • tz – timezone

Returns:

an ISO8601-formatted timestamp, or None

ironic_inspector.utils.processing_logger_prefix(data=None, node_info=None)[source]

Calculate prefix for logging.

Tries to use: * node UUID, node._state * node PXE MAC, * node BMC address

Parameters:
  • data – introspection data

  • node_info – NodeInfo or ironic node object

Returns:

logging prefix as a string