Assertions in Automate Models

Automate has a facility to check if an object should be included in the workspace at runtime when the engine is fetching objects from the database. This is called Assertion.

It’s defined in the class schema via a type called “assertion”

Key points about assertions

  • Assertions can be added anywhere in the schema but they will be evaluated before we process any attributes, relationships or methods.
  • Can have 1 or more assertions in a class
  • Empty assertions are skipped
  • If an assertion fails because of a missing attribute or a invalid syntax the process aborts.
  • If all the defined assertions in an instance pass only then would it be included in the workspace.
  • Most of the assertions would use substitution to fetch attributes from an object in the workspace.


If you want to check the vm name use
${/} == 'Fred’

If you want to check an option from the Provisioning request

${/#miq_provision_request.get_option(:number_of_vms)} == 9

If you want to check if a value exists in a list
%w(${/} Hoppy).include? 'Fred’

Multiple conditions can be combined into a single assertion with an &&
{/#miq_provision_request.get_option(:number_of_vms)} == 9 && {/} == 'Fred’

One condition from multiple condition can evaluate to true with an ||

{/#miq_provision_request.get_option(:number_of_vms)} != 9 || {/} == 'Fred’


Some of the well know attributes during provisioning are
miq_provision_request contains the request object
miq_provision contains the request task object
vm contains the vm object being processed as part of a button, custom action, alert etc.

These attribute names can be used in substitution

The format for substitution is


Some of the well known objects are
/ the root object
. the current object (which can’t be used with assertions)

in some of the examples above you would see us using some basic ruby string methods to manipulate the data.