lvm

package
v4.17.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultTag = "@lvms"
)

Variables

View Source
var (
	DefaultListLVColumns = []string{
		"lv_name",
		"vg_name",
		"pool_lv",
		"lv_attr",
		"lv_size",
		"metadata_percent",
		"chunk_size",
	}
)
View Source
var (
	ErrVolumeGroupNotFound = fmt.Errorf("volume group not found")
)

Functions

This section is empty.

Types

type ExitError

type ExitError interface {
	ExitCode() int
	error
}

type HostLVM

type HostLVM struct {
	exec.Executor
}

func NewDefaultHostLVM

func NewDefaultHostLVM() *HostLVM

func NewHostLVM

func NewHostLVM(executor exec.Executor) *HostLVM

func (*HostLVM) ActivateLV

func (hlvm *HostLVM) ActivateLV(ctx context.Context, lvName, vgName string) error

ActivateLV activates the logical volume

func (*HostLVM) AddTagToVG

func (hlvm *HostLVM) AddTagToVG(ctx context.Context, vgName string) error

AddTagToVG adds a lvms tag to the volume group

func (*HostLVM) CreateLV

func (hlvm *HostLVM) CreateLV(ctx context.Context, lvName, vgName string, sizePercent int, chunkSizeBytes int64) error

CreateLV creates the logical volume

func (*HostLVM) CreateVG

func (hlvm *HostLVM) CreateVG(ctx context.Context, vg VolumeGroup) error

CreateVG creates a new volume group

func (*HostLVM) DeleteLV

func (hlvm *HostLVM) DeleteLV(ctx context.Context, lvName, vgName string) error

DeleteLV deactivates the logical volume and deletes it

func (*HostLVM) DeleteVG

func (hlvm *HostLVM) DeleteVG(ctx context.Context, vg VolumeGroup) error

DeleteVG deletes a volume group and the physical volumes associated with it

func (*HostLVM) ExtendLV

func (hlvm *HostLVM) ExtendLV(ctx context.Context, lvName, vgName string, sizePercent int) error

ExtendLV extends the logical volume, sizePercent has to be calculated based on virtual gibibytes.

func (*HostLVM) ExtendVG

func (hlvm *HostLVM) ExtendVG(ctx context.Context, vg VolumeGroup, pvs []string) (VolumeGroup, error)

ExtendVG Extend extends the volume group only if new physical volumes are available

func (*HostLVM) GetVG

func (hlvm *HostLVM) GetVG(ctx context.Context, name string) (VolumeGroup, error)

GetVG returns a volume group along with the associated physical volumes

func (*HostLVM) LVExists

func (hlvm *HostLVM) LVExists(ctx context.Context, lvName, vgName string) (bool, error)

LVExists checks if a logical volume exists in a volume group

func (*HostLVM) ListLVs

func (hlvm *HostLVM) ListLVs(ctx context.Context, vgName string) (*LVReport, error)

ListLVs returns the output for `lvs` command in json format

func (*HostLVM) ListLVsByName

func (hlvm *HostLVM) ListLVsByName(ctx context.Context, vgName string) ([]string, error)

ListLVsByName returns list of logical volumes for a volume group

func (*HostLVM) ListPVs

func (hlvm *HostLVM) ListPVs(ctx context.Context, vgName string) ([]PhysicalVolume, error)

ListPVs returns list of physical volumes used to create the given volume group

func (*HostLVM) ListVGs

func (hlvm *HostLVM) ListVGs(ctx context.Context, tagged bool) ([]VolumeGroup, error)

ListVGs lists all volume groups and the physical volumes associated with them.

type LVM

type LVM interface {
	CreateVG(ctx context.Context, vg VolumeGroup) error
	ExtendVG(ctx context.Context, vg VolumeGroup, pvs []string) (VolumeGroup, error)
	AddTagToVG(ctx context.Context, vgName string) error
	DeleteVG(ctx context.Context, vg VolumeGroup) error
	GetVG(ctx context.Context, name string) (VolumeGroup, error)

	ListPVs(ctx context.Context, vgName string) ([]PhysicalVolume, error)
	ListVGs(ctx context.Context, taggedByLVMS bool) ([]VolumeGroup, error)
	ListLVsByName(ctx context.Context, vgName string) ([]string, error)
	ListLVs(ctx context.Context, vgName string) (*LVReport, error)

	LVExists(ctx context.Context, lvName, vgName string) (bool, error)
	CreateLV(ctx context.Context, lvName, vgName string, sizePercent int, chunkSizeBytes int64) error
	ExtendLV(ctx context.Context, lvName, vgName string, sizePercent int) error
	ActivateLV(ctx context.Context, lvName, vgName string) error
	DeleteLV(ctx context.Context, lvName, vgName string) error
}

type LVReport

type LVReport struct {
	Report []LVReportItem `json:"report"`
}

LVReport represents the output of the `lvs --reportformat json` command

type LVReportItem

type LVReportItem struct {
	Lv []LogicalVolume `json:"lv"`
}

type LogicalVolume

type LogicalVolume struct {
	Name            string `json:"lv_name"`
	VgName          string `json:"vg_name"`
	PoolName        string `json:"pool_lv"`
	LvAttr          string `json:"lv_attr"`
	LvSize          string `json:"lv_size"`
	MetadataPercent string `json:"metadata_percent"`
	ChunkSize       string `json:"chunk_size"`
}

type PVReport

type PVReport struct {
	Report []struct {
		Pv []PhysicalVolume `json:"pv"`
	} `json:"report"`
}

PVReport represents the output of the `pvs --reportformat json` command

type PhysicalVolume

type PhysicalVolume struct {
	// PvName is the name of the Physical Volume
	PvName string `json:"pv_name"`

	// UUID is the unique identifier of the Physical Volume used in the devices file
	UUID string `json:"pv_uuid"`

	// VgName is the name of the associated Volume Group, if any
	VgName string `json:"vg_name"`

	// PvFmt is the file format of the PhysicalVolume
	PvFmt string `json:"pv_fmt"`

	// PvAttr describes the attributes of the PhysicalVolume
	PvAttr string `json:"pv_attr"`

	// PvSize describes the total space of the PhysicalVolume
	PvSize string `json:"pv_size"`

	// PvFree describes the free space of the PhysicalVolume
	PvFree string `json:"pv_free"`

	// DevSize describes the size of the underlying device on which the PhysicalVolume was created
	DevSize string `json:"dev_size"`
}

PhysicalVolume represents a physical volume of linux lvm.

type VGReport

type VGReport struct {
	Report []struct {
		Vg []struct {
			Name   string `json:"vg_name"`
			VgSize string `json:"vg_size"`
			Tags   string `json:"vg_tags"`
		} `json:"vg"`
	} `json:"report"`
}

VGReport represents the output of the `vgs --reportformat json` command

type VolumeGroup

type VolumeGroup struct {
	// Name is the name of the volume group
	Name string `json:"vg_name"`

	// VgSize is the size of the volume group
	VgSize string `json:"vg_size"`

	// PVs is the list of physical volumes associated with the volume group
	PVs []PhysicalVolume `json:"pvs"`

	// Tags is the list of tags associated with the volume group
	Tags []string `json:"vg_tags"`
}

VolumeGroup represents a volume group of linux lvm.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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