What data is loaded in the Manage IQ model and $evm.root variable


#1

In the process of reading the documentation, I came across a line about the contents of variable $evm.root. Why it does not contain all the data, but only a small part? When forming a virtual machine name I need to use a “Request ID”, but it is not available in the VM Naming class. Can I change the contents of the variable’s data?
Doc Link


#2

When an automate instance is instantiated the URL passed defines what objects that get loaded into the $evm.root object.

During VM naming you are either being passed provision request, task or template object. Here is an example line from the default naming method:

prov = $evm.root['miq_provision_request'] || $evm.root['miq_provision'] || $evm.root['miq_provision_request_template']

These objects have associations to other objects which are defined in the automate service models (“vmdb/lib/miq_automation_engine/service_models”) and can also be discovered through inspection of the objects through an automate script:

prov.associations.sort.each { |assc| $evm.log("info", "    Associations - #{assc}") }

In your case if you have a provision task (miq_provision object) and want to get to the request object to determine the ID you would do this:

prov.miq_request.id