hal

package module
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: AGPL-3.0 Imports: 4 Imported by: 2

README

go-hal a hardware abstraction layer for servers

GoDoc

go server hardware abstraction, tries to lower the burden of supporting different server vendors.

Example usage:

package main

import (
    "fmt"
    "github.com/metal-stack/go-hal/detect"
)

func main() {
    smcInBand, err := detect.ConnectInBand()
    if err != nil {
        panic(err)
    }

    firmware, err := smcInBand.Firmware()
    if err != nil {
        panic(err)
    }
    fmt.Println(firmware)
    // UEFI

    err = smcInBand.PowerOff()
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BootTarget

type BootTarget int

BootTarget defines the way the server should boot

const (
	// BootTargetPXE the server boots via PXE
	BootTargetPXE BootTarget = iota + 1
	// BootTargetDisk the server boots from disk
	BootTargetDisk
	// BootTargetBIOS the server boots into Bios
	BootTargetBIOS
)

func (BootTarget) String

func (b BootTarget) String() string

type FirmwareMode

type FirmwareMode int

FirmwareMode the Firmware mode of the server, either Legacy, Dual or Uefi

const (
	// FirmwareModeUnknown server is in unknown firmware state
	FirmwareModeUnknown FirmwareMode = iota
	// FirmwareModeLegacy or BIOS
	FirmwareModeLegacy
	// FirmwareModeUEFI the server boots in uefi mode
	FirmwareModeUEFI
)

func (FirmwareMode) String

func (f FirmwareMode) String() string

type IdentifyLEDState

type IdentifyLEDState int

IdentifyLEDState the state of the LED to identify the server

const (
	// IdentifyLEDStateUnknown the LED is unknown
	IdentifyLEDStateUnknown IdentifyLEDState = iota
	// IdentifyLEDStateOn the LED is on
	IdentifyLEDStateOn
	// IdentifyLEDStateOff the LED is off
	IdentifyLEDStateOff
)

func (IdentifyLEDState) String

func (i IdentifyLEDState) String() string

type InBand

type InBand interface {
	// Board return board information of the current connection
	Board() *api.Board

	// UUID get the machine UUID
	// current usage in metal-hammer
	UUID() (*uuid.UUID, error)

	// PowerOff set power state of the server to off
	PowerOff() error
	// PowerReset reset the power state of the server
	PowerReset() error
	// PowerCycle cycle the power state of the server
	PowerCycle() error

	// IdentifyLEDState get the identify LED state
	IdentifyLEDState(IdentifyLEDState) error
	// IdentifyLEDOn set the identify LED to on
	IdentifyLEDOn() error
	// IdentifyLEDOff set the identify LED to off
	IdentifyLEDOff() error

	// BootFrom set the boot order of the server to the specified target
	BootFrom(BootTarget) error

	// Firmware get the FirmwareMode of the server
	Firmware() (FirmwareMode, error)
	// SetFirmware set the FirmwareMode of the server
	SetFirmware(FirmwareMode) error

	// Describe print a basic information about this connection
	Describe() string

	// BMCConnection returns a connection to the BMC
	BMCConnection() api.BMCConnection

	// ConfigureBIOS configures the BIOS regarding certain required options.
	// It returns whether the system needs to be rebooted afterwards
	ConfigureBIOS() (bool, error)

	// EnsureBootOrder ensures the boot order
	EnsureBootOrder(bootloaderID string) error
}

InBand get and set settings from the server via the inband interface.

type OutBand

type OutBand interface {
	// Board return board information of the current connection
	Board() *api.Board
	// UUID get the machine uuid
	// current usage in ipmi-catcher
	UUID() (*uuid.UUID, error)

	// PowerState returns the power state of the server
	PowerState() (PowerState, error)
	// PowerOff set power state of the server to off
	PowerOff() error
	// PowerOn set power state of the server to on
	PowerOn() error
	// PowerReset reset the power state of the server
	PowerReset() error
	// PowerCycle cycle the power state of the server
	PowerCycle() error

	// IdentifyLEDState get the identify LED state
	IdentifyLEDState(IdentifyLEDState) error
	// IdentifyLEDOn set the identify LED to on
	IdentifyLEDOn() error
	// IdentifyLEDOff set the identify LED to off
	IdentifyLEDOff() error

	// BootFrom set the boot order of the server to the specified target
	BootFrom(BootTarget) error

	// Describe print a basic information about this connection
	Describe() string

	IPMIConnection() (ip string, port int, user, password string)

	Console(ssh.Session) error

	UpdateBIOS(url string) error

	UpdateBMC(url string) error

	// Returns a connection to the BMC
	BMCConnection() api.OutBandBMCConnection
}

OutBand get and set settings from the server via the out of band interface.

type PowerState

type PowerState int

PowerState state of the power of a server

const (
	// PowerUnknownState the server power state is not known
	PowerUnknownState PowerState = iota
	// PowerOnState the server is powered on
	PowerOnState
	// PowerOffState the server is powered off
	PowerOffState
)

func GuessPowerState

func GuessPowerState(powerState string) PowerState

GuessPowerState try to figure out the power state of the server

func (PowerState) String

func (p PowerState) String() string

Stringer

Jump to

Keyboard shortcuts

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