vsphere/resource_vsphere_virtual_machine.go
func resourceVSphereVirtualMachineUpdateLocationRelocateWithSDRS(
	d *schema.ResourceData,
	meta interface{},
	vm *object.VirtualMachine,
	spec types.VirtualMachineRelocateSpec,
	timeout int,
) error {
	client := meta.(*VSphereClient).vimClient
	if err := viapi.ValidateVirtualCenter(client); err != nil {
		return fmt.Errorf("connection ineligible to use datastore_cluster_id: %s", err)
	}

	log.Printf("[DEBUG] %s: Running virtual machine relocate Storage DRS API", resourceVSphereVirtualMachineIDString(d))
	pod, err := storagepod.FromID(client, d.Get("datastore_cluster_id").(string))
	if err != nil {
		return fmt.Errorf("error getting datastore cluster: %s", err)
	}

	err = storagepod.RelocateVM(client, vm, spec, timeout, pod)
	if err != nil {
		return fmt.Errorf("error running vMotion on datastore cluster %q: %s", pod.Name(), err)
	}
	return nil
}
func resourceVSphereVirtualMachineUpdateLocationRelocateWithSDRS(
	d *schema.ResourceData,
	meta interface{},
	vm *object.VirtualMachine,
	spec types.VirtualMachineRelocateSpec,
	timeout int,
) error {
	client := meta.(*VSphereClient).vimClient
	if err := viapi.ValidateVirtualCenter(client); err != nil {
		return fmt.Errorf("connection ineligible to use datastore_cluster_id: %s", err)
	}

	log.Printf("[DEBUG] %s: Running virtual machine relocate Storage DRS API", resourceVSphereVirtualMachineIDString(d))
	pod, err := storagepod.FromID(client, d.Get("datastore_cluster_id").(string))
	if err != nil {
		return fmt.Errorf("error getting datastore cluster: %s", err)
	}

	err = storagepod.RelocateVM(client, vm, spec, timeout, pod)
	if err != nil {
		return fmt.Errorf("error running vMotion on datastore cluster %q: %s", pod.Name(), err)
	}
	return nil
}
func resourceVSphereVirtualMachineUpdateLocationRelocateWithSDRS ( d * schema . ResourceData , meta interface { } , vm * object . VirtualMachine , spec types . VirtualMachineRelocateSpec , timeout int , ) error { client := meta . ( * VSphereClient ) . vimClient if err := viapi . ValidateVirtualCenter ( client ) ; err != nil { return fmt . Errorf ( " " , err ) } log . Printf ( " " , resourceVSphereVirtualMachineIDString ( d ) ) pod , err := storagepod . FromID ( client , d . Get ( " " ) . ( string ) ) if err != nil { return fmt . Errorf ( " " , err ) } err = storagepod . RelocateVM ( client , vm , spec , timeout , pod ) if err != nil { return fmt . Errorf ( " " , pod . Name ( ) , err ) } return nil }
// resourceVSphereVirtualMachineUpdateLocationRelocateWithSDRS runs the storage vMotion
// part of resourceVSphereVirtualMachineUpdateLocation through storage DRS.
// It's designed to be run when a storage cluster is specified, versus simply
// specifying datastores.
resourceVSphereVirtualMachineUpdateLocationRelocateWithSDRS runs the storage vMotion part of resourceVSphereVirtualMachineUpdateLocation through storage DRS . It s designed to be run when a storage cluster is specified versus simply specifying datastores .