mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-24 03:11:24 -07:00
VMware: Add support in VMWare modules for BIOS and instance UUID's (#44399)
* Add support for changing UUID type referenced * Update all appropriate VMware modules to include UUID type * Add integration test for filtering on instance UUID
This commit is contained in:
parent
f135960fc2
commit
e18d5ea8b3
17 changed files with 179 additions and 21 deletions
|
@ -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 = []
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue