From e0373a73a87fb5a22b38316f25af3d1c5628ec9f Mon Sep 17 00:00:00 2001 From: Jiri Tyr Date: Thu, 14 Nov 2019 05:10:37 +0000 Subject: [PATCH] VMware: Simplifying get_vm() in module_utils.vmware (#62217) --- lib/ansible/module_utils/vmware.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/ansible/module_utils/vmware.py b/lib/ansible/module_utils/vmware.py index ff35412236f..34e9377e324 100644 --- a/lib/ansible/module_utils/vmware.py +++ b/lib/ansible/module_utils/vmware.py @@ -970,12 +970,10 @@ class PyVmomi(object): vms = [] for temp_vm_object in objects: - if len(temp_vm_object.propSet) != 1: - continue - for temp_vm_object_property in temp_vm_object.propSet: - if temp_vm_object_property.val == self.params['name']: - vms.append(temp_vm_object.obj) - break + if ( + len(temp_vm_object.propSet) == 1 and + temp_vm_object.propSet[0].val == self.params['name']): + vms.append(temp_vm_object.obj) # get_managed_objects_properties may return multiple virtual machine, # following code tries to find user desired one depending upon the folder specified.