lvm

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2023 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// NsenterCmd is the nsenter command
	NsenterCmd = "/nsenter --mount=/proc/1/ns/mnt"
	// VgNameTag is the vg name tag
	VgNameTag = "vgName"
	// PvTypeTag is the pv type tag
	PvTypeTag = "pvType"
	// FsTypeTag is the fs type tag
	FsTypeTag = "fsType"
	// LvmTypeTag is the lvm type tag
	LvmTypeTag = "lvmType"
	// LocalDisk local disk
	LocalDisk = "localdisk"
	// CloudDisk cloud disk
	CloudDisk = "clouddisk"
	// LinearType linear type
	LinearType = "linear"
	// StripingType striping type
	StripingType = "striping"
	// DefaultFs default fs
	DefaultFs = "ext4"
	// DefaultNA default NodeAffinity
	DefaultNA = "true"
	DirectTag = "direct"
	// TopologyNodeKey tag
	TopologyNodeKey = "topology.lvmplugin.csi.kubeservice.cn/hostname"
)
View Source
const (
	// MetadataURL is metadata server url
	MetadataURL = "http://100.100.100.200/latest/meta-data/"
	// InstanceID is the instance id tag
	InstanceID = "instance-id"
	// RegionIDTag is the region id tag
	RegionIDTag = "region-id"
)
View Source
const ErrInvalidLVName = simpleError("lvm: Name contains invalid character, valid set includes: [A-Za-z0-9_+.-]")
View Source
const ErrInvalidVGName = simpleError("lvm: Name contains invalid character, valid set includes: [A-Za-z0-9_+.-]")
View Source
const ErrLogicalVolumeNotFound = simpleError("lvm: logical volume not found")
View Source
const ErrNoSpace = simpleError("lvm: not enough free space")
View Source
const ErrPhysicalVolumeNotFound = simpleError("lvm: physical volume not found")
View Source
const ErrTagHasInvalidChars = simpleError("lvm: Tag must consist of only [A-Za-z0-9_+.-] and cannot start with a '-'")
View Source
const ErrTagInvalidLength = simpleError("lvm: Tag length must be between 1 and 1024 characters")
View Source
const ErrVolumeGroupNotFound = simpleError("lvm: volume group not found")
View Source
const MaxSize uint64 = 0

MaxSize states that all available space should be used by the create operation.

View Source
const (
	VolumeOperationAlreadyExistsErrorMsg = "An operation with the given Volume %s already exists"
)

Variables

View Source
var (
	// DeviceChars is chars of a device
	DeviceChars = []string{"b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"}
)
View Source
var ErrParse = errors.New("Cannot parse output of blkid")

ErrParse is an error that is returned when parse operation fails

View Source
var Verbose bool

Control verbose output of all LVM CLI commands

Functions

func GetMetaData

func GetMetaData(resource string) string

GetMetaData get host regionid, zoneid

func IsLogicalVolumeNotFound

func IsLogicalVolumeNotFound(err error) bool

func IsPhysicalVolumeNotFound

func IsPhysicalVolumeNotFound(err error) bool

func IsVolumeGroupNotFound

func IsVolumeGroupNotFound(err error) bool

func ListVolumeGroupNames

func ListVolumeGroupNames() ([]string, error)

ListVolumeGroupNames returns the names of the list of volume groups. This does not normally scan for devices. To scan for devices, use the `Scan()` function.

func ListVolumeGroupUUIDs

func ListVolumeGroupUUIDs() ([]string, error)

ListVolumeGroupUUIDs returns the UUIDs of the list of volume groups. This does not normally scan for devices. To scan for devices, use the `Scan()` function.

func NewNodeServer

func NewNodeServer(d *csicommon.CSIDriver, nodeID string) csi.NodeServer

NewNodeServer create a NodeServer object

func PVScan

func PVScan(dev string) error

PVScan runs the `pvscan --cache <dev>` command. It scans for the device at `dev` and adds it to the LVM metadata cache if `lvmetad` is running. If `dev` is an empty string, it scans all devices.

func VGScan

func VGScan(name string) error

VGScan runs the `vgscan --cache <name>` command. It scans for the volume group and adds it to the LVM metadata cache if `lvmetad` is running. If `name` is an empty string, it scans all volume groups.

func ValidateLogicalVolumeName

func ValidateLogicalVolumeName(name string) error

ValidateLogicalVolumeName validates a volume group name. A valid volume group name can consist of a limited range of characters only. The allowed characters are [A-Za-z0-9_+.-].

func ValidateTag

func ValidateTag(tag string) error

ValidateTag validates a tag. LVM tags are strings of up to 1024 characters. LVM tags cannot start with a hyphen. A valid tag can consist of a limited range of characters only. The allowed characters are [A-Za-z0-9_+.-]. As of the Red Hat Enterprise Linux 6.1 release, the list of allowed characters was extended, and tags can contain the /, =, !, :, #, and & characters. See https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/logical_volume_manager_administration/lvm_tags

func ValidateVolumeGroupName

func ValidateVolumeGroupName(name string) error

ValidateVolumeGroupName validates a volume group name. A valid volume group name can consist of a limited range of characters only. The allowed characters are [A-Za-z0-9_+.-].

Types

type InFlight

type InFlight struct {
	// contains filtered or unexported fields
}

