host

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2025 License: BSD-2-Clause Imports: 17 Imported by: 4

Documentation

Overview

Package host exposes functionality to interact with the host mashine.

Package host exposes functionality to interact with the host mashine.

Index

Constants

View Source
const (
	HostConfigInitrdPath = "/etc/host_configuration.json"
	HostConfigEFIVarName = "STHostConfig-f401f2c1-b005-4be0-8cee-f2e5945bcbe7"
)

Sources used by ConfigAutodetect.

View Source
const (
	Null = "null"
)

Variables

View Source
var (
	ErrMissingIPAddrMode        = errors.New("field IP address mode must be set")
	ErrMissingBondName          = errors.New("bond name must be set")
	ErrInvalidBondMode          = errors.New("bond mode is unknown")
	ErrMissingNetworkInterfaces = errors.New("one or more network interfaces must be set")
	ErrEmptyNetworkInterfaces   = errors.New("network interfaces are set but empty")
	ErrMissingOSPkgPointer      = errors.New("missing OS package pointer")
	ErrMissingIPAddr            = errors.New("field IP address must not be empty when static IP mode is set")
	ErrMissingGateway           = errors.New("default gateway must not be empty when static IP mode is set")
)
View Source
var (
	ErrConfigNotFound = errors.New("no host configuration found")
)

Errors which may be raised and wrapped in this package.

Functions

func Recover

func Recover()

Recover reboots the system after a few seconds. If reboot fails, it will try rebooting forever.

Types

type BondingMode

type BondingMode int

BondingMode sets the mode for bonding.

const (
	BondingUnset BondingMode = iota
	BondingBalanceRR
	BondingActiveBackup
	BondingBalanceXOR
	BondingBroadcast
	Bonding8023AD
	BondingBalanceTLB
	BondingBalanceALB
	BondingUnknown
)

func StringToBondingMode

func StringToBondingMode(str string) BondingMode

func (BondingMode) MarshalJSON

func (b BondingMode) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (BondingMode) String

func (b BondingMode) String() string

String implements fmt.Stringer.

func (*BondingMode) UnmarshalJSON

func (b *BondingMode) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

type Config

type Config struct {
	IPAddrMode        *IPAddrMode          `json:"network_mode"`
	HostIP            *netlink.Addr        `json:"host_ip"`
	DefaultGateway    *net.IP              `json:"gateway"`
	DNSServer         *[]*net.IP           `json:"dns"`
	NetworkInterfaces *[]*NetworkInterface `json:"network_interfaces"`
	OSPkgPointer      *string              `json:"ospkg_pointer"`
	BondingMode       BondingMode          `json:"bonding_mode"`
	BondName          *string              `json:"bond_name"`
	Description       *string              `json:"description,omitempty"`
}

Config stores host specific configuration.

func ConfigAutodetect

func ConfigAutodetect(ctx context.Context) (Config, error)

ConfigAutodetect looks for a known host configuration name in following order: - inside the initramfs at HostConfigInitrdPath - at the efivar filesystem for HostConfigEFIVarName

On success, returns the Config. Returns ErrConfigNotFound if no host configuration is found.

func (Config) MarshalJSON

func (c Config) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*Config) UnmarshalJSON

func (c *Config) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

All fields of Config need to be present in JSON.

type IPAddrMode

type IPAddrMode int

IPAddrMode sets the method for network setup.

const (
	IPUnset IPAddrMode = iota
	IPStatic
	IPDynamic
)

func (IPAddrMode) MarshalJSON

func (i IPAddrMode) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (IPAddrMode) String

func (i IPAddrMode) String() string

String implements fmt.Stringer.

func (*IPAddrMode) UnmarshalJSON

func (i *IPAddrMode) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

type NetworkInterface added in v0.1.0

type NetworkInterface struct {
	InterfaceName *string           `json:"interface_name"`
	MACAddress    *net.HardwareAddr `json:"mac_address"`
}

func (NetworkInterface) MarshalJSON added in v0.1.0

func (n NetworkInterface) MarshalJSON() ([]byte, error)

func (*NetworkInterface) UnmarshalJSON added in v0.1.0

func (n *NetworkInterface) UnmarshalJSON(data []byte) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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