In a previous article I explained how you can pass (user-defined) custom properties to the vRA 7 event broker, so they can be used as a filter in your event broker conditions. In this article the Extensibility.Lifecycle.Properties.VMPSMasterWorkflow32.Buildingmachine custom property was added to the properities of a virtual machine, so vRA sends the user defined custom properties in the Buildingmachine lifecycle state.
The format for the extensibility custom property is:
Extensibility.Lifecycle.Properties.{workflowName}.{stateName}
You can use this format for the different lifecycle states that are available:
The available extensibility custom properties for the machine provisioning event topic are:
Extensibility.Lifecycle.Properties.VMPSMasterWorkflow32.Buildingmachine Extensibility.Lifecycle.Properties.VMPSMasterWorkflow32.DeactivateMachine Extensibility.Lifecycle.Properties.VMPSMasterWorkflow32.Disposing Extensibility.Lifecycle.Properties.VMPSMasterWorkflow32.MachineActivated Extensibility.Lifecycle.Properties.VMPSMasterWorkflow32.MachineProvisioned Extensibility.Lifecycle.Properties.VMPSMasterWorkflow32.RegisterMachine Extensibility.Lifecycle.Properties.VMPSMasterWorkflow32.Requested Extensibility.Lifecycle.Properties.VMPSMasterWorkflow32.UnprovisionMachine Extensibility.Lifecycle.Properties.VMPSMasterWorkflow32.WaitingToBuild
Depending on your exact goals you might want to create a property group containing all these extensibility custom properties, so all the custom properties are alway passed to the event broker.
The value for each property will be something like viktorious.* (if you want to pass the custom properties starting with viktorious to the event broker). If you also want to add the hidden custom properties to the event broker payload the value has to be __*,viktorious*. The following custom properties will be added to the payload:
__api.request.callback.service.id : 0593262f-a3a8-41eb-9a9c-ca3c8c0386e3 __Cafe.Request.VM.HostnamePrefix : viktorious __clonefromid : e17422ad-fab5-4829-b1c7-9d2e2d92b110 __Cafe.Request.BlueprintType : 1 __InterfaceType : vSphere __trace_id : ouru7eNi __iaas_request_binding_id : ba99a32f-e029-42d9-b449-f2ffe3b1c8a8 __Legacy.Workflow.ImpersonatingUser : __Legacy.Workflow.User : admin_vbe@vsphere.local __VirtualMachine.ProvisioningWorkflowName : CloneWorkflow __VirtualMachine.Allocation.InitialMachineState : SubmittingRequest __Clone_Type : CloneWorkflow __reservationPolicyID : c9d8cc8f-ab94-4a8a-8f4a-b79cb63d2bbc __api.request.id : 7ba7eb35-8ee8-41e9-8611-7f83c159e7cb __clonefrom : template-centos63 __request_reason : __Cafe.Root.Request.Id : aa0bab77-288e-44e8-849d-d56014565f30
Notice that you only use these extensibility custom properties if you need the custom property in the event broker. If you just need the custom properties in your vRO workflow you can use the following vRO code:
var machineProp = eventPayloadProperties.get("machine"); var id = machineProp.get("id"); //Retrieve the machine id from the eventPayloadProperties var vcacVm = Server.findForType("vCAC:VirtualMachine", id); if (vcacVm != null) { var hostId = vcacVm.getEntity().hostId; var vCACHost = Server.findForType("vCAC:VCACHost", hostId); vCACVmProperties = System.getModule("com.vmware.library.vcac").getPropertiesFromVirtualMachine(vCACHost,vcacVm) ; }
Of course the vRealize Automation vRO plugin has to be configured. The vCACVmProperties properties object will contain all the custom properties and can easily be retrieved using a simple get:
vCACVmProperties.get("viktorious.os");
I hope this was helpful! If you have any questions, please use the reply option below.
1 Comments
KD
Thank you very much for the information.
I was looking for VM IP address of the deployed virtual machine
/*
var machineProp = eventPayloadProperties.get(“machine”);
var id = machineProp.get(“id”); //Retrieve the machine id from the eventPayloadProperties
var vcacVm = Server.findForType(“vCAC:VirtualMachine”, id);
*/
This helped me.
Regards,
KD