ipmi

package module
v0.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 13, 2019 License: Apache-2.0 Imports: 18 Imported by: 0

README

goipmi

Native IPMI implementation and ipmitool wrapper in Go.

License

This project is available under the Apache 2.0 license.

Documentation

Index

Constants

View Source
const (
	ControlPowerDown      = ChassisControl(0x0)
	ControlPowerUp        = ChassisControl(0x1)
	ControlPowerCycle     = ChassisControl(0x2)
	ControlPowerHardReset = ChassisControl(0x3)
	ControlPowerPulseDiag = ChassisControl(0x4)
	ControlPowerAcpiSoft  = ChassisControl(0x5)

	BootDeviceNone          = BootDevice(0x00)
	BootDevicePxe           = BootDevice(0x04)
	BootDeviceDisk          = BootDevice(0x08)
	BootDeviceSafe          = BootDevice(0x0c)
	BootDeviceDiag          = BootDevice(0x10)
	BootDeviceCdrom         = BootDevice(0x14)
	BootDeviceBios          = BootDevice(0x18)
	BootDeviceRemoteFloppy  = BootDevice(0x1c)
	BootDeviceRemotePrimary = BootDevice(0x24)
	BootDeviceRemoteCdrom   = BootDevice(0x20)
	BootDeviceRemoteDisk    = BootDevice(0x2c)
	BootDeviceFloppy        = BootDevice(0x3c)

	SystemPower       = 0x1
	PowerOverload     = 0x2
	PowerInterlock    = 0x4
	MainPowerFault    = 0x8
	PowerControlFault = 0x10

	PowerRestorePolicyAlwaysOff = 0x0
	PowerRestorePolicyPrevious  = 0x1
	PowerRestorePolicyAlwaysOn  = 0x2
	PowerRestorePolicyUnknown   = 0x3

	PowerEventUnknown   = 0x0
	PowerEventAcFailed  = 0x1
	PowerEventOverload  = 0x2
	PowerEventInterlock = 0x4
	PowerEventFault     = 0x8
	PowerEventCommand   = 0x10

	ChassisIntrusion  = 0x1
	FrontPanelLockout = 0x2
	DriveFault        = 0x4
	CoolingFanFault   = 0x8

	SleepButtonDisable  = 0x80
	DiagButtonDisable   = 0x40
	ResetButtonDisable  = 0x20
	PowerButtonDisable  = 0x10
	SleepButtonDisabled = 0x08
	DiagButtonDisabled  = 0x04
	ResetButtonDisabled = 0x02
	PowerButtonDisabled = 0x01

	BootParamSetInProgress = 0x0
	BootParamSvcPartSelect = 0x1
	BootParamSvcPartScan   = 0x2
	BootParamFlagValid     = 0x3
	BootParamInfoAck       = 0x4
	BootParamBootFlags     = 0x5
	BootParamInitInfo      = 0x6
	BootParamInitMbox      = 0x7
)
View Source
const (
	CommandGetDeviceID              = Command(0x01)
	CommandGetAuthCapabilities      = Command(0x38)
	CommandGetSessionChallenge      = Command(0x39)
	CommandActivateSession          = Command(0x3a)
	CommandSetSessionPrivilegeLevel = Command(0x3b)
	CommandCloseSession             = Command(0x3c)
	CommandChassisControl           = Command(0x02)
	CommandChassisStatus            = Command(0x01)
	CommandSetSystemBootOptions     = Command(0x08)
	CommandGetSystemBootOptions     = Command(0x09)
	CommandGetMcIdString            = Command(0x09)
	CommandSetMcIdString            = Command(0x0a)
)

Command Number Assignments (table G-1)

View Source
const (
	AuthTypeNone = iota
	AuthTypeMD2
	AuthTypeMD5

	AuthTypePassword
	AuthTypeOEM
)

AuthType

View Source
const (
	PrivLevelNone = iota
	PrivLevelCallback
	PrivLevelUser
	PrivLevelOperator
	PrivLevelAdmin
	PrivLevelOEM
)

PrivLevel

View Source
const (
	CommandCompleted     = CompletionCode(0x00)
	ErrNodeBusy          = CompletionCode(0xc0)
	ErrInvalidCommand    = CompletionCode(0xc1)
	ErrInvalidLunCommand = CompletionCode(0xc2)
	ErrCommandTimeout    = CompletionCode(0xc3)
	ErrOutOfSpace        = CompletionCode(0xc4)
	ErrInvalidResv       = CompletionCode(0xc5)
	ErrDataTruncated     = CompletionCode(0xc6)
	ErrShortPacket       = CompletionCode(0xc7)
	ErrLongPacket        = CompletionCode(0xc8)
	ErrParamRange        = CompletionCode(0xc9)
	ErrRequestData       = CompletionCode(0xca)
	ErrNoObj             = CompletionCode(0xcb)
	ErrInvalidPacket     = CompletionCode(0xcc)
	ErrInvalidObjCommand = CompletionCode(0xcd)
	ErrNoResponse        = CompletionCode(0xce)
	ErrDuplicateRequest  = CompletionCode(0xcf)
	ErrRepoUpMode        = CompletionCode(0xd0)
	ErrFirmwareUpMode    = CompletionCode(0xd1)
	ErrInitMode          = CompletionCode(0xd2)
	ErrDestUnavail       = CompletionCode(0xd3)
	ErrPrivLevel         = CompletionCode(0xd4)
	ErrInvalidState      = CompletionCode(0xd5)
	ErrUnspecified       = CompletionCode(0xff)
)

Completion Codes per section 5.2

View Source
const (
	MAX_MC_ID_STRING_LEN    = 16
	DCMI_GROUP_EXTENSION_ID = 0xDC
)
View Source
const (
	OemUnknown              = OemID(0)
	OemHP                   = OemID(11)
	OemSun                  = OemID(42)
	OemNokia                = OemID(94)
	OemBull                 = OemID(107)
	OemHitachi116           = OemID(116)
	OemNEC                  = OemID(119)
	OemToshiba              = OemID(186)
	OemIntel                = OemID(343)
	OemTatung               = OemID(373)
	OemHitachi399           = OemID(399)
	OemDell                 = OemID(674)
	OemLMC                  = OemID(2168)
	OemRadiSys              = OemID(4337)
	OemBroadcom             = OemID(4413)
	OemMagnum               = OemID(5593)
	OemTyan                 = OemID(6653)
	OemNewisys              = OemID(9237)
	OemFujitsuSiemens       = OemID(10368)
	OemAvocent              = OemID(10418)
	OemPeppercon            = OemID(10437)
	OemSupermicro           = OemID(10876)
	OemOSA                  = OemID(11102)
	OemGoogle               = OemID(11129)
	OemPICMG                = OemID(12634)
	OemRaritan              = OemID(13742)
	OemKontron              = OemID(15000)
	OemPPS                  = OemID(16394)
	OemAMI                  = OemID(20974)
	OemNokiaSiemensNetworks = OemID(28458)
	OemSupermicro47488      = OemID(47488)
)

IANA assigned manufacturer IDs

Variables

View Source
var (
	NetworkFunctionChassis = NetworkFunction(0x00)
	NetworkFunctionApp     = NetworkFunction(0x06)
	NetworkFunctionDcmi    = NetworkFunction(0x2c)
)

Network Function Codes per section 5.1

Functions

This section is empty.

Types

type ActivateSessionRequest

type ActivateSessionRequest struct {
	AuthType  uint8
	PrivLevel uint8
	AuthCode  [16]uint8
	InSeq     [4]uint8
}

ActivateSessionRequest per section 22.17

type ActivateSessionResponse

type ActivateSessionResponse struct {
	CompletionCode
	AuthType   uint8
	SessionID  uint32
	InboundSeq uint32
	MaxPriv    uint8
}

ActivateSessionResponse per section 22.17

type AuthCapabilitiesRequest

