redfish

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: GPL-3.0, LGPL-3.0 Imports: 17 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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.

View Source
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) BaseURL

func (c *Client) BaseURL() string

BaseURL is the root of the Redfish service on this host.

func (*Client) ClearBootOverride

func (c *Client) ClearBootOverride(ctx context.Context) error

ClearBootOverride removes a boot source override.

func (*Client) Do

func (c *Client) Do(ctx context.Context, method, path string, body any) (map[string]any, error)

Do performs one request and decodes the JSON body.

func (*Client) DoRaw

func (c *Client) DoRaw(ctx context.Context, method, path string, body any) ([]byte, int, error)

DoRaw performs one request and returns the body and the status.

func (*Client) Get

func (c *Client) Get(ctx context.Context, path string) (map[string]any, error)

Get reads a Redfish resource.

func (*Client) Post

func (c *Client) Post(ctx context.Context, path string, body any) (map[string]any, error)

Post sends an action to a Redfish resource.

func (*Client) PowerState

func (c *Client) PowerState(ctx context.Context) (string, error)

PowerState reads the current power state.

func (*Client) Reset

func (c *Client) Reset(ctx context.Context, resetType string) error

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

func (c *Client) SetBootOverride(ctx context.Context, target string, persistent bool) error

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.

func (*Client) System

func (c *Client) System(ctx context.Context) (*System, error)

System reads the computer system resource.

type PinMismatchError

type PinMismatchError struct {
	Host     string
	Recorded string
	Seen     string
}

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.

func (*PinStore) Get

func (s *PinStore) Get(host string) (string, bool, error)

Get returns the pin recorded for a host.

func (*PinStore) Load

func (s *PinStore) Load() (map[string]string, error)

Load reads the pins.

func (*PinStore) Remove

func (s *PinStore) Remove(ctx context.Context, host string) error

Remove drops the pin of a host, which is how a certificate replacement is accepted.

func (*PinStore) Set

func (s *PinStore) Set(ctx context.Context, host, pin string) error

Set records a pin, replacing any earlier one.

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.

Jump to

Keyboard shortcuts

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