Categorygithub.com/xstp/go-ipmi
repositorypackage
0.0.0-20230112230242-c12250604c35
Repository: https://github.com/xstp/go-ipmi.git
Documentation: pkg.go.dev

# Packages

No description provided by the author
No description provided by the author
No description provided by the author

# README

go-ipmi

go-ipmi is a pure golang native IPMI library. It DOES NOT wraps ipmitool.

Usage

import (
	"fmt"
	"github.com/xstp/go-ipmi"
)

func main() {
	host := "10.0.0.1"
	port := 623
	username := "root"
	password := "123456"

	client, err := ipmi.NewClient(host, port, username, password)
	// Support local mode client if runs directly on linux
	// client, err := ipmi.NewOpenClient()
	if err != nil {
		panic(err)
	}

	// you can optionally open debug switch
	// client.WithDebug(true)

	// Connect will create an authenticated session for you.
	if err := client.Connect(); err != nil {
		panic(err)
	}

	// Now you can execute other IPMI commands that need authentication.

	res, err := client.GetDeviceID()
	if err != nil {
		panic(err)
	}
	fmt.Println(res.Format())

	selEntries, err := client.GetSELEntries(0)
	if err != nil {
		panic(err)
	}
	fmt.Println(ipmi.FormatSELs(selEntries, nil))
}

Functions Comparision 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 sepcification, 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 is almost same. See Contributing

More commmands are ongoing ...

IPM Device Global Commands

MethodStatuscorresponding ipmitool usage
GetDeviceIDmc info
ColdResetmc reset cold
WarmResetmc reset warm
GetSelfTestResultsmc selftest, chassis selftest
ManufacturingTestOn
SetACPIPowerState
GetACPIPowerState
GetDeviceGUID
GetNetFnSupport
GetCommandSupport
GetCommandSubfunctionSupport
GetConfigurableCommands
GetConfigurableCommandSubfunctions
SetCommandEnables
GetCommandEnables
GetCommandSubfunctionsEnables
GetSubfunctionsEnables
GetOEMNetFnIanaSupport

BMC Watchdog Timer Commands

MethodStatuscorresponding ipmitool usage
ResetWatchdogTimermc watchdog reset
SetWatchdogTimer
GetWatchdogTimermc watchdog get

BMC Device and Messaging Commands

MethodStatuscorresponding ipmitool usage
SetBMCGlobalEnables
GetBMCGlobalEnables
ClearMessageFlags
GetMessageFlags
EnableMessageChannelReceive
GetMessage
SendMessage
ReadEventMessageBuffer
GetBTInterfaceCapabilities
GetSystemGUIDmc guid
SetSystemInfoParameters
GetSystemInfoParameters
GetChannelAuthCapabilities
GetSessionChallenge
ActivateSession
SetSessionPrivilegeLevel
CloseSession
GetSessionInfosession info
GetAuthCode
SetChannelAccesschannel setaccess
GetChannelAccesschannel info/getaccess
GetChannelInfochannel info
SetUserAccess
GetUserAccessuser summary
GetUsers (*)user list
SetUsernameuser set name
DisableUser (*)user disable
EnableUser (*)user enable
GetUsername
SetUserPassworduser set password
TestUserPassword (*)user test
ActivatePayload
DeactivatePayload
GetPayloadActivationStatus
GetPayloadInstanceInfo
SetUserPayloadAccess
GetUserPayloadAccess
GetChannelPayloadSupport
GetChannelPayloadVersion
GetChannelOEMPayloadInfo
MasterWriteRead
GetChannelCipherSuites
SuspendOrResumeEncryption
SetChannelCipherSuites
GetSystemInterfaceCapabilities

Chassis Device Commands

MethodStatuscorresponding ipmitool usage
GetChassisCapabilities
GetChassisStatuschassis status, chassis power status
ChassisControlchassis power on/off/cycle/reset/diag/soft
ChassisReset
ChassisIdentifychassis identify
SetChassisCapabilities
SetPowerRestorePolicychassis policy list/always-on/previous/always-off
GetSystemRestartCausechassis restart_cause
SetSystemBootOptionschassis bootparam set
SetBootParamBootFlags (*)chassis bootdev
GetSystemBootOptionschassis bootparam get
SetFrontPanelEnables
SetPowerCycleInterval
GetPOHCounterchassis poh

