bmc

package
v0.0.0-...-efee1bf Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultResourcePollingInterval is the default interval for polling resources.
	DefaultResourcePollingInterval = 30 * time.Second
	// DefaultResourcePollingTimeout is the default timeout for polling resources.
	DefaultResourcePollingTimeout = 5 * time.Minute
	// DefaultPowerPollingInterval is the default interval for polling power state.
	DefaultPowerPollingInterval = 30 * time.Second
	// DefaultPowerPollingTimeout is the default timeout for polling power state.
	DefaultPowerPollingTimeout = 5 * time.Minute
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BMC

type BMC interface {
	// PowerOn powers on the system.
	PowerOn(ctx context.Context, systemUUID string) error

	// PowerOff gracefully shuts down the system.
	PowerOff(ctx context.Context, systemUUID string) error

	// ForcePowerOff powers off the system.
	ForcePowerOff(ctx context.Context, systemUUID string) error

	// Reset performs a reset on the system.
	Reset(ctx context.Context, systemUUID string, resetType redfish.ResetType) error

	// SetPXEBootOnce sets the boot device for the next system boot.
	SetPXEBootOnce(ctx context.Context, systemUUID string) error

	// GetSystemInfo retrieves information about the system.
	GetSystemInfo(ctx context.Context, systemUUID string) (SystemInfo, error)

	// Logout closes the BMC client connection by logging out
	Logout()

	// GetSystems returns the managed systems
	GetSystems(ctx context.Context) ([]Server, error)

	// GetManager returns the manager
	GetManager() (*Manager, error)

	GetBootOrder(ctx context.Context, systemUUID string) ([]string, error)

	GetBiosAttributeValues(ctx context.Context, systemUUID string, attributes []string) (map[string]string, error)

	SetBiosAttributes(ctx context.Context, systemUUID string, attributes map[string]string) (reset bool, err error)

	GetBiosVersion(ctx context.Context, systemUUID string) (string, error)

	SetBootOrder(ctx context.Context, systemUUID string, order []string) error

	GetStorages(ctx context.Context, systemUUID string) ([]Storage, error)

	WaitForServerPowerState(ctx context.Context, systemUUID string, powerState redfish.PowerState) error
}

BMC defines an interface for interacting with a Baseboard Management Controller.

func NewRedfishKubeBMCClient

func NewRedfishKubeBMCClient(
	ctx context.Context,
	options BMCOptions,
	c client.Client,
	ns string,
) (BMC, error)

NewRedfishKubeBMCClient creates a new RedfishKubeBMC with the given connection details.

func NewRedfishLocalBMCClient

func NewRedfishLocalBMCClient(
	ctx context.Context,
	options BMCOptions,
) (BMC, error)

NewRedfishLocalBMCClient creates a new RedfishLocalBMC with the given connection details.

type BMCOptions

type BMCOptions struct {
	Endpoint  string
	Username  string
	Password  string
	BasicAuth bool

	ResourcePollingInterval time.Duration
	ResourcePollingTimeout  time.Duration
	PowerPollingInterval    time.Duration
	PowerPollingTimeout     time.Duration
}

BMCOptions contains the options for the BMC redfish client.

type Bios

type Bios struct {
	Version    string
	Attributes map[string]string
}

type BiosRegistry

type BiosRegistry struct {
	common.Entity
	// ODataContext is the odata context.
	ODataContext string `json:"@odata.context"`
	// ODataType is the odata type.
	ODataType string `json:"@odata.type"`
	// Description provides a description of this resource.
	Description string
	// Languages is the RFC5646-conformant language codes for the
	// available Message Registries.
	Languages []string
	// Registry shall contain the Message Registry name and it major and
	// minor versions, as defined by the Redfish Specification.
	RegistryEntries RegistryEntry
}

BiosRegistry describes the Message Registry file locator Resource.

type Drive

type Drive struct {
	Entity
	// MediaType specifies the media type of the storage device.
	MediaType string `json:"mediaType,omitempty"`
	// Type specifies the type of the storage device.
	Type redfish.FormFactor `json:"type,omitempty"`
	// SizeBytes specifies the size of the storage device in bytes.
	SizeBytes int64 `json:"sizeBytes,omitempty"`
	// Vendor specifies the vendor of the storage device.
	Vendor string `json:"vendor,omitempty"`
	// Model specifies the model of the storage device.
	Model string `json:"model,omitempty"`
	// State specifies the state of the storage device.
	State common.State `json:"state,omitempty"`
}

Drive represents a storage drive.

type Entity

type Entity struct {
	// ID uniquely identifies the resource.
	ID string `json:"Id"`
	// Name is the name of the resource or array element.
	Name string `json:"name"`
}

type KubeClient

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

type Manager

type Manager struct {
	UUID            string
	Manufacturer    string
	FirmwareVersion string
	SerialNumber    string
	SKU             string
	Model           string
	PowerState      string
	State           string
	MACAddress      string
}

Manager represents the manager information.

type NetworkInterface

type NetworkInterface struct {
	ID                  string
	MACAddress          string
	PermanentMACAddress string
}

type PowerState

type PowerState string

PowerState is the power state of the system.

const (
	// OnPowerState the system is powered on.
	OnPowerState PowerState = "On"
	// OffPowerState the system is powered off, although some components may
	// continue to have AUX power such as management controller.
	OffPowerState PowerState = "Off"
	// PausedPowerState the system is paused.
	PausedPowerState PowerState = "Paused"
	// PoweringOnPowerState A temporary state between Off and On. This
	// temporary state can be very short.
	PoweringOnPowerState PowerState = "PoweringOn"
	// PoweringOffPowerState A temporary state between On and Off. The power
	// off action can take time while the OS is in the shutdown process.
	PoweringOffPowerState PowerState = "PoweringOff"
)

type Processor

type Processor struct {
	ID                    string
	ProcessorType         string
	ProcessorArchitecture string
	InstructionSet        string
	Manufacturer          string
	Model                 string
	MaxSpeedMHz           int32
	TotalCores            int32
	TotalThreads          int32
}

type RedfishBMC

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

RedfishBMC is an implementation of the BMC interface for Redfish.

func NewRedfishBMCClient

func NewRedfishBMCClient(
	ctx context.Context,
	options BMCOptions,
) (*RedfishBMC, error)

NewRedfishBMCClient creates a new RedfishBMC with the given connection details.

func (*RedfishBMC) ForcePowerOff

func (r *RedfishBMC) ForcePowerOff(ctx context.Context, systemUUID string) error

ForcePowerOff powers off the system using Redfish.

func (*RedfishBMC) GetBiosAttributeValues

func (r *RedfishBMC) GetBiosAttributeValues(
	ctx context.Context,
	systemUUID string,
	attributes []string,
) (
	result map[string]string,
	err error,
)

func (*RedfishBMC) GetBiosVersion

func (r *RedfishBMC) GetBiosVersion(ctx context.Context, systemUUID string) (string, error)

func (*RedfishBMC) GetBootOrder

func (r *RedfishBMC) GetBootOrder(ctx context.Context, systemUUID string) ([]string, error)

func (*RedfishBMC) GetManager

func (r *RedfishBMC) GetManager() (*Manager, error)

func (*RedfishBMC) GetStorages

func (r *RedfishBMC) GetStorages(ctx context.Context, systemUUID string) ([]Storage, error)

func (*RedfishBMC) GetSystemInfo

func (r *RedfishBMC) GetSystemInfo(ctx context.Context, systemUUID string) (SystemInfo, error)

GetSystemInfo retrieves information about the system using Redfish.

func (*RedfishBMC) GetSystems

func (r *RedfishBMC) GetSystems(ctx context.Context) ([]Server, error)

GetSystems get managed systems

func (*RedfishBMC) Logout

func (r *RedfishBMC) Logout()

Logout closes the BMC client connection by logging out

func (*RedfishBMC) PowerOff

func (r *RedfishBMC) PowerOff(ctx context.Context, systemUUID string) error

PowerOff gracefully shuts down the system using Redfish.

func (*RedfishBMC) PowerOn

func (r *RedfishBMC) PowerOn(ctx context.Context, systemUUID string) error

