VMware: vmware_guest template find (#35088)

This fix adds logic to find unique virtual machine template using name.

Fixes: #26669

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
Abhijeet Kasurde
2018-01-29 21:39:50 +05:30
committed by GitHub
parent 2b0ad2c88a
commit 8606bfde4f
2 changed files with 32 additions and 3 deletions

View File

@@ -1465,7 +1465,6 @@ class PyVmomiHelper(PyVmomi):
# https://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/vim.vm.RelocateSpec.html
# FIXME:
# - multiple templates by the same name
# - static IPs
self.folder = self.params.get('folder', None)
@@ -1515,8 +1514,7 @@ class PyVmomiHelper(PyVmomi):
destfolder = f_obj
if self.params['template']:
# FIXME: need to search for this in the same way as guests to ensure accuracy
vm_obj = find_obj(self.content, [vim.VirtualMachine], self.params['template'])
vm_obj = self.get_vm_or_template(template_name=self.params['template'])
if vm_obj is None:
self.module.fail_json(msg="Could not find a template named %(template)s" % self.params)
else: