metal

package
v0.28.4 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: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// VFAT is used for the UEFI boot partition
	VFAT = Format("vfat")
	// EXT3 is usually only used for /boot
	EXT3 = Format("ext3")
	// EXT4 is the default fs
	EXT4 = Format("ext4")
	// SWAP is for the swap partition
	SWAP = Format("swap")
	// TMPFS is used for a memory filesystem typically /tmp
	TMPFS = Format("tmpfs")
	// None
	NONE = Format("none")

	// GPTBoot EFI Boot Partition
	GPTBoot = GPTType("ef00")
	// GPTLinux Linux Partition
	GPTLinux = GPTType("8300")
	// GPTLinuxRaid Linux Raid Partition
	GPTLinuxRaid = GPTType("fd00")
	// GPTLinux Linux Partition
	GPTLinuxLVM = GPTType("8e00")

	// RaidLevel0 is a stripe of two or more disks
	RaidLevel0 = RaidLevel("0")
	// RaidLevel1 is a mirror of two disks
	RaidLevel1 = RaidLevel("1")

	// LVMTypeLinear append across all physical volumes
	LVMTypeLinear = LVMType("linear")
	// LVMTypeStriped stripe across all physical volumes
	LVMTypeStriped = LVMType("striped")
	// LVMTypeStripe mirror with raid across all physical volumes
	LVMTypeRaid1 = LVMType("raid1")
)
View Source
const (
	// TagIPSeperator is the seperator character for key and values in IP-Tags
	TagIPSeperator = "="

	// Ephemeral IPs will be cleaned up automatically on machine, network, project deletion
	Ephemeral IPType = "ephemeral"
	// Static IPs will not be cleaned up and can be re-used for machines, networks within a project
	Static IPType = "static"

	// ScopeEmpty IPs are not bound to a project, machine or cluster
	ScopeEmpty IPScope = ""
	// ScopeProject IPs can be assigned to machines or used by cluster services
	ScopeProject IPScope = "project"
	// ScopeMachine IPs are bound to the usage directly at machines
	ScopeMachine IPScope = "machine"
)

Variables

View Source
var (
	SupportedFormats    = map[Format]bool{VFAT: true, EXT3: true, EXT4: true, SWAP: true, TMPFS: true, NONE: true}
	SupportedGPTTypes   = map[GPTType]bool{GPTBoot: true, GPTLinux: true, GPTLinuxLVM: true, GPTLinuxRaid: true}
	SupportedRaidLevels = map[RaidLevel]bool{RaidLevel0: true, RaidLevel1: true}
	SupportedLVMTypes   = map[LVMType]bool{LVMTypeLinear: true, LVMTypeStriped: true, LVMTypeRaid1: true}
)
View Source
var (
	// AllStates contains all possible values of a machine state
	AllStates = []MState{AvailableState, ReservedState, LockedState}
	// AllRoles contains all possible values of a role
	AllRoles = map[Role]bool{
		RoleMachine:  true,
		RoleFirewall: true,
	}
)
View Source
var (
	PrivatePrimaryUnshared = NetworkType{
		Name:           mn.PrivatePrimaryUnshared,
		Private:        true,
		PrivatePrimary: true,
		Shared:         false,
		Underlay:       false,
		Supported:      true,
	}
	PrivatePrimaryShared = NetworkType{
		Name:           mn.PrivatePrimaryShared,
		Private:        true,
		PrivatePrimary: true,
		Shared:         true,
		Underlay:       false,
		Supported:      true,
	}
	PrivateSecondaryShared = NetworkType{
		Name:           mn.PrivateSecondaryShared,
		Private:        true,
		PrivatePrimary: false,
		Shared:         true,
		Underlay:       false,
		Supported:      true,
	}
	// PrivateSecondaryUnshared this case is not a valid configuration
	PrivateSecondaryUnshared = NetworkType{
		Name:           mn.PrivateSecondaryUnshared,
		Private:        true,
		PrivatePrimary: false,
		Shared:         false,
		Underlay:       false,
		Supported:      false,
	}
	External = NetworkType{
		Name:           mn.External,
		Private:        false,
		PrivatePrimary: false,
		Shared:         false,
		Underlay:       false,
		Supported:      true,
	}
	Underlay = NetworkType{
		Name:           mn.Underlay,
		Private:        false,
		PrivatePrimary: false,
		Shared:         false,
		Underlay:       true,
		Supported:      true,
	}
	AllNetworkTypes = []NetworkType{PrivatePrimaryUnshared, PrivatePrimaryShared, PrivateSecondaryShared, PrivateSecondaryUnshared, External, Underlay}
)
View Source
var (
	// View Groupname
	ViewGroups = []security.ResourceAccess{
		security.ResourceAccess("k8s_kaas-view"),
		security.ResourceAccess("maas-all-all-view"),
	}

	// Edit Groupname
	EditGroups = []security.ResourceAccess{
		security.ResourceAccess("k8s_kaas-edit"),
		security.ResourceAccess("maas-all-all-edit"),
	}

	// Admin Groupname
	AdminGroups = []security.ResourceAccess{
		security.ResourceAccess("k8s_kaas-admin"),
		security.ResourceAccess("maas-all-all-admin"),
	}

	// Groups that have view permission
	ViewAccess = sec.MergeResourceAccess(ViewGroups, EditGroups, AdminGroups)
	// Groups that have edit permission
	EditAccess = sec.MergeResourceAccess(EditGroups, AdminGroups)
	// Groups that have admin permission
	AdminAccess = AdminGroups
)

These are our supported groups.

View Source
var (
	TopicMachine    = NSQTopic{Name: "machine", PartitionAgnostic: true}
	TopicAllocation = NSQTopic{Name: "allocation", PartitionAgnostic: false}
)
View Source
var DefaultImageExpiration = time.Hour * 24 * 90

DefaultImageExpiration if not specified images will last for about 3 month

View Source
var FirmwareKinds = []string{
	FirmwareBIOS,
	FirmwareBMC,
}

Topics is a list of topics of which the metal-api is a producer. metal-api will make sure these topics exist when it is started.

Functions

func Conflict

func Conflict(format string, args ...interface{}) error

Conflict creates a new conflict error with a given error message.

func Internal

func Internal(format string, args ...interface{}) error

Internal creates a new Internal error with a given error message and the original error.

func IpTag

func IpTag(key, value string) string

func IsConflict

func IsConflict(e error) bool

IsConflict checks if an error is a conflict error.

func IsInternal

func IsInternal(e error) bool

IsInternal checks if an error is a Internal error.

func IsNotFound

func IsNotFound(e error) bool

IsNotFound checks if an error is a notfound error.

func NotFound

func NotFound(format string, args ...interface{}) error

NotFound creates a new notfound error with a given error message.

Types

type AllocationEvent added in v0.8.1

type AllocationEvent struct {
	MachineID string `json:"old,omitempty"`
}

AllocationEvent is propagated when a machine is allocated.

type BIOS

type BIOS struct {
	Version string `rethinkdb:"version" json:"version"`
	Vendor  string `rethinkdb:"vendor" json:"vendor"`
	Date    string `rethinkdb:"date" json:"date"`
}

BIOS contains machine bios information

type Base

type Base struct {
	ID          string    `rethinkdb:"id,omitempty" json:"id,omitempty"`
	Name        string    `rethinkdb:"name" json:"name"`
	Description string    `rethinkdb:"description" json:"description"`
	Created     time.Time `rethinkdb:"created" json:"created"`
	Changed     time.Time `rethinkdb:"changed" json:"changed"`
}

Base implements common fields for most basic entity types (not all).

func (*Base) GetChanged

func (b *Base) GetChanged() time.Time

GetChanged returns the last changed timestamp of the entity

func (*Base) GetCreated

func (b *Base) GetCreated() time.Time

GetCreated returns the creation timestamp of the entity

func (*Base) GetID

func (b *Base) GetID() string

GetID returns the ID of the entity

func (*Base) SetChanged

func (b *Base) SetChanged(changed time.Time)

SetChanged sets the last changed timestamp of the entity

func (*Base) SetCreated

func (b *Base) SetCreated(created time.Time)

SetCreated sets the creation timestamp of the entity

func (*Base) SetID

func (b *Base) SetID(id string)

SetID sets the ID of the entity

type BlockDevice

type BlockDevice struct {
	Name string `rethinkdb:"name" json:"name"`
	Size uint64 `rethinkdb:"size" json:"size"`
}

BlockDevice information.

type BootConfiguration

type BootConfiguration struct {
	ImageURL    string `rethinkdb:"imageurl" json:"imageurl"`
	KernelURL   string `rethinkdb:"kernelurl" json:"kernelurl"`
	CommandLine string `rethinkdb:"commandline" json:"commandline"`
}

BootConfiguration defines the metal-hammer initrd, kernel and commandline

type ChassisIdentifyLEDState

type ChassisIdentifyLEDState struct {
	Value       LEDState `rethinkdb:"value" json:"value"`
	Description string   `rethinkdb:"description" json:"description"`
}

A ChassisIdentifyLEDState describes the state of a chassis identify LED, i.e. LED-ON/LED-OFF.

type Connection

type Connection struct {
	Nic       Nic    `rethinkdb:"nic" json:"nic"`
	MachineID string `rethinkdb:"machineid" json:"machineid"`
}

Connection between switch port and machine.

type ConnectionMap

type ConnectionMap map[string]Connections

ConnectionMap is an indexed map of connection-lists

func (ConnectionMap) ByNicName added in v0.8.0

func (c ConnectionMap) ByNicName() (map[string]Connection, error)

ByNicName builds a map of nic names to machine connection

type Connections

type Connections []Connection

Connections is a list of connections.

type Constraint

type Constraint struct {
	Type ConstraintType `rethinkdb:"type" json:"type"`
	Min  uint64         `rethinkdb:"min" json:"min"`
	Max  uint64         `rethinkdb:"max" json:"max"`
}

A Constraint describes the hardware constraints for a given size. At the moment we only consider the cpu cores and the memory.

func (*Constraint) Matches

Matches returns true if the given machine hardware is inside the min/max values of the constraint.

type ConstraintMatchingLog

type ConstraintMatchingLog struct {
	Constraint Constraint
	Match      bool
	Log        string
}

A ConstraintMatchingLog is used do return a log message to the caller beside the contraint itself.

type ConstraintType

type ConstraintType string

ConstraintType ...

const (
	CoreConstraint    ConstraintType = "cores"
	MemoryConstraint  ConstraintType = "memory"
	StorageConstraint ConstraintType = "storage"
)

come constraint types

type Disk added in v0.15.0

type Disk struct {
	// Device is the full device path
	Device string `rethinkdb:"device" json:"device"`
	// Partitions to create on this device
	Partitions []DiskPartition `rethinkdb:"partitions" json:"partitions"`
	// WipeOnReinstall, if set to true the whole disk will be erased if reinstall happens
	// during fresh install all disks are wiped
	WipeOnReinstall bool `rethinkdb:"wipeonreinstall" json:"wipeonreinstall"`
}

Disk represents a single block device visible from the OS, required

type DiskPartition added in v0.6.0

type DiskPartition struct {
	// Number of this partition, will be added to partitionprefix
	Number uint8 `rethinkdb:"number" json:"number"`
	// Label to enhance readability
	Label *string `rethinkdb:"label" json:"label"`
	// Size of this partition in mebibytes (MiB)
	// if "0" is given the rest of the device will be used, this requires Number to be the highest in this partition
	Size uint64 `rethinkdb:"size" json:"size"`
	// GPTType defines the GPT partition type
	GPTType *GPTType `rethinkdb:"gpttype" json:"gpttype"`
}

DiskPartition is a single partition on a device, only GPT partition types are supported

type EgressRule added in v0.27.0

type EgressRule struct {
	Protocol Protocol `rethinkdb:"protocol" json:"protocol"`
	Ports    []int    `rethinkdb:"ports" json:"ports"`
	To       []string `rethinkdb:"to" json:"to"`
	Comment  string   `rethinkdb:"comment" json:"comment"`
}

func (EgressRule) Validate added in v0.27.0

func (r EgressRule) Validate() error

type Entity

type Entity interface {
	// GetID returns the entity's id
	GetID() string
	// SetID sets the entity's id
	SetID(id string)
	// GetChanged returns the entity's changed time
	GetChanged() time.Time
	// SetChanged sets the entity's changed time
	SetChanged(changed time.Time)
	// GetCreated sets the entity's creation time
	GetCreated() time.Time
	// SetCreated sets the entity's creation time
	SetCreated(created time.Time)
}

Entity is an interface that allows metal entities to be created and stored into the database with the generic creation and update functions.

type EventType

type EventType string

EventType is the type for event types.

const (
	CREATE  EventType = "create"
	UPDATE  EventType = "update"
	DELETE  EventType = "delete"
	COMMAND EventType = "command"
)

Some enums.

type Filesystem added in v0.15.0

type Filesystem struct {
	// Path defines the mountpoint, if nil, it will not be mounted
	Path *string `rethinkdb:"path" json:"path"`
	// Device where the filesystem is created on, must be the full device path seen by the OS
	Device string `rethinkdb:"device" json:"device"`
	// Format is the type of filesystem should be created
	Format Format `rethinkdb:"format" json:"format"`
	// Label is optional enhances readability
	Label *string `rethinkdb:"label" json:"label"`
	// MountOptions which might be required
	MountOptions []string `rethinkdb:"mountoptions" json:"mountoptions"`
	// CreateOptions during filesystem creation
	CreateOptions []string `rethinkdb:"createoptions" json:"createoptions"`
}

Filesystem defines a single filesystem to be mounted

type FilesystemLayout added in v0.15.0

