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 = [] vms = []
for temp_vm_object in objects: for temp_vm_object in objects:
if len(temp_vm_object.propSet) != 1: if (
continue len(temp_vm_object.propSet) == 1 and
for temp_vm_object_property in temp_vm_object.propSet: temp_vm_object.propSet[0].val == self.params['name']):
if temp_vm_object_property.val == self.params['name']:
vms.append(temp_vm_object.obj) vms.append(temp_vm_object.obj)
break
# get_managed_objects_properties may return multiple virtual machine, # get_managed_objects_properties may return multiple virtual machine,
# following code tries to find user desired one depending upon the folder specified. # following code tries to find user desired one depending upon the folder specified.