vsphere/internal/helper/storagepod/storage_pod_helper.go
func ReconfigureVM(
	client *govmomi.Client,
	vm *object.VirtualMachine,
	spec types.VirtualMachineConfigSpec,
	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] Reconfiguring virtual machine %q through Storage DRS API, on datastore cluster %q",
		vm.InventoryPath,
		pod.Name(),
	)

	sps := types.StoragePlacementSpec{
		Type: string(types.StoragePlacementSpecPlacementTypeReconfigure),
		PodSelectionSpec: types.StorageDrsPodSelectionSpec{
			InitialVmConfig: expandVMPodConfigForPlacement(spec.DeviceChange, pod),
		},
		Vm:         types.NewReference(vm.Reference()),
		ConfigSpec: &spec,
	}

	_, err = recommendAndApplySDRS(client, sps, provider.DefaultAPITimeout)
	return err
}
func ReconfigureVM(
	client *govmomi.Client,
	vm *object.VirtualMachine,
	spec types.VirtualMachineConfigSpec,
	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] Reconfiguring virtual machine %q through Storage DRS API, on datastore cluster %q",
		vm.InventoryPath,
		pod.Name(),
	)

	sps := types.StoragePlacementSpec{
		Type: string(types.StoragePlacementSpecPlacementTypeReconfigure),
		PodSelectionSpec: types.StorageDrsPodSelectionSpec{
			InitialVmConfig: expandVMPodConfigForPlacement(spec.DeviceChange, pod),
		},
		Vm:         types.NewReference(vm.Reference()),
		ConfigSpec: &spec,
	}

	_, err = recommendAndApplySDRS(client, sps, provider.DefaultAPITimeout)
	return err
}
func ReconfigureVM ( client * govmomi . Client , vm * object . VirtualMachine , spec types . VirtualMachineConfigSpec , pod * object . StoragePod , ) error { sdrsEnabled , err := StorageDRSEnabled ( pod ) if err != nil { return err } if ! sdrsEnabled { return fmt . Errorf ( " " , pod . Name ( ) ) } log . Printf ( " " , vm . InventoryPath , pod . Name ( ) , ) sps := types . StoragePlacementSpec { Type : string ( types . StoragePlacementSpecPlacementTypeReconfigure ) , PodSelectionSpec : types . StorageDrsPodSelectionSpec { InitialVmConfig : expandVMPodConfigForPlacement ( spec . DeviceChange , pod ) , } , Vm : types . NewReference ( vm . Reference ( ) ) , ConfigSpec : & spec , } _ , err = recommendAndApplySDRS ( client , sps , provider . DefaultAPITimeout ) return err }
// ReconfigureVM reconfigures a virtual machine via the StorageResourceManager
// API, applying any disk modifications that will require going through Storage
// DRS. It mimics our helper in the virtualmachine package in functionality.
//
// Note that this function will fail if there are no new disks in the spec,
// check this first before using this function. If no disk create operations
// are necessary, use the regular Reconfigure function in the virtualmachine
// helper package.
ReconfigureVM reconfigures a virtual machine via the StorageResourceManager API applying any disk modifications that will require going through Storage DRS . It mimics our helper in the virtualmachine package in functionality . Note that this function will fail if there are no new disks in the spec check this first before using this function . If no disk create operations are necessary use the regular Reconfigure function in the virtualmachine helper package .