The ironic.common.fsm Module

class ironic.common.fsm.FSM[source]

Bases: automaton.machines.FiniteMachine

An ironic state-machine class with some ironic specific additions.

add_state(*args, **kwargs)[source]

Adds a given state to the state machine.

Parameters:
  • stable – Use this to specify that this state is a stable/passive state. A state must have been previously defined as ‘stable’ before it can be used as a ‘target’
  • target – The target state for ‘state’ to go to. Before a state can be used as a target it must have been previously added and specified as ‘stable’

Further arguments are interpreted as for parent method add_state.

add_transition(*args, **kwargs)

Adds an allowed transition from start -> end for the given event.

Parameters:
  • start – starting state
  • end – ending state
  • event – event that causes start state to transition to end state
  • replace – replace existing event instead of raising a Duplicate exception when the transition already exists.
initialize(*args, **kwargs)[source]

Initialize the FSM.

Parameters:
  • start_state – the FSM is initialized to start from this state
  • target_state – if specified, the FSM is initialized to this target state. Otherwise use the default target state
is_stable(state)[source]

Is the state stable?

Parameters:state – the state of interest
Raises:InvalidState if the state is invalid
Returns:True if it is a stable state; False otherwise
process_event(*args, **kwargs)[source]

process the event.

Parameters:
  • event – the event to be processed
  • target_state – if specified, the ‘final’ target state for the event. Otherwise, use the default target state

Project Source

This Page