Reputation: 706
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 saw SI.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)
Upvotes: 3
Views: 4660
Reputation: 523
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.
Upvotes: 2
Reputation: 3737
vAPI is based on REST, even more, it does network requests every time, so it will be slow. Another way is to use VCDB, where are stored all VMs (there us such one, but I can not help you here more), see https://pubs.vmware.com/vsphere-4-esx-vcenter/index.jsp?topic=/com.vmware.vsphere.installclassic.doc_41/install/prep_db/c_preparing_the_vmware_infrastructure_databases.html or https://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1025914
Upvotes: 0