Skip to content

Commit

Permalink
Fix NoneType object has no attribute datastoreUrl for inaccessible VMs (
Browse files Browse the repository at this point in the history
#1408)

vmware_vm_info: Fix NoneType object has no attribute datastoreUrl for inaccessible VMs

SUMMARY
The module fails on inaccessible VMs with 'NoneType' object has no attribute 'datastoreUrl'.
Fixes #1407
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
vmware_vm_info
ADDITIONAL INFORMATION
  • Loading branch information
mariolenz authored Jul 25, 2022
1 parent d01cc4b commit 570cc7c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/1407-vmware_vm_info-inaccessible_vm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- vmware_vm_info - Fix 'NoneType' object has no attribute 'datastoreUrl' for inaccessible VMs (https://github.com/ansible-collections/community.vmware/issues/1407).
5 changes: 3 additions & 2 deletions plugins/modules/vmware_vm_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,9 @@ def get_virtual_machines(self):
datacenter = get_parent_datacenter(vm)
datastore_url = list()
datastore_attributes = ('name', 'url')
if vm.config.datastoreUrl:
for entry in vm.config.datastoreUrl:
vm_datastore_urls = _get_vm_prop(vm, ('config', 'datastoreUrl'))
if vm_datastore_urls:
for entry in vm_datastore_urls:
datastore_url.append({key: getattr(entry, key) for key in dir(entry) if key in datastore_attributes})
virtual_machine = {
"guest_name": summary.config.name,
Expand Down

0 comments on commit 570cc7c

Please sign in to comment.