utils

package
v0.2.17 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2024 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Overview

nolint: wsl,gocritic

Index

Constants

View Source
const (
	// EnvAsrrBiosUtility - to override the utility path
	EnvAsrrBiosUtility = "IRONLIB_UTIL_ASRR_BIOSCONTROL"

	// EnvAsrrKernelModule - to overide the kernel module path
	EnvAsrrKernelModule = "KERNEL_MODULE_ASRR"
)
View Source
const (
	// see test_data/dsu_return_codes.md
	DSUExitCodeUpdatesApplied     = 0
	DSUExitCodeRebootRequired     = 8
	DSUExitCodeNoUpdatesAvailable = 34

	LocalUpdatesDirectory = "/root/dsu"

	EnvDsuUtility = "IRONLIB_UTIL_DSU"
)
View Source
const (
	EnvMvcliUtility = "IRONLIB_UTIL_MVCLI"
	BitsUint8       = 8
	BitsInt64       = 64
)
View Source
const DellRacadmPath = "/opt/dell/srvadmin/bin/idracadm7"
View Source
const (
	// EnvDnfUtility - to override the utility path
	EnvDnfUtility = "IRONLIB_UTIL_DNF"
)
View Source
const (
	EnvFlashromUtility = "IRONLIB_UTIL_FLASHROM"
)
View Source
const (
	EnvHdparmUtility = "IRONLIB_UTIL_HDPARM"
)
View Source
const (
	EnvLsblkUtility = "IRONLIB_UTIL_LSBLK"
)
View Source
const (
	EnvLshwUtility = "IRONLIB_UTIL_LSHW"
)
View Source
const (
	EnvMlxupUtility = "IRONLIB_UTIL_MLXUP"
)
View Source
const (
	EnvMsecliUtility = "IRONLIB_UTIL_MSECLI"
)
View Source
const EnvNvmeUtility = "IRONLIB_UTIL_NVME"
View Source
const EnvSmartctlUtility = "IRONLIB_UTIL_SMARTCTL"
View Source
const EnvSmcIpmicfgUtility = "IRONLIB_UTIL_SMC_IPMICFG"
View Source
const EnvStorecliUtility = "IRONLIB_UTIL_STORECLI"
View Source
const (
	EnvUefiFirmwareParserUtility = "IRONLIB_UTIL_UTIL_UEFI_FIRMWARE_PARSER"
)
View Source
const EnvVarRacadm7 = "IRONLIB_UTIL_RACADM7"
View Source
const EnvVarSumPath = "IRONLIB_UTIL_SUM"

Variables

View Source
var (
	ErrDsuInventoryCollectorBinMissing   = errors.New("dsu inventory collector executable missing 'invcol_*_*.BIN'")
	ErrMultipleDsuInventoryCollectorBins = errors.New("multiple inventory collector bins found")
	ErrDsuUpdatesDirectoryMissing        = errors.New("dsu updates directory missing")
	ErrDsuVersionQuery                   = errors.New("dsu version query error")
)
View Source
var (
	ErrNoCommandOutput          = errors.New("command returned no output")
	ErrVersionStrExpectedSemver = errors.New("expected version string to follow semver format")
	ErrFakeExecutorInvalidArgs  = errors.New("invalid number of args passed to fake executor")
	ErrRepositoryBaseURL        = errors.New("repository base URL undefined, ensure UpdateOptions.BaseURL OR UPDATE_BASE_URL env var is set")
)
View Source
var (
	ErrInvalidInfoType      = errors.New("invalid info type")
	ErrInvalidRaidMode      = errors.New("invalid raid mode")
	ErrInvalidBlockSize     = errors.New("invalid block size")
	ErrInvalidInitMode      = errors.New("invalid init mode")
	ErrInvalidVirtualDiskID = errors.New("invalid virtual disk id")
	ErrDestroyVirtualDisk   = errors.New("failed to destroy virtual disk")
	ErrCreateVirtualDisk    = errors.New("failed to create virtual disk")
)
View Source
var (
	DellRepoTemplate = `` /* 1057-byte string literal not displayed */

)
View Source
var ErrASRRBIOSKernelModule = errors.New("error loading asrr bios kernel module")
View Source
var ErrDellBiosCfgFileEmpty = errors.New("BIOS config file empty or invalid")
View Source
var ErrDellBiosCfgFileUndefined = errors.New("no BIOS config file defined")
View Source
var ErrDellBiosCfgNil = errors.New("expected valid bios config object, got nil")
View Source
var ErrLsblkTransportUnsupported = errors.New("Unsupported transport type")
View Source
var (
	ErrMseCliDriveNotIdentified = errors.New("failed to identify drive for update")
)
View Source
var (
	ErrParseLshwOutput = errors.New("lshw output parse error")
)

Functions

func CreateVirtualDiskError added in v0.2.0

func CreateVirtualDiskError(createStdout []byte) error

func DestroyVirtualDiskError added in v0.2.0

func DestroyVirtualDiskError(destroyStdout []byte) error

func InvalidBlockSizeError added in v0.2.0

func InvalidBlockSizeError(blockSize uint) error

func InvalidInfoTypeError added in v0.2.0

func InvalidInfoTypeError(infoType string) error

func InvalidInitModeError added in v0.2.0

func InvalidInitModeError(initMode string) error

func InvalidRaidModeError added in v0.2.0

func InvalidRaidModeError(raidMode string) error

func InvalidVirtualDiskIDError added in v0.2.0

func InvalidVirtualDiskIDError(virtualDiskID int) error

Types

type AsrrBioscontrol

type AsrrBioscontrol struct {
	Executor Executor
	// contains filtered or unexported fields
}

AsrrBiosControl is a asrr-bioscontrol executor

func NewAsrrBioscontrol

func NewAsrrBioscontrol(trace bool) *AsrrBioscontrol

NewAsrrBioscontrol returns a new Asrr bios control utility executor

func (*AsrrBioscontrol) Attributes added in v0.2.2

func (a *AsrrBioscontrol) Attributes() (utilName model.CollectorUtility, absolutePath string, err error)

Attributes implements the actions.UtilAttributeGetter interface

func (*AsrrBioscontrol) GetBIOSConfiguration

func (a *AsrrBioscontrol) GetBIOSConfiguration(ctx context.Context, _ string) (map[string]string, error)

GetBIOSConfiguration returns a BIOS configuration object

type CommandStatus

type CommandStatus struct {
	Status      string `json:"Status"`
	Description string `json:"Description"`
}

type Controller

type Controller struct {
	CommandStatus *CommandStatus `json:"Command Status"`
	ResponseData  *ResponseData  `json:"Response Data"`
}

type DellRacadm

type DellRacadm struct {
	Executor       Executor
	ConfigJSON     string
	BIOSCfgTmpFile string // where we dump the BIOS config to before processing it
	KeepConfigFile bool   // flag to keep the BIOS config file generated (mainly for testing)
}

DellRacadm is a dell racadm executor

func NewDellRacadm

func NewDellRacadm(trace bool) *DellRacadm

Return a new Dell racadm command executor

func NewFakeRacadm

func NewFakeRacadm(biosCfgFile string) *DellRacadm

NewFakeRacadm returns a fake lshw executor for testing

func (*DellRacadm) Attributes added in v0.2.2

func (s *DellRacadm) Attributes() (utilName model.CollectorUtility, absolutePath string, err error)

Attributes implements the actions.UtilAttributeGetter interface

func (*DellRacadm) GetBIOSConfiguration

func (s *DellRacadm) GetBIOSConfiguration(ctx context.Context, deviceModel string) (map[string]string, error)

GetBIOSConfiguration returns a BIOS configuration object

type DeviceIdentifiers

type DeviceIdentifiers struct {
	Vendor string
	Model  string
	Serial string
}

func IdentifyVendorModel

func IdentifyVendorModel(dmidecode *Dmidecode) (*DeviceIdentifiers, error)

IdentifyVendorModel returns the device vendor, model, serial number attributes

type Dmidecode

type Dmidecode struct {
	// contains filtered or unexported fields
}

func InitFakeDmidecode added in v0.2.0

func InitFakeDmidecode(testFile string) (*Dmidecode, error)

InitFakeDmidecode returns a fake dmidecode instance loaded with the dmidecode output from testFile

func NewDmidecode

func NewDmidecode() (d *Dmidecode, err error)

func (*Dmidecode) Attributes added in v0.2.2

func (d *Dmidecode) Attributes() (utilName model.CollectorUtility, absolutePath string, err error)

Attributes implements the actions.UtilAttributeGetter interface

func (*Dmidecode) BIOSVersion

func (d *Dmidecode) BIOSVersion() (string, error)

BIOSVersion queries dmidecode and returns the BIOS version

func (*Dmidecode) BaseBoardManufacturer

func (d *Dmidecode) BaseBoardManufacturer() (string, error)

BaseBoardManufacturer queries dmidecode and returns the baseboard-manufacturer

func (*Dmidecode) BaseBoardProductName

func (d *Dmidecode) BaseBoardProductName() (string, error)

BaseBoardProductName queries dmidecode and returns the base board product name

func (*Dmidecode) BaseBoardSerialNumber

func (d *Dmidecode) BaseBoardSerialNumber() (string, error)

BaseBoardSerialNumber queries dmidecode and returns the base board serial number

func (*Dmidecode) ChassisSerialNumber

func (d *Dmidecode) ChassisSerialNumber() (string, error)

ChassisSerialNumber queries dmidecode and returns the chassis serial number

func (*Dmidecode) Manufacturer

func (d *Dmidecode) Manufacturer() (string, error)

Manufacturer queries dmidecode and returns server vendor

func (*Dmidecode) ProductName

func (d *Dmidecode) ProductName() (string, error)

ProductName queries dmidecode and returns the product name

func (*Dmidecode) SerialNumber

func (d *Dmidecode) SerialNumber() (string, error)

SerialNumber queries dmidecode and returns the serial number

func (*Dmidecode) TPMs added in v0.2.0

func (d *Dmidecode) TPMs(ctx context.Context) ([]*common.TPM, error)

type Dnf

type Dnf struct {
	Executor Executor
}

func NewDnf

func NewDnf(trace bool) *Dnf

Return a new dnf executor

func NewFakeDnf

func NewFakeDnf() *Dnf

Returns a fake dnf instance for tests

func (*Dnf) AddRepo

func (d *Dnf) AddRepo(path string, params *DnfRepoParams, _ []byte) (err error)

AddRepo sets up a dnf repo file with the given template and params

path: the directory where the repo file is created, default: "/etc/yum.repos.d/"

func (*Dnf) Attributes added in v0.2.2

