mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
VMware: use UUID to find templates and VMs (#45208)
This fix adds functionality to find the templates or VMs for cloning operations. Fixes: #45081 Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
parent
d61b4492cf
commit
d41e568a4d
2 changed files with 6 additions and 1 deletions
|
@ -975,7 +975,7 @@ class PyVmomi(object):
|
|||
|
||||
def get_vm_or_template(self, template_name=None):
|
||||
"""
|
||||
Function to find the virtual machine or virtual machine template using name
|
||||
Find the virtual machine or virtual machine template using name
|
||||
used for cloning purpose.
|
||||
Args:
|
||||
template_name: Name of virtual machine or virtual machine template
|
||||
|
@ -986,6 +986,10 @@ class PyVmomi(object):
|
|||
template_obj = None
|
||||
|
||||
if template_name:
|
||||
template_obj = find_vm_by_id(self.content, vm_id=template_name, vm_id_type="uuid")
|
||||
if template_obj:
|
||||
return template_obj
|
||||
|
||||
objects = self.get_managed_objects_properties(vim_type=vim.VirtualMachine, properties=['name'])
|
||||
templates = []
|
||||
|
||||
|
|
|
@ -87,6 +87,7 @@ options:
|
|||
- If this value is not set, virtual machine is created without using a template.
|
||||
- If the virtual machine already exists, this parameter will be ignored.
|
||||
- This parameter is case sensitive.
|
||||
- You can also specify template or VM UUID for identifying source. version_added 2.8. Use C(hw_product_uuid) from M(vmware_guest_facts) as UUID value.
|
||||
aliases: [ 'template_src' ]
|
||||
is_template:
|
||||
description:
|
||||
|
|
Loading…
Reference in a new issue