type FilesystemLayout struct {
	Base
	// Filesystems to create on the server
	Filesystems []Filesystem `rethinkdb:"filesystems" json:"filesystem"`
	// Disks to configure in the server with their partitions
	Disks []Disk `rethinkdb:"disks" json:"disks"`
	// Raid if not empty, create raid arrays out of the individual disks, to place filesystems onto
	Raid []Raid `rethinkdb:"raid" json:"raid"`
	// VolumeGroups to create
	VolumeGroups []VolumeGroup `rethinkdb:"volumegroups" json:"volumegroups"`
	// LogicalVolumes to create on top of VolumeGroups
	LogicalVolumes LogicalVolumes `rethinkdb:"logicalvolumes" json:"logicalvolumes"`
	// Constraints which must match to select this Layout
	Constraints FilesystemLayoutConstraints `rethinkdb:"constraints" json:"constraints"`
}

FilesystemLayout to be created on the given machine

func (*FilesystemLayout) IsReinstallable added in v0.15.0

func (fl *FilesystemLayout) IsReinstallable() bool

IsReinstallable returns true if at least one disk configures has WipeOnReInstall set, otherwise false

func (*FilesystemLayout) Matches added in v0.15.0

func (fl *FilesystemLayout) Matches(hardware MachineHardware) error

Matches the specific FilesystemLayout against the selected Hardware

func (FilesystemLayout) Validate added in v0.15.0

func (f FilesystemLayout) Validate() error

Validate a existing FilesystemLayout

type FilesystemLayoutConstraints added in v0.15.0

type FilesystemLayoutConstraints struct {
	// Sizes defines the list of sizes this layout applies to
	Sizes []string `rethinkdb:"sizes" json:"sizes"`
	// Images defines a map from os to versionconstraint
	// the combination of os and versionconstraint per size must be conflict free over all filesystemlayouts
	Images map[string]string `rethinkdb:"images" json:"images"`
}

type FilesystemLayouts added in v0.15.0

type FilesystemLayouts []FilesystemLayout

FilesystemLayouts is a slice of FilesystemLayout

func (FilesystemLayouts) From added in v0.15.0

func (fls FilesystemLayouts) From(size, image string) (*FilesystemLayout, error)

From will pick a filesystemlayout from all filesystemlayouts which matches given size and image

func (FilesystemLayouts) Validate added in v0.15.0

func (fls FilesystemLayouts) Validate() error

Validate ensures that for all Filesystemlayouts not more than one constraint matches the same size and image constraint

type FirewallRules added in v0.27.0

type FirewallRules struct {
	Egress  []EgressRule  `rethinkdb:"egress" json:"egress"`
	Ingress []IngressRule `rethinkdb:"ingress" json:"ingress"`
}

type FirmwareKind added in v0.18.6

type FirmwareKind = string
const (
	FirmwareBIOS FirmwareKind = "bios"
	FirmwareBMC  FirmwareKind = "bmc"
)

type FirmwareUpdate added in v0.18.6

type FirmwareUpdate struct {
	Kind FirmwareKind `json:"kind"`
	URL  string       `json:"url"`
}

type Format added in v0.15.0

type Format string

func ToFormat added in v0.15.0

func ToFormat(format string) (*Format, error)

type Fru

type Fru struct {
	ChassisPartNumber   string `rethinkdb:"chassis_part_number" json:"chassis_part_number"`
	ChassisPartSerial   string `rethinkdb:"chassis_part_serial" json:"chassis_part_serial"`
	BoardMfg            string `rethinkdb:"board_mfg" json:"board_mfg"`
	BoardMfgSerial      string `rethinkdb:"board_mfg_serial" json:"board_mfg_serial"`
	BoardPartNumber     string `rethinkdb:"board_part_number" json:"board_part_number"`
	ProductManufacturer string `rethinkdb:"product_manufacturer" json:"product_manufacturer"`
	ProductPartNumber   string `rethinkdb:"product_part_number" json:"product_part_number"`
	ProductSerial       string `rethinkdb:"product_serial" json:"product_serial"`
}

Fru (Field Replaceable Unit) data

type GPTType added in v0.15.0

type GPTType string

func ToGPTType added in v0.15.0

func ToGPTType(gptType string) (*GPTType, error)

type IP

type IP struct {
	IPAddress string `rethinkdb:"id" json:"id"`
	// AllocationID will be randomly generated during IP creation and helps identifying the point in time
	// when an IP was created. This is not the primary key!
	// This field can help to distinguish whether an IP address was re-acquired or
	// if it is still the same ip address as before.
	AllocationUUID   string    `rethinkdb:"allocationuuid" json:"allocationuuid"`
	ParentPrefixCidr string    `rethinkdb:"prefix" json:"prefix"`
	Name             string    `rethinkdb:"name" json:"name"`
	Description      string    `rethinkdb:"description" json:"description"`
	ProjectID        string    `rethinkdb:"projectid" json:"projectid"`
	NetworkID        string    `rethinkdb:"networkid" json:"networkid"`
	Type             IPType    `rethinkdb:"type" json:"type"`
	Tags             []string  `rethinkdb:"tags" json:"tags"`
	Created          time.Time `rethinkdb:"created" json:"created"`
	Changed          time.Time `rethinkdb:"changed" json:"changed"`
}

IP of a machine/firewall.

func (*IP) AddMachineId

func (ip *IP) AddMachineId(id string)

func (*IP) GetChanged

func (ip *IP) GetChanged() time.Time

GetChanged returns the last changed timestamp of the entity

func (*IP) GetCreated

func (ip *IP) GetCreated() time.Time

GetCreated returns the creation timestamp of the entity

func (*IP) GetID

func (ip *IP) GetID() string

GetID returns the ID of the entity

func (*IP) GetMachineIds

func (ip *IP) GetMachineIds() []string

func (*IP) GetScope

func (ip *IP) GetScope() IPScope

GetScope determines the scope of an ip address

func (*IP) HasMachineId

func (ip *IP) HasMachineId(id string) bool

func (*IP) RemoveMachineId

func (ip *IP) RemoveMachineId(id string)

func (*IP) SetChanged

func (ip *IP) SetChanged(changed time.Time)

SetChanged sets the last changed timestamp of the entity

func (*IP) SetCreated

func (ip *IP) SetCreated(created time.Time)

SetCreated sets the creation timestamp of the entity

func (*IP) SetID

func (ip *IP) SetID(id string)

SetID sets the ID of the entity

type IPMI

type IPMI struct {
	// Address is host:port of the connection to the ipmi BMC, host can be either a ip address or a hostname
	Address     string       `rethinkdb:"address" json:"address"`
	MacAddress  string       `rethinkdb:"mac" json:"mac"`
	User        string       `rethinkdb:"user" json:"user"`
	Password    string       `rethinkdb:"password" json:"password"`
	Interface   string       `rethinkdb:"interface" json:"interface"`
	Fru         Fru          `rethinkdb:"fru" json:"fru"`
	BMCVersion  string       `rethinkdb:"bmcversion" json:"bmcversion"`
	PowerState  string       `rethinkdb:"powerstate" json:"powerstate"`
	PowerMetric *PowerMetric `rethinkdb:"powermetric" json:"powermetric"`
	LastUpdated time.Time    `rethinkdb:"last_updated" json:"last_updated"`
}

