Preserve data in ManageIQ state machines

Posted by Christian Jung on Mon, Mar 30, 2015
In CloudForms, IT, ManageIQ

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:

  • state_var_exist?(var_name)

  • set_state_var(var_name, value)

  • get_state_var(var_name)


    if $evm.state_var_exist?("test_data")
          test_data = $evm.get_state_var("test_data")
          # TODO: Something interesting
          # First time through, initialize data
          $evm.set_state_var("test_data", 1)

Found this here: