Working with vRealize Orchestrator and vRA IaaS Objects: A Hands-on Guide
In my previous article, we explored how to use vRealize Orchestrator (vRO) to interact with vRA IaaS objects. We saw how to capture a virtual machine named TESTVM02 using the model manager and access its properties. In this follow-up post, we’ll dive deeper into working with vRA IaaS objects in vRO and explore some advanced use cases.
Accessing Virtual Machine Hard Disks
One common requirement when working with virtual machines is the need to access their hard disks. However, the VCAC:Entity object does not have a direct property for accessing hard disks. To overcome this limitation, we can use the expand method of the get_link function. Here’s an example of how to access the hard disks of a virtual machine:
“`
// Get the VirtualMachine object
var vm = mm.get_object(“VirtualMachine”, “TESTVM02”);
// Expand the hard disks property
var hardDisks = mm.get_link(vm, “VMDiskHardware”).expand();
// Iterate over the hard disks and display their details
hardDisks.forEach(function (hd) {
console.log(“Hard Disk: ” + hd.Name);
});
“`
In this example, we first get the VirtualMachine object using the model manager’s get_object method. We then use the get_link method to expand the VMDiskHardware property of the virtual machine. Finally, we iterate over the hard disks and display their details.
Retrieving Virtual Machines Created After a Defined Date
Another common requirement is the need to retrieve virtual machines created after a defined date. To do this, we can use the get_objects method of the model manager with a filter expression that includes the creation date. Here’s an example of how to retrieve all virtual machines created after January 1st, 2020:
“`
// Get all virtual machines created after January 1st, 2020
var vmList = mm.get_objects(“VirtualMachine”, null, {
“creationDate”: {
“gte”: “2020-01-01T00:00:00Z”
}
});
// Iterate over the virtual machines and display their details
vmList.forEach(function (vm) {
console.log(“Virtual Machine: ” + vm.Name);
});
“`
In this example, we use the get_objects method to retrieve all virtual machines created after January 1st, 2020. We specify a filter expression that includes the creation date and set the gte (greater than or equal to) operator to ensure we only get virtual machines created on or after the specified date. Finally, we iterate over the virtual machines and display their details.
Conclusion
In this article, we explored some advanced use cases for working with vRA IaaS objects in vRO. We saw how to access hard disks of virtual machines and retrieve virtual machines created after a defined date. These use cases demonstrate the power of vRO and the vRA IaaS object model in managing and automating virtualized infrastructure. With these skills, you’ll be well-equipped to tackle a wide range of vRO and vRAIaaS challenges.
As always, we welcome your feedback and questions in the comments section below. If you have any other use cases or requirements you’d like to see covered in future articles, please let us know!