diff options
author | Abhijeet Kasurde <akasurde@redhat.com> | 2017-08-22 13:52:51 +0530 |
---|---|---|
committer | Dag Wieers <dag@wieers.com> | 2017-08-31 13:43:19 +0200 |
commit | c4984a4c4c5e96b36d336b9b6b8113b006deefab (patch) | |
tree | 15b94a9e131e17fbc9b2f145de537d8b93fae412 | |
parent | 11346284b113611dd12bc384596b4043bb11de35 (diff) | |
download | ansible-c4984a4c4c5e96b36d336b9b6b8113b006deefab.tar.gz |
Handle AttributeError in vmware module_utils
When vm has no MAC address assigned to it. Fix handles
attribute error if MAC address is not set.
Fixes: #28471
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
-rw-r--r-- | lib/ansible/module_utils/vmware.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/ansible/module_utils/vmware.py b/lib/ansible/module_utils/vmware.py index b29b0d7cd3..71adda1e82 100644 --- a/lib/ansible/module_utils/vmware.py +++ b/lib/ansible/module_utils/vmware.py @@ -238,13 +238,18 @@ def gather_vm_facts(content, vm): if not hasattr(entry, 'macAddress'): continue + mac_addr = mac_addr_dash = None + if entry.macAddress: + mac_addr_dash = entry.macAddress.replace(':', '-') + mac_addr = entry.macAddress + factname = 'hw_eth' + str(ethernet_idx) facts[factname] = { 'addresstype': entry.addressType, 'label': entry.deviceInfo.label, - 'macaddress': entry.macAddress, + 'macaddress': mac_addr, 'ipaddresses': net_dict.get(entry.macAddress, None), - 'macaddress_dash': entry.macAddress.replace(':', '-'), + 'macaddress_dash': mac_addr_dash, 'summary': entry.deviceInfo.summary, } facts['hw_interfaces'].append('eth' + str(ethernet_idx)) |