Documentation ¶
Overview ¶
Package lvm contains code for running and interpreting output of system logical volume manager utils such as: pvcreate/pvremove, vgcreate/vgremove, lvcreate/lvremove
Index ¶
- Constants
- type LVM
- func (l *LVM) ExpandLV(lvName string, requiredSize int64) error
- func (l *LVM) GetAllPVs() ([]string, error)
- func (l *LVM) GetLVsInVG(vgName string) ([]string, error)
- func (l *LVM) GetVGNameByPVName(pvName string) (string, error)
- func (l *LVM) GetVgFreeSpace(vgName string) (int64, error)
- func (l *LVM) IsVGContainsLVs(vgName string) bool
- func (l *LVM) LVCreate(name, size, vgName string) error
- func (l *LVM) LVRemove(fullLVName string) error
- func (l *LVM) PVCreate(dev string) error
- func (l *LVM) PVRemove(name string) error
- func (l *LVM) RemoveOrphanPVs() error
- func (l *LVM) VGCreate(name string, pvs ...string) error
- func (l *LVM) VGRemove(name string) error
- type WrapLVM
Constants ¶
const ( // EmptyName represents empty name for PV/LV/VG EmptyName = " " // PVCreateCmdTmpl create PV cmd PVCreateCmdTmpl = lvmPath + "pvcreate --yes %s" // add PV name // PVRemoveCmdTmpl remove PV cmd PVRemoveCmdTmpl = lvmPath + "pvremove --yes %s" // add PV name // PVsInVGCmdTmpl print PVs in VG cmd PVsInVGCmdTmpl = lvmPath + "pvs --select vg_name=%s -o pv_name --noheadings" // add VG name // PVsListCmdTmpl print all PVs name on node PVsListCmdTmpl = lvmPath + "pvdisplay --short" // VGCreateCmdTmpl create VG on provided PVs cmd VGCreateCmdTmpl = lvmPath + "vgcreate --yes %s %s" // add VG name and PV names // VGRemoveCmdTmpl remove VG cmd VGRemoveCmdTmpl = lvmPath + "vgremove --yes %s" // add VG name // AllPVsCmd returns all physical volumes on the system AllPVsCmd = lvmPath + "pvs --options pv_name --noheadings" // VGFreeSpaceCmdTmpl check VG free space cmd VGFreeSpaceCmdTmpl = "vgs %s --options vg_free --units b --noheadings" // add VG name // LVCreateCmdTmpl create LV on provided VG cmd LVCreateCmdTmpl = lvmPath + "lvcreate --yes --name %s --size %s %s" // add LV name, size and VG name // LVRemoveCmdTmpl remove LV cmd LVRemoveCmdTmpl = lvmPath + "lvremove --yes %s" // add full LV name // LVsInVGCmdTmpl print LVs in VG cmd LVsInVGCmdTmpl = lvmPath + "lvs --select vg_name=%s -o lv_name --noheadings" // add VG name // PVInfoCmdTmpl returns colon (:) separated output, where pv name on first place and vg on second PVInfoCmdTmpl = lvmPath + "pvdisplay %s --colon" // add PV name // LVExpandCmdTmpl expand LV LVExpandCmdTmpl = lvmPath + "lvextend --size %sb --resizefs %s" // add full LV name )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LVM ¶
type LVM struct {
// contains filtered or unexported fields
}
LVM is an implementation of WrapLVM interface and is a wrap for system /sbin/lvm util in
func NewLVM ¶
func NewLVM(e command.CmdExecutor, l *logrus.Logger) *LVM
NewLVM is a constructor for LVM struct
func (*LVM) ExpandLV ¶
ExpandLV expand logical volume Receives full name of a logical volume and requiredSize to resize Returns error if something went wrong
func (*LVM) GetLVsInVG ¶
GetLVsInVG collects LVs for given volume group Receives Volume Group name Returns slice of found logical volumes
func (*LVM) GetVGNameByPVName ¶
GetVGNameByPVName finds out volume group name based on physical volume name
func (*LVM) GetVgFreeSpace ¶
GetVgFreeSpace returns VG free space in bytes Receives VG name to count ints free space Returns -1 in case of error and error
func (*LVM) IsVGContainsLVs ¶
IsVGContainsLVs checks whether VG vgName contains any LVs or no Receives Volume Group name to check Returns true in case of error to prevent mistaken VG remove
func (*LVM) LVCreate ¶
LVCreate created logical volume in volume group, ignore error if LV already exists Receives name of created LV, size which is a string like 1.2G, 100M and name of VG which LV should be based on Returns error if something went wrong
func (*LVM) LVRemove ¶
LVRemove removes logical volume, ignore error if LV doesn't exist Receives fullLVName that is a path to LV Returns error if something went wrong
func (*LVM) PVCreate ¶
PVCreate creates physical volume based on provided device or partition Receives device path Returns error if something went wrong
func (*LVM) PVRemove ¶
PVRemove removes physical volumes, ignore error if PV doesn't exist Receives name of a physical volume to delete Returns error if something went wrong
func (*LVM) RemoveOrphanPVs ¶
RemoveOrphanPVs removes PVs that do not have VG Returns error if something went wrong
type WrapLVM ¶
type WrapLVM interface { PVCreate(dev string) error PVRemove(name string) error VGCreate(name string, pvs ...string) error VGRemove(name string) error LVCreate(name, size, vgName string) error LVRemove(fullLVName string) error IsVGContainsLVs(vgName string) bool RemoveOrphanPVs() error GetVgFreeSpace(vgName string) (int64, error) GetAllPVs() ([]string, error) GetLVsInVG(vgName string) ([]string, error) GetVGNameByPVName(pvName string) (string, error) ExpandLV(lvName string, requiredSize int64) error }
WrapLVM is an interface that encapsulates operation with system logical volume manager (/sbin/lvm)