InFlight is a struct used to manage in flight requests per volumeId.

func NewInFlight

func NewInFlight() *InFlight

NewInFlight instanciates a InFlight structures.

func (*InFlight) Delete

func (db *InFlight) Delete(key string)

Delete removes the entry from the inFlight entries map. It doesn't return anything, and will do nothing if the specified key doesn't exist.

func (*InFlight) Insert

func (db *InFlight) Insert(key string) bool

Insert inserts the entry to the current list of inflight request key is volumeId for node and req hash for controller . Returns false when the key already exists.

type LVM

type LVM struct {
	// contains filtered or unexported fields
}

LVM the LVM struct

func NewDriver

func NewDriver(nodeID, endpoint string) *LVM

NewDriver create the identity/node/controller server and disk driver

func (*LVM) Run

func (lvm *LVM) Run()

Run start a new server

type LogicalVolume

type LogicalVolume struct {
	// contains filtered or unexported fields
}

func (*LogicalVolume) Expand

func (lv *LogicalVolume) Expand(size uint64) error

func (*LogicalVolume) IsSnapshot

func (lv *LogicalVolume) IsSnapshot() bool

func (*LogicalVolume) Name

func (lv *LogicalVolume) Name() string

func (*LogicalVolume) OriginLVName

func (lv *LogicalVolume) OriginLVName() string

func (*LogicalVolume) Path

func (lv *LogicalVolume) Path() (string, error)

Path returns the device path for the logical volume.

func (*LogicalVolume) Remove

func (lv *LogicalVolume) Remove() error

func (*LogicalVolume) SizeInBytes

func (lv *LogicalVolume) SizeInBytes() uint64

func (*LogicalVolume) Usage

func (lv *LogicalVolume) Usage() float64

type PhysicalVolume

type PhysicalVolume struct {
	// contains filtered or unexported fields
}

func CreatePhysicalVolume

func CreatePhysicalVolume(dev string, force bool) (*PhysicalVolume, error)

CreatePhysicalVolume creates a physical volume of the given device.

func ListPhysicalVolumes

func ListPhysicalVolumes() ([]*PhysicalVolume, error)

ListPhysicalVolumes lists all physical volumes.

func LookupPhysicalVolume

func LookupPhysicalVolume(name string) (*PhysicalVolume, error)

LookupPhysicalVolume returns a physical volume with the given name.

func (*PhysicalVolume) Check

func (pv *PhysicalVolume) Check() error

Check runs the pvck command on the physical volume.

func (*PhysicalVolume) Remove

func (pv *PhysicalVolume) Remove() error

Remove removes the physical volume.

type VolumeGroup

type VolumeGroup struct {
	// contains filtered or unexported fields
}

func CreateVolumeGroup

func CreateVolumeGroup(
	name string,
	pvs []*PhysicalVolume,
	tags []string,
	force bool) (*VolumeGroup, error)

CreateVolumeGroup creates a new volume group.

func LookupVolumeGroup

func LookupVolumeGroup(name string) (*VolumeGroup, error)

LookupVolumeGroup returns the volume group with the given name.

func (*VolumeGroup) BytesFree

func (vg *VolumeGroup) BytesFree() (uint64, error)

BytesFree returns the unallocated space in bytes of the volume group.

func (*VolumeGroup) BytesTotal

func (vg *VolumeGroup) BytesTotal() (uint64, error)

BytesTotal returns the current size in bytes of the volume group.

func (*VolumeGroup) Check

func (vg *VolumeGroup) Check() error

Check runs the vgck command on the volume group.

func (*VolumeGroup) CreateLogicalVolume

func (vg *VolumeGroup) CreateLogicalVolume(name string, sizeInBytes uint64, tags []string) (*LogicalVolume, error)

CreateLogicalVolume creates a logical volume of the given device and size.

The actual size may be larger than asked for as the smallest increment is the size of an extent on the volume group in question.

If sizeInBytes is zero the entire available space is allocated.

func (*VolumeGroup) ExtentCount

func (vg *VolumeGroup) ExtentCount() (uint64, error)

ExtentCount returns the number of extents.

func (*VolumeGroup) ExtentFreeCount

func (vg *VolumeGroup) ExtentFreeCount() (uint64, error)

ExtentFreeCount returns the number of free extents.

func (*VolumeGroup) ExtentSize

func (vg *VolumeGroup) ExtentSize() (uint64, error)

ExtentSize returns the size in bytes of a single extent.

func (*VolumeGroup) ListLogicalVolumeNames

func (vg *VolumeGroup) ListLogicalVolumeNames() ([]string, error)

ListLogicalVolumes returns the names of the logical volumes in this volume group.

func (*VolumeGroup) ListPhysicalVolumeNames

func (vg *VolumeGroup) ListPhysicalVolumeNames() ([]string, error)

ListPhysicalVolumeNames returns the names of the physical volumes in this volume group.

func (*VolumeGroup) LookupLogicalVolume

func (vg *VolumeGroup) LookupLogicalVolume(name string) (*LogicalVolume, error)

LookupLogicalVolume looks up the logical volume in the volume group with the given name.

func (*VolumeGroup) Name

func (vg *VolumeGroup) Name() string

func (*VolumeGroup) Remove

func (vg *VolumeGroup) Remove() error

Remove removes the volume group from disk.

Jump to

Keyboard shortcuts

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