From 6608629d25559bc81da1d4bd43409b34a02855ee Mon Sep 17 00:00:00 2001 From: Gawain Date: Fri, 14 Jul 2017 22:25:20 +0800 Subject: [PATCH] Add 'mac_address' to the attributes returned from the vmware_vm_facts module (#26527) * Add 'mac_address' to the attributes returned from the vmware_vm_facts module * fix pep8 issue --- lib/ansible/modules/cloud/vmware/vmware_vm_facts.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/ansible/modules/cloud/vmware/vmware_vm_facts.py b/lib/ansible/modules/cloud/vmware/vmware_vm_facts.py index 410aa8fab50..8f359e90a7a 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_vm_facts.py +++ b/lib/ansible/modules/cloud/vmware/vmware_vm_facts.py @@ -68,12 +68,17 @@ def get_all_virtual_machines(content): _ip_address = summary.guest.ipAddress if _ip_address is None: _ip_address = "" + _mac_address = [] + for dev in vm.config.hardware.device: + if isinstance(dev, vim.vm.device.VirtualEthernetCard): + _mac_address.append(dev.macAddress) virtual_machine = { summary.config.name: { "guest_fullname": summary.config.guestFullName, "power_state": summary.runtime.powerState, "ip_address": _ip_address, + "mac_address": _mac_address, "uuid": summary.config.uuid } }