From f6a809ba921837b46257f4eb96e4b00be8ccba28 Mon Sep 17 00:00:00 2001 From: Mike Morency Date: Thu, 23 May 2024 10:05:47 -0400 Subject: [PATCH] fix guest info bug --- plugins/modules/guest_info.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/plugins/modules/guest_info.py b/plugins/modules/guest_info.py index d335098b..1de18eb3 100644 --- a/plugins/modules/guest_info.py +++ b/plugins/modules/guest_info.py @@ -71,6 +71,7 @@ ''' from collections import defaultdict +from com.vmware.vcenter_client import VM from ansible.module_utils.basic import AnsibleModule from ansible_collections.vmware.vmware.plugins.module_utils.vmware import PyVmomi @@ -114,7 +115,12 @@ def get_guest_info(self): guests = [] if self.params.get('guest_name'): - vms = self._get_vm(self.params.get('guest_name')) + matching_vms = self._get_vm(self.params.get('guest_name')) + try: + _ = iter(matching_vms) + vms = matching_vms + except TypeError: + vms = [] if not matching_vms else [matching_vms] else: vms = self.vmware_client.api_client.vcenter.VM.list() @@ -140,7 +146,7 @@ def _vvars(self, vmware_obj, r): def _get_vm(self, vm_name): names = set([vm_name]) vms = self.vmware_client.api_client.vcenter.VM.list( - self.vmware_client.api_client.VM.FilterSpec(names=names) + VM.FilterSpec(names=names) ) if len(vms) == 0: