Documentation
¶
Overview ¶
Package inventory answers questions about the nodes of a site: their attributes, where they sit, what address they have and what they boot.
It replaces the genders file, the rack spreadsheet and the boot path table the shell tools read separately.
Index ¶
- func BootPath(inv *Inventory, rules []v1alpha1.BootPathRule, node string) (string, bool, error)
- type Document
- type Inventory
- func (inv *Inventory) All() []*Node
- func (inv *Inventory) AttributeKeys() []string
- func (inv *Inventory) AttributeValues(key string) []string
- func (inv *Inventory) InRack(rack string) *nodeset.NodeSet
- func (inv *Inventory) Len() int
- func (inv *Inventory) Lookup(name string) (*Node, bool)
- func (inv *Inventory) Names() []string
- func (inv *Inventory) NodeSet() *nodeset.NodeSet
- func (inv *Inventory) Racks() []string
- func (inv *Inventory) Select(ns *nodeset.NodeSet) (known []*Node, unknown []string)
- func (inv *Inventory) WithAttribute(key, value string) *nodeset.NodeSet
- type Node
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BootPath ¶
BootPath returns the boot path configured for a node: the one on its inventory entry, else the first cluster rule that names it.
A node matched by more than one rule is an error rather than a silent first-match, because two rules pointing at different installations is a mistake worth stopping for.
Types ¶
type Document ¶ added in v0.3.0
type Document struct {
Spec v1alpha1.NodeInventorySpec
// Where returns where entry i, counted from zero, was written, such as
// "inventory.yaml:31:7". It may be nil, or return "" when that is not
// known.
Where func(entry int) string
}
Document is one NodeInventory together with a way to say where each of its entries was written, so that an error can point at the lines to fix.
type Inventory ¶
type Inventory struct {
// contains filtered or unexported fields
}
Inventory holds the nodes of a site, indexed by name.
func FromDocuments ¶ added in v0.3.0
FromDocuments is New for documents that know where their entries were written.
Addresses, service processor addresses, cids and MACs identify one machine, so two nodes sharing one are refused: a copied entry would otherwise send an action meant for one machine to another. An address must be an IP address and a MAC a MAC address, because both end up in the names of files on the PXE server and in DHCP.
A host is named the same way in every entry. Padding and case are not part of a host's identity, so exe1, exe0001 and EXE1 are one machine; an entry spelling a host differently from the entry that first named it would either make a second record for the same machine or silently merge into the first, and which one the author meant cannot be told, so it is refused. A name is written in lower case, because that is how every lookup asks for it.
func New ¶
func New(specs ...v1alpha1.NodeInventorySpec) (*Inventory, error)
New builds an inventory from the NodeInventory documents of a site.
Entries are applied in order, so a general entry may be written first and refined by a later one naming fewer nodes. Fields that describe a single machine may only be set by an entry that names exactly one node.
func (*Inventory) AttributeKeys ¶
AttributeKeys lists every attribute name in the inventory.
func (*Inventory) AttributeValues ¶
AttributeValues lists the distinct values of an attribute, in sorted order.
func (*Inventory) InRack ¶
InRack returns the nodes of one rack. It reads the rack attribute and compares it exactly, the way the @rack: group does, so that the two never disagree about what a rack holds.
func (*Inventory) Select ¶
Select returns the nodes of a set that the inventory knows, and the names of those it does not.
A name is matched through the node set, so that a set written as exe[1-2] finds the nodes an inventory wrote as exe0001 and exe0002: padding is a display property, not part of a host's identity.
type Node ¶
type Node struct {
Name string `json:"name" yaml:"name"`
Attributes map[string]string `json:"attributes,omitempty" yaml:"attributes,omitempty"`
Rack string `json:"rack,omitempty" yaml:"rack,omitempty"`
Level string `json:"level,omitempty" yaml:"level,omitempty"`
Address string `json:"address,omitempty" yaml:"address,omitempty"`
BMCAddress string `json:"bmcAddress,omitempty" yaml:"bmcAddress,omitempty"`
CID string `json:"cid,omitempty" yaml:"cid,omitempty"`
MACs []string `json:"macs,omitempty" yaml:"macs,omitempty"`
BootPath string `json:"bootPath,omitempty" yaml:"bootPath,omitempty"`
}
Node is everything the inventory knows about one machine.