VMware: filter VMs of Same name on the basis of folder (#65922)

vmware_guest now filters VMs of same name on the basis of additional information of folder.
This commit is contained in:
ngp-star 2019-12-20 08:54:15 +05:30 committed by Abhijeet Kasurde
parent 50eb4eec90
commit 4769d731ac
2 changed files with 7 additions and 1 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- Vmware Fix for Create overwrites a VM of same name even when the folder is different(https://github.com/ansible/ansible/issues/43161)

View file

@ -1053,6 +1053,10 @@ class PyVmomi(object):
break break
elif vms: elif vms:
# Unique virtual machine found. # Unique virtual machine found.
actual_vm_folder_path = self.get_vm_path(content=self.content, vm_name=vms[0])
if self.params.get('folder') is None:
vm_obj = vms[0]
elif self.params['folder'] in actual_vm_folder_path:
vm_obj = vms[0] vm_obj = vms[0]
elif 'moid' in self.params and self.params['moid']: elif 'moid' in self.params and self.params['moid']:
vm_obj = VmomiSupport.templateOf('VirtualMachine')(self.params['moid'], self.si._stub) vm_obj = VmomiSupport.templateOf('VirtualMachine')(self.params['moid'], self.si._stub)