Chapter 33. Creating a Service Catalog Item

In this chapter we’ll go through the steps involved in creating a service catalog item to provision a virtual machine into Red Hat Enterprise Virtualization (RHEV). We’ll create a service dialog that allows the user to specify a name for both the new virtual machine and the service, and specify the number of CPUs and memory size of the provisioned virtual machine from a drop-down list.


Although for this example we’ll be provisioning into RHEV, the same procedure can be used to create a service catalog item to provision into other providers.

The Service Dialog

We’re going to create a service dialog to prompt for the number of CPUs and the amount of memory for the new virtual machine. These two characteristics will be added to the provisioning task object for the new VM, and we know that such items are stored in the task object’s options hash for a provisioning operation. The CatalogItemInitialization state machine can handle the insertion of our dialog values into the options hash for us, as long as we name our dialog elements correctly.

Finding the Correct Element Names

We saw from Chapter 31 that CatalogItemInitialization recognizes and special-cases some element names, including vm_name and service_name, so we can create two of our elements with these names. If this is all we wish to prompt for, then we can move straight on to creating the service dialog.

For our use case, however, we are also prompting for number of CPUs and ...

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.