Cache for nodes currently under introspection.
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 |
Store look up attribute for a node in the database.
Parameters: |
|
---|---|
Raises: | Error if attributes values are already in database |
Create one or several ports for this node.
A warning is issued if port already exists on a node.
Delete port.
Parameters: |
|
---|
Record status for this node.
Also deletes look up attributes from the cache.
Parameters: | error – error message |
---|
Construct NodeInfo from a database row.
Update node_info.state based on a fsm.process_event(event) call.
An AutomatonException triggers an error event. If strict, node_info.finished(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 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 |
Apply JSON patches to a node.
Refreshes cached node instance.
Parameters: |
|
---|---|
Raises: | ironicclient exceptions |
Apply JSON patches to a port.
Parameters: |
|
---|
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 a field on ironic node.
Parameters: |
|
---|---|
Raises: | KeyError if value is not found and default is not set |
Raises: | everything that patch() may raise |
Update capabilities on a node.
Parameters: |
|
---|
List all MAC’s that are on introspection right now.
Store information about a node under introspection.
All existing information about this node is dropped. Empty values are skipped.
Parameters: |
|
---|---|
Returns: | NodeInfo |
Clean up the cache.
Returns: | list of timed out node UUID’s |
---|
Create ironic node and cache it.
Parameters: |
|
---|---|
Returns: | 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 |
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: |
|
---|
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: |
|
---|
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: |
|
---|
Get node from cache.
Parameters: |
|
---|---|
Returns: | structure NodeInfo. |
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. |
Check if introspection is active for at least one node.
Decorate a node_info-function to release the node_info lock.
Assumes the first parameter of the function func is always a NodeInfo instance.
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 |
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: |
|
---|