func (d *Dnf) Attributes() (utilName model.CollectorUtility, absolutePath string, err error)

Attributes implements the actions.UtilAttributeGetter interface

func (*Dnf) Install

func (d *Dnf) Install(pkgNames []string) (err error)

Install given packages

type DnfRepoParams

type DnfRepoParams struct {
	GPGCheck    bool
	Name        string
	BaseURL     string
	RepoVersion string
}

type Dsu

type Dsu struct {
	Executor Executor
}

func NewDsu

func NewDsu(trace bool) *Dsu

NewDsu returns a executor to run dsu commands if trace is enabled, stdout is printed to the terminal

func NewFakeDsu

func NewFakeDsu(r io.Reader) (*Dsu, error)

Returns a dsu instance with a fake executor for tests

func (*Dsu) ApplyLocalUpdates

func (d *Dsu) ApplyLocalUpdates(updateDir string) (int, error)

ApplyLocalUpdates installs update files fetched by FetchUpdateFiles() DSU needs to be pointed to the right inventory bin or it barfs returns the resulting exitcode and error if any

func (*Dsu) ApplyUpdates

func (d *Dsu) ApplyUpdates() (int, error)

ApplyUpdates installs all available updates

func (*Dsu) Attributes added in v0.2.2

func (d *Dsu) Attributes() (utilName model.CollectorUtility, absolutePath string, err error)

Attributes implements the actions.UtilAttributeGetter interface

func (*Dsu) ComponentFirmwareUpdatePreview

func (d *Dsu) ComponentFirmwareUpdatePreview() ([]*model.Component, int, error)

Returns component firmware updates available based on the dell system update

func (*Dsu) FetchUpdateFiles

func (d *Dsu) FetchUpdateFiles(dstDir string) (int, error)

FetchUpdateFiles executes dsu to fetch applicable updates into to local directory returns the exitcode and error if any NOTE: dsu 1.8 drops update files under the given $updateDir dsu 1.9 creates a directory '$updateDir/dellupdates' and drops the updates in there

func (*Dsu) Inventory

func (d *Dsu) Inventory() ([]*model.Component, error)

Inventory collects inventory with the dell-system-update utility and updates device component firmware based on data listed by the dell system update tool

func (*Dsu) Version

func (d *Dsu) Version() (string, error)

Version returns the dsu currently installed

type ExecError

type ExecError struct {
	Cmd      string
	Stderr   string
	Stdout   string
	ExitCode int
}

ExecError is returned when the command exits with an error or a non zero exit status

func (*ExecError) Error

func (u *ExecError) Error() string

Error implements the error interface

type Execute

type Execute struct {
	Cmd      string
	Args     []string
	Env      []string
	Stdin    io.Reader
	CheckBin bool
	Quiet    bool
}

An execute instace

func (*Execute) CheckExecutable added in v0.2.2

func (e *Execute) CheckExecutable() error

CheckExecutable determines if the set Cmd value exists as a file and is an executable.

func (*Execute) CmdPath added in v0.2.2

func (e *Execute) CmdPath() string

CmdPath returns the absolute path to the executable this means the caller should not have disabled CheckBin.

func (*Execute) DisableBinCheck

func (e *Execute) DisableBinCheck()

DisableBinCheck disables validating the binary exists and is executable

func (*Execute) ExecWithContext

func (e *Execute) ExecWithContext(ctx context.Context) (result *Result, err error)

ExecWithContext executes the command and returns the Result object

func (*Execute) GetCmd

func (e *Execute) GetCmd() string

GetCmd returns the command with args as a string

func (*Execute) SetArgs

func (e *Execute) SetArgs(a []string)

SetArgs sets the command args

func (*Execute) SetEnv

func (e *Execute) SetEnv(env []string)

SetEnv sets the env variables

func (*Execute) SetExitCode

func (e *Execute) SetExitCode(_ int)

SetExitCode doesn't do much, is around for tests

func (*Execute) SetQuiet

func (e *Execute) SetQuiet()

SetQuiet lowers the verbosity

func (*Execute) SetStderr

func (e *Execute) SetStderr(_ []byte)

SetStderr doesn't do much, is around for tests

func (*Execute) SetStdin

func (e *Execute) SetStdin(r io.Reader)

SetStdin sets the reader to the command stdin

func (*Execute) SetStdout

func (e *Execute) SetStdout(_ []byte)

SetStdout doesn't do much, is around for tests

func (*Execute) SetVerbose

func (e *Execute) SetVerbose()

SetVerbose does whats it says

type Executor

type Executor interface {
	ExecWithContext(context.Context) (*Result, error)
	SetArgs([]string)
	SetEnv([]string)
	SetQuiet()
	SetVerbose()
	GetCmd() string
	DisableBinCheck()
	SetStdin(io.Reader)
	CmdPath() string
	CheckExecutable() error
	// for tests
	SetStdout([]byte)
	SetStderr([]byte)
	SetExitCode(int)
}

Executor interface lets us implement dummy executors for tests

func NewExecutor

func NewExecutor(cmd string) Executor

func NewFakeExecutor

func NewFakeExecutor(cmd string) Executor

func NewFakeLshwExecutor

func NewFakeLshwExecutor(cmd string) Executor

NewFakeLshwExecutor returns a fake lshw executor for tests

func NewFakeRacadmExecutor

func NewFakeRacadmExecutor(cmd string) Executor

NewFakeRacadmExecute returns a fake SMC sum executor for tests

