One of my customers asked me what is the most efficient way to find VM’s in vCenter based on UUID/moRef/IP/Name with vRO… Well… this is a good question! and this post will show you how you can do it.
The most inefficient way to find VM by IP/Name/ID is like this:
- vms = VcPlugin.getAllVirtualMachines();
- for each (vm in vms) {
- if (vm.guest.ipAddress == ip) {
- System.log(“VM name: “+vm.name);
- }
- }
In large environments this could take some time.