device

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2021 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PartitionDiskID    = "fdisk -l /dev/%s"
	PartitionDiskList  = "lsblk -b"
	PartitionPrintFree = "parted /dev/%s unit b print free --script"
	PartitionPrint     = "parted /dev/%s unit b print --script"
	PartitionCreate    = "parted /dev/%s mkpart %s %dMiB %dMiB --script"
	PartitionDelete    = "parted /dev/%s rm %d --script"
	PartitionWipeFS    = "wipefs --force -a %s"
)

Partition Commands

View Source
const (
	// DeviceNamespaceKey is the environment variable to get openebs namespace
	//
	// This environment variable is set via kubernetes downward API
	DeviceNamespaceKey string = "DEVICE_DRIVER_NAMESPACE"
	// GoogleAnalyticsKey This environment variable is set via env
	GoogleAnalyticsKey string = "OPENEBS_IO_ENABLE_ANALYTICS"
	// DeviceFinalizer for the DeviceVolume CR
	DeviceFinalizer string = "device.openebs.io/finalizer"
	// DeviceNameKey is key for Device group name
	DeviceNameKey string = "openebs.io/devicename"
	// DeviceNodeKey will be used to insert Label in DeviceVolume CR
	DeviceNodeKey string = "kubernetes.io/nodename"
	// DeviceTopologyKey is supported topology key for the device driver
	DeviceTopologyKey string = "openebs.io/nodename"
	// DeviceStatusPending shows object has not handled yet
	DeviceStatusPending string = "Pending"
	// DeviceStatusFailed shows object operation has failed
	DeviceStatusFailed string = "Failed"
	// DeviceStatusReady shows object has been processed
	DeviceStatusReady string = "Ready"
	// OpenEBSCasTypeKey for the cas-type label
	OpenEBSCasTypeKey string = "openebs.io/cas-type"
	// LocalDeviceCasTypeName for the name of the cas-type
	LocalDeviceCasTypeName string = "localpv-device"
)

Variables

View Source
var (
	// DeviceNamespace is openebs system namespace
	DeviceNamespace string

	// NodeID is the NodeID of the node on which the pod is present
	NodeID string

	// GoogleAnalyticsEnabled should send google analytics or not
	GoogleAnalyticsEnabled string
)

Functions

func CreateVolume

func CreateVolume(vol *apis.DeviceVolume) error

CreateVolume Todo

func DeleteVolume

func DeleteVolume(volumeID string) (err error)

DeleteVolume deletes the corresponding Device Volume CR

func DestroyVolume

func DestroyVolume(vol *apis.DeviceVolume) error

DestroyVolume Todo

func FormatAndMountVol

func FormatAndMountVol(devicePath string, mountInfo *MountInfo) error

FormatAndMountVol formats and mounts the created volume to the desired mount path

func GetDeviceVolume

func GetDeviceVolume(volumeID string) (*apis.DeviceVolume, error)

GetDeviceVolume fetches the given DeviceVolume

func GetDeviceVolumeState

func GetDeviceVolumeState(volID string) (string, string, error)

GetDeviceVolumeState returns DeviceVolume OwnerNode and State for the given volume. CreateVolume request may call it again and again until volume is "Ready".

func GetDiskDetails

func GetDiskDetails() ([]apis.Device, error)

GetDiskDetails Todo

func GetFreeCapacity

func GetFreeCapacity(diskName string) (uint64, error)

GetFreeCapacity Todo

func GetPartitionList

func GetPartitionList(diskName string, diskMetaName string, free bool) ([][]string, error)

GetPartitionList Todo

func GetVolumeDevPath

func GetVolumeDevPath(vol *apis.DeviceVolume) (string, error)

GetVolumeDevPath Todo

func MountBlock

func MountBlock(vol *apis.DeviceVolume, mountinfo *MountInfo) error

MountBlock mounts the block disk to the specified path

func MountFilesystem

func MountFilesystem(vol *apis.DeviceVolume, mount *MountInfo) error

MountFilesystem mounts the disk to the specified path

func MountVolume

func MountVolume(vol *apis.DeviceVolume, mount *MountInfo) error

MountVolume mounts the disk to the specified path

func ProvisionVolume

func ProvisionVolume(
	vol *apis.DeviceVolume,
) (*apis.DeviceVolume, error)

ProvisionVolume creates a DeviceVolume CR, watcher for volume is present in CSI agent

func RemoveVolFinalizer

func RemoveVolFinalizer(vol *apis.DeviceVolume) error

RemoveVolFinalizer adds finalizer to DeviceVolume CR

func RunCommand

func RunCommand(cList []string) (string, error)

RunCommand Todo

func UmountVolume

func UmountVolume(vol *apis.DeviceVolume, targetPath string,
) error

UmountVolume unmounts the volume and the corresponding mount path is removed

func UpdateVolInfo

func UpdateVolInfo(vol *apis.DeviceVolume) error

UpdateVolInfo updates DeviceVolume CR with node id and finalizer

func WaitForDeviceVolumeDestroy

func WaitForDeviceVolumeDestroy(ctx context.Context, volumeID string) error

WaitForDeviceVolumeDestroy waits till the device volume gets deleted.

func WaitForDeviceVolumeProcessed

func WaitForDeviceVolumeProcessed(ctx context.Context, volumeID string) (*apis.DeviceVolume, error)

WaitForDeviceVolumeProcessed waits till the device volume becomes ready or failed (i.e reaches to terminal state).

Types

type MountInfo

type MountInfo struct {
	// FSType of a volume will specify the
	// format type - ext4(default), xfs of PV
	FSType string `json:"fsType"`

	// AccessMode of a volume will hold the
	// access mode of the volume
	AccessModes []string `json:"accessModes"`

	// MountPath of the volume will hold the
	// path on which the volume is mounted
	// on that node
	MountPath string `json:"mountPath"`

	// MountOptions specifies the options with
	// which mount needs to be attempted
	MountOptions []string `json:"mountOptions"`
}

MountInfo contains the volume related info for all types of volumes in Volume

type PartUsed added in v0.4.0

type PartUsed struct {
	DiskName string
	PartNum  uint32

	// Name denotes name of the partition.
	Name string

	// DevicePath denotes path of partition device file.
	DevicePath string

	// Total size of the partition in bytes.
	Size uint64
}

PartUsed represents disk partition created by device plugin.

func ListPartUsed added in v0.4.0

func ListPartUsed() ([]PartUsed, error)

ListPartUsed lists all disk partitions created by plugin.

func (*PartUsed) GetPVName added in v0.4.0

func (p *PartUsed) GetPVName() string

GetPVName returns the related persistent volume name.

Jump to

Keyboard shortcuts

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