func NewFakeSMCSumExecutor

func NewFakeSMCSumExecutor(cmd string) Executor

NewFakeSMCSumExecute returns a fake SMC sum executor for tests

func NewFakeSmartctlExecutor

func NewFakeSmartctlExecutor(cmd, dir string) Executor

NewFakeSmartctlExecutor returns a fake smartctl executor for tests

type FakeExecute

type FakeExecute struct {
	Cmd      string
	Args     []string
	Env      []string
	CheckBin bool
	Stdin    io.Reader
	Stdout   []byte // Set this for the dummy data to be returned
	Stderr   []byte // Set this for the dummy data to be returned
	Quiet    bool
	ExitCode int
}

FakeExecute implements the utils.Executor interface to enable testing

func (*FakeExecute) CheckExecutable added in v0.2.2

func (e *FakeExecute) CheckExecutable() error

CheckExecutable implements the Executor interface

func (*FakeExecute) CmdPath added in v0.2.2

func (e *FakeExecute) CmdPath() string

CmdPath returns the absolute path to the executable this means the caller should not have disabled CheckBin.

func (*FakeExecute) DisableBinCheck

func (e *FakeExecute) DisableBinCheck()

func (*FakeExecute) ExecWithContext

func (e *FakeExecute) ExecWithContext(_ context.Context) (*Result, error)

nolint:gocyclo // TODO: break this method up and move into each $util_test.go FakeExecute method returns whatever you want it to return Set e.Stdout and e.Stderr to data to be returned

func (*FakeExecute) GetCmd

func (e *FakeExecute) GetCmd() string

func (*FakeExecute) SetArgs

func (e *FakeExecute) SetArgs(a []string)

func (*FakeExecute) SetEnv

func (e *FakeExecute) SetEnv(env []string)

func (*FakeExecute) SetExitCode

func (e *FakeExecute) SetExitCode(i int)

func (*FakeExecute) SetQuiet

func (e *FakeExecute) SetQuiet()

func (*FakeExecute) SetStderr

func (e *FakeExecute) SetStderr(b []byte)

func (*FakeExecute) SetStdin

func (e *FakeExecute) SetStdin(r io.Reader)

func (*FakeExecute) SetStdout

func (e *FakeExecute) SetStdout(b []byte)

func (*FakeExecute) SetVerbose

func (e *FakeExecute) SetVerbose()

type FakeLshwExecute

type FakeLshwExecute struct {
	Cmd    string
	Args   []string
	Env    []string
	Stdin  io.Reader
	Stdout []byte // Set this for the dummy data to be returned
	Stderr []byte // Set this for the dummy data to be returned
	Quiet  bool
	// Executor embedded in here to skip having to implement all the utils.Executor methods
	Executor
}

FakeLshwExecute implements the utils.Executor interface for testing

func (*FakeLshwExecute) ExecWithContext

func (e *FakeLshwExecute) ExecWithContext(ctx context.Context) (*Result, error)

ExecWithContext implements the utils.Executor interface

func (*FakeLshwExecute) SetArgs

func (e *FakeLshwExecute) SetArgs(a []string)

SetArgs is to set cmd args to the fake execute method

func (*FakeLshwExecute) SetStdin

func (e *FakeLshwExecute) SetStdin(r io.Reader)

SetStdin is to set input to the fake execute method

type FakeRacadmExecute

type FakeRacadmExecute struct {
	Cmd    string
	Args   []string
	Env    []string
	Stdin  io.Reader
	Stdout []byte // Set this for the dummy data to be returned
	Stderr []byte // Set this for the dummy data to be returned
	Quiet  bool
	// Executor embedded in here to skip having to implement all the utils.Executor methods
	Executor
}

FakeRacadmExecute implements the utils.Executor interface for testing

func (*FakeRacadmExecute) ExecWithContext

func (e *FakeRacadmExecute) ExecWithContext(ctx context.Context) (*Result, error)

ExecWithContext implements the utils.Executor interface

func (*FakeRacadmExecute) SetArgs

func (e *FakeRacadmExecute) SetArgs(a []string)

SetArgs is to set cmd args to the fake execute method

type FakeSMCSumExecute

type FakeSMCSumExecute struct {
	Cmd    string
	Args   []string
	Env    []string
	Stdin  io.Reader
	Stdout []byte // Set this for the dummy data to be returned
	Stderr []byte // Set this for the dummy data to be returned
	Quiet  bool
	// Executor embedded in here to skip having to implement all the utils.Executor methods
	Executor
}

FakeSMCSumExecute implements the utils.Executor interface for testing

func (*FakeSMCSumExecute) ExecWithContext

func (e *FakeSMCSumExecute) ExecWithContext(_ context.Context) (*Result, error)

ExecWithContext implements the utils.Executor interface

func (*FakeSMCSumExecute) GetCmd added in v0.2.0

func (e *FakeSMCSumExecute) GetCmd() string

GetCmd is to retrieve the cmd args for the fake execute method

func (*FakeSMCSumExecute) SetArgs

func (e *FakeSMCSumExecute) SetArgs(a []string)

SetArgs is to set cmd args to the fake execute method

func (*FakeSMCSumExecute) SetStdin

func (e *FakeSMCSumExecute) SetStdin(r io.Reader)

SetStdin is to set input to the fake execute method

type FakeSmartctlExecute

type FakeSmartctlExecute struct {
	Cmd          string
	Args         []string
	Env          []string
	Stdin        io.Reader
	Stdout       []byte // Set this for the dummy data to be returned
	Stderr       []byte // Set this for the dummy data to be returned
	Quiet        bool
	JSONFilesDir string
	ExitCode     int
	CheckBin     bool
	// Executor embedded in here to skip having to implement all the utils.Executor methods
	Executor
}

FakeSmartctlExecute implements the utils.Executor interface for testing

func (*FakeSmartctlExecute) CheckExecutable added in v0.2.4

func (e *FakeSmartctlExecute) CheckExecutable() error

CheckExecutable implements the Executor interface

func (*FakeSmartctlExecute) CmdPath added in v0.2.4

func (e *FakeSmartctlExecute) CmdPath() string

func (*FakeSmartctlExecute) ExecWithContext

func (e *FakeSmartctlExecute) ExecWithContext(ctx context.Context) (*Result, error)

nolint:gocyclo // test code ExecWithContext implements the utils.Executor interface

func (*FakeSmartctlExecute) SetArgs

func (e *FakeSmartctlExecute) SetArgs(a []string)

SetArgs is to set cmd args to the fake execute method

func (*FakeSmartctlExecute) SetExitCode

func (e *FakeSmartctlExecute) SetExitCode(i int)

func (*FakeSmartctlExecute) SetStdin

func (e *FakeSmartctlExecute) SetStdin(r io.Reader)

SetStdin is to set input to the fake execute method

type Flashrom added in v0.2.15

type Flashrom struct {
	Executor Executor
}

func NewFlashromCmd added in v0.2.15

func NewFlashromCmd(trace bool) *Flashrom

Return a new flashrom executor

func (*Flashrom) Attributes added in v0.2.15

func (f *Flashrom) Attributes() (utilName model.CollectorUtility, absolutePath string, err error)

Attributes implements the actions.UtilAttributeGetter interface

func (*Flashrom) WriteBIOSImage added in v0.2.15

func (f *Flashrom) WriteBIOSImage(ctx context.Context, path string) error

ExtractBIOSImage writes the BIOS image to the given file system path.

type Hdparm added in v0.2.0

type Hdparm struct {
	Executor Executor
}

func NewFakeHdparm added in v0.2.0

func NewFakeHdparm() *Hdparm

NewFakeHdparm returns a mock hdparm collector that returns mock data for use in tests.

func NewHdparmCmd added in v0.2.0

func NewHdparmCmd(trace bool) *Hdparm

Return a new hdparm executor

func (*Hdparm) Attributes added in v0.2.2

func (h *Hdparm) Attributes() (utilName model.CollectorUtility, absolutePath string, err error)

Attributes implements the actions.UtilAttributeGetter interface

func (*Hdparm) DriveCapabilities added in v0.2.0

func (h *Hdparm) DriveCapabilities(ctx context.Context, logicalName string) ([]*common.Capability, error)

DriveCapabilities returns the capability attributes obtained through hdparm

The logicalName is the kernel/OS assigned drive name - /dev/sdX

This method implements the actions.DriveCapabilityCollector interface.

nolint:gocyclo // line parsing is cyclomatic

type Ipmicfg

type Ipmicfg struct {
	Executor Executor
}

func NewFakeIpmicfg

func NewFakeIpmicfg(r io.Reader) *Ipmicfg

Fake IPMI executor for tests

func NewIpmicfgCmd

func NewIpmicfgCmd(trace bool) *Ipmicfg

Return a new Supermicro IPMICFG executor

func (*Ipmicfg) Attributes added in v0.2.2

func (i *Ipmicfg) Attributes() (utilName model.CollectorUtility, absolutePath string, err error)

Attributes implements the actions.UtilAttributeGetter interface

func (*Ipmicfg) BIOS

func (i *Ipmicfg) BIOS(ctx context.Context) (*common.BIOS, error)

BIOS returns a SMC BIOS component

func (Ipmicfg) BMC

func (i Ipmicfg) BMC(_ context.Context) (*common.BMC, error)

BMC returns a SMC BMC component

func (Ipmicfg) CPLDs added in v0.2.0

func (i Ipmicfg) CPLDs(ctx context.Context) ([]*common.CPLD, error)

CPLDs returns a slice of SMC CPLD components

func (*Ipmicfg) Summary

func (i *Ipmicfg) Summary() (*IpmicfgSummary, error)

type IpmicfgSummary

type IpmicfgSummary struct {
	FirmwareRevision  string // BMC
	FirmwareBuildDate string
	BIOSVersion       string
	BIOSBuildDate     string
	CPLDVersion       string
}

type Lsblk added in v0.2.0

type Lsblk struct {
	Executor Executor
}

func NewFakeLsblk added in v0.2.0

func NewFakeLsblk() *Lsblk

NewFakeLsblk returns a mock lsblk collector that returns mock data for use in tests.

func NewLsblkCmd added in v0.2.0

func NewLsblkCmd(trace bool) *Lsblk

Return a new lsblk executor

func (*Lsblk) Attributes added in v0.2.2

func (l *Lsblk) Attributes() (utilName model.CollectorUtility, absolutePath string, err error)

Attributes implements the actions.UtilAttributeGetter interface

func (*Lsblk) Drives added in v0.2.0

func (l *Lsblk) Drives(ctx context.Context) ([]*common.Drive, error)

