Chapter 7. $evm and the Workspace

When we write automation scripts, we access the Automation Engine and all of its objects through a single $evm variable.1 This is sometimes referred to as the workspace.

As discussed in Chapter 6, the $evm variable is a DRb::DRbObject object representing a dRuby client connection back to the Automation Engine. The object at the dRuby server side of our $evm variable is an instance of an MiqAeService object, which contains over 40 methods. In practice we generally use only a few of these methods, most commonly:

$evm.current (this is equivalent to calling $evm.object(nil))

We will look at these methods in more detail in the next sections.


$evm.log is a simple method that we’ve used already. It writes a message to automation.log and accepts two arguments: a log level and the text string to write. The log level can be written as a Ruby symbol (e.g., :info, :warn), or as a text string (e.g., "info", "warn").


$evm.root, illustrated in Figure 7-1, is the method that returns to us the root object in the workspace (environment, variables, linked objects, etc.). This is the instance whose invocation took us into the Automation Engine. From $evm.root we can access other service model objects, such as $evm.root['vm'], $evm.root['user'], or $evm.root['miq_request'] (the actual objects available depend on the context of the Automate tasks that we are performing). ...

Get Mastering CloudForms Automation now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.