1
0
Fork 0
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:
Abhijeet Kasurde 2018-09-10 12:45:47 +05:30 committed by GitHub
parent d61b4492cf
commit d41e568a4d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View file

@ -975,7 +975,7 @@ class PyVmomi(object):
def get_vm_or_template(self, template_name=None): 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. used for cloning purpose.
Args: Args:
template_name: Name of virtual machine or virtual machine template template_name: Name of virtual machine or virtual machine template
@ -986,6 +986,10 @@ class PyVmomi(object):
template_obj = None template_obj = None
if template_name: 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']) objects = self.get_managed_objects_properties(vim_type=vim.VirtualMachine, properties=['name'])
templates = [] templates = []

View file

@ -87,6 +87,7 @@ options:
- If this value is not set, virtual machine is created without using a template. - 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. - If the virtual machine already exists, this parameter will be ignored.
- This parameter is case sensitive. - 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' ] aliases: [ 'template_src' ]
is_template: is_template:
description: description: