Skip to content

Commit

Permalink
fix guest info bug
Browse files Browse the repository at this point in the history
  • Loading branch information
mikemorency committed May 23, 2024
1 parent 6b28899 commit f6a809b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions plugins/modules/guest_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()

Expand All @@ -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:
Expand Down

0 comments on commit f6a809b

Please sign in to comment.