In part 4 and part 5, I covered a lot of ground on how to work with vcac virtual machine objects, such as getting property values and discovering relationships to other entities. This post will continue exploring vcac virtual machines and will focus on custom properties.
Custom Properties are key/value pairs of data that are associated with the virtual machine. There are many default/built-in custom properties that provide the compute cluster, storage cluster, disk, cpu, network information and much more.
It’s also possible to create your own custom properties and associate these with your virtual machine deployments. This allows great flexibility as you can apply any key/value to your deployments and use this information in your workflows. An example might be to set a site identifier that associates the virtual machine to a specific site.
VMware provides a Custom Properties Reference, which details all the built-in custom properties that are available.
All code that I have provided or talked about in this post can be downloaded as a vRO package for your consumption here.
Retrieving Custom Properties Assigned to a Virtual Machine
There are two main ways to retrieve the custom properties that have been associated with a virtual machine deployment. The first, is during the build process, where an Event Broker Subscription is used to call a vRO workflow, to perform some task. The second, is by reading the custom properties from the vcac database (via the entities) for those that are related to the virtual machine.
Here is an example of a default set of Custom Properties associated with a deployed virtual machine:
__api.request.callback.service.id: 8596e261-d50d-4139-9de4-0785e65aa56e __api.request.id: f4c168ec-5ce6-4afb-b985-a4dc2a46fee7 __Cafe.Request.BlueprintType: 1 __Cafe.Root.Request.Id: 681db0aa-3a52-47dc-9b62-8a6f5262bd8c __iaas_request_binding_id: f8832686-273b-491e-bfa5-3a42b7c060d0 __InterfaceType: vSphere __Legacy.Workflow.ImpersonatingUser: __Legacy.Workflow.User: email@example.com __ovf_use_proxy: False __ovfAuthNeeded: False __request_reason: __reservationPolicyID: 2a539d78-c6a8-446b-b9d7-a72d04fbbdda __trace_id: CmGY5ZR3 __VirtualMachine.Allocation.InitialMachineState: SubmittingRequest __VirtualMachine.ProvisioningWorkflowName: BasicVmWorkflow _number_of_instances: 1 Cafe.Shim.VirtualMachine.TotalStorageSize: 1 trace_id: CmGY5ZR3 VirtualMachine.Admin.AgentID: f8611a42-2d9a-8544-df8e-bf4e5291bd37 VirtualMachine.Admin.Hostname: SITEA-CLS-CLOUD-01 VirtualMachine.Admin.ThinProvision: True VirtualMachine.Admin.TotalDiskUsage: 1024 VirtualMachine.Admin.UUID: 501a484f-d95c-0cb8-42b6-cf174af3db2d VirtualMachine.Cafe.Blueprint.Component.Cluster.Index: 0 VirtualMachine.Cafe.Blueprint.Component.Id: vm1 VirtualMachine.Cafe.Blueprint.Component.TypeId: Infrastructure.CatalogItem.Machine.Virtual.vSphere VirtualMachine.Cafe.Blueprint.Id: VM_NoDisk VirtualMachine.Cafe.Blueprint.Name: VM_NoDisk VirtualMachine.CPU.Count: 1 VirtualMachine.Disk0.DeviceID: SCSI (0:0) VirtualMachine.Disk0.ExternalID: 6000C296-9f11-58ec-31ca-058625b51c19 VirtualMachine.Disk0.IsClone: false VirtualMachine.Disk0.IsFixed: False VirtualMachine.Disk0.Name: Hard disk 1 VirtualMachine.Disk0.Size: 1 VirtualMachine.Disk0.Storage: DSC-SITEA-BRONZE-01 VirtualMachine.Disk0.Storage.Cluster.ExternalReferenceId: group-p291 VirtualMachine.Disk0.Storage.Cluster.Name: DSC-SITEA-BRONZE-01 VirtualMachine.Memory.Size: 1024 VirtualMachine.Network0.MacAddress: 00:50:56:9a:3e:5f VirtualMachine.Network0.Name: vxw-dvs-314-virtualwire-8-sid-5005-SiteA-Transit-South VirtualMachine.Storage.Cluster.Automation.Behavior: manual VirtualMachine.Storage.Cluster.Automation.Enabled: True VirtualMachine.Storage.Cluster.ExternalReferenceId: group-p291 VirtualMachine.Storage.Cluster.Name: DSC-SITEA-BRONZE-01 VirtualMachine.Storage.Name: DSC-SITEA-BRONZE-01 VMware.VirtualCenter.OperatingSystem: windows7Server64Guest Vrm.ProxyAgent.Uri: https://sg1-vrm001.sgroot.local/VMPS2Proxy
The first set are prefixed with a double underscore (__), which denotes that these are ‘hidden’ properties that are used by the system and provide object references to the reservation and the request (note that these properties will not be referenced in the official VMware Custom Properties Reference).
The remaining properties are the key/values associated with the virtual machine and can provide cpu count, amount of assigned memory, used storage, etc. and any user-defined custom properties that you have created. Unlike the hidden properties. you will find a reference to all of these in the VMware Custom Properties Reference.
One important thing to note, is that when you are working with custom property values, these are always returned as a string, regardless of what data is being stored. I.e. if a custom property has a value of ‘false’, this is the literal string “false” and not Boolean false. Read more “vRA Developer: Part 6 – Working with vCAC Virtual Machine Custom Properties”