lvm2

package
v3.0.0-beta13 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrExist = errors.New("does not exist")
)

Functions

func DMDevPath

func DMDevPath(vg, lv string) string

func DMName

func DMName(vg, lv string) string

func IsCapable

func IsCapable() bool

func PVScan

func PVScan(log *plog.Logger) error

func WithLogger

func WithLogger(log *plog.Logger) funcopt.O

Types

type LV

type LV struct {
	LVName string
	VGName string
	// contains filtered or unexported fields
}

func NewLV

func NewLV(vg string, lv string, opts ...funcopt.O) *LV

func (*LV) Activate

func (t *LV) Activate(ctx context.Context) error

func (*LV) Attrs

func (t *LV) Attrs(ctx context.Context) (LVAttrs, error)

func (*LV) Create

func (t *LV) Create(ctx context.Context, size string, args []string) error

func (*LV) Deactivate

func (t *LV) Deactivate(ctx context.Context) error

func (LV) DevPath

func (t LV) DevPath() string

func (*LV) Devices

func (t *LV) Devices(ctx context.Context) (device.L, error)

func (LV) DriverName

func (t LV) DriverName() string

func (*LV) Exists

func (t *LV) Exists(ctx context.Context) (bool, error)

func (LV) FQN

func (t LV) FQN() string

func (*LV) IsActive

func (t *LV) IsActive(ctx context.Context) (bool, error)

func (*LV) Log

func (t *LV) Log() *plog.Logger

func (*LV) Remove

func (t *LV) Remove(ctx context.Context, args []string) error

func (*LV) SetLog

func (t *LV) SetLog(log *plog.Logger)

func (*LV) Show

func (t *LV) Show(ctx context.Context) (*LVInfo, error)

func (*LV) Wipe

func (t *LV) Wipe(ctx context.Context) error

type LVAttr

type LVAttr rune
const (
	LVAttrStateActive                               LVAttr = 'a'
	LVAttrStateHistorical                           LVAttr = 'h'
	LVAttrStateSuspended                            LVAttr = 's'
	LVAttrStateInvalidSnapshot                      LVAttr = 'I'
	LVAttrStateSuspendedSnapshot                    LVAttr = 'S'
	LVAttrStateSnapshotMergeFailed                  LVAttr = 'm'
	LVAttrStateSuspendedSnapshotMergeFailed         LVAttr = 'M'
	LVAttrStateMappedDevicePresentWithoutTable      LVAttr = 'd'
	LVAttrStateMappedDevicePresentWithInactiveTable LVAttr = 'i'
	LVAttrStateThinPoolCheckNeeded                  LVAttr = 'c'
	LVAttrStateSuspendedThinPoolCheckNeeded         LVAttr = 'C'
	LVAttrStateUnknown                              LVAttr = 'X'
)

type LVAttrIndex

type LVAttrIndex uint8
const (
	LVAttrIndexType        LVAttrIndex = 0
	LVAttrIndexPermissions LVAttrIndex = iota
	LVAttrIndexAllocationPolicy
	LVAttrIndexAllocationFixedMinor
	LVAttrIndexState
	LVAttrIndexDeviceOpen
	LVAttrIndexTargetType
	LVAttrIndexZeroDataBlocks
	LVAttrIndexVolumeHealth
	LVAttrIndexSkipActivation
)

type LVAttrs

type LVAttrs string

func (LVAttrs) Attr

func (t LVAttrs) Attr(index LVAttrIndex) LVAttr

type LVInfo

type LVInfo struct {
	LVName          string `json:"lv_name"`
	VGName          string `json:"vg_name"`
	LVAttr          string `json:"lv_attr"`
	LVSize          string `json:"lv_size"`
	Origin          string `json:"origin"`
	DataPercent     string `json:"data_percent"`
	CopyPercent     string `json:"copy_percent"`
	MetadataPercent string `json:"metadata_percent"`
	MetadataDevices string `json:"metadata_devices"`
	MovePV          string `json:"move_pv"`
	ConvertPV       string `json:"convert_pv"`
	MirrorLog       string `json:"mirror_log"`
	Devices         string `json:"devices"`
}

type LVReport

type LVReport struct {
	LV []LVInfo `json:"lv"`
	VG []VGInfo `json:"vg"`
}

type ShowData

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

type VG

type VG struct {
	VGName string
	// contains filtered or unexported fields
}

func NewVG

func NewVG(vg string, opts ...funcopt.O) *VG

func (*VG) Activate

func (t *VG) Activate(ctx context.Context) error

func (*VG) ActiveLVs

func (t *VG) ActiveLVs() (device.L, error)

func (*VG) AddNodeTag

func (t *VG) AddNodeTag(ctx context.Context) error

func (*VG) AddTag

func (t *VG) AddTag(ctx context.Context, s string) error

func (*VG) Attrs

func (t *VG) Attrs(ctx context.Context) (VGAttrs, error)

func (*VG) CachedDevicesShow

