From f5fd6a94fd53c4d5fb0dff6c602cfb85f17cdf17 Mon Sep 17 00:00:00 2001 From: "kota.nakamoto" Date: Thu, 14 Apr 2016 11:37:53 +0900 Subject: [PATCH] add resource pool on relocateSpec --- .../vsphere/resource_vsphere_virtual_machine.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/builtin/providers/vsphere/resource_vsphere_virtual_machine.go b/builtin/providers/vsphere/resource_vsphere_virtual_machine.go index d290dd885ecb..56b4f8ecc950 100644 --- a/builtin/providers/vsphere/resource_vsphere_virtual_machine.go +++ b/builtin/providers/vsphere/resource_vsphere_virtual_machine.go @@ -774,9 +774,10 @@ func buildStoragePlacementSpecCreate(f *object.DatacenterFolders, rp *object.Res } // buildStoragePlacementSpecClone builds StoragePlacementSpec for clone action. -func buildStoragePlacementSpecClone(c *govmomi.Client, f *object.DatacenterFolders, vm *object.VirtualMachine, storagePod *object.StoragePod) types.StoragePlacementSpec { +func buildStoragePlacementSpecClone(c *govmomi.Client, f *object.DatacenterFolders, vm *object.VirtualMachine, rp *object.ResourcePool, storagePod *object.StoragePod) types.StoragePlacementSpec { vmr := vm.Reference() vmfr := f.VmFolder.Reference() + rpr := rp.Reference() spr := storagePod.Reference() var o mo.VirtualMachine @@ -792,7 +793,9 @@ func buildStoragePlacementSpecClone(c *govmomi.Client, f *object.DatacenterFolde StoragePod: &spr, }, CloneSpec: &types.VirtualMachineCloneSpec{ - Location: types.VirtualMachineRelocateSpec{}, + Location: types.VirtualMachineRelocateSpec{ + Pool: &rpr, + }, PowerOn: false, Template: false, }, @@ -1049,7 +1052,7 @@ func (vm *virtualMachine) deployVirtualMachine(c *govmomi.Client) error { if err != nil { return err } - sps := buildStoragePlacementSpecClone(c, dcFolders, template, sp) + sps := buildStoragePlacementSpecClone(c, dcFolders, template, resourcePool, sp) datastore, err = findDatastore(c, sps) if err != nil { return err