You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
go-ipmi is a pure golang native IPMI library. It DOES NOT wraps ipmitool.
Usage
import (
"fmt""github.com/bougou/go-ipmi"
)
funcmain() {
host:="10.0.0.1"port:=623username:="root"password:="123456"client, err:=ipmi.NewClient(host, port, username, password)
// Support local mode client if runs directly on linux// client, err := ipmi.NewOpenClient()iferr!=nil {
panic(err)
}
// you can optionally open debug switch// client.WithDebug(true)// you can set interface type, enum range: open/lan/lanplus/tool, default open// client.WithInterface(ipmi.InterfaceLanplus)// !!! Note !!!,// From v0.6.0, all IPMI command methods of the Client accept a context as the first argument.ctx:=context.Background()
// Connect will create an authenticated session for you.iferr:=client.Connect(ctx); err!=nil {
panic(err)
}
// Now you can execute other IPMI commands that need authentication.res, err:=client.GetDeviceID(ctx)
iferr!=nil {
panic(err)
}
fmt.Println(res.Format())
selEntries, err:=client.GetSELEntries(ctx, 0)
iferr!=nil {
panic(err)
}
fmt.Println(ipmi.FormatSELs(selEntries, nil))
}
goipmi binary
The goipmi is a binary tool which provides the same command usages like ipmitool.
The goipmi calls go-ipmi library underlying.
The purpose of creating goipmi tool was not intended to substitute ipmitool.
It was just used to verify the correctness of go-ipmi library.
Functions Comparison with ipmitool
Each command defined in the IPMI specification is a pair of request/response messages.
These IPMI commands are implemented as methods of the ipmi.Client struct in this library.
Some ipmitool cmdline usages are implemented by calling just one IPMI command,
but others are not. Like ipmitool sdr list, it's a loop of GetSDR IPMI command.
So this library also implements some methods that are not IPMI commands defined
in IPMI specification, but just some common helpers, like GetSDRs to get all SDRs.
These methods are marked with an asterisk (*) after the method name in the following docs.
The implementation logic of IPMI commands are almost same. See Contributing