func (t *VG) CachedDevicesShow(ctx context.Context) (*VGInfo, error)

func (*VG) CachedNormalShow

func (t *VG) CachedNormalShow(ctx context.Context) (l []VGInfo, err error)

CachedNormalShow retrieves cached volume group information, unmarshals the output data, and filters by the specified VGName.

It uses the command: vgs --reportformat json -o "+tags,pv_name". => The following cmd output will return 2 entries when t.VGName == "data"

{
  "report": [
    {"vg": [
       {"vg_name": "data", "pv_count": "1", "lv_count": "0", "snap_count": "0", "vg_attr": "wz--n-","vg_size": "<5.00g", "vg_free": "<5.00g", "vg_tags": "local", "pv_name": "/dev/vdb"},
       {"vg_name": "data", "pv_count": "1", "lv_count": "0", "snap_count": "0", "vg_attr": "wz--n-","vg_size": "<5.00g", "vg_free": "<5.00g", "vg_tags": "local", "pv_name": "/dev/vdc"},
       {"vg_name": "root", "pv_count": "1", "lv_count": "2", "snap_count": "0", "vg_attr": "wz--n-","vg_size": "<38.75g", "vg_free": "0 ", "vg_tags": "local", "pv_name": "/dev/vda3"}
   ]}
  ]
}

func (*VG) Create

func (t *VG) Create(ctx context.Context, size string, pvs []string, options []string) error

func (*VG) Deactivate

func (t *VG) Deactivate(ctx context.Context) error

func (*VG) DelNodeTag

func (t *VG) DelNodeTag(ctx context.Context) error

func (*VG) DelTag

func (t *VG) DelTag(ctx context.Context, s string) error

func (*VG) Devices

func (t *VG) Devices(ctx context.Context) (device.L, error)

func (VG) DriverName

func (t VG) DriverName() string

func (*VG) Exists

func (t *VG) Exists(ctx context.Context) (bool, error)

func (VG) FQN

func (t VG) FQN() string

func (*VG) HasNodeTag

func (t *VG) HasNodeTag(ctx context.Context) (bool, error)

func (*VG) HasTag

func (t *VG) HasTag(ctx context.Context, s string) (bool, error)

func (*VG) ImportDevices

func (t *VG) ImportDevices(ctx context.Context) error

func (*VG) IsActive

func (t *VG) IsActive(ctx context.Context) (bool, error)

func (*VG) Log

func (t *VG) Log() *plog.Logger

func (*VG) PVs

func (t *VG) PVs(ctx context.Context) (device.L, error)

func (*VG) Remove

func (t *VG) Remove(ctx context.Context, args []string) error

func (*VG) SetLog

func (t *VG) SetLog(log *plog.Logger)

func (*VG) Show

func (t *VG) Show(ctx context.Context, fields string) (*VGInfo, error)

func (*VG) Tags

func (t *VG) Tags(ctx context.Context) ([]string, error)

func (*VG) Wipe

func (t *VG) Wipe() error

type VGAttr

type VGAttr rune
const (
	VGAttrStateWriteable       VGAttr = 'w'
	VGAttrStateReadOnly        VGAttr = 'r'
	VGAttrStateResizeable      VGAttr = 'z'
	VGAttrStateExported        VGAttr = 'x'
	VGAttrStatePartial         VGAttr = 'p'
	VGAttrStateAllocContiguous VGAttr = 'c'
	VGAttrStateAllocCling      VGAttr = 'l'
	VGAttrStateAllocNormal     VGAttr = 'n'
	VGAttrStateAllocAnywhere   VGAttr = 'a'
	VGAttrStateClustered       VGAttr = 'c'
	VGAttrStateShared          VGAttr = 's'
)

type VGAttrIndex

type VGAttrIndex uint8
const (
	VGAttrIndexPermissions VGAttrIndex = 0
	VGAttrIndexResizeable  VGAttrIndex = iota
	VGAttrIndexExported
	VGAttrIndexPartial
	VGAttrIndexAllocationPolicy
	VGAttrIndexClusteredOrShared
)

type VGAttrs

type VGAttrs string

func (VGAttrs) Attr

func (t VGAttrs) Attr(index VGAttrIndex) VGAttr

type VGInfo

type VGInfo struct {
	VGName    string `json:"vg_name"`
	VGAttr    string `json:"vg_attr"`
	VGSize    string `json:"vg_size"`
	VGFree    string `json:"vg_free"`
	VGTags    string `json:"vg_tags"`
	SnapCount string `json:"snap_count"`
	PVCount   string `json:"pv_count"`
	LVCount   string `json:"lv_count"`
	PVName    string `json:"pv_name"`
	LVName    string `json:"lv_name"`
	Devices   string `json:"devices"`
}

func (*VGInfo) Free

func (t *VGInfo) Free() (int64, error)

func (*VGInfo) Size

func (t *VGInfo) Size() (int64, error)

Jump to

Keyboard shortcuts

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