IPMI connection data

type IPScope

type IPScope string

IPScope is the scope of an ip.

type IPType

type IPType string

IPType is the type of an ip.

type IPs

type IPs []IP

func (IPs) ByProjectID

func (l IPs) ByProjectID() IPsMap

type IPsMap

type IPsMap map[string]IPs

type Image

type Image struct {
	Base
	URL      string                    `rethinkdb:"url" json:"url"`
	Features map[ImageFeatureType]bool `rethinkdb:"features" json:"features"`
	// OS is parsed from id and is the first part, specifies operating system derivate, internal usage only
	OS string `rethinkdb:"os" json:"os"`
	// Version is parsed from id and is the second part, specifies operating system version, internal usage only
	Version string `rethinkdb:"version" json:"version"`
	// ExpirationDate defines the time in the future, when this image is not considered for machine allocations anymore
	ExpirationDate time.Time `rethinkdb:"expirationDate" json:"expirationDate"`
	// Classification defines the state of a version (preview, supported, deprecated)
	// only informational, no action depending on the classification done
	Classification VersionClassification `rethinkdb:"classification" json:"classification"`
}

An Image describes an image which could be used for provisioning.

func (*Image) HasFeature

func (i *Image) HasFeature(feature ImageFeatureType) bool

HasFeature returns true if this image has given feature enabled, otherwise false.

func (*Image) ImageFeatureString

func (i *Image) ImageFeatureString() string

ImageFeatureString returns the features of an image as a string.

type ImageFeatureType

type ImageFeatureType string

ImageFeatureType specifies the features of a images

const (
	// ImageFeatureFirewall from this image only a firewall can created
	ImageFeatureFirewall ImageFeatureType = "firewall"
	// ImageFeatureMachine from this image only a machine can created
	ImageFeatureMachine ImageFeatureType = "machine"
)

func ImageFeatureTypeFrom

func ImageFeatureTypeFrom(name string) (ImageFeatureType, error)

ImageFeatureTypeFrom a given name to a ImageFeatureType or error.

type ImageMap

type ImageMap map[string]Image

ImageMap is an indexed map for images.

type Images

type Images []Image

Images is a collection of images.

func (Images) ByID

func (ii Images) ByID() ImageMap

ByID creates an indexed map from an image collection.

type IngressRule added in v0.27.0

type IngressRule struct {
	Protocol Protocol `rethinkdb:"protocol" json:"protocol"`
	Ports    []int    `rethinkdb:"ports" json:"ports"`
	To       []string `rethinkdb:"to" json:"to"`
	From     []string `rethinkdb:"from" json:"from"`
	Comment  string   `rethinkdb:"comment" json:"comment"`
}

func (IngressRule) Validate added in v0.27.0

func (r IngressRule) Validate() error

type LEDState

type LEDState string

LEDState is the state of the LED of the Machine

const (
	// LEDStateOn LED is on
	LEDStateOn LEDState = "LED-ON"
	// LEDStateOff LED is off
	LEDStateOff LEDState = "LED-OFF"
)

func LEDStateFrom

func LEDStateFrom(name string) (LEDState, error)

LEDStateFrom converts an LEDState string to the corresponding type

type LVMType added in v0.15.0

type LVMType string

func ToLVMType added in v0.15.0

func ToLVMType(lvmtype string) (*LVMType, error)

type LogicalVolume added in v0.15.0

type LogicalVolume struct {
	// Name the name of the logical volume, without /dev prefix, will be accessible at /dev/vgname/lvname
	Name string `rethinkdb:"name" json:"name"`
	// VolumeGroup the name of the volumegroup
	VolumeGroup string `rethinkdb:"volumegroup" json:"volumegroup"`
	// Size of this LV in mebibytes (MiB), if zero all remaining space in the vg will be used.
	Size uint64 `rethinkdb:"size" json:"size"`
	// LVMType can be either linear, striped or raid1
	LVMType LVMType `rethinkdb:"lvmtype" json:"lvmtype"`
}

LogicalVolume is a block devices created with lvm on top of a volumegroup

type LogicalVolumes added in v0.16.0

type LogicalVolumes []LogicalVolume

LogicalVolumes is a slice of LogicalVolume

type MState

type MState string

A MState is an enum which indicates the state of a machine

const (
	// AvailableState describes a machine state where a machine is available for an allocation
	AvailableState MState = ""
	// ReservedState describes a machine state where a machine is not being considered for random allocation
	ReservedState MState = "RESERVED"
	// LockedState describes a machine state where a machine cannot be deleted or allocated anymore
	LockedState MState = "LOCKED"
)

func MachineStateFrom

func MachineStateFrom(name string) (MState, error)

MachineStateFrom converts a machineState string to the type

type MacAddress

type MacAddress string

A MacAddress is the type for mac adresses. When using a custom type, we cannot use strings directly.

type Machine

type Machine struct {
	Base
	Allocation   *MachineAllocation      `rethinkdb:"allocation" json:"allocation"`
	PartitionID  string                  `rethinkdb:"partitionid" json:"partitionid"`
	SizeID       string                  `rethinkdb:"sizeid" json:"sizeid"`
	RackID       string                  `rethinkdb:"rackid" json:"rackid"`
	Waiting      bool                    `rethinkdb:"waiting" json:"waiting"`
	PreAllocated bool                    `rethinkdb:"preallocated" json:"preallocated"`
	Hardware     MachineHardware         `rethinkdb:"hardware" json:"hardware"`
	State        MachineState            `rethinkdb:"state" json:"state"`
	LEDState     ChassisIdentifyLEDState `rethinkdb:"ledstate" json:"ledstate"`
	Tags         []string                `rethinkdb:"tags" json:"tags"`
	IPMI         IPMI                    `rethinkdb:"ipmi" json:"ipmi"`
	BIOS         BIOS                    `rethinkdb:"bios" json:"bios"`
}

A Machine is a piece of metal which is under the control of our system. It registers itself and can be allocated or freed. If the machine is allocated, the substructure Allocation will be filled. Any unallocated (free) machine won't have such values.

func (*Machine) HasMAC

func (m *Machine) HasMAC(mac string) bool

HasMAC returns true if this machine has the given MAC.

func (*Machine) IsFirewall

func (m *Machine) IsFirewall() bool

IsFirewall returns true if this machine is a firewall machine.

type MachineAllocation

type MachineAllocation struct {
	Creator          string            `rethinkdb:"creator" json:"creator"`
	Created          time.Time         `rethinkdb:"created" json:"created"`
	Name             string            `rethinkdb:"name" json:"name"`
	Description      string            `rethinkdb:"description" json:"description"`
	Project          string            `rethinkdb:"project" json:"project"`
	ImageID          string            `rethinkdb:"imageid" json:"imageid"`
	FilesystemLayout *FilesystemLayout `rethinkdb:"filesystemlayout" json:"filesystemlayout"`
	MachineNetworks  []*MachineNetwork `rethinkdb:"networks" json:"networks"`
	Hostname         string            `rethinkdb:"hostname" json:"hostname"`
	SSHPubKeys       []string          `rethinkdb:"sshPubKeys" json:"sshPubKeys"`
	UserData         string            `rethinkdb:"userdata" json:"userdata"`
	ConsolePassword  string            `rethinkdb:"console_password" json:"console_password"`
	Succeeded        bool              `rethinkdb:"succeeded" json:"succeeded"`
	Reinstall        bool              `rethinkdb:"reinstall" json:"reinstall"`
	MachineSetup     *MachineSetup     `rethinkdb:"setup" json:"setup"`
	Role             Role              `rethinkdb:"role" json:"role"`
	VPN              *MachineVPN       `rethinkdb:"vpn" json:"vpn"`
	UUID             string            `rethinkdb:"uuid" json:"uuid"`
	FirewallRules    *FirewallRules    `rethinkdb:"firewall_rules" json:"firewall_rules"`
}

A MachineAllocation stores the data which are only present for allocated machines.

type MachineCommand

type MachineCommand string

A MachineCommand is an alias of a string

const (
	MachineOnCmd             MachineCommand = "ON"
	MachineOffCmd            MachineCommand = "OFF"
	MachineResetCmd          MachineCommand = "RESET"
	MachineCycleCmd          MachineCommand = "CYCLE"
	MachineBiosCmd           MachineCommand = "BIOS"
	MachineDiskCmd           MachineCommand = "DISK"
	MachinePxeCmd            MachineCommand = "PXE"
	MachineReinstallCmd      MachineCommand = "REINSTALL"
	ChassisIdentifyLEDOnCmd  MachineCommand = "LED-ON"
	ChassisIdentifyLEDOffCmd MachineCommand = "LED-OFF"
	UpdateFirmwareCmd        MachineCommand = "UPDATE-FIRMWARE"
)

our supported machines commands.

type MachineEvent

type MachineEvent struct {
	Type         EventType           `json:"type,omitempty"`
	OldMachineID string              `json:"old,omitempty"`
	NewMachineID string              `json:"new,omitempty"`
	Cmd          *MachineExecCommand `json:"cmd,omitempty"`
}

MachineEvent is propagated when a machine is create/updated/deleted.

type MachineExecCommand

type MachineExecCommand struct {
	TargetMachineID string          `json:"target,omitempty"`
	Command         MachineCommand  `json:"cmd,omitempty"`
	IPMI            *IPMI           `json:"ipmi,omitempty"`
	FirmwareUpdate  *FirmwareUpdate `json:"firmwareupdate,omitempty"`
}

A MachineExecCommand can be sent via a MachineEvent to execute the command against the specific machine. The specified command should be executed against the given target machine. The parameters is an optional array of strings which are implementation specific and dependent of the command.

type MachineHardware

type MachineHardware struct {
	Memory   uint64        `rethinkdb:"memory" json:"memory"`
	CPUCores int           `rethinkdb:"cpu_cores" json:"cpu_cores"`
	Nics     Nics          `rethinkdb:"network_interfaces" json:"network_interfaces"`
	Disks    []BlockDevice `rethinkdb:"block_devices" json:"block_devices"`
}

MachineHardware stores the data which is collected by our system on the hardware when it registers itself.

func (*MachineHardware) DiskCapacity

func (hw *MachineHardware) DiskCapacity() uint64

DiskCapacity calculates the capacity of all disks.

func (*MachineHardware) ReadableSpec

func (hw *MachineHardware) ReadableSpec() string

ReadableSpec returns a human readable string for the hardware.

type MachineIPMISuperUser added in v0.22.5

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

func DisabledIPMISuperUser added in v0.22.5

func DisabledIPMISuperUser() MachineIPMISuperUser

func NewIPMISuperUser added in v0.22.5

func NewIPMISuperUser(log *slog.Logger, path string) MachineIPMISuperUser

func (*MachineIPMISuperUser) IsEnabled added in v0.22.5

func (i *MachineIPMISuperUser) IsEnabled() bool

func (*MachineIPMISuperUser) Password added in v0.22.5

func (i *MachineIPMISuperUser) Password() string

func (*MachineIPMISuperUser) User added in v0.22.5

func (i *MachineIPMISuperUser) User() string

type MachineLiveliness

type MachineLiveliness string

MachineLiveliness indicates the liveliness of a machine

const (
	MachineLivelinessAlive   MachineLiveliness = "Alive"
	MachineLivelinessDead    MachineLiveliness = "Dead"
	MachineLivelinessUnknown MachineLiveliness = "Unknown"
	MachineDeadAfter         time.Duration     = 5 * time.Minute
	MachineResurrectAfter    time.Duration     = time.Hour
)

The enums for the machine liveliness states.

type MachineNetwork

type MachineNetwork struct {
	NetworkID           string   `rethinkdb:"networkid" json:"networkid"`
	Prefixes            []string `rethinkdb:"prefixes" json:"prefixes"`
	IPs                 []string `rethinkdb:"ips" json:"ips"`
	DestinationPrefixes []string `rethinkdb:"destinationprefixes" json:"destinationprefixes"`
	Vrf                 uint     `rethinkdb:"vrf" json:"vrf"`
	PrivatePrimary      bool     `rethinkdb:"privateprimary" json:"privateprimary"`
	Private             bool     `rethinkdb:"private" json:"private"`
	ASN                 uint32   `rethinkdb:"asn" json:"asn"`
	Nat                 bool     `rethinkdb:"nat" json:"nat"`
	Underlay            bool     `rethinkdb:"underlay" json:"underlay"`
	Shared              bool     `rethinkdb:"shared" json:"shared"`
}

MachineNetwork stores the Network details of the machine

func (*MachineNetwork) ContainsIP

func (n *MachineNetwork) ContainsIP(ip string) bool

ContainsIP checks whether the given ip is included in the networks prefixes

func (*MachineNetwork) Is added in v0.10.0

func (mn *MachineNetwork) Is(n NetworkType) bool

Is checks whether the machine network has the given type

func (*MachineNetwork) NetworkType added in v0.10.0

func (mn *MachineNetwork) NetworkType() (*NetworkType, error)

NetworkType determines the network type based on the flags stored in the db entity.

type MachineSetup added in v0.6.0

type MachineSetup struct {
	ImageID      string `rethinkdb:"imageid" json:"imageid"`
	PrimaryDisk  string `rethinkdb:"primarydisk" json:"primarydisk"`
	OSPartition  string `rethinkdb:"ospartition" json:"ospartition"`
	Initrd       string `rethinkdb:"initrd" json:"initrd"`
	Cmdline      string `rethinkdb:"cmdline" json:"cmdline"`
	Kernel       string `rethinkdb:"kernel" json:"kernel"`
	BootloaderID string `rethinkdb:"bootloaderid" json:"bootloaderid"`
}

A MachineSetup stores the data used for machine reinstallations.

type MachineState

type MachineState struct {
	Value              MState `rethinkdb:"value" json:"value"`
	Description        string `rethinkdb:"description" json:"description"`
	Issuer             string `rethinkdb:"issuer" json:"issuer,omitempty"`
	MetalHammerVersion string `rethinkdb:"metal_hammer_version" json:"metal_hammer_version"`
}

