metal-toolbox / ironlib

Vendor neutral hardware in-band library
Apache License 2.0
3 stars 3 forks source link

Go Reference

Ironlib wraps various opensource and various vendor utilities to expose a consistent set of interface methods to,

For the available methods,

Currently supported hardware

Requirements

Ironlib expects various vendor utilities to be made available.

TODO: define a list of utility path env vars a user can set.

Invoking ironlib

Ironlib identifies the hardware and executes tooling respective to the hardware/component being queried or updated,

The list of tools that ironlib wraps around, in no particular order,

Examples

More examples can be found in the examples directory

package main

import (
    "context"
    "encoding/json"
    "fmt"

    "github.com/metal-toolbox/ironlib"
    "github.com/sirupsen/logrus"
)

func main() {
    logger := logrus.New()
    device, err := ironlib.New(logger)
    if err != nil {
        logger.Fatal(err)
    }

    inv, err := device.GetInventory(context.TODO())
    if err != nil {
        logger.Fatal(err)
    }

    j, err := json.MarshalIndent(inv, "", "  ")
    if err != nil {
        logger.Fatal(err)
    }

    fmt.Println(string(j))
}

Executable path environment variables.

By default ironlib will lookup the executable path, if required the path can be overriden by exporting one or more of these environment variables

IRONLIB_UTIL_ASRR_BIOSCONTROL
IRONLIB_UTIL_RACADM7
IRONLIB_UTIL_DNF
IRONLIB_UTIL_DSU
IRONLIB_UTIL_BLKDISCARD
IRONLIB_UTIL_HDPARM
IRONLIB_UTIL_LSBLK
IRONLIB_UTIL_LSHW
IRONLIB_UTIL_MLXUP
IRONLIB_UTIL_MSECLI
IRONLIB_UTIL_MVCLI
IRONLIB_UTIL_NVME
IRONLIB_UTIL_SMARTCTL
IRONLIB_UTIL_SMC_IPMICFG
IRONLIB_UTIL_SUM
IRONLIB_UTIL_STORECLI

Check out this snippet to determine if all required dependencies are available to ironlib.

Build image without the non-distributable files.

docker build -f Dockerfile -t ironlib:devel .

Build image with non-distributable files

ironlib will attempt to execute proprietary vendor executables based on the hardware its run on, to build docker image with executables like mvcli, mlxup, SMCI sum etc follow the steps below.

docker build -f Dockerfile \
  --build-arg INSTALL_NON_DISTRIBUTABLE=true
  --build-arg S3_BUCKET_ALIAS="tools"
  --build-arg S3_PATH="tools/bucket-name/path/non-dist"
  --build-arg ACCESS_KEY=<>
  --build-arg SECRET_KEY=<>
  -t ironlib:devel-non-dist .