As you know vCloud Director 9.7 comes with a default compute policy for VDC , that does provide options for custom vm sizing and this can go out of control from provides point of view as tenant can try to deploy any size of VM which might impact many things and to control this behaviour we need to limit the VM’s maximum number of vCPU and vRAM of a customer VDC can have and with vCloud Director 9.7, this is now easily can be achieved using few API calls , here is the step by step procedure to set the maximum limits:
NOTE – This gets applied on the policy like default policy which has cpuCount and memory fields as null values.
Step-1 – Create a MAX compute Policy
Let’s suppose we want to setup MAX vCPU = 32 and MAX RAM = 32 GB , so to setup this max , let’s first create a compute policy.
Procedure: Make an API call with below content to create MAX VDC compute policy:
- POST: https://<vcd-hostname>/cloudapi/1.0.0/vdcComputePolicies
- Payload: ( i kept payload short , you can create based on sample section)
“description”:”Max sized vm policy”,
- Post to create compute Policy
Step-2: Create a Default Policy for VDC
Publish MAX policy to VDC.
- Get VDC using below API Call
- Take the entire output of above GET call and put in to body of new call with PUT as below screenshot and inside body add below line after DefaultComputePolicy element
- <MaxComputePolicy href=”https://vcd-01b.corp.local/cloudapi/1.0.0/vdcComputePolicies/urn:vcloud:vdcComputePolicy:cd38493a-2254-446e-b782-168982c980e1” id=”urn:vcloud:vdcComputePolicy:cd38493a-2254-446e-b782-168982c980e1” name=”max-policy” type=”application/json”/>
- Highlighted is policy ID , that we captured in Step-1 and update in your API call.
- Header of the above API call is as below:
Now if you go back and try to provision a virtual machine with more than 32GB memory , it will through the error as below:
Simple two API calls , will complete the much awaited feature now.