type AuthCapabilitiesRequest struct {
	ChannelNumber uint8
	PrivLevel     uint8
}

AuthCapabilitiesRequest per section 22.13

type AuthCapabilitiesResponse

type AuthCapabilitiesResponse struct {
	CompletionCode
	ChannelNumber   uint8
	AuthTypeSupport uint8
	Status          uint8
	Reserved        uint8
	OEMID           uint16
	OEMAux          uint8
}

AuthCapabilitiesResponse per section 22.13

type BootDevice

type BootDevice uint8

func (BootDevice) String

func (d BootDevice) String() string

type ChassisControl

type ChassisControl uint8

func (ChassisControl) String

func (c ChassisControl) String() string

type ChassisControlRequest

type ChassisControlRequest struct {
	ChassisControl
}

ChassisControlRequest per section 28.3

type ChassisControlResponse

type ChassisControlResponse struct {
	CompletionCode
}

ChassisControlResponse per section 28.3

type ChassisStatusRequest

type ChassisStatusRequest struct{}

ChassisStatusRequest per section 28.2

type ChassisStatusResponse

type ChassisStatusResponse struct {
	CompletionCode
	PowerState        uint8
	LastPowerEvent    uint8
	State             uint8
	FrontControlPanel uint8
}

ChassisStatusResponse per section 28.2

func (*ChassisStatusResponse) IsSystemPowerOn

func (s *ChassisStatusResponse) IsSystemPowerOn() bool

func (*ChassisStatusResponse) PowerRestorePolicy

func (s *ChassisStatusResponse) PowerRestorePolicy() uint8

func (*ChassisStatusResponse) String

func (s *ChassisStatusResponse) String() string

func (*ChassisStatusResponse) UnmarshalBinary

func (r *ChassisStatusResponse) UnmarshalBinary(buf []byte) error

UnmarshalBinary implementation to handle variable length Data

type Client

type Client struct {
	*Connection
	// contains filtered or unexported fields
}

Client provides common high level functionality around the underlying transport

func NewClient

func NewClient(c *Connection) (*Client, error)

NewClient creates a new Client with the given Connection properties

func (*Client) Close

func (c *Client) Close() error

Close the IPMI session

func (*Client) Control

func (c *Client) Control(ctl ChassisControl) error

Control sends a chassis power control command

func (*Client) DeviceID

func (c *Client) DeviceID() (*DeviceIDResponse, error)

DeviceID get the Device ID of the BMC

func (*Client) GetMcId

func (c *Client) GetMcId() (*DcmiGetMcIdResponse, error)

func (*Client) Open

func (c *Client) Open() error

Open a new IPMI session

func (*Client) Send

func (c *Client) Send(req *Request, res Response) error

Send a Request and unmarshal to given Response type

func (*Client) SetBootDevice

func (c *Client) SetBootDevice(dev BootDevice) error

SetBootDevice is a wrapper around SetSystemBootOptionsRequest to configure the BootDevice per section 28.12 - table 28

func (*Client) SetMcId

func (c *Client) SetMcId(mcId string) (*DcmiSetMcIdResponse, error)

type CloseSessionRequest

type CloseSessionRequest struct {
	SessionID uint32
}

CloseSessionRequest per section 22.19

type CloseSessionResponse

type CloseSessionResponse struct {
	CompletionCode
}

CloseSessionResponse per section 22.19

type Command

type Command uint8

Command fields on an IPMI message

type CompletionCode

type CompletionCode uint8

CompletionCode is the first byte in the data field of all IPMI responses

func (CompletionCode) Code

func (c CompletionCode) Code() uint8

Code returns the CompletionCode as uint8

func (CompletionCode) Error

func (c CompletionCode) Error() string

Error for CompletionCode

type Connection

type Connection struct {
	Path      string
	Hostname  string
	Port      int
	Username  string
	Password  string
	Interface string
}

Connection properties for a Client

func (*Connection) LocalIP

func (c *Connection) LocalIP() string

LocalIP returns the local (client) IP address of the Connection

func (*Connection) RemoteIP

func (c *Connection) RemoteIP() string

RemoteIP returns the remote (bmc) IP address of the Connection

type DcmiGetMcIdRequest

type DcmiGetMcIdRequest struct {
	GroupExtensionId uint8
	Offset           uint8
	NumBytes         uint8
}

DcmiGetMcIdRequest per section 6.4.6.1

func (*DcmiGetMcIdRequest) MarshalBinary

func (r *DcmiGetMcIdRequest) MarshalBinary() ([]byte, error)

MarshalBinary implementation to handle variable length Data

func (*DcmiGetMcIdRequest) UnmarshalBinary

func (r *DcmiGetMcIdRequest) UnmarshalBinary(buf []byte) error

UnmarshalBinary implementation to handle variable length Data

type DcmiGetMcIdResponse

type DcmiGetMcIdResponse struct {
	CompletionCode
	GroupExtensionId uint8
	NumBytes         uint8
	Data             string
}

DcmiGetMcIdResponse per section 6.4.6.1

func (*DcmiGetMcIdResponse) MarshalBinary

func (r *DcmiGetMcIdResponse) MarshalBinary() ([]byte, error)

MarshalBinary implementation to handle variable length Data

func (*DcmiGetMcIdResponse) UnmarshalBinary

func (r *DcmiGetMcIdResponse) UnmarshalBinary(buf []byte) error

UnmarshalBinary implementation to handle variable length Data

type DcmiSetMcIdRequest

type DcmiSetMcIdRequest struct {
	GroupExtensionId uint8
	Offset           uint8
	NumBytes         uint8
	Data             string
}

DcmiSetMcIdRequest per section 6.4.6.2

func (*DcmiSetMcIdRequest) MarshalBinary

func (r *DcmiSetMcIdRequest) MarshalBinary() ([]byte, error)

MarshalBinary implementation to handle variable length Data

func (*DcmiSetMcIdRequest) UnmarshalBinary

func (r *DcmiSetMcIdRequest) UnmarshalBinary(buf []byte) error

UnmarshalBinary implementation to handle variable length Data

type DcmiSetMcIdResponse

type DcmiSetMcIdResponse struct {
	CompletionCode
	GroupExtensionId  uint8
	LastOffsetWritten uint8
}

DcmiSetMcIdResponse per section 6.4.6.2

func (*DcmiSetMcIdResponse) MarshalBinary

func (r *DcmiSetMcIdResponse) MarshalBinary() ([]byte, error)

MarshalBinary implementation to handle variable length Data

func (*DcmiSetMcIdResponse) UnmarshalBinary

func (r *DcmiSetMcIdResponse) UnmarshalBinary(buf []byte) error

UnmarshalBinary implementation to handle variable length Data

type DeviceIDRequest

type DeviceIDRequest struct{}

DeviceIDRequest per section 20.1

type DeviceIDResponse

type DeviceIDResponse struct {
	CompletionCode
	DeviceID                uint8
	DeviceRevision          uint8
	FirmwareRevision1       uint8
	FirmwareRevision2       uint8
	IPMIVersion             uint8
	AdditionalDeviceSupport uint8
	ManufacturerID          OemID
	ProductID               uint16
}

DeviceIDResponse per section 20.1

type Handler

type Handler func(*Message) Response

Handler function

type Message

type Message struct {
	AuthCode [16]byte

	Data      []byte
	RequestID string
	// contains filtered or unexported fields
}

Message encapsulates an IPMI message

func (*Message) CompletionCode

func (m *Message) CompletionCode() CompletionCode

CompletionCode of an IPMI command response

func (*Message) NetFn

func (m *Message) NetFn() NetworkFunction

NetFn returns the NetworkFunction portion of the NetFn/RsLUN field

func (*Message) Request

func (m *Message) Request(data interface{}) Response

Request specific to the request IPMI command Unmarshal errors are returned as a Response such that they can be propagated to the client.

func (*Message) Response

func (m *Message) Response(data Response) error

Response specific to the request IPMI command

type NetworkFunction

type NetworkFunction uint8

NetworkFunction identifies the functional class of an IPMI message

type OemID

type OemID uint16

OemID aka IANA assigned Enterprise Number per: http://www.iana.org/assignments/enterprise-numbers/enterprise-numbers Note that constants defined here are the same subset that ipmitool recognizes.

func (OemID) String

func (id OemID) String() string

type Request

type Request struct {
	NetworkFunction
	Command
	Data interface{}
}

Request structure

type Response

type Response interface {
	Code() uint8
}

Response to an IPMI request must include at least a CompletionCode

type SessionChallengeRequest

type SessionChallengeRequest struct {
	AuthType uint8
	Username [16]uint8
}

SessionChallengeRequest per section 22.16

type SessionChallengeResponse

type SessionChallengeResponse struct {
	CompletionCode
	TemporarySessionID uint32
	Challenge          [16]byte
}

SessionChallengeResponse per section 22.16

type SessionPrivilegeLevelRequest

type SessionPrivilegeLevelRequest struct {
	PrivLevel uint8
}

SessionPrivilegeLevelRequest per section 22.18

type SessionPrivilegeLevelResponse

type SessionPrivilegeLevelResponse struct {
	CompletionCode
	NewPrivilegeLevel uint8
}

SessionPrivilegeLevelResponse per section 22.18

type SetSystemBootOptionsRequest

type SetSystemBootOptionsRequest struct {
	Param uint8
	Data  []uint8
}

SetSystemBootOptionsRequest per section 28.12

func (*SetSystemBootOptionsRequest) MarshalBinary

func (r *SetSystemBootOptionsRequest) MarshalBinary() ([]byte, error)

MarshalBinary implementation to handle variable length Data

func (*SetSystemBootOptionsRequest) UnmarshalBinary

func (r *SetSystemBootOptionsRequest) UnmarshalBinary(buf []byte) error

UnmarshalBinary implementation to handle variable length Data

type SetSystemBootOptionsResponse

type SetSystemBootOptionsResponse struct {
	CompletionCode
}

SetSystemBootOptionsResponse per section 28.12

type Simulator

type Simulator struct {
	// contains filtered or unexported fields
}

Simulator for IPMI

func NewSimulator

func NewSimulator(addr net.UDPAddr) *Simulator

NewSimulator constructs a Simulator with the given addr

func (*Simulator) LocalAddr

func (s *Simulator) LocalAddr() *net.UDPAddr

LocalAddr returns the address the server is bound to.

func (*Simulator) NewConnection

func (s *Simulator) NewConnection() *Connection

NewConnection to this Simulator instance

func (*Simulator) Run

func (s *Simulator) Run() error

Run the Simulator.

func (*Simulator) SetHandler

func (s *Simulator) SetHandler(netfn NetworkFunction, command Command, handler Handler)

SetHandler sets the command handler for the given netfn and command

func (*Simulator) Stop

func (s *Simulator) Stop()

Stop the Simulator.

type SystemBootOptionsRequest

type SystemBootOptionsRequest struct {
	Param uint8
	Set   uint8
	Block uint8
}

SystemBootOptionsRequest per section 28.13

type SystemBootOptionsResponse

type SystemBootOptionsResponse struct {
	CompletionCode
	Version uint8
	Param   uint8
	Data    []uint8
}

SystemBootOptionsResponse per section 28.13

func (*SystemBootOptionsResponse) BootDeviceSelector

func (r *SystemBootOptionsResponse) BootDeviceSelector() BootDevice

func (*SystemBootOptionsResponse) MarshalBinary

func (r *SystemBootOptionsResponse) MarshalBinary() ([]byte, error)

MarshalBinary implementation to handle variable length Data

func (*SystemBootOptionsResponse) UnmarshalBinary

func (r *SystemBootOptionsResponse) UnmarshalBinary(buf []byte) error

UnmarshalBinary implementation to handle variable length Data

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL