vmware / pyvmomi-community-samples

A place for community contributed samples for the pyVmomi library.
Apache License 2.0
1.01k stars 922 forks source link

Sample to list all VM network controllers #710

Open amdei opened 1 year ago

amdei commented 1 year ago

I find it difficult to get list of VM(s) virtual Ethernet cards on my ESXi Datacenter. Hope my humble contribution will help my fellow developers.

Sample usage:

python3 samples/getallvm_nics.py --host my-esx-host.org.con --user my-login -p my-secret-password -nossl --sort --datacenter-name MY-DATACENTER-NAME

Sample output:

VM Name    :  whipsec-mc2
Path       :  [esx-vpn-datastore] whipsec-mc2/whipsec-mc2.vmx
Guest      :  Debian GNU/Linux 8 (64-bit)
Network adapter 1 -> MY_DSwitch/VM Network
Network adapter 2 -> switch-4