Documentation ¶
Index ¶
- Constants
- Variables
- func IsLogicalVolumeNotFound(err error) bool
- func IsPhysicalVolumeNotFound(err error) bool
- func IsVolumeGroupNotFound(err error) bool
- func LVMatchTag(tag string) func(lvsItem) bool
- func ListVolumeGroupNames() ([]string, error)
- func ListVolumeGroupUUIDs() ([]string, error)
- func PVScan(dev string) error
- func SetLockFilePath(filepath string)
- func SetLogger(l logger)
- func VGScan(name string) error
- func ValidateLogicalVolumeName(name string) error
- func ValidateTag(tag string) error
- func ValidateVolumeGroupName(name string) error
- type CleanupSteps
- type CreateLogicalVolumeOpt
- type LVOpts
- type LinearConfig
- type LogicalVolume
- func (lv *LogicalVolume) Extend(size string, resizeFS bool) error
- func (lv *LogicalVolume) ExtendWithLogicalExtents(extend string, resizeFS bool) error
- func (lv *LogicalVolume) Name() string
- func (lv *LogicalVolume) Path() (string, error)
- func (lv *LogicalVolume) Remove() error
- func (lv *LogicalVolume) SizeInBytes() uint64
- func (lv *LogicalVolume) Tags() ([]string, error)
- type LoopDevice
- type PhysicalVolume
- type VolumeGroup
- func (vg *VolumeGroup) BytesFree(raid VolumeLayout) (uint64, error)
- func (vg *VolumeGroup) BytesTotal() (uint64, error)
- func (vg *VolumeGroup) Check() error
- func (vg *VolumeGroup) CreateLogicalVolume(name string, sizeInBytes uint64, tags []string, defaultYes bool, ...) (*LogicalVolume, error)
- func (vg *VolumeGroup) ExtentCount() (uint64, error)
- func (vg *VolumeGroup) ExtentFreeCount(raid VolumeLayout) (uint64, error)
- func (vg *VolumeGroup) ExtentSize() (uint64, error)
- func (vg *VolumeGroup) FindLogicalVolume(matchFirst func(lvsItem) bool) (*LogicalVolume, error)
- func (vg *VolumeGroup) ListLogicalVolumeNames() ([]string, error)
- func (vg *VolumeGroup) ListPhysicalVolumeNames() ([]string, error)
- func (vg *VolumeGroup) LookupLogicalVolume(name string) (*LogicalVolume, error)
- func (vg *VolumeGroup) Name() string
- func (vg *VolumeGroup) Remove() error
- func (vg *VolumeGroup) Tags() ([]string, error)
- type VolumeLayout
- type VolumeType
Constants ¶
const ErrInvalidLVName = simpleError("lvm: Name contains invalid character, valid set includes: [A-Za-z0-9_+.-]")
const ErrInvalidVGName = simpleError("lvm: Name contains invalid character, valid set includes: [A-Za-z0-9_+.-]")
const ErrLogicalVolumeNotFound = simpleError("lvm: logical volume not found")
const ErrNoSpace = simpleError("lvm: not enough free space")
const ErrPhysicalVolumeNotFound = simpleError("lvm: physical volume not found")
const ErrTagHasInvalidChars = simpleError("lvm: Tag must consist of only [A-Za-z0-9_+.-] and cannot start with a '-'")
const ErrTagInvalidLength = simpleError("lvm: Tag length must be between 1 and 1024 characters")
const ErrTooFewDisks = simpleError("lvm: not enough underlying devices")
const ErrVolumeGroupNotFound = simpleError("lvm: volume group not found")
const MaxSize uint64 = 0
MaxSize states that all available space should be used by the create operation.
Variables ¶
var ( // VolumeTypeDefault is the zero-value of VolumeType and is used to // specify no --type= flag if an empty VolumeLayout is provided. VolumeTypeDefault VolumeType VolumeTypeLinear = VolumeType{"linear"} VolumeTypeRAID1 = VolumeType{"raid1"} )
var Verbose bool
Control verbose output of all LVM CLI commands
Functions ¶
func IsLogicalVolumeNotFound ¶
func IsVolumeGroupNotFound ¶
func LVMatchTag ¶
func ListVolumeGroupNames ¶
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 ¶
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 PVScan ¶
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 SetLockFilePath ¶
func SetLockFilePath(filepath string)
SetLockFilePath sets the path to the LOCK file to use for preventing concurrent invocations of LVM command-line utilities.
See - https://jira.mesosphere.com/browse/DCOS_OSS-5434 - https://github.com/lvmteam/lvm2/issues/23
func VGScan ¶
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 ¶
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 ¶
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 ¶
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 CleanupSteps ¶
type CleanupSteps []func() error
CleanupSteps performs deferred cleanup on condition that an error was returned in the caller. This simplifies code where earlier steps need to be undone if a later step fails. It is not currently resilient to panics as this library is not expected to panic.
func (*CleanupSteps) Add ¶
func (fns *CleanupSteps) Add(fn func() error)
Add appends the given cleanup function to those that will be called if an error occurs.
func (*CleanupSteps) Unwind ¶
func (fns *CleanupSteps) Unwind()
Unwind calls the cleanup funcions in LIFO order. It panics if any of them return an error as failure during recovery is itself unrecoverable.
type CreateLogicalVolumeOpt ¶
type CreateLogicalVolumeOpt func(opts *LVOpts)
func VolumeLayoutOpt ¶
func VolumeLayoutOpt(r VolumeLayout) CreateLogicalVolumeOpt
type LinearConfig ¶
type LinearConfig struct{}
func (LinearConfig) Flags ¶
func (c LinearConfig) Flags() (fs []string)
type LogicalVolume ¶
type LogicalVolume struct {
// contains filtered or unexported fields
}
func (*LogicalVolume) ExtendWithLogicalExtents ¶
func (lv *LogicalVolume) ExtendWithLogicalExtents(extend string, resizeFS bool) error
func (*LogicalVolume) Name ¶
func (lv *LogicalVolume) Name() 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) Tags ¶
func (lv *LogicalVolume) Tags() ([]string, error)
Tags returns the volume group tags.
type LoopDevice ¶
type LoopDevice struct {
// contains filtered or unexported fields
}
LoopDevice represents a loop device such as `/dev/loop0` backed by a file.
func CreateLoopDevice ¶
func CreateLoopDevice(size uint64) (device *LoopDevice, err error)
CreateLoopDevice returns a file-backed loop device. The caller is responsible for calling `Close()` on the `*LoopDevice` when done with it.
CreateLoopDevice may panic if an error occurs during error recovery.
func (*LoopDevice) Close ¶
func (d *LoopDevice) Close() error
Close detaches the loop device and removes the backing file.
func (*LoopDevice) Path ¶
func (d *LoopDevice) Path() string
func (*LoopDevice) String ¶
func (d *LoopDevice) String() string
type PhysicalVolume ¶
type PhysicalVolume struct {
// contains filtered or unexported fields
}
func CreatePhysicalVolume ¶
func CreatePhysicalVolume(dev string) (*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) (*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(raid VolumeLayout) (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, defaultYes bool, optFns ...CreateLogicalVolumeOpt) (*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.
Additional optional config items can be specified using CreateLogicalVolumeOpt
func (*VolumeGroup) ExtentCount ¶
func (vg *VolumeGroup) ExtentCount() (uint64, error)
ExtentCount returns the number of extents.
func (*VolumeGroup) ExtentFreeCount ¶
func (vg *VolumeGroup) ExtentFreeCount(raid VolumeLayout) (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) FindLogicalVolume ¶
func (vg *VolumeGroup) FindLogicalVolume(matchFirst func(lvsItem) bool) (*LogicalVolume, error)
FindLogicalVolume looks up the logical volume in the volume group with the given name.
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.
func (*VolumeGroup) Tags ¶
func (vg *VolumeGroup) Tags() ([]string, error)
Tags returns the volume group tags.
type VolumeLayout ¶
type VolumeLayout struct { // Type corresponds to the --type= option to lvcreate. Type VolumeType // Type corresponds to the --mirrors= option to lvcreate. Mirrors uint64 // Type corresponds to the --stripes= option to lvcreate. Stripes uint64 // Type corresponds to the --stripesize= option to lvcreate. StripeSize uint64 }
VolumeLayout controls the RAID-related CLI options passed to lvcreate. See the lvmraid or lvcreate man pages for more details on what these options mean and how they may be used.
func (VolumeLayout) Flags ¶
func (c VolumeLayout) Flags() (fs []string)
func (VolumeLayout) MinNumberOfDevices ¶
func (c VolumeLayout) MinNumberOfDevices() uint64
type VolumeType ¶
type VolumeType struct {
// contains filtered or unexported fields
}
VolumeType controls the value of the --type= flag when logical volumes are created. Its constructor is not exported to ensure that the user cannot specify unexpected values.