Skip to content

Commit

Permalink
VMware: handle permission denied while reading facts (ansible#37163)
Browse files Browse the repository at this point in the history
This fix adds exception handling which is raised when user
does not have correct set of permissions/privileges to read virtual machine
facts especially host system configuration.

Fixes: ansible#37056

Signed-off-by: Abhijeet Kasurde <[email protected]>
  • Loading branch information
Akasurde authored and ansibot committed Apr 17, 2018
1 parent 3922b6c commit efc3f4f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/ansible/module_utils/vmware.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,14 @@ def gather_vm_facts(content, vm):

# facts that may or may not exist
if vm.summary.runtime.host:
host = vm.summary.runtime.host
facts['hw_esxi_host'] = host.summary.config.name
try:
host = vm.summary.runtime.host
facts['hw_esxi_host'] = host.summary.config.name
except vim.fault.NoPermission:
# User does not have read permission for the host system,
# proceed without this value. This value does not contribute or hamper
# provisioning or power management operations.
pass
if vm.summary.runtime.dasVmProtection:
facts['hw_guest_ha_state'] = vm.summary.runtime.dasVmProtection.dasProtected

Expand Down

0 comments on commit efc3f4f

Please sign in to comment.