From 6732be3e62d35526376379db161c330fbef63853 Mon Sep 17 00:00:00 2001 From: tchernomax Date: Wed, 29 Nov 2017 05:14:23 +0100 Subject: [PATCH] VMware: fix hw_guest_ha_state fact (#33318) Set hw_guest_ha_state as None if `vm.summary.runtime.dasVmProtection` isn't printable/json-able. So if vm.summary.runtime.dasVmProtection is defined, return vm.summary.runtime.dasVmProtection.dasProtected. --- lib/ansible/module_utils/vmware.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/ansible/module_utils/vmware.py b/lib/ansible/module_utils/vmware.py index 1aa1d1a8910..305c26a04cc 100644 --- a/lib/ansible/module_utils/vmware.py +++ b/lib/ansible/module_utils/vmware.py @@ -280,7 +280,7 @@ def gather_vm_facts(content, vm): 'hw_datastores': [], 'hw_files': [], 'hw_esxi_host': None, - 'hw_guest_ha_state': vm.summary.runtime.dasVmProtection, + 'hw_guest_ha_state': None, 'hw_is_template': vm.config.template, 'hw_folder': None, 'guest_tools_status': _get_vm_prop(vm, ('guest', 'toolsRunningStatus')), @@ -299,6 +299,8 @@ def gather_vm_facts(content, vm): if vm.summary.runtime.host: host = vm.summary.runtime.host facts['hw_esxi_host'] = host.summary.config.name + if vm.summary.runtime.dasVmProtection: + facts['hw_guest_ha_state'] = vm.summary.runtime.dasVmProtection.dasProtected datastores = vm.datastore for ds in datastores: