func RelocateVM(
	client *govmomi.Client,
	vm *object.VirtualMachine,
	spec types.VirtualMachineRelocateSpec,
	timeout int,
	pod *object.StoragePod,
) error {
	sdrsEnabled, err := StorageDRSEnabled(pod)
	if err != nil {
		return err
	}
	if !sdrsEnabled {
		return fmt.Errorf("storage DRS is not enabled on datastore cluster %q", pod.Name())
	}
	log.Printf(
		"[DEBUG] Relocating virtual machine %q to datastore cluster %q",
		vm.InventoryPath,
		pod.Name(),
	)

	sps := types.StoragePlacementSpec{
		Vm: types.NewReference(vm.Reference()),
		PodSelectionSpec: types.StorageDrsPodSelectionSpec{
			StoragePod: types.NewReference(pod.Reference()),
		},
		Priority:     types.VirtualMachineMovePriorityDefaultPriority,
		RelocateSpec: &spec,
		Type:         string(types.StoragePlacementSpecPlacementTypeRelocate),
	}

	_, err = recommendAndApplySDRS(client, sps, time.Minute*time.Duration(timeout))
	return err
}
func RelocateVM(
	client *govmomi.Client,
	vm *object.VirtualMachine,
	spec types.VirtualMachineRelocateSpec,
	timeout int,
	pod *object.StoragePod,
) error {
	sdrsEnabled, err := StorageDRSEnabled(pod)
	if err != nil {
		return err
	}
	if !sdrsEnabled {
		return fmt.Errorf("storage DRS is not enabled on datastore cluster %q", pod.Name())
	}
	log.Printf(
		"[DEBUG] Relocating virtual machine %q to datastore cluster %q",
		vm.InventoryPath,
		pod.Name(),
	)

	sps := types.StoragePlacementSpec{
		Vm: types.NewReference(vm.Reference()),
		PodSelectionSpec: types.StorageDrsPodSelectionSpec{
			StoragePod: types.NewReference(pod.Reference()),
		},
		Priority:     types.VirtualMachineMovePriorityDefaultPriority,
		RelocateSpec: &spec,
		Type:         string(types.StoragePlacementSpecPlacementTypeRelocate),
	}

	_, err = recommendAndApplySDRS(client, sps, time.Minute*time.Duration(timeout))
	return err
}
// RelocateVM migrates a virtual machine to a datastore cluster via the
// StorageResourceManager API. It mimics our helper in the virtualmachine
// package in functionality.