PowerOn powers on the system using Redfish.

func (*RedfishBMC) Reset

func (r *RedfishBMC) Reset(ctx context.Context, systemUUID string, resetType redfish.ResetType) error

Reset performs a reset on the system using Redfish.

func (*RedfishBMC) SetBiosAttributes

func (r *RedfishBMC) SetBiosAttributes(
	ctx context.Context,
	systemUUID string,
	attributes map[string]string,
) (
	reset bool,
	err error,
)

SetBiosAttributes sets given bios attributes. Returns true if bios reset is required

func (*RedfishBMC) SetBootOrder

func (r *RedfishBMC) SetBootOrder(ctx context.Context, systemUUID string, bootOrder []string) error

SetBootOrder sets bios boot order

func (*RedfishBMC) SetPXEBootOnce

func (r *RedfishBMC) SetPXEBootOnce(ctx context.Context, systemUUID string) error

SetPXEBootOnce sets the boot device for the next system boot using Redfish.

func (*RedfishBMC) WaitForServerPowerState

func (r *RedfishBMC) WaitForServerPowerState(
	ctx context.Context,
	systemUUID string,
	powerState redfish.PowerState,
) error

type RedfishKubeBMC

type RedfishKubeBMC struct {
	*RedfishBMC
	*KubeClient
}

RedfishKubeBMC is an implementation of the BMC interface for Redfish.

func (*RedfishKubeBMC) SetPXEBootOnce

func (r *RedfishKubeBMC) SetPXEBootOnce(ctx context.Context, systemUUID string) error

SetPXEBootOnce sets the boot device for the next system boot using Redfish.

type RedfishLocalBMC

type RedfishLocalBMC struct {
	*RedfishBMC
}

RedfishLocalBMC is an implementation of the BMC interface for Redfish.

func (RedfishLocalBMC) PowerOff

func (r RedfishLocalBMC) PowerOff(ctx context.Context, systemUUID string) error

func (RedfishLocalBMC) PowerOn

func (r RedfishLocalBMC) PowerOn(ctx context.Context, systemUUID string) error

type RegistryEntry

type RegistryEntry struct {
	Attributes []RegistryEntryAttributes
}

type RegistryEntryAttributes

type RegistryEntryAttributes struct {
	AttributeName string
	CurrentValue  interface{}
	DisplayName   string
	DisplayOrder  int
	HelpText      string
	Hidden        bool
	Immutable     bool
	MaxLength     int
	MenuPath      string
	MinLength     int
	ReadOnly      bool
	ResetRequired bool
	Type          string
	WriteOnly     bool
}

type Server

type Server struct {
	UUID         string
	Model        string
	Manufacturer string
	PowerState   PowerState
	SerialNumber string
}

type Storage

type Storage struct {
	Entity
	// State specifies the state of the storage.
	State common.State `json:"state,omitempty"`
	// Drives is a collection of drives associated with this storage.
	Drives []Drive `json:"drives,omitempty"`
	// Volumes is a collection of volumes associated with this storage.
	Volumes []Volume `json:"volumes,omitempty"`
}

Storage represents a storage resource.

type SystemInfo

type SystemInfo struct {
	Manufacturer      string
	Model             string
	Status            common.Status
	PowerState        redfish.PowerState
	NetworkInterfaces []NetworkInterface
	Processors        []Processor
	TotalSystemMemory resource.Quantity
	SystemUUID        string
	SerialNumber      string
	SKU               string
	IndicatorLED      string
}

SystemInfo represents basic information about the system.

type Volume

type Volume struct {
	Entity
	// CapacityBytes specifies the capacity of the volume in bytes.
	SizeBytes int64 `json:"sizeBytes,omitempty"`
	// Status specifies the status of the volume.
	State common.State `json:"state,omitempty"`
	// RAIDType specifies the RAID type of the associated Volume.
	RAIDType redfish.RAIDType `json:"raidType,omitempty"`
	// VolumeUsage specifies the volume usage type for the Volume.
	VolumeUsage string `json:"volumeUsage,omitempty"`
}

Volume represents a storage volume.

Jump to

Keyboard shortcuts

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