Library to abstract Baseboard Management Controller interaction
Go to file
2023-03-08 16:30:37 +01:00
.github Fix mergify 2022-11-25 16:56:09 +00:00
bmc typo fix 2023-03-08 10:31:20 +01:00
constants Add constants 2022-07-26 10:52:57 +02:00
errors providers/redfish: check session is active before executing action 2022-11-07 10:29:33 +01:00
examples Add example for GetBiosConfiguration 2023-03-08 16:30:37 +01:00
internal Support redfish VirtualMedia 2023-02-09 15:36:40 -08:00
logging Update dependencies; registrar, logr, logrusr 2021-11-24 20:59:51 -07:00
providers Use redfishwrapper instead of underlying client 2023-03-08 16:09:33 +01:00
.gitignore Lint make target will download golangci-lint if it doesnt exist: 2022-11-15 22:22:40 +00:00
.golangci.yml Update golangci linter, GH workflow, Makefile, mergify configurations 2022-07-26 11:46:32 +02:00
client_test.go redfish: adds an optional client parameter to specify incompatible Redfish versions 2023-01-30 14:11:58 +01:00
client.go Implement redfish bios config getter 2023-03-08 10:31:16 +01:00
doc.go Update go doc 2022-11-22 07:54:04 +01:00
go.mod redfish: added support for adapters with multiple ports 2023-02-21 12:58:27 +01:00
go.sum redfish: added support for adapters with multiple ports 2023-02-21 12:58:27 +01:00
LICENSE Add license file 2022-11-22 07:53:36 +01:00
lint.mk Fix import issues: 2022-11-16 09:49:37 -07:00
Makefile Fix Make help target: 2022-11-15 22:31:32 +00:00
README.md README: include notes on filtering out BMCs based on the driver, redfish version. 2023-02-06 14:52:43 +01:00

bmclib v2 - board management controller library

Status Go Report Card GoDoc

bmclib v2 is a library to abstract interacting with baseboard management controllers.

Supported BMC interfaces.

Installation

go get github.com/bmc-toolbox/bmclib/v2

Import

import (
  bmclib "github.com/bmc-toolbox/bmclib/v2"
)

Usage

The snippet below connects to a BMC and retrieves the device hardware, firmware inventory.

import (
  bmclib "github.com/bmc-toolbox/bmclib/v2"
)

    // setup logger
    l := logrus.New()
    l.Level = logrus.DebugLevel
    logger := logrusr.New(l)

    clientOpts := []bmclib.Option{bmclib.WithLogger(logger)}

    // init client
    client := bmclib.NewClient(*host, "", "admin", "hunter2", clientOpts...)

    // open BMC session
    err := client.Open(ctx)
    if err != nil {
        log.Fatal(err, "bmc login failed")
    }

    defer client.Close(ctx)

    // retrieve inventory data
    inventory, err := client.Inventory(ctx)
    if err != nil {
        l.Error(err)
    }

    b, err := json.MarshalIndent(inventory, "", "  ")
    if err != nil {
        l.Error(err)
    }

    fmt.Println(string(b))

More sample code can be found in examples

BMC connections

bmclib performs queries on BMCs using multiple drivers, these drivers are the various services exposed by a BMC - redfish IPMI SSH and vendor API which is basically a custom vendor API endpoint.

The bmclib client determines which driver to use for an action like Power cycle or Create user based on its availability or through a compatibility test (when enabled).

When querying multiple BMCs through bmclib its often useful to to limit the BMCs and drivers that bmclib will attempt to use to connect, the options to limit or filter out BMCs are described below,

Query just using the redfish endpoint.

cl := bmclib.NewClient("192.168.1.1", "", "admin", "hunter2")
cl.Registry.Drivers = cl.Registry.Using("redfish")

Query using the redfish endpoint and fall back to IPMI

client := bmclib.NewClient("192.168.1.1", "", "admin", "hunter2")

// overwrite registered drivers by appending Redfish, IPMI drivers in order
drivers := append(registrar.Drivers{}, bmcClient.Registry.Using("redfish")...)
drivers = append(drivers, bmcClient.Registry.Using("ipmi")...)
client.Registry.Drivers = driver

Filter drivers to query based on compatibility, this will attempt to check if the driver is compatible ideally, this method should be invoked when the client is ready to perform a BMC action.

client := bmclib.NewClient("192.168.1.1", "", "admin", "hunter2")
client.Registry.Drivers = cl.Registry.FilterForCompatible(ctx)

Ignore the Redfish endpoint completely on BMCs running a specific Redfish version.

Note: this version should match the one returned through curl -k "https://<BMC IP>/redfish/v1" | jq .RedfishVersion

opt := bmclib.WithRedfishVersionsNotCompatible([]string{"1.5.0"})

client := bmclib.NewClient("192.168.1.1", "", "admin", "hunter2", opt...)
cl.Registry.Drivers = cl.Registry.FilterForCompatible(ctx)

bmclib versions

The current bmclib version is v2 and is being developed on the main branch.

The previous bmclib version is in maintenance mode and can be found here v1.

Acknowledgments

bmclib v2 interfaces with Redfish on BMCs through the Gofish library https://github.com/stmcginnis/gofish

bmclib was originally developed for Booking.com. With approval from Booking.com, the code and specification were generalized and published as Open Source on github, for which the authors would like to express their gratitude.

Authors