Documentation
¶
Overview ¶
Package host exposes functionality to interact with the host mashine.
Package host exposes functionality to interact with the host mashine.
Index ¶
Constants ¶
const ( HostConfigInitrdPath = "/etc/host_configuration.json" HostConfigEFIVarName = "STHostConfig-f401f2c1-b005-4be0-8cee-f2e5945bcbe7" )
Sources used by ConfigAutodetect.
const (
Null = "null"
)
Variables ¶
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") )
var (
ErrConfigNotFound = errors.New("no host configuration found")
)
Errors which may be raised and wrapped in this package.
Functions ¶
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) 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 ¶
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 ¶
MarshalJSON implements json.Marshaler.
func (*Config) UnmarshalJSON ¶
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) 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