Documentation ¶
Index ¶
- Constants
- Variables
- func CreateVolume(vol *apis.DeviceVolume) error
- func DeleteVolume(volumeID string) (err error)
- func DestroyVolume(vol *apis.DeviceVolume) error
- func FormatAndMountVol(devicePath string, mountInfo *MountInfo) error
- func GetDeviceVolume(volumeID string) (*apis.DeviceVolume, error)
- func GetDeviceVolumeState(volID string) (string, string, error)
- func GetDiskDetails() ([]apis.Device, error)
- func GetFreeCapacity(diskPath string) (uint64, error)
- func GetPartitionList(diskPath string, diskMetaName string, free bool) ([]partedOutput, error)
- func GetVolumeDevPath(vol *apis.DeviceVolume) (string, error)
- func MountBlock(vol *apis.DeviceVolume, mountinfo *MountInfo) error
- func MountFilesystem(vol *apis.DeviceVolume, mount *MountInfo) error
- func MountVolume(vol *apis.DeviceVolume, mount *MountInfo) error
- func ProvisionVolume(vol *apis.DeviceVolume) (*apis.DeviceVolume, error)
- func RemoveVolFinalizer(vol *apis.DeviceVolume) error
- func RunCommand(cList []string) (string, error)
- func UmountVolume(vol *apis.DeviceVolume, targetPath string) error
- func UpdateVolInfo(vol *apis.DeviceVolume, state string) error
- func WaitForDeviceVolumeDestroy(ctx context.Context, volumeID string) error
- func WaitForDeviceVolumeProcessed(ctx context.Context, volumeID string) (*apis.DeviceVolume, error)
- type DeviceConfig
- type MountInfo
- type PartUsed
Constants ¶
const ( PartitionDiskID = "fdisk -l /dev/%s" PartitionDiskList = "lsblk -b" PartitionPrintFree = "parted /dev/%s unit b print free --script -m" PartitionPrint = "parted /dev/%s unit b print --script -m" PartitionCreate = "parted /dev/%s mkpart %s %dMiB %dMiB --script" PartitionDelete = "parted /dev/%s rm %d --script" PartitionWipeFS = "wipefs --force -a %s" )
Partition Commands
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 ¶
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 // DeviceConfiguration *DeviceConfig )
Functions ¶
func CreateVolume ¶
func CreateVolume(vol *apis.DeviceVolume) error
CreateVolume creates a partition on the disk with partition name as the pv name and size as pv size.
func DeleteVolume ¶
DeleteVolume deletes the corresponding Device Volume CR
func DestroyVolume ¶
func DestroyVolume(vol *apis.DeviceVolume) error
DestroyVolume gets the partition corresponding to a DeviceVolume resource, wipes the partition and delete the partition from the disk.
func FormatAndMountVol ¶
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 ¶
GetDeviceVolumeState returns DeviceVolume OwnerNode and State for the given volume. CreateVolume request may call it again and again until volume is "Ready".
func GetDiskDetails ¶
GetDiskDetails gets the list of all disks on the node along with disk metaname, unique identifier for the disk, free and total size of the disk.
func GetFreeCapacity ¶
GetFreeCapacity returns the size of the maximum free slot available on the disk
func GetPartitionList ¶
GetPartitionList gets the list of free/used partitions on the given disk with the given meta partition name
func GetVolumeDevPath ¶
func GetVolumeDevPath(vol *apis.DeviceVolume) (string, error)
GetVolumeDevPath returns the path to the volume. eg: /dev/sda1, /dev/nvme0n1p1
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 ¶
RunCommand runs command and returns the output/error
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, state string) error
UpdateVolInfo updates DeviceVolume CR with node id and finalizer
func WaitForDeviceVolumeDestroy ¶
WaitForDeviceVolumeDestroy waits till the device volume gets deleted.
func WaitForDeviceVolumeProcessed ¶
WaitForDeviceVolumeProcessed waits till the device volume becomes ready or failed (i.e reaches to terminal state).
Types ¶
type DeviceConfig ¶ added in v0.8.0
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 { DiskPath 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
ListPartUsed lists all disk partitions created by plugin.