volume

package
v2.7.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 25, 2023 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearTaskInfoObjects

func ClearTaskInfoObjects()

ClearTaskInfoObjects is a go routine which runs in the background to clean up expired taskInfo objects from volumeTaskMap.

func ExtractFaultTypeFromErr

func ExtractFaultTypeFromErr(ctx context.Context, err error) string

ExtractFaultTypeFromErr extracts the fault type from err. Return the vim fault type if the input err is a SoapFault, and can exract the fault type of VimFault. Otherwise, it returns fault type as "csi.fault.Internal".

func ExtractFaultTypeFromVolumeResponseResult

func ExtractFaultTypeFromVolumeResponseResult(ctx context.Context,
	resp *cnstypes.CnsVolumeOperationResult) string

ExtractFaultTypeFromVolumeResponseResult extracts the fault type from CnsVolumeOperationResult. Return the vim fault type is CnsVolumeOperationResult.Fault is set, and can extract the fault type of VimFault. Return "" if CnsVolumeOperationResult.Fault not set.

func IsDiskAttached

func IsDiskAttached(ctx context.Context, vm *cnsvsphere.VirtualMachine, volumeID string,
	checkNVMeController bool) (string, error)

IsDiskAttached checks if the volume is attached to the VM. If the volume is attached to the VM, return disk uuid of the volume, else return empty string.

func IsDiskAttachedToVMs

func IsDiskAttachedToVMs(ctx context.Context, volumeID string, vms []*cnsvsphere.VirtualMachine,
	checkNVMeController bool) (string, error)

IsDiskAttachedToVMs checks if the volume is attached to any of the input VMs. If the volume is attached to the VM, return disk uuid of the volume, else return empty string.

Types

type CnsSnapshotInfo

type CnsSnapshotInfo struct {
	SnapshotID                string
	SourceVolumeID            string
	SnapshotDescription       string
	SnapshotCreationTimestamp time.Time
}

type CnsVolumeInfo

type CnsVolumeInfo struct {
	DatastoreURL string
	VolumeID     cnstypes.CnsVolumeId
}

CnsVolumeInfo hold information related to volume created by CNS.

type Manager

type Manager interface {
	// CreateVolume creates a new volume given its spec.
	// When CreateVolume failed, the second return value (faultType) and third return value(error) need to be set, and
	// should not be nil.
	CreateVolume(ctx context.Context, spec *cnstypes.CnsVolumeCreateSpec) (*CnsVolumeInfo, string, error)
	// AttachVolume attaches a volume to a virtual machine given the spec.
	// When AttachVolume failed, the second return value (faultType) and third return value(error) need to be set, and
	// should not be nil.
	AttachVolume(ctx context.Context, vm *cnsvsphere.VirtualMachine,
		volumeID string, checkNVMeController bool) (string, string, error)
	// DetachVolume detaches a volume from the virtual machine given the spec.
	// When DetachVolume failed, the first return value (faultType) and second return value(error) need to be set, and
	// should not be nil.
	DetachVolume(ctx context.Context, vm *cnsvsphere.VirtualMachine, volumeID string) (string, error)
	// DeleteVolume deletes a volume given its spec.
	// When DeleteVolume failed, the first return value (faultType) and second return value(error) need to be set, and
	// should not be nil.
	DeleteVolume(ctx context.Context, volumeID string, deleteDisk bool) (string, error)
	// UpdateVolumeMetadata updates a volume metadata given its spec.
	UpdateVolumeMetadata(ctx context.Context, spec *cnstypes.CnsVolumeMetadataUpdateSpec) error
	// QueryVolumeInfo calls the CNS QueryVolumeInfo API and return a task, from
	// which CnsQueryVolumeInfoResult is extracted.
	QueryVolumeInfo(ctx context.Context, volumeIDList []cnstypes.CnsVolumeId) (*cnstypes.CnsQueryVolumeInfoResult, error)
	// QueryAllVolume returns all volumes matching the given filter and selection.
	QueryAllVolume(ctx context.Context, queryFilter cnstypes.CnsQueryFilter,
		querySelection cnstypes.CnsQuerySelection) (*cnstypes.CnsQueryResult, error)
	// QueryVolumeAsync returns CnsQueryResult matching the given filter by using
	// CnsQueryAsync API. QueryVolumeAsync takes querySelection spec, which helps
	// to specify which fields have to be returned for the query entities. All
	// volume fields would be returned as part of the CnsQueryResult, if the
	// querySelection parameters are not specified.
	QueryVolumeAsync(ctx context.Context, queryFilter cnstypes.CnsQueryFilter,
		querySelection *cnstypes.CnsQuerySelection) (*cnstypes.CnsQueryResult, error)
	// QueryVolume returns volumes matching the given filter.
	QueryVolume(ctx context.Context, queryFilter cnstypes.CnsQueryFilter) (*cnstypes.CnsQueryResult, error)
	// RelocateVolume migrates volumes to their target datastore as specified in relocateSpecList.
	RelocateVolume(ctx context.Context, relocateSpecList ...cnstypes.BaseCnsVolumeRelocateSpec) (*object.Task, error)
	// ExpandVolume expands a volume to a new size.
	// When ExpandVolume failed, the first return value (faultType) and second return value(error) need to be set, and
	// should not be nil.
	ExpandVolume(ctx context.Context, volumeID string, size int64) (string, error)
	// ResetManager helps set new manager instance and VC configuration.
	ResetManager(ctx context.Context, vcenter *cnsvsphere.VirtualCenter)
	// ConfigureVolumeACLs configures net permissions for a given CnsVolumeACLConfigureSpec.
	ConfigureVolumeACLs(ctx context.Context, spec cnstypes.CnsVolumeACLConfigureSpec) error
	// RegisterDisk registers virtual disks as FCDs using Vslm endpoint.
	RegisterDisk(ctx context.Context, path string, name string) (string, error)
	// RetrieveVStorageObject helps in retreiving virtual disk information for a given volume id.
	RetrieveVStorageObject(ctx context.Context, volumeID string) (*vim25types.VStorageObject, error)
	// ProtectVolumeFromVMDeletion sets keepAfterDeleteVm control flag on migrated volume
	ProtectVolumeFromVMDeletion(ctx context.Context, volumeID string) error
	// CreateSnapshot helps create a snapshot for a block volume
	CreateSnapshot(ctx context.Context, volumeID string, desc string) (*CnsSnapshotInfo, error)
	// DeleteSnapshot helps delete a snapshot for a block volume
	DeleteSnapshot(ctx context.Context, volumeID string, snapshotID string) error
	// QuerySnapshots retrieves the list of snapshots based on the query filter.
	QuerySnapshots(ctx context.Context, snapshotQueryFilter cnstypes.CnsSnapshotQueryFilter) (
		*cnstypes.CnsSnapshotQueryResult, error)
}

Manager provides functionality to manage volumes.

func GetManager

func GetManager(ctx context.Context, vc *cnsvsphere.VirtualCenter,
	operationStore cnsvolumeoperationrequest.VolumeOperationRequest,
	idempotencyHandlingEnabled bool) Manager

GetManager returns the Manager instance.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL