Documentation
¶
Overview ¶
Package ipmi implements functions to communicate with the OpenIPMI driver interface. For a detailed description of OpenIPMI, see http://openipmi.sourceforge.net/IPMI.pdf https://www.intel.com/content/dam/www/public/us/en/documents/specification-updates/ipmi-intelligent-platform-mgt-interface-spec-2nd-gen-v2-0-spec-update.pdf
Index ¶
- Constants
- type ChassisStatus
- type Command
- type CompletionCode
- type CompletionError
- type DevID
- type Event
- type IPMI
- func (i *IPMI) Close() error
- func (i *IPMI) EnableSEL() (bool, error)
- func (d IPMI) File() *os.File
- func (i *IPMI) GetChassisStatus() (*ChassisStatus, error)
- func (i *IPMI) GetDeviceID() (*DevID, error)
- func (i *IPMI) GetLanConfig(channel byte, param byte) ([]byte, error)
- func (i *IPMI) GetSELInfo() (*SELInfo, error)
- func (i *IPMI) LogSystemEvent(e *Event) error
- func (i *IPMI) RawCmd(param []byte) ([]byte, error)
- func (i *IPMI) RawSendRecv(msg Msg) ([]byte, error)
- func (d IPMI) ReceiveResponse(msgID int64, resp *response, buf []byte) ([]byte, error)
- func (i *IPMI) SendRecv(netfn NetFn, cmd Command, data []byte) ([]byte, error)
- func (d IPMI) SendRequest(req *request) error
- func (i *IPMI) SetSystemFWVersion(version string) error
- func (i *IPMI) ShutoffWatchdog() error
- func (i *IPMI) WatchdogRunning() (bool, error)
- type Msg
- type NetFn
- type OEMNonTsEvent
- type OEMTsEvent
- type SELInfo
- type StandardEvent
Constants ¶
const ( // IPM Device "Global" Commands BMC_GET_DEVICE_ID Command = 0x01 // BMC Device and Messaging Commands BMC_SET_WATCHDOG_TIMER Command = 0x24 BMC_GET_WATCHDOG_TIMER Command = 0x25 BMC_SET_GLOBAL_ENABLES Command = 0x2E BMC_GET_GLOBAL_ENABLES Command = 0x2F SET_SYSTEM_INFO_PARAMETERS Command = 0x58 BMC_ADD_SEL Command = 0x44 // Chassis Device Commands BMC_GET_CHASSIS_STATUS Command = 0x01 // SEL device Commands BMC_GET_SEL_INFO Command = 0x40 // LAN Device Commands BMC_GET_LAN_CONFIG Command = 0x02 // Completion codes. // See Intelligent Platform Management Interface Specification v2.0 rev. 1.1, section 5.2. IPMI_CC_OK CompletionCode = 0x00 IPMI_CC_NODE_BUSY CompletionCode = 0xc0 IPMI_CC_INV_CMD CompletionCode = 0xc1 IPMI_CC_INV_CMD_FOR_LUN CompletionCode = 0xc2 IPMI_CC_TIMEOUT CompletionCode = 0xc3 IPMI_CC_OUT_OF_SPACE CompletionCode = 0xc4 IPMI_CC_RES_CANCELED CompletionCode = 0xc5 IPMI_CC_REQ_DATA_TRUNC CompletionCode = 0xc6 IPMI_CC_REQ_DATA_INV_LENGTH CompletionCode = 0xc7 IPMI_CC_REQ_DATA_FIELD_EXCEED CompletionCode = 0xc8 IPMI_CC_PARAM_OUT_OF_RANGE CompletionCode = 0xc9 IPMI_CC_CANT_RET_NUM_REQ_BYTES CompletionCode = 0xca IPMI_CC_REQ_DATA_NOT_PRESENT CompletionCode = 0xcb IPMI_CC_INV_DATA_FIELD_IN_REQ CompletionCode = 0xcc IPMI_CC_ILL_SENSOR_OR_RECORD CompletionCode = 0xcd IPMI_CC_RESP_COULD_NOT_BE_PRV CompletionCode = 0xce IPMI_CC_CANT_RESP_DUPLI_REQ CompletionCode = 0xcf IPMI_CC_CANT_RESP_SDRR_UPDATE CompletionCode = 0xd0 IPMI_CC_CANT_RESP_FIRM_UPDATE CompletionCode = 0xd1 IPMI_CC_CANT_RESP_BMC_INIT CompletionCode = 0xd2 IPMI_CC_DESTINATION_UNAVAILABLE CompletionCode = 0xd3 IPMI_CC_INSUFFICIENT_PRIVILEGES CompletionCode = 0xd4 IPMI_CC_NOT_SUPPORTED_PRESENT_STATE CompletionCode = 0xd5 IPMI_CC_ILLEGAL_COMMAND_DISABLED CompletionCode = 0xd6 IPMI_CC_UNSPECIFIED_ERROR CompletionCode = 0xff IPM_WATCHDOG_NO_ACTION = 0x00 IPM_WATCHDOG_SMS_OS = 0x04 IPM_WATCHDOG_CLEAR_SMS_OS = 0x10 ADTL_SEL_DEVICE = 0x04 EN_SYSTEM_EVENT_LOGGING = 0x08 // SEL // STD_TYPE = 0x02 OEM_NTS_TYPE = 0xFB )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChassisStatus ¶
type ChassisStatus struct {
CurrentPowerState byte
LastPowerEvent byte
MiscChassisState byte
FrontPanelButton byte
}
ChassisStatus holds information about status of the chassis reported by the BMC via IPMI
type CompletionCode ¶ added in v0.15.0
type CompletionCode byte
CompletionCode is the completion code in the response from a command.
func (CompletionCode) String ¶ added in v0.15.0
func (cc CompletionCode) String() string
type CompletionError ¶ added in v0.15.0
type CompletionError CompletionCode
CompletionError is returned when a command completes with a non-OK code.
func (CompletionError) Error ¶ added in v0.15.0
func (ce CompletionError) Error() string
type DevID ¶
type DevID struct {
DeviceID byte
DeviceRevision byte
FwRev1 byte
FwRev2 byte
IpmiVersion byte
AdtlDeviceSupport byte
ManufacturerID [3]byte
ProductID [2]byte
AuxFwRev [4]byte
}
DevID holds information of a Device provided by the BMC via IPMI
type Event ¶
type Event struct {
RecordID uint16
RecordType uint8
StandardEvent
OEMTsEvent
OEMNonTsEvent
}
Event is included three kinds of events, Standard, OEM timestamped and OEM non-timestamped
The record type decides which event should be used
type IPMI ¶
type IPMI struct {
// contains filtered or unexported fields
}
IPMI represents access to the IPMI interface.
func Open ¶
Open opens a channel to an IPMI device by device number (e.g., 0 for /dev/ipmi{devnum}).
func OpenPath ¶ added in v0.12.0
OpenPath opens a channel to an IPMI device by path (e.g., /dev/ipmi0).
func (*IPMI) EnableSEL ¶
EnableSEL enables the System Event Log (SEL) if it is supported and not already enabled. It first checks if the SEL device is supported by retrieving the device ID. If supported, it then checks the current global enables to see if SEL is already enabled. If SEL is not enabled, it enables SEL by setting the appropriate global enable flag.
func (*IPMI) GetChassisStatus ¶
func (i *IPMI) GetChassisStatus() (*ChassisStatus, error)
GetChassisStatus retrieves the chassis status from the IPMI interface. It sends a command to the BMC to get the chassis status and parses the response.
The response data is expected to be in a specific format as per the IPMI specification v2.0. If the response data is shorter than expected, it will be parsed into a shortened struct.
Returns: - A pointer to a ChassisStatus struct containing the current power state, last power event, and miscellaneous chassis state. - An error if there is an issue with sending/receiving the command or parsing the response data.
func (*IPMI) GetDeviceID ¶
GetDeviceID retrieves the device ID information from the IPMI interface. It sends a command to the BMC to get the device ID and parses the response into a DevID struct.
Returns:
- A pointer to a DevID struct containing the device ID information.
- An error if there is any issue in sending the command or parsing the response.
The function reads the following fields from the response data:
- DeviceID
- DeviceRevision
- FwRev1
- FwRev2
- IpmiVersion
- AdtlDeviceSupport
- ManufacturerID
- ProductID
- AuxFwRev (conditionally, if additional bytes are present in the response)
func (*IPMI) GetLanConfig ¶
GetLanConfig retrieves the LAN configuration parameters for a specified channel.
func (*IPMI) GetSELInfo ¶
GetSELInfo retrieves the System Event Log (SEL) information from the IPMI interface. It sends a command to the BMC to get the SEL info and parses the response into an SELInfo structure.
Returns:
- A pointer to an SELInfo structure containing the SEL information.
- An error if there is an issue with sending the command, receiving the response, or parsing the data.
func (*IPMI) LogSystemEvent ¶
LogSystemEvent adds an SEL (System Event Log) entry.
func (*IPMI) RawSendRecv ¶
RawSendRecv sends the IPMI message, receives the response, and returns the response data.
func (IPMI) ReceiveResponse ¶ added in v0.9.0
ReceiveResponse uses syscall Rawconn to read a response via unix.Syscall IOCTL from the BMC. It takes the message ID of the request and awaits the response with the same message ID.
func (*IPMI) SendRecv ¶
SendRecv sends the IPMI message, receives the response, and returns the response data. This is recommended for use unless the user must be able to specify the data pointer and length on their own.
func (IPMI) SendRequest ¶ added in v0.9.0
func (d IPMI) SendRequest(req *request) error
SendRequest uses unix.Syscall IOCTL to send a request to the BMC.
func (*IPMI) SetSystemFWVersion ¶
SetSystemFWVersion sets the provided system firmware version to BMC via IPMI.
func (*IPMI) ShutoffWatchdog ¶
ShutoffWatchdog disables the watchdog timer on the IPMI device. It sends a command to the BMC to set the watchdog timer to a shutoff state. Returns an error if the command fails to send or receive a response.
func (*IPMI) WatchdogRunning ¶
WatchdogRunning checks if the watchdog timer is currently running. It sends a command to the BMC to get the watchdog timer status. Returns true if the watchdog timer is running, otherwise false. If there is an error in sending or receiving the command, it returns the error.
type OEMNonTsEvent ¶ added in v0.9.0
type OEMNonTsEvent struct {
OEMNontsDefinedData [13]uint8
}
OEMNonTsEvent is a non-timestamped OEM-custom event.
It holds 13 bytes of OEM-defined arbitrary data.
type OEMTsEvent ¶
OEMTsEvent is a timestamped OEM-custom event.
It holds 6 bytes of OEM-defined arbitrary data.