Chapter 27. Creating Provisioning Requests Programmatically
As we’ve seen, the most common way to provision a virtual machine is via the CloudForms WebUI (see Chapter 16). We click on Lifecycle → Provision VMs, complete the provisioning dialog, and a few minutes later our new virtual machine is ready.
There are times, however, when it is useful to be able to start the virtual machine provisioning process from an automation script, with no manual interaction. This then allows us to autoscale our virtual infrastructure, based on real-time or anticipated performance criteria. Perhaps we are an online retailer selling barbeques, for example. We could automatically monitor the short-range weather forecast via the API of a well-known weather website and scale out our online store servers if a period of fine weather is anticipated.
Making the Call
We can initiate the provisioning process programmatically by calling
$evm.execute to run the method
create_provision_request (see Chapter 7 for more information on these methods).
create_provision_request method takes a number of arguments, which correspond to the argument list for the original
EVMProvisionRequestEx SOAP API call. A typical call to provision a VM into RHEV might be:
# arg1 = version
# arg2 = templateFields
# arg3 = vmFields
# arg4 = requester