vmware_vm_facts: Add error check for config.vm (#31629)

Add a simple check to see if vm.config exists before looking for
vm.config.hardware
(cherry picked from commit 4034630625)
This commit is contained in:
Zubair Lutfullah Kakakhel
2017-10-12 15:32:06 +01:00
committed by Toshio Kuratomi
parent 0afc3ae3ed
commit 5f8a126d35

View File

@ -72,9 +72,10 @@ def get_all_virtual_machines(content):
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)
if vm.config is not None:
for dev in vm.config.hardware.device:
if isinstance(dev, vim.vm.device.VirtualEthernetCard):
_mac_address.append(dev.macAddress)
virtual_machine = {
summary.config.name: {