I'm trying to get a list of registered virtual machines - by their name - in my vcenter. The problem that I have many vms (~5K), and I am doing it a lot of times (O(1000)/hour).
The SDKs I'm using causing it a lot of traffic (1-2MB/request):
pysphere
: which ask for all vms, and filters on client side.pyVmomi
, which need to use recursion to list all vms (I sawSI.content.searchIndex.FindByDnsName
on reboot_vm.py, but my machines' DNS configuration is not true)
Looking into SOAP documentation didn't help (got into RetrievePropertiesEx.objectSet
but it doesn't looks to filter anything), and the new REST (v6.5) didn't help too (since I need to get its "datastore path", and all I can get is the name)
Have you tried a using a property collector, as in
pyVmomi.vmodl.query.PropertyCollector.FilterSpec
?The pyVmomi Community Samples contain examples of using this API, such as https://github.com/vmware/pyvmomi-community-samples/blob/master/samples/filter_vms.py.