Documentation
¶
Index ¶
- Variables
- type BMC
- func (bmc *BMC) CloseSerialConsole() error
- func (bmc *BMC) IsSecureBootEnabled() (bool, error)
- func (bmc *BMC) OpenSerialConsole(openConsoleCliCmd string) (io.Reader, io.WriteCloser, error)
- func (bmc *BMC) PowerUsage() (float32, error)
- func (bmc *BMC) RunCLICommand(cmd string, combineOutput bool, timeout time.Duration) (stdout string, stderr string, err error)
- func (bmc *BMC) SecureBootDisable() error
- func (bmc *BMC) SecureBootEnable() error
- func (bmc *BMC) SetSystemBootOrderReferences(bootOrderReferences []string) error
- func (bmc *BMC) SystemBootOptions() (map[string]string, error)
- func (bmc *BMC) SystemBootOrderReferences() ([]string, error)
- func (bmc *BMC) SystemForceReset() error
- func (bmc *BMC) SystemGracefulShutdown() error
- func (bmc *BMC) SystemManufacturer() (string, error)
- func (bmc *BMC) SystemPowerCycle() error
- func (bmc *BMC) SystemPowerOff() error
- func (bmc *BMC) SystemPowerOn() error
- func (bmc *BMC) SystemPowerState() (string, error)
- func (bmc *BMC) SystemResetAction(action redfish.ResetType) error
- func (bmc *BMC) WaitForSystemPowerState(powerState redfish.PowerState, timeout time.Duration) error
- func (bmc *BMC) WithRedfishPowerControlIndex(index int) *BMC
- func (bmc *BMC) WithRedfishSystemIndex(index int) *BMC
- func (bmc *BMC) WithRedfishTimeout(timeout time.Duration) *BMC
- func (bmc *BMC) WithRedfishUser(username, password string) *BMC
- func (bmc *BMC) WithSSHPort(port uint16) *BMC
- func (bmc *BMC) WithSSHTimeout(timeout time.Duration) *BMC
- func (bmc *BMC) WithSSHUser(username, password string) *BMC
- type TimeOuts
- type User
Constants ¶
This section is empty.
Variables ¶
var ( // DefaultTimeOuts holds the default redfish and ssh timeouts. DefaultTimeOuts = TimeOuts{ Redfish: defaultTimeOut, SSH: defaultTimeOut, } )
Functions ¶
This section is empty.
Types ¶
type BMC ¶
type BMC struct {
// contains filtered or unexported fields
}
BMC is the holder struct for BMC access through redfish & ssh.
func New ¶
New returns a BMC struct with the specified host. The host should be nonempty. WithRedfishUser and WithSSHUser must be called before connecting to Redfish or over SSH, respectively. The SSH port and timeouts are set to DefaultSSHPort and DefaultTimeOuts, with indices defaulting to 0.
func (*BMC) CloseSerialConsole ¶
CloseSerialConsole closes the serial console's underlying ssh session.
func (*BMC) IsSecureBootEnabled ¶
IsSecureBootEnabled returns whether the SecureBoot feature is enabled using the BMC's RedFish API endpoint.
func (*BMC) OpenSerialConsole ¶
OpenSerialConsole opens the serial console port. The console is tunneled in an underlying (CLI) ssh session that is opened in the BMC's ssh server. If openConsoleCliCmd is provided, it will be sent to the BMC's cli. Otherwise, a best effort will be made to run the appropriate cli command based on the system manufacturer. This method requires both a Redfish and SSH user configured.
func (*BMC) PowerUsage ¶
PowerUsage returns the current power usage of the chassis in watts using the Redfish API. This method uses the first chassis with a power link and the power control index for the BMC client.
func (*BMC) RunCLICommand ¶
func (bmc *BMC) RunCLICommand( cmd string, combineOutput bool, timeout time.Duration) (stdout string, stderr string, err error)
RunCLICommand runs a CLI command in the BMC's console over SSH. This method will block until the command has finished, and its output is copied to stdout and/or stderr if applicable. If combineOutput is true, stderr content is merged in stdout. The timeout param is used to avoid the caller to be stuck forever in case something goes wrong or the command is stuck.
func (*BMC) SecureBootDisable ¶
SecureBootDisable disables the SecureBoot feature using the BMC's RedFish API endpoint.
func (*BMC) SecureBootEnable ¶
SecureBootEnable enables the SecureBoot feature using the BMC's RedFish API endpoint.
func (*BMC) SetSystemBootOrderReferences ¶
SetSystemBootOrderReferences sets the boot order references of the current system using the redfish API. The boot order references are not updated until the system is resetted, meaning that a following call to SystemBootOrderReferences() won't reflect the change until the system has been actually resetted.
func (*BMC) SystemBootOptions ¶
SystemBootOptions uses the redfish api to get the current system's boot options and returns a map references to display names, e.g.:
- "Boot0000":"PXE Device 1: Embedded NIC 1 Port 1 Partition 1"
- "Boot0003":"RAID Controller in SL 3: Red Hat Enterprise Linux]"
func (*BMC) SystemBootOrderReferences ¶
SystemBootOrderReferences returns the current system's boot order (references) in an ordered slice using redfish API.
func (*BMC) SystemForceReset ¶
SystemForceReset performs a (non-graceful) forced system reset using Redfish API.
func (*BMC) SystemGracefulShutdown ¶
SystemGracefulShutdown performs a graceful shutdown using the Redfish API.
func (*BMC) SystemManufacturer ¶
SystemManufacturer gets system's manufacturer from the BMC's RedFish API endpoint.
func (*BMC) SystemPowerCycle ¶
SystemPowerCycle performs a power cycle in the system using the Redfish API. If PowerCycle reset type is not supported, alternate PowerOff + On reset actions will be performed as fallback mechanism. Use bmc.SystemResetAction(redfish.PowerCycleResetType) if this fallback mechanism is not needed/wanted.
func (*BMC) SystemPowerOff ¶
SystemPowerOff performs a non-graceful power off of the system using the Redfish API.
func (*BMC) SystemPowerOn ¶
SystemPowerOn powers on the system using the Redfish API.
func (*BMC) SystemPowerState ¶
SystemPowerState returns the system's current power state using the Redfish API. Returned string can be one of On/Off/Paused/PoweringOn/PoweringOff.
func (*BMC) SystemResetAction ¶
SystemResetAction performs the specified reset action against the system.
func (*BMC) WaitForSystemPowerState ¶
WaitForSystemPowerState waits up to timeout until the BMC returns the provided system power state.
func (*BMC) WithRedfishPowerControlIndex ¶
WithRedfishPowerControlIndex provides the index of the PowerControl object to use from the Power link on the Chassis service in the Redfish API. The order of the PowerControl objects is deterministic.
func (*BMC) WithRedfishSystemIndex ¶
WithRedfishSystemIndex provies the index of the system to use in the Redfish API. Note that the order of the systems is nondeterministic.
func (*BMC) WithRedfishTimeout ¶
WithRedfishTimeout provides the timeout to use when connecting to the Redfish API. It should not be zero or negative.
func (*BMC) WithRedfishUser ¶
WithRedfishUser provides the credentials to access the Redfish API. Neither the username nor password should be empty.
func (*BMC) WithSSHPort ¶
WithSSHPort provides the port to use when connecting to the BMC over SSH. It should not be zero.
func (*BMC) WithSSHTimeout ¶
WithSSHTimeout provides the timeout to use when connecting to the BMC over SSH. It should not be zero or negative.
func (*BMC) WithSSHUser ¶
WithSSHUser provides the credentials to use when connecting to the BMC over SSH. Neither the username nor the password should be empty.