In vsphere java SDK there is Browser sample class that shows how to list virtual machines
ManagedObjectReference containerView =
vimPort.createContainerView(viewManager, folder,
Arrays.asList("VirtualMachine"), true);
How can I check if such virtual machine is template ? Or better how to query about template virtual machines, so as to get only templates in soap response ?
To check a VM is template or not. You can check for vm_obj.config.template
.
The VirtualMachine
manged object has the property config
which is of type VirtualMachineConfigInfo
. And in the VirtualMachineConfigInfo
you can find the boolean template
property.