vmware_guest: do not assume disk params contain a datastore (#2974)
* vmware_guest: do not assume disk params contain a datastore * Fix missed line during connection refactor
This commit is contained in:
parent
99a9933026
commit
ddbd63c8a6
1 changed files with 9 additions and 4 deletions
|
@ -294,7 +294,7 @@ class PyVmomiHelper(object):
|
||||||
folder_path = None
|
folder_path = None
|
||||||
|
|
||||||
if uuid:
|
if uuid:
|
||||||
vm = self.si.content.searchIndex.FindByUuid(uuid=uuid, vmSearch=True)
|
vm = self.content.searchIndex.FindByUuid(uuid=uuid, vmSearch=True)
|
||||||
|
|
||||||
elif folder:
|
elif folder:
|
||||||
|
|
||||||
|
@ -524,14 +524,19 @@ class PyVmomiHelper(object):
|
||||||
hostsystem = get_obj(self.content, [vim.HostSystem], self.params['esxi_hostname'])
|
hostsystem = get_obj(self.content, [vim.HostSystem], self.params['esxi_hostname'])
|
||||||
|
|
||||||
# set the destination datastore in the relocation spec
|
# set the destination datastore in the relocation spec
|
||||||
|
datastore_name = None
|
||||||
|
datastore = None
|
||||||
if self.params['disk']:
|
if self.params['disk']:
|
||||||
datastore_name = self.params['disk'][0]['datastore']
|
if 'datastore' in self.params['disk'][0]:
|
||||||
datastore = get_obj(self.content, [vim.Datastore], datastore_name)
|
datastore_name = self.params['disk'][0]['datastore']
|
||||||
else:
|
datastore = get_obj(self.content, [vim.Datastore], datastore_name)
|
||||||
|
if not datastore:
|
||||||
# use the template's existing DS
|
# use the template's existing DS
|
||||||
disks = [x for x in template.config.hardware.device if isinstance(x, vim.vm.device.VirtualDisk)]
|
disks = [x for x in template.config.hardware.device if isinstance(x, vim.vm.device.VirtualDisk)]
|
||||||
datastore = disks[0].backing.datastore
|
datastore = disks[0].backing.datastore
|
||||||
datastore_name = datastore.name
|
datastore_name = datastore.name
|
||||||
|
if not datastore:
|
||||||
|
self.module.fail_json(msg="Failed to find a matching datastore")
|
||||||
|
|
||||||
# create the relocation spec
|
# create the relocation spec
|
||||||
relospec = vim.vm.RelocateSpec()
|
relospec = vim.vm.RelocateSpec()
|
||||||
|
|
Loading…
Reference in a new issue