Documentation
¶
Overview ¶
Package redfish talks to the Redfish interface of a service processor.
The client is written here rather than taken from a library because three of its properties are requirements rather than preferences: the TLS certificate is pinned instead of verified against public roots, which is the only check available for a self signed BMC certificate; an action is never retried automatically, because a reset that timed out may well have been carried out; and the reset types a machine accepts are asked for rather than guessed, because firmware differs about which ones exist.
Index ¶
- Constants
- func Fingerprint(cert *x509.Certificate) string
- type Client
- func (c *Client) BaseURL() string
- func (c *Client) ClearBootOverride(ctx context.Context) error
- func (c *Client) Do(ctx context.Context, method, path string, body any) (map[string]any, error)
- func (c *Client) DoRaw(ctx context.Context, method, path string, body any) ([]byte, int, error)
- func (c *Client) Get(ctx context.Context, path string) (map[string]any, error)
- func (c *Client) Post(ctx context.Context, path string, body any) (map[string]any, error)
- func (c *Client) PowerState(ctx context.Context) (string, error)
- func (c *Client) Reset(ctx context.Context, resetType string) error
- func (c *Client) SetBootOverride(ctx context.Context, target string, persistent bool) error
- func (c *Client) System(ctx context.Context) (*System, error)
- type PinMismatchError
- type PinStore
- type System
Constants ¶
const ( ResetOn = "On" ResetForceOff = "ForceOff" ResetGracefulShutdown = "GracefulShutdown" ResetForceRestart = "ForceRestart" ResetGracefulRestart = "GracefulRestart" ResetPowerCycle = "PowerCycle" ResetForceOn = "ForceOn" ResetNmi = "Nmi" )
The reset types this program uses, named as the Redfish schema names them.
const DefaultSystemPath = "/redfish/v1/Systems/1"
DefaultSystemPath is where most firmware puts the computer system.
Variables ¶
This section is empty.
Functions ¶
func Fingerprint ¶
func Fingerprint(cert *x509.Certificate) string
Fingerprint renders the SHA-256 fingerprint of a certificate.
Types ¶
type Client ¶
type Client struct {
// Host is the name or address of the service processor.
Host string
// Username and Password authenticate with it.
Username string
Password string
// SystemPath is the Redfish path of the computer system.
SystemPath string
// Timeout bounds one request.
Timeout time.Duration
// Verify checks the certificate against the system roots instead of
// pinning it. Few sites can use this.
Verify bool
// Pins records the certificate seen for each host.
Pins *PinStore
// MinTLSVersion allows old firmware to be reached: "1.0" to "1.3".
MinTLSVersion string
// Transport overrides the HTTP transport, which the tests use.
Transport http.RoundTripper
// contains filtered or unexported fields
}
Client talks to one service processor.
func (*Client) ClearBootOverride ¶
ClearBootOverride removes a boot source override.
func (*Client) PowerState ¶
PowerState reads the current power state.
func (*Client) Reset ¶
Reset asks the system to change power state.
The reset type is checked against what the machine says it accepts, so that a type its firmware does not implement is reported here rather than as an opaque rejection. The request is sent exactly once: a reset that timed out may already have been carried out, and sending it again would power cycle a running machine.
func (*Client) SetBootOverride ¶
SetBootOverride asks the system to boot from a given source next time.
persistent selects whether the override survives the first boot; ClusterShell era tooling defaulted to persistent and left machines reinstalling in a loop, so the default here is once.
type PinMismatchError ¶
PinMismatchError says that a service processor presented a different certificate than the one recorded.
func (*PinMismatchError) Error ¶
func (e *PinMismatchError) Error() string
type PinStore ¶
type PinStore struct {
// Path is the file the pins are kept in. An empty path disables
// pinning, which is reported rather than assumed.
Path string
}
PinStore records the certificate a service processor presented, so that a change is noticed.
Service processors carry self signed certificates that no public authority vouches for, so verifying against the system roots is not an option. What can be done is to remember the certificate seen the first time and refuse a silent change, which is what an ssh known_hosts file does for host keys.
type System ¶
type System struct {
Name string `json:"name,omitempty" yaml:"name,omitempty"`
PowerState string `json:"powerState,omitempty" yaml:"powerState,omitempty"`
Health string `json:"health,omitempty" yaml:"health,omitempty"`
State string `json:"state,omitempty" yaml:"state,omitempty"`
Manufacturer string `json:"manufacturer,omitempty" yaml:"manufacturer,omitempty"`
Model string `json:"model,omitempty" yaml:"model,omitempty"`
SerialNumber string `json:"serialNumber,omitempty" yaml:"serialNumber,omitempty"`
BIOSVersion string `json:"biosVersion,omitempty" yaml:"biosVersion,omitempty"`
BootSource string `json:"bootSource,omitempty" yaml:"bootSource,omitempty"`
BootEnabled string `json:"bootEnabled,omitempty" yaml:"bootEnabled,omitempty"`
// ResetTypes are the reset types this machine says it accepts.
ResetTypes []string `json:"resetTypes,omitempty" yaml:"resetTypes,omitempty"`
// BootTargets are the boot sources it says it accepts.
BootTargets []string `json:"bootTargets,omitempty" yaml:"bootTargets,omitempty"`
}
System is what a computer system reports about itself.