vsphere/internal/helper/virtualmachine/virtual_machine_helper.go
func Relocate(vm *object.VirtualMachine, spec types.VirtualMachineRelocateSpec, timeout int) error {
	log.Printf("[DEBUG] Beginning migration of virtual machine %q (timeout %d)", vm.InventoryPath, timeout)
	ctx, cancel := context.WithTimeout(context.Background(), time.Minute*time.Duration(timeout))
	defer cancel()
	task, err := vm.Relocate(ctx, spec, "")
	if err != nil {
		return err
	}
	if err := task.Wait(ctx); err != nil {
		// Provide a friendly error message if we timed out waiting for the migration.
		if ctx.Err() == context.DeadlineExceeded {
			return errors.New("timeout waiting for migration to complete")
		}
	}
	return nil
}
func Relocate(vm *object.VirtualMachine, spec types.VirtualMachineRelocateSpec, timeout int) error {
	log.Printf("[DEBUG] Beginning migration of virtual machine %q (timeout %d)", vm.InventoryPath, timeout)
	ctx, cancel := context.WithTimeout(context.Background(), time.Minute*time.Duration(timeout))
	defer cancel()
	task, err := vm.Relocate(ctx, spec, "")
	if err != nil {
		return err
	}
	if err := task.Wait(ctx); err != nil {
		// Provide a friendly error message if we timed out waiting for the migration.
		if ctx.Err() == context.DeadlineExceeded {
			return errors.New("timeout waiting for migration to complete")
		}
	}
	return nil
}
func Relocate ( vm * object . VirtualMachine , spec types . VirtualMachineRelocateSpec , timeout int ) error { log . Printf ( " " , vm . InventoryPath , timeout ) ctx , cancel := context . WithTimeout ( context . Background ( ) , time . Minute * time . Duration ( timeout ) ) defer cancel ( ) task , err := vm . Relocate ( ctx , spec , " " ) if err != nil { return err } if err := task . Wait ( ctx ) ; err != nil { // Provide a friendly error message if we timed out waiting for the migration. if ctx . Err ( ) == context . DeadlineExceeded { return errors . New ( " " ) } } return nil }
// Relocate wraps the Relocate task and the subsequent waiting for the task to
// complete.
Relocate wraps the Relocate task and the subsequent waiting for the task to complete .