Chapter 22. Customizing Virtual Machine Provisioning
In Chapter 21 we saw how the VM provision state machine was designed to be customizable. In this chapter we’ll go through the steps involved in copying and extending the state machine to add a second hard disk to the virtual machine. This is a simple example but a typical real-world requirement.
We are using an RHEV provider with our CloudForms installation, and we can successfully provision virtual machines using the Native Clone provision type from fully configured RHEV templates. The templates all have a single 30 GB thin-provisioned hard drive.
We would like all virtual machines provisioned from these templates to have a second 30 GB hard drive added automatically during provisioning. The second drive should be created in the same RHEV storage domain as the first drive (i.e., not hardcoded to a storage domain).
Edit the VMProvision_VM state machine to add two new states to perform the task. We’ll add the second disk using the RHEV RESTful API, using credentials stored for the provider. We can achieve this in a series of steps.
Step 1: Extend the State Machine
We’re going to extend the VM provisioning state machine by adding states, but we cannot do this to the state machine in the locked ManageIQ domain.
Copy the state machine
The first thing that we must do is copy the ManageIQ/Infrastructure/VM/Provisioning/StateMachines/VMProvision_VM/Provision VM from Template (template) state machine ...