*Note that the credentials used in these API calls should have either Administrator or Automator permissions.
This tutorial provides an example of how to deploy VMs from a Bash command prompt. It also makes use of grep in order to filter out the API's response and only return relevant information. When you follow these steps, remember to replace the username, password, and server IP address in each step, as well as the UUIDs that are obtained in each step.
1) Find template you want to clone into new VMs. Note the “uuid” property (bolded). Note that some earlier versions of Operations Manager have different conventions for how the “name” property is set (e.g. They might start with "VirtualMachine::")
- You can use “grep” if you know the display name of the template that you want to use to avoid scanning through a lot of XML
- In this example, this is a discovered VCenter VM template. You can see the memory capacity (vMemSize) and the number of configured VCPUs (numVCPUs).
vmturbo:~ # curl -X GET http://username:firstname.lastname@example.org/vmturbo/api/templates | grep "TMP-linux"
<TopologyElement accessSpeedConsumed="0.0" cpuConsumedFactor="0.5" creationClassName="VirtualMachineProfile" displayName="10.10.10.2::TMP-linux" ioThroughputConsumed="0.0" memConsumedFactor="0.75" model="" name="vm-803" networkThroughputConsumed="0.0" numVCPUs="1" price="0.0" storageConsumedFactor="1.0" uuid="T421ebff3-350d-0cc9-4eb2-02982a8059c6" vMemSize="3072.0" vStorageSize="0" vendor="”/>
2) Get the deployment profiles that are associated with it. Note the “uuid” property (italicized and underlined), shown below.
- You can use “grep” to find only deployment profiles that are related to the template you chose below.
vmturbo:~ # curl -X GET http://username:email@example.com/vmturbo/api/deploymentprofiles | grep -B3 -A1 "T421ebff3-350d-0cc9-4eb2-02982a8059c6"
<TopologyElement creationClassName="ServiceCatalogItem" discovered="true" displayName="DEP-linux" name="linux" uuid="_kvPKccVrEeOOn73Mmc1_Hg">
<TopologyRelationship childrenUuids="T421ebff3-350d-0cc9-4eb2-02982a8059c6" name="RelatedProfiles"/>
3) Request recommendations for where you should deploy the VMs that you want. The “deploy item” that is returned will be needed in the next two steps.
- The templateName is the uuid from step 1 (bolded)
- The serviceName is the uuid from step 2 (italicized and underlined)
- The count is the number of VMs you would like to deploy (maximum is 25). In this example, we chose 2.
- Although the API will return immediately, the server internally can take 30-60 seconds to make these decisions, depending on how many VMs you are attempting to place.
vmturbo:~ # curl -X POST http://username:firstname.lastname@example.org/vmturbo/api/markets/Market/virtualmachines/test_VM_deploy -d "templateName=T421ebff3-350d-0cc9-4eb2-02982a8059c6&serviceName=_kvPKccVrEeOOn73Mmc1_Hg&count=2"
4) Review the Deploy Recommendations to confirm the host and datastore where the VMs are being placed.
- This step is optional, and can be skipped if you trust the automated placement decisions of VMTurbo Operations Manager.
vmturbo:~ # curl -X GET http://username:email@example.com/vmturbo/api/deployitems/_kKi8ccWAEeOOn73Mmc1_Hg
<?xml version="1.0" encoding="ISO-8859-1"?><ActionItems>
<ActionItem datastore="Quantastor583:ESXDC2DS2" datastoreState="Recommended" host="hp-esx15.corp.vmturbo.com" hostState="Pending Accept" name="vm_Test_deploy_0" status="OK" user=“username" vdc="" vdcState=""/>
<ActionItem datastore="Quantastor583:ESXDC2DS2" datastoreState="Recommended" host="hp-esx17.corp.vmturbo.com" hostState="Pending Accept" name="vm_Test_deploy_1" status="OK" user=“username" vdc="" vdcState=""/>
5) Accept the recommendations to execute this deployment. If you choose not to use these recommendations, you can also reject them by specifying "action=reject" instead of accept.
vmturbo:~ # curl -X POST http://username:firstname.lastname@example.org/vmturbo/api/deployitems/_kKi8ccWAEeOOn73Mmc1_Hg -d "action=accept"
You will now see these VMs being deployed in the hypervisor where this template was discovered from. First the template will be cloned and then the VMs will be powered on. After they are finished cloning, it can take 10-20 minutes for them to fully display in the VMTurbo Operations Manager interface.