Executes lsblk list, parses the output and returns a slice of *common.Drive

type Lshw

type Lshw struct {
	Executor Executor
	Device   *common.Device
	// contains filtered or unexported fields
}

The lshw command

func NewFakeLshw

func NewFakeLshw(stdin io.Reader) *Lshw

NewFakeLshw returns a fake lshw executor for testing

func NewLshwCmd

func NewLshwCmd(trace bool) *Lshw

Return a new lshw executor

func (*Lshw) Attributes added in v0.2.2

func (l *Lshw) Attributes() (utilName model.CollectorUtility, absolutePath string, err error)

Attributes implements the actions.UtilAttributeGetter interface

func (*Lshw) Collect

func (l *Lshw) Collect(ctx context.Context, device *common.Device) error

Inventory collects and returns device hardware inventory based on the data parsed from lshw

Implements the InventoryCollector interface

func (*Lshw) ListJSON

func (l *Lshw) ListJSON() (*LshwOutput, error)

ListJSON returns the lshw output as a struct

type LshwNode

type LshwNode struct {
	ID            string                `json:"id,omitempty"`
	Class         string                `json:"class,omitempty"`
	Claimed       bool                  `json:"claimed,omitempty"`
	Handle        string                `json:"handle,omitempty"`
	Description   string                `json:"description,omitempty"`
	Product       string                `json:"product,omitempty"`
	Vendor        string                `json:"vendor,omitempty"`
	Physid        string                `json:"physid,omitempty"`
	Businfo       string                `json:"businfo,omitempty"`
	LogicalName   interface{}           `json:"logicalname,omitempty"`
	Dev           string                `json:"dev,omitempty"`
	Slot          string                `json:"slot,omitempty"`
	Units         string                `json:"units,omitempty"`
	Size          float64               `json:"size,omitempty"`
	Capacity      int64                 `json:"capacity,omitempty"`
	Clock         int64                 `json:"clock,omitempty"`
	Version       string                `json:"version,omitempty"`
	Serial        string                `json:"serial,omitempty"`
	Width         int                   `json:"width,omitempty"`
	ChildNodes    []*LshwNode           `json:"children,omitempty"`
	Configuration LshwNodeConfiguration `json:"configuration,omitempty"`
	Capabilities  LshwNodeCapabilities  `json:"capabilities,omitempty"`
}

lshw -json output is unmarshalled into this struct each ChildNode is a LshwNode with almost all of the same fields https://ezix.org/project/wiki/HardwareLiSter

type LshwNodeCapabilities

type LshwNodeCapabilities map[string]interface{}

type LshwNodeConfiguration

type LshwNodeConfiguration map[string]string

fields of the ChildNodes in the lshw output theres some fields with non-string attributes, in these fields, which are currently ignored

type LshwOutput

type LshwOutput []*LshwNode

lshw JSON unmarshal data structure

type Mlxup

type Mlxup struct {
	Executor Executor
}

Mlxup is a mlxup command executor object

func NewFakeMlxup

func NewFakeMlxup(r io.Reader) (*Mlxup, error)

func NewMlxupCmd

func NewMlxupCmd(trace bool) *Mlxup

Return a new mellanox mlxup command executor

func (*Mlxup) Attributes added in v0.2.2

func (m *Mlxup) Attributes() (utilName model.CollectorUtility, absolutePath string, err error)

Attributes implements the actions.UtilAttributeGetter interface

func (*Mlxup) NICs

func (m *Mlxup) NICs(ctx context.Context) ([]*common.NIC, error)

NICs returns a slice of mellanox components as *common.NIC's

func (*Mlxup) Query

func (m *Mlxup) Query() ([]*MlxupDevice, error)

Query returns a slice of mellanox devices

func (*Mlxup) UpdateNIC

func (m *Mlxup) UpdateNIC(ctx context.Context, updateFile, modelNumber string) error

UpdateNIC updates mellanox NIC with the given update file

type MlxupDevice

type MlxupDevice struct {
	PartNumber    string
	DeviceType    string
	Description   string
	PCIDeviceName string
	PSID          string
	BaseMAC       string
	Firmware      []string // [version_current, version_available]
	FirmwarePXE   []string
	FirmwareUEFI  []string
	Status        string
}

MlxupDevice is a mellanox device object

type Msecli

type Msecli struct {
	Executor Executor
}

Msecli is an msecli executor

func NewMsecli

func NewMsecli(trace bool) *Msecli

NewMsecli returns a Msecli object to run msecli commands

func (*Msecli) Attributes added in v0.2.2

func (m *Msecli) Attributes() (utilName model.CollectorUtility, absolutePath string, err error)

Attributes implements the actions.UtilAttributeGetter interface

func (*Msecli) Drives

func (m *Msecli) Drives(_ context.Context) ([]*common.Drive, error)

Drives returns a slice of drive components identified

func (*Msecli) Query

func (m *Msecli) Query() ([]*MsecliDevice, error)

Query parses the output of mseli -L and returns a slice of *MsecliDevice's

func (*Msecli) UpdateDrive

func (m *Msecli) UpdateDrive(ctx context.Context, updateFile, modelNumber, serialNumber string) error

UpdateDrive installs drive updates

type MsecliDevice

type MsecliDevice struct {
	ModelNumber      string // Micron_5200_MTFDDAK480TDN
	SerialNumber     string
	FirmwareRevision string
}

MseclieDevice is a Micron disk device object

