VMware: Simplifying get_vm() in module_utils.vmware (#62217)

This commit is contained in:
Jiri Tyr 2019-11-14 05:10:37 +00:00 committed by Abhijeet Kasurde
parent 46a6c28bb0
commit e0373a73a8

View file

@ -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.