vmware: Only add configured network interfaces to facts (#28552)

This change effectively filters out any network interfaces which were
not explicitly configured for the guest. This fixes some unexpected behaviour where a machine with multiple IP addresses (for example, when Docker is installed, an internal IPv4 interface is added to
communicate with the container) would show one of the internal
addresses in the 'ipv4' field, but then no other information about the
corresponding hardware interface.
This commit is contained in:
Nik Reiman 2019-10-07 18:11:50 +02:00 committed by Abhijeet Kasurde
parent e48202838c
commit 785ba62867
2 changed files with 4 additions and 1 deletions

View file

@ -0,0 +1,2 @@
minor_changes:
- vmware.py - Only add configured network interfaces to facts.

View file

@ -365,7 +365,8 @@ def gather_vm_facts(content, vm):
vmnet = _get_vm_prop(vm, ('guest', 'net'))
if vmnet:
for device in vmnet:
net_dict[device.macAddress] = list(device.ipAddress)
if device.deviceConfigId > 0:
net_dict[device.macAddress] = list(device.ipAddress)
if vm.guest.ipAddress:
if ':' in vm.guest.ipAddress: