ironic_inspector.node_cache
Module¶Cache for nodes currently under introspection.
ironic_inspector.node_cache.
NodeInfo
(uuid, version_id=None, state=None, started_at=None, finished_at=None, error=None, node=None, ports=None, ironic=None, manage_boot=True)[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_lock
(blocking=True)[source]¶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.
Parameters: |
|
---|
add_trait
(trait, ironic=None)[source]¶Add a trait to the node.
Parameters: |
|
---|
attributes
¶Node look up attributes as a dict.
create_ports
(ports, ironic=None)[source]¶Create one or several ports for this node.
Parameters: |
|
---|
delete_port
(port, ironic=None)[source]¶Delete port.
Parameters: |
|
---|
finished
(event, error=None)[source]¶Record status for this node and process a terminal transition.
Also deletes look up attributes from the cache.
Parameters: |
|
---|
fsm_event
(event, strict=False)[source]¶Update node_info.state based on a fsm.process_event(event) call.
An AutomatonException triggers an error event. If strict, node_info.finished(istate.Events.error, error=str(exc)) is called with the AutomatonException instance and a EventError raised.
Parameters: | event – an event to process by the fsm |
---|---|
Strict: | whether to fail the introspection upon an invalid event |
Raises: | NodeStateInvalidEvent |
get_by_path
(path)[source]¶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 |
ironic
¶Ironic client instance.
manage_boot
¶Whether to manage boot for this node.
options
¶Node introspection options as a dict.
patch
(patches, ironic=None, **kwargs)[source]¶Apply JSON patches to a node.
Refreshes cached node instance.
Parameters: |
|
---|---|
Raises: | ironicclient exceptions |
patch_port
(port, patches, ironic=None)[source]¶Apply JSON patches to a port.
Parameters: |
|
---|
ports
(ironic=None)[source]¶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_lock
()[source]¶Release a lock on a node.
Does nothing if lock was not acquired using this NodeInfo object.
remove_trait
(trait, ironic=None)[source]¶Remove a trait from the node.
Parameters: |
|
---|
replace_field
(path, func, **kwargs)[source]¶Replace a field on ironic node.
Parameters: |
|
---|---|
Raises: | KeyError if value is not found and default is not set |
Raises: | everything that patch() may raise |
state
¶State of the node_info object.
update_capabilities
(ironic=None, **caps)[source]¶Update capabilities on a node.
Parameters: |
|
---|
update_properties
(ironic=None, **props)[source]¶Update properties on a node.
Parameters: |
|
---|
version_id
¶Get the version id
ironic_inspector.node_cache.
active_macs
()[source]¶List all MAC’s that are on introspection right now.
ironic_inspector.node_cache.
add_node
(uuid, state, manage_boot=True, **attributes)[source]¶Store information about a node under introspection.
All existing information about this node is dropped. Empty values are skipped.
Parameters: |
|
---|---|
Returns: | NodeInfo |
ironic_inspector.node_cache.
clean_up
()[source]¶Clean up the cache.
Finish introspection for timed out nodes.
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.
Parameters: |
|
---|---|
Returns: | NodeInfo, or None in case error happened. |
ironic_inspector.node_cache.
delete_nodes_not_in_list
(uuids)[source]¶Delete nodes which don’t exist in Ironic node UUIDs.
Parameters: | uuids – Ironic node UUIDs |
---|
ironic_inspector.node_cache.
find_node
(**attributes)[source]¶Find node in cache.
Looks up a node based on attributes in a best-match fashion. 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 or multiple nodes match the attributes |
ironic_inspector.node_cache.
fsm_event_after
(event, strict=False)[source]¶Trigger an fsm event after the function execution.
It is assumed the first function arg of the decorated function is always a NodeInfo instance.
Parameters: |
|
---|
ironic_inspector.node_cache.
fsm_event_before
(event, strict=False)[source]¶Trigger an fsm event before the function execution.
It is assumed the first function arg of the decorated function is always a NodeInfo instance.
Parameters: |
|
---|
ironic_inspector.node_cache.
fsm_transition
(event, reentrant=True, **exc_kwargs)[source]¶Decorate a function to perform a (non-)reentrant transition.
If True, reentrant transition will be performed at the end of a function call. If False, the transition will be performed before the function call. The function is decorated with the triggers_fsm_error_transition decorator as well.
Parameters: |
|
---|
ironic_inspector.node_cache.
get_introspection_data
(node_id, processed=True)[source]¶Get introspection data for this node.
Parameters: |
|
---|---|
Returns: | A dictionary representation of intropsected data |
ironic_inspector.node_cache.
get_node
(node_id, ironic=None)[source]¶Get node from cache.
Parameters: |
|
---|---|
Returns: | structure NodeInfo. |
ironic_inspector.node_cache.
get_node_list
(ironic=None, marker=None, limit=None)[source]¶Get node list from the cache.
The list of the nodes is ordered based on the (started_at, uuid) attribute pair, newer items first.
Parameters: |
|
---|---|
Returns: | a list of NodeInfo instances. |
ironic_inspector.node_cache.
introspection_active
()[source]¶Check if introspection is active for at least one node.
ironic_inspector.node_cache.
record_node
(ironic=None, bmc_addresses=None, macs=None)[source]¶Create a cache record for a known active node.
Parameters: |
|
---|---|
Returns: | NodeInfo |
ironic_inspector.node_cache.
release_lock
(func)[source]¶Decorate a node_info-function to release the node_info lock.
Assumes the first parameter of the function func is always a NodeInfo instance.
ironic_inspector.node_cache.
start_introspection
(uuid, **kwargs)[source]¶Start the introspection of a node.
If a node_info record exists in the DB, a start transition is used rather than dropping the record in order to check for the start transition validity in particular node state.
Parameters: |
|
---|---|
Raises: | NodeStateInvalidEvent in case the start transition is invalid in the current node state |
Raises: | NodeStateRaceCondition if a mismatch was detected between the node_info cache and the DB |
Returns: | NodeInfo |
ironic_inspector.node_cache.
store_introspection_data
(node_id, introspection_data, processed=True)[source]¶Store introspection data for this node.
Parameters: |
|
---|
ironic_inspector.node_cache.
triggers_fsm_error_transition
(errors=(<type 'exceptions.Exception'>, ), no_errors=(<class 'ironic_inspector.utils.NodeStateInvalidEvent'>, <class 'ironic_inspector.utils.NodeStateRaceCondition'>))[source]¶Trigger an fsm error transition upon certain errors.
It is assumed the first function arg of the decorated function is always a NodeInfo instance.
Parameters: |
|
---|
Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.