converge: github.com/asteris-llc/converge/resource/lvm/lowlevel Index | Files

package lowlevel

import "github.com/asteris-llc/converge/resource/lvm/lowlevel"

Index

Package Files

exec.go lv.go pv.go query.go size.go systemd.go util.go vg.go

type Exec Uses

type Exec interface {
    Run(prog string, args []string) error
    RunWithExitCode(prog string, args []string) (int, error) // for mountpoint querying
    Read(prog string, args []string) (stdout string, err error)
    ReadWithExitCode(prog string, args []string) (stdout string, rc int, err error) // for blkid querying
    Lookup(prog string) error
    Getuid() int

    // unit read/write injection
    ReadFile(fn string) ([]byte, error)
    WriteFile(fn string, c []byte, p os.FileMode) error
    MkdirAll(path string, perm os.FileMode) error
    Exists(path string) (bool, error)

    // Local Filesystem Functions
    EvalSymlinks(string) (string, error)
}

Exec is interface to `real system` also used for test injections NB: should be reviewed, and possible refactored as base for all

processes/filesystem operrations, to make the easy mockable

NB: possoble split to ExecInterface, FilesystemInterface (possible also SystemInterface for Getuid) Related issue: https://github.com/asteris-llc/converge/issues/455

func MakeOsExec Uses

func MakeOsExec() Exec

MakeOsExec create Exec backend

type LVM Uses

type LVM interface {
    // Check for LVM tools installed and useable
    Check() error

    // Check for mkfs.* tools installed and useable
    CheckFilesystemTools(fstype string) error

    QueryLogicalVolumes(vg string) (map[string]*LogicalVolume, error)
    QueryPhysicalVolumes() (map[string]*PhysicalVolume, error)
    QueryVolumeGroups() (map[string]*VolumeGroup, error)
    CreateVolumeGroup(vg string, devs []string) error
    ExtendVolumeGroup(vg string, dev string) error
    ReduceVolumeGroup(vg string, dev string) error
    CreatePhysicalVolume(dev string) error
    RemovePhysicalVolume(dev string, force bool) error
    CreateLogicalVolume(group string, volume string, size *LvmSize) error
    Mkfs(dev string, fstype string) error
    Mountpoint(path string) (bool, error)
    Blkid(dev string) (string, error)
    WaitForDevice(path string) error

    // systemd units
    CheckUnit(filename string, content string) (bool, error)
    UpdateUnit(filename string, content string) error
    StartUnit(filename string) error
}

LVM is a public interface to LVM guts for converge highlevel modules

func MakeLvmBackend Uses

func MakeLvmBackend() LVM

MakeLvmBackend creates default LVM backend

func MakeRealLVM Uses

func MakeRealLVM(backend Exec) LVM

MakeRealLVM is actually kludge for DI (intended for creating test-backed RealLVM, and unpublish type inself)

type LogicalVolume Uses

type LogicalVolume struct {
    Name       string `mapstructure:"LVM2_LV_NAME"`
    DevicePath string `mapstructure:"LVM2_LV_DM_PATH"`
}

LogicalVolume is parsed record for LVM Logical Volume (from `lvs` output) Add more fields, if required

type LvmSize Uses

type LvmSize struct {
    Size     int64
    Relative bool
    Unit     string
}

LvmSize represent parsed and validated LVM compatible size

func ParseSize Uses

func ParseSize(sizeToParse string) (*LvmSize, error)

ParseSize parsing and validating sizes in format acceptable by LVM tools

func (*LvmSize) CommandLine Uses

func (size *LvmSize) CommandLine() [2]string

CommandLine return part of command line for calling LVM tools like lvcreate

func (*LvmSize) Option Uses

func (size *LvmSize) Option() string

Option reconstruct -l/-L parameter from size.Relative

func (*LvmSize) String Uses

func (size *LvmSize) String() string

String reconstruct size to LVM compatible form

type PhysicalVolume Uses

type PhysicalVolume struct {
    Name   string `mapstructure:"LVM2_PV_NAME"`
    Group  string `mapstructure:"LVM2_VG_NAME"`
    Device string
}

PhysicalVolume is parsed record for LVM Physical Volume (from `pvs` output) Add more fields, if required

type VolumeGroup Uses

type VolumeGroup struct {
    Name string `mapstructure:"LVM2_VG_NAME"`
}

VolumeGroup is parsed record for LVM Volume Groups (from `vgs` output) Add more fields, if required (at the moment we need only LVM2_VG_NAME to get list all existing groups)

Package lowlevel imports 13 packages (graph) and is imported by 4 packages. Updated 2016-12-25. Refresh now. Tools for package owners.