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 monitoring for changes in the MAC addresses of VMs. #735

Closed karaatanassov closed 10 months ago

karaatanassov commented 10 months ago

The monitor uses the PropertyCollector API to detect changes in the MAC addresses of VMs. The PropertyCollector is initialized with a ContainerView of all VMs. As we can observe MAC addresses either from the virtual ethernet cards or through the guest the property spec includes all VM virtual devices - config.hardware.device and guest networks - guest.net. As ethernet cards are only one of many possible virtual devices, we will receive spurious updates related to other hardware. Also DHCP changes will update the guest.net values even when the MAC and IP addresses do not change. To mitigate the spurious updates the property collector output is filtered through a cache of currently known values that only lets through real changes to MAC and IP addresses.

The code can be enhanced to run in a background executor and provide query capability to query the cache as necessary.

This change also fixes the suds dependency for python 3.