type Mvcli added in v0.2.0

type Mvcli struct {
	Executor Executor
}

Mvcli is a mvcli command executor object

func NewFakeMvcli added in v0.2.0

func NewFakeMvcli(r io.Reader) (*Mvcli, error)

Return a Fake mvcli executor for tests

func NewMvcliCmd added in v0.2.0

func NewMvcliCmd(trace bool) *Mvcli

Return a new mvcli executor

func (*Mvcli) Attributes added in v0.2.2

func (m *Mvcli) Attributes() (utilName model.CollectorUtility, absolutePath string, err error)

Attributes implements the actions.UtilAttributeGetter interface

func (*Mvcli) Create added in v0.2.0

func (m *Mvcli) Create(ctx context.Context, physicalDiskIDs []uint, raidMode, name string, blockSize uint, _ bool, initMode string) error

func (*Mvcli) CreateVirtualDisk added in v0.2.0

func (m *Mvcli) CreateVirtualDisk(ctx context.Context, raidMode string, physicalDisks []uint, name string, blockSize uint) error

func (*Mvcli) Destroy added in v0.2.0

func (m *Mvcli) Destroy(ctx context.Context, virtualDiskID int) error

func (*Mvcli) DestroyVirtualDisk added in v0.2.0

func (m *Mvcli) DestroyVirtualDisk(ctx context.Context, virtualDiskID int) error

func (*Mvcli) Drives added in v0.2.0

func (m *Mvcli) Drives(ctx context.Context) ([]*common.Drive, error)

func (*Mvcli) FindVdBy added in v0.2.0

func (m *Mvcli) FindVdBy(ctx context.Context, k string, v interface{}) *MvcliDevice

func (*Mvcli) FindVdByID added in v0.2.0

func (m *Mvcli) FindVdByID(ctx context.Context, virtualDiskID int) *MvcliDevice

func (*Mvcli) FindVdByName added in v0.2.0

func (m *Mvcli) FindVdByName(ctx context.Context, name string) *MvcliDevice

func (*Mvcli) Info added in v0.2.0

func (m *Mvcli) Info(ctx context.Context, infoType string) ([]*MvcliDevice, error)

func (*Mvcli) StorageControllers added in v0.2.0

func (m *Mvcli) StorageControllers(ctx context.Context) ([]*common.StorageController, error)

func (*Mvcli) VirtualDisks added in v0.2.0

func (m *Mvcli) VirtualDisks(ctx context.Context) ([]*MvcliDevice, error)

type MvcliDevice added in v0.2.0

type MvcliDevice struct {
	ID                 int
	Name               string
	Status             string
	Product            string
	SubProduct         string
	Model              string
	Serial             string
	SupportedRAIDModes string
	Firmware           string
	FirmwareRom        string
	FirmwareBios       string
	FirmwareBootLoader string
	SSDType            string
	Type               string
	CurrentSpeed       int64
	Size               int64
	PDSize             int64
	AdapterID          int
}

MvcliDevice is a marvell device object

type Nvme

type Nvme struct {
	Executor Executor
}

func NewFakeNvme added in v0.2.0

func NewFakeNvme() *Nvme

NewFakeNvme returns a mock nvme collector that returns mock data for use in tests.

func NewNvmeCmd

func NewNvmeCmd(trace bool) *Nvme

Return a new nvme executor

func (*Nvme) Attributes added in v0.2.2

func (n *Nvme) Attributes() (utilName model.CollectorUtility, absolutePath string, err error)

Attributes implements the actions.UtilAttributeGetter interface

func (*Nvme) DriveCapabilities added in v0.2.0

func (n *Nvme) DriveCapabilities(ctx context.Context, logicalName string) ([]*common.Capability, error)

DriveCapabilities returns the drive capability attributes obtained through hdparm

The logicalName is the kernel/OS assigned drive name - /dev/nvmeX

This method implements the actions.DriveCapabilityCollector interface.

nolint:gocyclo // line parsing is cyclomatic

func (*Nvme) Drives

func (n *Nvme) Drives(ctx context.Context) ([]*common.Drive, error)

Executes nvme list, parses the output and returns a slice of *common.Drive

type ResponseData

type ResponseData struct {
	ProductName     string `json:"Product Name"`
	SerialNumber    string `json:"Serial Number"`
	FirmwareVersion string `json:"FW Version"`
	BIOSVersion     string `json:"BIOS Version"`
	PhysicalDrives  int    `json:"Physical Drives"`
}

type Result

type Result struct {
	Stdout   []byte
	Stderr   []byte
	ExitCode int
}

The result of a command execution

type ShowController

type ShowController struct {
	Controllers []*Controller `json:"Controllers"`
}

type Smartctl

type Smartctl struct {
	Executor Executor
}

func NewFakeSmartctl

func NewFakeSmartctl(dataDir string) *Smartctl

NewFakeSmartctl returns a fake smartctl object for testing

func NewSmartctlCmd

func NewSmartctlCmd(trace bool) *Smartctl

Return a new smartctl executor

func (*Smartctl) All

func (s *Smartctl) All(device string) (*SmartctlDriveAttributes, error)

All runs smartctl -a /dev/<device> and returns its value as an object

func (*Smartctl) Attributes added in v0.2.2

func (s *Smartctl) Attributes() (utilName model.CollectorUtility, absolutePath string, err error)

Attributes implements the actions.UtilAttributeGetter interface