A MachineState describes the state of a machine. If the Value is AvailableState, the machine will be available for allocation. In all other cases the allocation must explicitly point to this machine.

type MachineVPN added in v0.20.0

type MachineVPN struct {
	ControlPlaneAddress string `rethinkdb:"address" json:"address"`
	AuthKey             string `rethinkdb:"auth_key" json:"auth_key"`
	Connected           bool   `rethinkdb:"connected" json:"connected"`
}

type Machines

type Machines []Machine

Machines is a slice of Machine

func (Machines) ByProjectID

func (ms Machines) ByProjectID() map[string]Machines

ByProjectID creates a map of machines with the project id as the index.

func (Machines) WithPartition added in v0.26.1

func (ms Machines) WithPartition(id string) Machines

func (Machines) WithSize added in v0.26.0

func (ms Machines) WithSize(id string) Machines

type NSQTopic

type NSQTopic struct {
	Name              string
	PartitionAgnostic bool
}

NSQTopic .

func (NSQTopic) GetFQN

func (t NSQTopic) GetFQN(partitionID string) string

GetFQN gets the fully qualified name of a NSQTopic

type Network

type Network struct {
	Base
	Prefixes            Prefixes          `rethinkdb:"prefixes" json:"prefixes"`
	DestinationPrefixes Prefixes          `rethinkdb:"destinationprefixes" json:"destinationprefixes"`
	PartitionID         string            `rethinkdb:"partitionid" json:"partitionid"`
	ProjectID           string            `rethinkdb:"projectid" json:"projectid"`
	ParentNetworkID     string            `rethinkdb:"parentnetworkid" json:"parentnetworkid"`
	Vrf                 uint              `rethinkdb:"vrf" json:"vrf"`
	PrivateSuper        bool              `rethinkdb:"privatesuper" json:"privatesuper"`
	Nat                 bool              `rethinkdb:"nat" json:"nat"`
	Underlay            bool              `rethinkdb:"underlay" json:"underlay"`
	Shared              bool              `rethinkdb:"shared" json:"shared"`
	Labels              map[string]string `rethinkdb:"labels" json:"labels"`
}

Network is a network in a metal as a service infrastructure. TODO specify rethinkdb restrictions.

func (*Network) FindPrefix

func (n *Network) FindPrefix(cidr string) *Prefix

FindPrefix returns the prefix by cidr if contained in this network, nil otherwise

func (*Network) SubstractPrefixes

func (n *Network) SubstractPrefixes(prefixes ...Prefix) []Prefix

SubstractPrefixes returns the prefixes of the network minus the prefixes passed in the arguments

type NetworkMap

type NetworkMap map[string]Network

NetworkMap is an indexed map of networks

type NetworkType added in v0.10.0

type NetworkType struct {
	Name           string `json:"name,omitempty"`
	Private        bool   `json:"private,omitempty"`
	PrivatePrimary bool   `json:"private_primary,omitempty"`
	Shared         bool   `json:"shared,omitempty"`
	Underlay       bool   `json:"underlay,omitempty"`
	Supported      bool   `json:"-"`
}

NetworkType represents the type of a network

func (NetworkType) String added in v0.10.0

func (n NetworkType) String() string

type NetworkUsage

type NetworkUsage struct {
	AvailableIPs      uint64 `json:"available_ips" description:"the total available IPs" readonly:"true"`
	UsedIPs           uint64 `json:"used_ips" description:"the total used IPs" readonly:"true"`
	AvailablePrefixes uint64 `json:"available_prefixes" description:"the total available Prefixes" readonly:"true"`
	UsedPrefixes      uint64 `json:"used_prefixes" description:"the total used Prefixes" readonly:"true"`
}

NetworkUsage contains usage information of a network

type Networks

type Networks []Network

Networks is a list of networks.

func (Networks) ByID

func (nws Networks) ByID() NetworkMap

ByID creates an indexed map of partitions whre the id is the index.

type Nic

type Nic struct {
	MacAddress MacAddress `rethinkdb:"macAddress" json:"macAddress"`
	Name       string     `rethinkdb:"name" json:"name"`
	Identifier string     `rethinkdb:"identifier" json:"identifier"`
	Vrf        string     `rethinkdb:"vrf" json:"vrf"`
	Neighbors  Nics       `rethinkdb:"neighbors" json:"neighbors"`
	Hostname   string     `rethinkdb:"hostname" json:"hostname"`
}

Nic information.

func (*Nic) GetIdentifier added in v0.22.2

func (n *Nic) GetIdentifier() string

GetIdentifier returns the identifier of a nic. It returns the mac address as a fallback if no identifier was found. (this is for backwards compatibility with old metal-core and metal-hammer versions)

type Nics

type Nics []Nic

Nics is a list of nics.

func (Nics) ByIdentifier added in v0.22.2

func (nics Nics) ByIdentifier() map[string]*Nic

ByIdentifier creates a map (nic identifier --> nic) from a nic list.

func (Nics) ByName added in v0.8.0

func (nics Nics) ByName() map[string]*Nic

ByName creates a map (nic names --> nic) from a nic list.

func (Nics) FilterByHostname added in v0.22.2

func (nics Nics) FilterByHostname(hostname string) (res Nics)

type Partition

type Partition struct {
	Base
	BootConfiguration          BootConfiguration `rethinkdb:"bootconfig" json:"bootconfig"`
	MgmtServiceAddress         string            `rethinkdb:"mgmtserviceaddr" json:"mgmtserviceaddr"`
	PrivateNetworkPrefixLength uint8             `rethinkdb:"privatenetworkprefixlength" json:"privatenetworkprefixlength"`
	Labels                     map[string]string `rethinkdb:"labels" json:"labels"`
}

A Partition represents a location.

type PartitionMap

type PartitionMap map[string]Partition

PartitionMap is an indexed map of partitions

type Partitions

type Partitions []Partition

Partitions is a list of partitions.

func (Partitions) ByID

func (sz Partitions) ByID() PartitionMap

ByID creates an indexed map of partitions whre the id is the index.

type PowerMetric added in v0.21.5

type PowerMetric struct {
	// AverageConsumedWatts shall represent the
	// average power level that occurred averaged over the last IntervalInMin
	// minutes.
	AverageConsumedWatts float32 `rethinkdb:"averageconsumedwatts" json:"averageconsumedwatts"`
	// IntervalInMin shall represent the time
	// interval (or window), in minutes, in which the PowerMetrics properties
	// are measured over.
	// Should be an integer, but some Dell implementations return as a float.
	IntervalInMin float32 `rethinkdb:"intervalinmin" json:"intervalinmin"`
	// MaxConsumedWatts shall represent the
	// maximum power level in watts that occurred within the last
	// IntervalInMin minutes.
	MaxConsumedWatts float32 `rethinkdb:"maxconsumedwatts" json:"maxconsumedwatts"`
	// MinConsumedWatts shall represent the
	// minimum power level in watts that occurred within the last
	// IntervalInMin minutes.
	MinConsumedWatts float32 `rethinkdb:"minconsumedwatts" json:"minconsumedwatts"`
}

type Prefix

type Prefix struct {
	IP     string `rethinkdb:"ip" json:"ip"`
	Length string `rethinkdb:"length" json:"length"`
}

Prefix is a ip with mask, either ipv4/ipv6

func NewPrefixFromCIDR

func NewPrefixFromCIDR(cidr string) (*Prefix, error)

NewPrefixFromCIDR returns a new prefix from a given cidr.

func (*Prefix) Equals

func (p *Prefix) Equals(other *Prefix) bool

Equals returns true when prefixes have the same cidr.

func (*Prefix) String

func (p *Prefix) String() string

String implements the Stringer interface

type Prefixes

type Prefixes []Prefix

Prefixes is an array of prefixes

func (Prefixes) String

func (p Prefixes) String() []string

type Protocol added in v0.27.0

type Protocol string
const (
	ProtocolTCP Protocol = "TCP"
	ProtocolUDP Protocol = "UDP"
)

func ProtocolFromString added in v0.27.0

func ProtocolFromString(s string) (Protocol, error)

type ProvisioningEvent

type ProvisioningEvent struct {
	Time    time.Time             `rethinkdb:"time" json:"time"`
	Event   ProvisioningEventType `rethinkdb:"event" json:"event"`
	Message string                `rethinkdb:"message" json:"message"`
}

ProvisioningEvent is an event emitted by a machine during the provisioning sequence

type ProvisioningEventContainer

type ProvisioningEventContainer struct {
	Base
	Liveliness           MachineLiveliness  `rethinkdb:"liveliness" json:"liveliness"`
	Events               ProvisioningEvents `rethinkdb:"events" json:"events"`
	LastEventTime        *time.Time         `rethinkdb:"last_event_time" json:"last_event_time"`
	LastErrorEvent       *ProvisioningEvent `rethinkdb:"last_error_event" json:"last_error_event"`
	CrashLoop            bool               `rethinkdb:"crash_loop" json:"crash_loop"`
	FailedMachineReclaim bool               `rethinkdb:"failed_machine_reclaim" json:"failed_machine_reclaim"`
}

ProvisioningEventContainer stores the provisioning events of a machine

func (*ProvisioningEventContainer) TrimEvents

func (p *ProvisioningEventContainer) TrimEvents(maxCount int)

TrimEvents trim the events to maxCount

func (*ProvisioningEventContainer) Validate added in v0.19.0

func (c *ProvisioningEventContainer) Validate() error

type ProvisioningEventContainerMap

type ProvisioningEventContainerMap map[string]ProvisioningEventContainer

ProvisioningEventContainerMap is an indexed map of machine event containers.

type ProvisioningEventContainers

type ProvisioningEventContainers []ProvisioningEventContainer

ProvisioningEventContainers is a list of machine provisioning event containers.

func (ProvisioningEventContainers) ByID

ByID creates a map of event provisioning containers with the id as the index.

type ProvisioningEventType

type ProvisioningEventType string

ProvisioningEventType indicates an event emitted by a machine during the provisioning sequence

const (
	ProvisioningEventAlive            ProvisioningEventType = "Alive"
	ProvisioningEventCrashed          ProvisioningEventType = "Crashed"
	ProvisioningEventPXEBooting       ProvisioningEventType = "PXE Booting"
	ProvisioningEventPlannedReboot    ProvisioningEventType = "Planned Reboot"
	ProvisioningEventPreparing        ProvisioningEventType = "Preparing"
	ProvisioningEventRegistering      ProvisioningEventType = "Registering"
	ProvisioningEventWaiting          ProvisioningEventType = "Waiting"
	ProvisioningEventInstalling       ProvisioningEventType = "Installing"
	ProvisioningEventBootingNewKernel ProvisioningEventType = "Booting New Kernel"
	ProvisioningEventPhonedHome       ProvisioningEventType = "Phoned Home"
	ProvisioningEventMachineReclaim   ProvisioningEventType = "Machine Reclaim"
)

The enums for the machine provisioning events.

func (ProvisioningEventType) String added in v0.19.0

func (t ProvisioningEventType) String() string

type ProvisioningEvents

type ProvisioningEvents []ProvisioningEvent

ProvisioningEvents is just a list of ProvisioningEvents

type Raid added in v0.15.0

type Raid struct {
	// ArrayName of the raid device, most often this will be /dev/md0 and so forth
	ArrayName string `rethinkdb:"arrayname" json:"arrayname"`
	// Devices the devices to form a raid device
	Devices []string `rethinkdb:"devices" json:"devices"`
	// Level the raidlevel to use, can be one of 0,1
	Level RaidLevel `rethinkdb:"raidlevel" json:"raidlevel"`
	// CreateOptions required during raid creation, example: --metadata=1.0 for uefi boot partition
	CreateOptions []string `rethinkdb:"createoptions" json:"createoptions"`
	// Spares defaults to 0
	Spares int `rethinkdb:"spares" json:"spares"`
}

Raid is optional, if given the devices must match.

type RaidLevel added in v0.15.0

type RaidLevel string

func ToRaidLevel added in v0.15.0

func ToRaidLevel(level string) (*RaidLevel, error)

type Reservation added in v0.26.0

type Reservation struct {
	Amount       int      `rethinkdb:"amount" json:"amount"`
	Description  string   `rethinkdb:"description" json:"description"`
	ProjectID    string   `rethinkdb:"projectid" json:"projectid"`
	PartitionIDs []string `rethinkdb:"partitionids" json:"partitionids"`
}

Reservation defines a reservation of a size for machine allocations

type Reservations added in v0.26.0

type Reservations []Reservation

func (*Reservations) ForPartition added in v0.26.0

func (rs *Reservations) ForPartition(partitionID string) Reservations

func (*Reservations) ForProject added in v0.26.0

func (rs *Reservations) ForProject(projectID string) Reservations

func (*Reservations) Validate added in v0.26.0

func (rs *Reservations) Validate(partitions PartitionMap, projects map[string]*mdmv1.Project) error

type Role added in v0.15.4

type Role string

Role describes the role of a machine.

var (
	// RoleMachine is a role that indicates the allocated machine acts as a machine
	RoleMachine Role = "machine"
	// RoleFirewall is a role that indicates the allocated machine acts as a firewall
	RoleFirewall Role = "firewall"
)

type Size

type Size struct {
	Base
	Constraints  []Constraint      `rethinkdb:"constraints" json:"constraints"`
	Reservations Reservations      `rethinkdb:"reservations" json:"reservations"`
	Labels       map[string]string `rethinkdb:"labels" json:"labels"`
}

A Size represents a supported machine size.

func UnknownSize

func UnknownSize() *Size

UnknownSize is the size to use, when someone requires a size we do not know.

func (*Size) Overlaps added in v0.11.4

func (s *Size) Overlaps(ss *Sizes) *Size

Overlaps returns nil if Size does not overlap with any other size, otherwise returns overlapping Size

func (*Size) Validate added in v0.26.0

func (s *Size) Validate(partitions PartitionMap, projects map[string]*mdmv1.Project) error

Validate a size, returns error if a invalid size is passed

type SizeImageConstraint added in v0.16.3

type SizeImageConstraint struct {
	Base
	// Images a map from imageID to semver compatible matcher string
	// example:
	// images:
	//    ubuntu: ">= 20.04.20211011"
	//    debian: ">= 10.0.20210101"
	Images map[string]string `rethinkdb:"images" json:"images"`
}

SizeImageConstraint expresses optional restrictions for specific size to image combinations this might be required if the support for a specific hardware in a given size is only supported with a newer version of the image.

If the size in question is not found, no restrictions apply. If the image in question is not found, no restrictions apply as well. If the image in question is found, but does not match the given expression, machine creation must be forbidden.

func (*SizeImageConstraint) Matches added in v0.16.3

func (sc *SizeImageConstraint) Matches(size Size, image Image) error

func (*SizeImageConstraint) Validate added in v0.16.3

func (sc *SizeImageConstraint) Validate() error

type SizeImageConstraints added in v0.16.3

type SizeImageConstraints []SizeImageConstraint

SizeImageConstraints is a slice of ImageConstraint

func (*SizeImageConstraints) Matches added in v0.16.3

func (scs *SizeImageConstraints) Matches(size Size, image Image) error

func (*SizeImageConstraints) Validate added in v0.16.3

func (scs *SizeImageConstraints) Validate() error

type SizeMap

type SizeMap map[string]Size

SizeMap is an indexed map of sizes.

type SizeMatchingLog

type SizeMatchingLog struct {
	Name        string
	Log         string
	Match       bool
	Constraints []ConstraintMatchingLog
}

A SizeMatchingLog returns information about a list of constraints.

type Sizes

type Sizes []Size

Sizes is a list of sizes.

func (Sizes) ByID

func (sz Sizes) ByID() SizeMap

ByID creates a map of sizes with the id as the index.

func (Sizes) FromHardware

func (sz Sizes) FromHardware(hardware MachineHardware) (*Size, []*SizeMatchingLog, error)

FromHardware searches a Size for given hardware specs. It will search for a size where the constraints matches the given hardware.

type Switch

type Switch struct {
	Base
	Nics               Nics          `rethinkdb:"network_interfaces" json:"network_interfaces"`
	MachineConnections ConnectionMap `rethinkdb:"machineconnections" json:"machineconnections"`
	PartitionID        string        `rethinkdb:"partitionid" json:"partitionid"`
	RackID             string        `rethinkdb:"rackid" json:"rackid"`
	Mode               SwitchMode    `rethinkdb:"mode" json:"mode"`
	OS                 *SwitchOS     `rethinkdb:"os" json:"os"`
	ManagementIP       string        `rethinkdb:"management_ip" json:"management_ip"`
	ManagementUser     string        `rethinkdb:"management_user" json:"management_user"`
	ConsoleCommand     string        `rethinkdb:"console_command" json:"console_command"`
}

Switch have to register at the api. As metal-core is a stateless application running on a switch, the api needs persist all the information such that the core can create or restore a its entire switch configuration.

func (*Switch) ConnectMachine

func (s *Switch) ConnectMachine(machine *Machine) int

ConnectMachine iterates over all switch nics and machine nic neighbor to find existing wire connections. Implementation is very inefficient, will also find all connections, which should not happen in a real environment.

func (*Switch) SetVrfOfMachine added in v0.18.0

func (s *Switch) SetVrfOfMachine(m *Machine, vrf string)

SetVrfOfMachine set port on switch where machine is connected to given vrf

type SwitchEvent

type SwitchEvent struct {
	Type     EventType `json:"type"`
	Machine  Machine   `json:"machine"`
	Switches []Switch  `json:"switches"`
}

SwitchEvent is propagated when a switch needs to update its configuration.

type SwitchMode added in v0.8.0

type SwitchMode string

A SwitchMode is an enum which indicates the mode of a switch

const (
	SwitchOperational SwitchMode = "operational"
	SwitchReplace     SwitchMode = "replace"
)

The enums for the switch modes.

func SwitchModeFrom added in v0.8.0

func SwitchModeFrom(name string) SwitchMode

SwitchModeFrom converts a switch mode string to the type

type SwitchOS added in v0.22.1

type SwitchOS struct {
	Vendor           string `rethinkdb:"vendor" json:"vendor"`
	Version          string `rethinkdb:"version" json:"version"`
	MetalCoreVersion string `rethinkdb:"metal_core_version" json:"metal_core_version"`
}

type SwitchStatus added in v0.22.8

type SwitchStatus struct {
	Base
	LastSync      *SwitchSync `rethinkdb:"last_sync" json:"last_sync" description:"last successful synchronization to the switch" optional:"true"`
	LastSyncError *SwitchSync `` /* 134-byte string literal not displayed */
}

SwitchStatus stores the received switch notifications in a separate table

type SwitchSync added in v0.7.1

type SwitchSync struct {
	Time     time.Time     `rethinkdb:"time" json:"time"`
	Duration time.Duration `rethinkdb:"duration" json:"duration"`
	Error    *string       `rethinkdb:"error" json:"error"`
}

SwitchSync contains information about the last synchronization of the state held in the metal-api to a switch.

type Switches added in v0.22.1

type Switches []Switch

type VersionClassification added in v0.7.0

type VersionClassification string

VersionClassification is the logical state of a version

const (
	// ClassificationPreview indicates that a version has recently been added and not promoted to "Supported" yet.
	// ClassificationPreview versions will not be considered for automatic OperatingSystem patch version updates.
	ClassificationPreview VersionClassification = "preview"
	// ClassificationSupported indicates that a patch version is the default version for the particular minor version.
	// There is always exactly one supported OperatingSystem patch version for every still maintained OperatingSystem minor version.
	// Supported versions are eligible for the automated OperatingSystem patch version update machines.
	ClassificationSupported VersionClassification = "supported"
	// ClassificationDeprecated indicates that a patch version should not be used anymore, should be updated to a new version
	// and will eventually expire.
	// Every version that is neither in preview nor supported is deprecated.
	// All patch versions of not supported minor versions are deprecated.
	ClassificationDeprecated VersionClassification = "deprecated"
)

func VersionClassificationFrom added in v0.7.0

func VersionClassificationFrom(classification string) (VersionClassification, error)

VersionClassificationFrom create a VersionClassification from string

type VolumeGroup added in v0.15.0

type VolumeGroup struct {
	// Name of the volumegroup without the /dev prefix
	Name string `rethinkdb:"name" json:"name"`
	// Devices the devices to form a volumegroup device
	Devices []string `rethinkdb:"devices" json:"devices"`
	// Tags to attach to the volumegroup
	Tags []string `rethinkdb:"tags" json:"tags"`
}

VolumeGroup is optional, if given the devices must match.

Jump to

Keyboard shortcuts

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