module

Krikri::PluginHelpers::LvolSize

LvolSize - parses community.general.lvol's size: parameter into the pieces the lvcreate/lvextend/lvreduce command lines need, mirroring real lvol.py's own parsing loop (the section between if size: and the Bad size specification fail_json).

Kept as a pure, side-effect-free helper so the whole grammar can be unit-tested without an LVM stack (the plugin itself shells out to vgs/lvs, which need real volume groups to exercise).

Grammar (lvcreate(8)/lvextend(8)/lvreduce(8) -L/-l): [+-]N[bBsSkKmMgGtTpPeE] absolute size, default unit MiB [+-]N%VG|PVS|FREE|ORIGIN extents as a percentage The +/- operator only applies when resizing (an existing LV); lvcreate itself never takes it.

Constants

DEFAULT_EXTENT_UNIT = "m"
DEFAULT_SIZE_UNIT = "m"
PERCENT_TARGETS = ["VG", "PVS", "FREE", "ORIGIN"]
UNIT_SUFFIXES = "bskmgtpe"

Class methods

parse(size : String | Nil) : Tuple(Parsed | Nil, String | Nil)

Returns {Parsed, nil} on success or {nil, error_message} - the exact error strings real lvol.py's fail_json calls produce.

Source

Nested types