Event Commands

MethodStatuscorresponding ipmitool usage
SetEventReceiver
GetEventReceiver
PlatformEventMessage

PEF and Alerting Commands

MethodStatuscorresponding ipmitool usage
GetPEFCapabilitiespef capabilities
ArmPEFPostponeTimer
SetPEFConfigParameters
GetPEFConfigParameters
SetLastProcessedEventId
GetLastProcessedEventId
AlertImmediate
PEFAck

Sensor Device Commands

MethodStatuscorresponding ipmitool usage
GetDeviceSDRInfo
GetDeviceSDR
ReserveDeviceSDRRepo
GetSensorReadingFactors
SetSensorHysteresis
GetSensorHysteresis
SetSensorThresholds
GetSensorThresholds
SetSensorEventEnable
GetSensorEventEnable
RearmSensorEvents
GetSensorEventStatus
GetSensorReading
SetSensorType
GetSensorType
SetSensorReadingAndEventStatus
GetSensors (*)sensor list
GetSensorByID (*)
GetSensorByName (*)sensor get

FRU Device Commands

MethodStatuscorresponding ipmitool usage
GetFRUInventoryAreaInfo
ReadFRUData
WriteFRUData
GetFRU (*)fru print
GetFRUs (*)fru print

SDR Device Commands

MethodStatuscorresponding ipmitool usage
GetSDRRepoInfosdr info
GetSDRRepoAllocInfosdr info
ReserveSDRRepo
GetSDR
GetSDRs (*)
GetSDRBySensorID (*)
GetSDRBySensorName (*)
AddSDR
PartialAddSDR
DeleteSDR
ClearSDRRepo
GetSDRRepoTime
SetSDRRepoTime
EnterSDRRepoUpateMode
ExitSDRRepoUpdateMode
RunInitializationAgent

SEL Device Commands

MethodStatuscorresponding ipmitool usage
GetSELInfosel info
GetSELAllocInfosel info
ReserveSEL
GetSELEntry
AddSELEntry
PartialAddSELEntry
DeleteSELEntry
ClearSELsel clear
GetSELTime
SetSELTime
GetAuxLogStatus
SetAuxLogStatus
GetSELTimeUTCOffset
SetSELTimeUTCOffset

LAN Device Commands

MethodStatuscorresponding ipmitool usage
SetLanConfigParams
GetLanConfigParams
SuspendARPs
GetIpStatistics

Serial/Modem Device Commands

MethodStatuscorresponding ipmitool usage
SetSerialConfig
GetSerialConfig
SetSerialMux
GetTapResponseCodes
SetPPPTransmitData
GetPPPTransmitData
SendPPPPacket
GetPPPReceiveData
SerialConnectionActive
Callback
SetUserCallbackOptions
GetUserCallbackOptions
SetSerialRoutingMux
SOLActivating
GetSOLConfigParams
SetSOLConfigParams
SOLInfosol info

Command Forwarding Commands

MethodStatuscorresponding ipmitool usage
Fowarded
SetForwarded
GetForwarded
EnableForwarded

Bridge Management Commands (ICMB)

MethodStatuscorresponding ipmitool usage
GetBridgeState
SetBridgeState
GetICMBAddress
SetICMBAddress
SetBridgeProxyAddress
GetBridgeStatistics
GetICMBCapabilities
ClearBridgeStatistics
GetBridgeProxyAddress
GetICMBConnectorInfo
GetICMBConnectionID
SendICMBConnectionID

Discovery Commands (ICMB)

MethodStatuscorresponding ipmitool usage
PrepareForDiscovery
GetAddresses
SetDiscovered
GetChassisDeviceId
SetChassisDeviceId

Bridging Commands (ICMB)

MethodStatuscorresponding ipmitool usage
BridgeRequest
BridgeMessage

Event Commands (ICMB)

MethodStatuscorresponding ipmitool usage
GetEventCount
SetEventDestination
SetEventReceptionState
SendICMBEventMessage
GetEventDestination
GetEventReceptionState

Other Bridge Commands

MethodStatuscorresponding ipmitool usage
ErrorReport

Reference