A state machine in ManageIQ or CloudForms can be used to describe a sequence of tasks executed during specific actions. A state machine offers logic for retries, error handling and can be easily created and optimised to accomplish complex tasks.
For quite some time there was a limitation in the state machine, if variables had to be carried between different stages (Bugzilla #1044175). It worked fine, until a state had to be re-executed (retry) which caused the “collect” feature to loose the data.
Since CloudForms 3.1 there are three new calls to store and retrieve data between different stages in a state machine:
1if $evm.state_var_exist?("test_data") 2 test_data = $evm.get_state_var("test_data") 3 # TODO: Something interesting 4else 5 # First time through, initialize data 6 $evm.set_state_var("test_data", 1) 7end
Found this here: http://talk.manageiq.org/t/how-to-maintain-stateful-data-through-state-retries/538