Many of my customer with whom i directly interact has been asking this feature from quite some time , few of them says that T-shirt sized based offering matches of what hyper scalars offer, so with the release of vCloud Director 9.7, we can now control the resource allocation and the VM placement much better by using compute policies. As you know traditionally vCloud Director has two type of scope one is Provider VDC and another one Organisation VDC, similarly based on the scope and the function, there are two types of compute policies – provider virtual data center (VDC) compute policies and VDC compute policies.
In this post i will discusses VDC compute Policies and how you can leverage VDC compute policies to offer T-Shirt size option to your Best in class VMware vCloud director based cloud.
Provider VDC Compute Policies
Provider VDC compute policies applies to provider VDC level. A provider VDC compute policy defines VM-host affinity rules that decides the placement of tenant workloads. as you know Provider VDC level configuration is not visible to Tenant users and same applies to PVDC policies.
VDC Compute Policies
VDC compute policies control the compute characteristics of a VM at the organization VDC level and using VDC compute policies. A VDC compute policy groups attributes that define the compute resource allocation for VMs within an organization VDC. The compute resource allocation includes CPU and memory allocation, reservations, limits, and shares. here is the sample configuration:
“description”:”2vCPU and 2 GB RAM”,
“config1″:”value1” – Key Value Pair
For More detailed description of there parameters , please refer here we will going to create few policies which will reflect your cloud’s T-Shirt sizing options for your tenants/customers.
Step-1: Create VDC Compute Policy
Let’s first Create a VDC compute policy, which should be matching to your T-Shirt Sizes that you want to offer , for example here i am creating four T-shirt sizes as below:
- X1 – 1 vCPU and 1024 MB Memory
- X2 – 2 vCPU and 2048 MB Memory
- X3 – 4 vCPU and 4096 MB Memory
- X4 – 8 vCPU and 8192 MB Memory
Make an API call with below content to create 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”:”8vCPU & 8GB RAM”,
- Here is my one of four API call. similarly you make other 3 calls for other three T-Shirt sizes.
- After each successful API call , you will get a return like above , here note down the “id” of each T-Shirt size policy , which we will use in subsequent steps. you can also see the compatibility of policy for VDC type.
- X8 – “id”: “urn:vcloud:vdcComputePolicy:b209edac-10fc-455e-8cbc-2d720a67e812”
- X4 – “id”: “urn:vcloud:vdcComputePolicy:69548b08-c9ff-411a-a7d1-f81996b9a4bf”
- X2 – “id”: “urn:vcloud:vdcComputePolicy:c71f0a47-d3c5-49fc-9e7e-df6930660817”
- X1 – “id”: “urn:vcloud:vdcComputePolicy:1c87f0c1-ffa4-41d8-ac5b-9ec3fab211bb”
Step-2: Get VDC Id to Assign VDC Compute Policies
Make an API call to your vCloud Director with below content to get the VDC ID:
- Get: https://<vcd-hostname>/api/query?type=adminOrgVdc
- Use Header as in below screenshot:
- and write down the VDC ID ( as highlighted in above screenshot in return body) , this we will use in other calls. you can also get VDC id from vCD GUI.
Step-3: Get current Compute Policies Applied to the VDC
Using VDC identifier from step2 , Get the current compute policies applied on this VDC using below API Call:
- Get: https://<vcd-hostname>/api/admin/vdc/443e0c43-7a6d-43f0-9d16-9d160e651fa8/computePolicies
- 443e0c43-7a6d-43f0-9d16-9d160e651fa8 – got from step2
- use Header as per below image
- Since this is an Get call , so no body.
- Copy the output of this Get and paste in to a new postman window to make a new API Call as this is going to be body for the our next API call.
Step-4: Publish the T-Shirt Size Compute Policies to VDC
In this step we will publish the policies to VDC , let’s create a new API call with below content:
- PUT: https://<vcd-hostname>/api/admin/vdc/443e0c43-7a6d-43f0-9d16-9d160e651fa8/computePolicies
- Header as below image: ensure correct “Content-Type” – application/vnd.vmware.vcloud.vdcComputePolicyReferences+xml
- paste the output of step3 in the body
- copy full line starting with <VdcComputePolicyReference ******** /> and paste number of times as your policies. in my case i have four policies , i pasted four times.
- in each line (underline RED) replace policy identifier with identifier we captured in step1 (compute policy identifier).
- Here is API call which will associate VDC compute policies to your Tenant’s VDC.
Now go back and login to tenant portal and click on “New VM” and see under compute policy , now you can see all your compute policy which is nothing but your T-shirt size virtual machine offerings..
Once tenant chooses a policy , he can’t choose CPU and Memory parameters..
Step-5: Create a Default Policy for VDC
With Every VDC , there is default policy which is auto generated and has empty parameters. Now since we have published our four sizing policies to this VDC, we will make one of them default policy of the VDC. This means that if user does not provide any policy during VM creation then the default policy of the vDC would be applied on the VM.
- 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 within <DefaultComputePolicy section , change the id of the Policy.
Step-6: Delete System Default Policy
There is “System Default” policy which when selected , give options like “Pre-defined Sizing Options” and “Custom Sizing Options” , and will allow your tenants to define sizes of their choice , to restrict this , we need to un-publish this policy from VDC.
To disable this policy , follow the procedure in Step-5
- Query VDC and copy the return Body
- Make a PUT and inside body paste body copied in above step and remove the “system Default” policy , only keep policy , which you want to offer for this particular VDC.
- After above call if you see , there is no “System Default” policy.
NOTE – Ensure that non of the VM and catalogs are associated with this “System Default” policy , ideally after creation of VDC , you must create and assign policy before these policies are consumed by VM/catalogs.
Extra-Step: Update the Policy
if you want to update the policy make an “PUT” api call to policy with updated body content , see below my policy update API call for reference.
Compute policies cannot be edited except for name and description ,I hope this helps providers now offer various T-Shirt size options to their customers.