func (*Smartctl) Drives

func (s *Smartctl) Drives(ctx context.Context) ([]*common.Drive, error)

Drives returns drives identified by smartctl

func (*Smartctl) Scan

func (s *Smartctl) Scan() (*SmartctlScan, error)

Scan runs smartctl scan -j and returns its value as an object

type SmartctlDrive

type SmartctlDrive struct {
	Name     string `json:"name"`     // /dev/sdX
	Type     string `json:"type"`     // scsi / nvme
	Protocol string `json:"protocol"` // SCSI / NVMe
}

type SmartctlDriveAttributes

type SmartctlDriveAttributes struct {
	ModelName       string          `json:"model_name"`
	OemProductID    string          `json:"ata_additional_product_id"`
	ModelFamily     string          `json:"model_family"`
	SerialNumber    string          `json:"serial_number"`
	FirmwareVersion string          `json:"firmware_version"`
	Status          *SmartctlStatus `json:"smart_status"`
	Errors          []string        `json:"-"`
}

type SmartctlScan

type SmartctlScan struct {
	Drives []*SmartctlDrive `json:"Devices"`
}

type SmartctlStatus

type SmartctlStatus struct {
	Passed bool `json:"passed"`
}

type StoreCLI

type StoreCLI struct {
	Executor Executor
}

func NewFakeStoreCLI

func NewFakeStoreCLI(r io.Reader) (*StoreCLI, error)

Return a Fake storecli executor for tests

func NewStoreCLICmd

func NewStoreCLICmd(trace bool) *StoreCLI

Return a new storecli executor

func (*StoreCLI) Attributes added in v0.2.2

func (s *StoreCLI) Attributes() (utilName model.CollectorUtility, absolutePath string, err error)

Attributes implements the actions.UtilAttributeGetter interface

func (*StoreCLI) ShowController0

func (s *StoreCLI) ShowController0() ([]byte, error)

ShowController0 runs storecli to list controller 0

func (*StoreCLI) StorageControllers

func (s *StoreCLI) StorageControllers(_ context.Context) ([]*common.StorageController, error)

StorageControllers returns a slice of model.StorageControllers from the output of nvme list

type SupermicroSUM

type SupermicroSUM struct {
	Executor Executor
}

func NewFakeSMCIpmiCfg

func NewFakeSMCIpmiCfg() *SupermicroSUM

NewFakeSMCIpmiCfg returns a fake lshw executor for testing

func NewFakeSMCSum

func NewFakeSMCSum(stdin io.Reader) *SupermicroSUM

NewFakeSMCSum returns a fake lshw executor for testing

func NewSupermicroSUM

func NewSupermicroSUM(trace bool) *SupermicroSUM

Return a new Supermicro sum command executor

func (*SupermicroSUM) ApplyUpdate

func (s *SupermicroSUM) ApplyUpdate(ctx context.Context, updateFile, componentSlug string) error

ApplyUpdate installs the SMC update based on the component

func (*SupermicroSUM) Attributes added in v0.2.2

func (s *SupermicroSUM) Attributes() (utilName model.CollectorUtility, absolutePath string, err error)

Attributes implements the actions.UtilAttributeGetter interface

func (*SupermicroSUM) Collect

func (s *SupermicroSUM) Collect(_ *common.Device) error

Collect implements the Utility interface

func (*SupermicroSUM) Components

func (s *SupermicroSUM) Components() ([]*model.Component, error)

Components implements the Utility interface

func (*SupermicroSUM) GetBIOSConfiguration

func (s *SupermicroSUM) GetBIOSConfiguration(ctx context.Context, _ string) (map[string]string, error)

GetBIOSConfiguration implements the Getter

func (*SupermicroSUM) UpdateBIOS

func (s *SupermicroSUM) UpdateBIOS(ctx context.Context, updateFile, modelNumber string) error

UpdateBIOS installs the SMC BIOS update

func (*SupermicroSUM) UpdateBMC

func (s *SupermicroSUM) UpdateBMC(ctx context.Context, updateFile, _ string) error

UpdateBMC installs the SMC BMC update

type UEFIVarEntry added in v0.2.15

type UEFIVarEntry struct {
	Path      string `json:"path"`
	Size      int64  `json:"size"`
	Sha256sum string `json:"sha256sum"`
	Error     bool   `json:"error"`
}

type UEFIVariableCollector added in v0.2.15

type UEFIVariableCollector struct{}

func (UEFIVariableCollector) Attributes added in v0.2.15

func (UEFIVariableCollector) GetUEFIVars added in v0.2.15

func (UEFIVariableCollector) GetUEFIVars(ctx context.Context) (UEFIVars, error)

type UEFIVars added in v0.2.15

type UEFIVars map[string]UEFIVarEntry

type UefiFirmwareParser added in v0.2.15

type UefiFirmwareParser struct {
	Executor Executor
}

func NewUefiFirmwareParserCmd added in v0.2.15

func NewUefiFirmwareParserCmd(trace bool) *UefiFirmwareParser

Return a new UefiFirmwareParser executor

func (*UefiFirmwareParser) Attributes added in v0.2.15

Attributes implements the actions.UtilAttributeGetter interface

func (u *UefiFirmwareParser) ExtractLogo(ctx context.Context, outputPath, biosImg string) error

ExtractLogo extracts the Logo BMP image. It creates the output directory if required.

Jump to

Keyboard shortcuts

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