vmware / vsphere-automation-sdk-python

Python samples, language bindings, and API reference documentation for vSphere, VMC, and NSX-T using the VMware REST API
MIT License
748 stars 312 forks source link

Retrive VM information #264

Closed Elinoy-1 closed 3 years ago

Elinoy-1 commented 3 years ago

Environment


Hi,

I'm using the SDK to retrieve all powered on machines and I added mapping from VM id to IP address using the following code: vsphere_client.vcenter.vm.guest.Identity.get(vm=vm_id).ip_address How can I add more information such as cluster and folder for each VM?

Thank you

Elinoy-1 commented 3 years ago

Solved it by iterating over the clusters using the "vsphere_client.vcenter.Cluster.list()" to retrieve the cluster id and add it as a filter to the VM.FilterSpec().