Chapter 6. Peeping Under the Hood

We’ve now worked with an Automation Engine object that represents a virtual machine, and we’ve called one of its methods to add a custom attribute to the VM.

In this chapter we’ll take a deeper look at these Automation Engine objects and at some of the technology that exists behind the scenes in Rails when we run automation scripts. It is useful background information but can be skipped on first read if required.

A Little Rails Knowledge (Goes a Long Way)

Firstly, by way of reassurance…

We do not need to know Ruby on Rails to write CloudForms Automation scripts.

It can, however, be useful to have an appreciation of Rails models, and how the Automation Engine encapsulates these as Ruby objects that we can program with. The objects represent the things that we are typically interested in when we write automation code, such as VMs, clusters, guest applications, or even provisioning requests.

Plain Old Ruby

The Ruby scripts that we write are just plain Ruby 2.2, although the Active Support core extensions to Ruby are available if we wish to use them.

Note

The Active Support extensions can make our lives easier. For example, rather than adding math to our Automation script to work out the number of seconds in a two-month time span (perhaps to specify a VM retirement period), we can just specify 2.months.

Our automation scripts access Ruby objects, made available to us by the Automation Engine via the $evm variable ($evm is described in more detail ...

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.