VMware: handle permission denied while reading facts (#38868)

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: #37056

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
(cherry picked from commit efc3f4f824)
pull/38877/head
Abhijeet Kasurde 7 years ago committed by GitHub
parent 5f8758d6a3
commit bb50c65769
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
bugfixes:
- Adds exception handling which is raised when user does not have correct set of permissions/privileges to read virtual machine facts.

@ -305,8 +305,14 @@ def gather_vm_facts(content, vm):
# facts that may or may not exist # facts that may or may not exist
if vm.summary.runtime.host: if vm.summary.runtime.host:
try:
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
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: if vm.summary.runtime.dasVmProtection:
facts['hw_guest_ha_state'] = vm.summary.runtime.dasVmProtection.dasProtected facts['hw_guest_ha_state'] = vm.summary.runtime.dasVmProtection.dasProtected

Loading…
Cancel
Save