How to maintain stateful data through state retries?

I’m implementing a control policy that reacts to “VM settings change” events. It tracks changes of the VM ‘annotation’ (it corresponds to the “description” field in RHEV-M), parses it, then tags the VM accordingly. The problem I’m faced with is that reading the ‘annotation’ in response to the event, I get an out-to-date value. In fact the new value is available only after a while. From measurement I made, the delay varies from about 30 s to 5 minutes.

To circumvent the problem, I delay the reading of the annotation by managing a retry in my automaton, with a 6 minutes delay. I would like to improve the automaton by looping on shorter retries (say with e.g. 30 s delays) until I detect the change. This requires to retain the value of ‘annotation’ from a retry to the next, so that to compare them and detect the change. But I’m a newbie with ManageIQ, and I don’t know how to do it.

1 Like

See Persistent state data through retries here

  • 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)

Thanks, exactly what I need. I can now detect the change earlyer and more safely.

Is there somewhere some documentation on $evm?

I have read the “CloudForms Management Engine 5.3 Methods Available for Automation” document, but it does not say anything about it.