lowlevel

package
v0.0.0-...-02c76fb Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2020 License: Apache-2.0 Imports: 13 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Exec

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

func MakeOsExec() Exec

MakeOsExec create Exec backend

type LVM

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

func MakeLvmBackend() LVM

MakeLvmBackend creates default LVM backend

func MakeRealLVM

func MakeRealLVM(backend Exec) LVM

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

type LogicalVolume

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

type LvmSize struct {
	Size     int64
	Relative bool
	Unit     string
}

LvmSize represent parsed and validated LVM compatible size

func ParseSize

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

ParseSize parsing and validating sizes in format acceptable by LVM tools

func (*LvmSize) CommandLine

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

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

func (*LvmSize) Option

func (size *LvmSize) Option() string

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

func (*LvmSize) String

func (size *LvmSize) String() string

String reconstruct size to LVM compatible form

type PhysicalVolume

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

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)

Jump to

Keyboard shortcuts

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