@ -181,7 +181,8 @@ def find_network_by_name(content, network_name):
return find_object_by_name ( content , network_name , [ vim . Network ] )
def find_vm_by_id ( content , vm_id , vm_id_type = " vm_name " , datacenter = None , cluster = None , folder = None , match_first = False ) :
def find_vm_by_id ( content , vm_id , vm_id_type = " vm_name " , datacenter = None ,
cluster = None , folder = None , match_first = False ) :
""" UUID is unique to a VM, every other id returns the first match. """
si = content . searchIndex
vm = None
@ -191,6 +192,8 @@ def find_vm_by_id(content, vm_id, vm_id_type="vm_name", datacenter=None, cluster
elif vm_id_type == ' uuid ' :
# Search By BIOS UUID rather than instance UUID
vm = si . FindByUuid ( datacenter = datacenter , instanceUuid = False , uuid = vm_id , vmSearch = True )
elif vm_id_type == ' instance_uuid ' :
vm = si . FindByUuid ( datacenter = datacenter , instanceUuid = True , uuid = vm_id , vmSearch = True )
elif vm_id_type == ' ip ' :
vm = si . FindByIp ( datacenter = datacenter , ip = vm_id , vmSearch = True )
elif vm_id_type == ' vm_name ' :
@ -870,9 +873,12 @@ class PyVmomi(object):
vm_obj = None
user_desired_path = None
if self . params [ ' uuid ' ] :
if self . params [ ' uuid ' ] and not self . params [ ' use_instance_uuid ' ] :
vm_obj = find_vm_by_id ( self . content , vm_id = self . params [ ' uuid ' ] , vm_id_type = " uuid " )
elif self . params [ ' uuid ' ] and self . params [ ' use_instance_uuid ' ] :
vm_obj = find_vm_by_id ( self . content ,
vm_id = self . params [ ' uuid ' ] ,
vm_id_type = " instance_uuid " )
elif self . params [ ' name ' ] :
objects = self . get_managed_objects_properties ( vim_type = vim . VirtualMachine , properties = [ ' name ' ] )
vms = [ ]