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.
This commit is contained in:
tchernomax 2017-11-29 05:14:23 +01:00 committed by Abhijeet Kasurde
parent ef37a7fbd6
commit 6732be3e62

View file

@ -280,7 +280,7 @@ def gather_vm_facts(content, vm):
'hw_datastores': [], 'hw_datastores': [],
'hw_files': [], 'hw_files': [],
'hw_esxi_host': None, 'hw_esxi_host': None,
'hw_guest_ha_state': vm.summary.runtime.dasVmProtection, 'hw_guest_ha_state': None,
'hw_is_template': vm.config.template, 'hw_is_template': vm.config.template,
'hw_folder': None, 'hw_folder': None,
'guest_tools_status': _get_vm_prop(vm, ('guest', 'toolsRunningStatus')), 'guest_tools_status': _get_vm_prop(vm, ('guest', 'toolsRunningStatus')),
@ -299,6 +299,8 @@ def gather_vm_facts(content, vm):
if vm.summary.runtime.host: if vm.summary.runtime.host:
host = vm.summary.runtime.host host = vm.summary.runtime.host
facts['hw_esxi_host'] = host.summary.config.name 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 datastores = vm.datastore
for ds in datastores: for ds in datastores: