redfish

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

View Source
var ErrUnsupported = errors.New("not supported by BMC")

ErrUnsupported indicates the BMC does not support the requested operation.

Functions

func CaptureFingerprint

func CaptureFingerprint(ctx context.Context, url string) (string, error)

CaptureFingerprint connects to a BMC without cert pinning and returns the SHA256 fingerprint of its TLS certificate (for TOFU).

func ValidateStaticIPv4Config added in v0.1.22

func ValidateStaticIPv4Config(config StaticIPv4Config) error

ValidateStaticIPv4Config validates the IP fields in a static network configuration.

Types

type BootConfig

type BootConfig struct {
	Target         BootTarget
	Enabled        BootEnabled
	Mode           BootMode
	UefiHTTPSource string
	HasHTTPBootURI bool
}

BootConfig holds the current boot source override configuration.

type BootEnabled

type BootEnabled string

BootEnabled represents a Redfish boot source override enabled mode.

const (
	BootContinuous BootEnabled = "Continuous"
	BootOnce       BootEnabled = "Once"
	BootDisabled   BootEnabled = "Disabled"
)

type BootMode added in v0.1.20

type BootMode string

BootMode represents a Redfish boot source override mode.

const (
	BootModeUEFI BootMode = "UEFI"
)

type BootTarget

type BootTarget string

BootTarget represents a Redfish boot source override target.

const (
	BootTargetPxe      BootTarget = "Pxe"
	BootTargetHdd      BootTarget = "Hdd"
	BootTargetUefiHTTP BootTarget = "UefiHttp"
)

type Client

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

Client provides Redfish operations against a single BMC. Created via Pool.Get or Dial. Must be closed when no longer needed.

func Dial

func Dial(ctx context.Context, url, certSHA256, user, pass, deviceID string) (*Client, error)

Dial connects to a BMC and returns a ready-to-use Client. It creates a Redfish session (falling back to basic auth) and resolves the device ID. The caller must call Close when done.

func (*Client) Close

func (c *Client) Close()

Close releases the client's Redfish session.

func (*Client) DisableBootOverride

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

DisableBootOverride disables the boot source override. Returns ErrUnsupported if the BMC does not support disabling.

func (*Client) GetBIOSHTTPBootURI added in v0.1.22

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

GetBIOSHTTPBootURI returns the pending BIOS UEFI HTTP boot URI. Returns ErrUnsupported if the BMC does not support BIOS settings.

func (*Client) GetBootConfig

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

GetBootConfig returns the current boot source override configuration.

func (*Client) PowerState

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

PowerState returns the current power state of the system.

func (*Client) Reset

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

Reset sends a ComputerSystem.Reset action.

func (*Client) SetBIOSHTTPBootURI added in v0.1.22

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

SetBIOSHTTPBootURI sets the pending BIOS UEFI HTTP boot URI. Returns ErrUnsupported if the BMC does not support BIOS settings.

func (*Client) SetBIOSStaticIPv4 added in v0.1.22

func (c *Client) SetBIOSStaticIPv4(ctx context.Context, config StaticIPv4Config) error

SetBIOSStaticIPv4 sets pending BIOS UEFI HTTP boot IPv4 settings. Returns ErrUnsupported if the BMC does not support BIOS settings.

func (*Client) SetBootOverride

func (c *Client) SetBootOverride(ctx context.Context, target BootTarget, enabled BootEnabled) error

SetBootOverride sets the boot source override target and enabled mode. Returns ErrUnsupported if the BMC does not support the PATCH.

func (*Client) SetHTTPBootOverride added in v0.1.20

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

SetHTTPBootOverride sets a persistent Redfish UEFI HTTP boot override. Returns ErrUnsupported if the BMC does not support the PATCH.

func (*Client) SetStaticIPv4 added in v0.1.22

func (c *Client) SetStaticIPv4(ctx context.Context, config StaticIPv4Config) error

SetStaticIPv4 configures a host EthernetInterface with static IPv4 settings. The interface is selected by MACAddress or PermanentMACAddress. Returns ErrUnsupported if the BMC does not expose writable EthernetInterface resources.

type Pool

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

Pool manages Redfish clients for multiple BMCs. It reuses sessions to avoid creating and destroying a Redfish session on every reconcile. Safe for concurrent use.

func NewPool

func NewPool() *Pool

NewPool returns a new empty client pool.

func (*Pool) Close

func (p *Pool) Close()

Close closes all cached Clients.

func (*Pool) Get

func (p *Pool) Get(ctx context.Context, url, certSHA256, user, pass, deviceID string) (*Client, error)

Get returns a Client for the given BMC. If a cached Client exists with matching credentials, it is returned. If credentials have changed or no cached Client exists, a new one is created (closing the old one).

type PowerState

type PowerState string

PowerState represents the power state of a Redfish system.

const (
	PowerOn  PowerState = "On"
	PowerOff PowerState = "Off"
)

type Reconciler

type Reconciler struct {
	Client       client.Client
	Pool         *Pool
	FileResolver *netboot.FileResolver
}

func (*Reconciler) Reconcile

func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

func (*Reconciler) SetupWithManager

func (r *Reconciler) SetupWithManager(mgr ctrl.Manager) error

type ResetType

type ResetType string

ResetType represents a Redfish ComputerSystem.Reset action type.

Example
fmt.Println(ResetForceRestart)
Output:
ForceRestart
const (
	ResetForceOff     ResetType = "ForceOff"
	ResetForceRestart ResetType = "ForceRestart"
	ResetOn           ResetType = "On"
)

type StaticIPv4Config added in v0.1.22

type StaticIPv4Config struct {
	MAC        string
	Address    string
	SubnetMask string
	Gateway    string
	DNS        []string
}

StaticIPv4Config holds static host NIC settings for Redfish EthernetInterface.

Jump to

Keyboard shortcuts

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