inventory

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: GPL-3.0, LGPL-3.0 Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func BootPath

func BootPath(inv *Inventory, rules []v1alpha1.BootPathRule, node string) (string, bool, error)

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 Inventory

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

Inventory holds the nodes of a site, indexed by name.

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) All

func (inv *Inventory) All() []*Node

All returns every node in name order.

func (*Inventory) AttributeKeys

func (inv *Inventory) AttributeKeys() []string

AttributeKeys lists every attribute name in the inventory.

func (*Inventory) AttributeValues

func (inv *Inventory) AttributeValues(key string) []string

AttributeValues lists the distinct values of an attribute, in sorted order.

func (*Inventory) AttributeValuesOf

func (inv *Inventory) AttributeValuesOf(field func(*Node) string) []string

AttributeValuesOf lists the distinct non-empty values a field takes.

func (*Inventory) InRack

func (inv *Inventory) InRack(rack string) *nodeset.NodeSet

InRack returns the nodes of one rack.

func (*Inventory) Len

func (inv *Inventory) Len() int

Len reports how many nodes the inventory knows.

func (*Inventory) Lookup

func (inv *Inventory) Lookup(name string) (*Node, bool)

Lookup returns a node by name.

func (*Inventory) Names

func (inv *Inventory) Names() []string

Names returns every known node name in sorted order.

func (*Inventory) NodeSet

func (inv *Inventory) NodeSet() *nodeset.NodeSet

NodeSet returns every known node as a set.

func (*Inventory) Racks

func (inv *Inventory) Racks() []string

Racks lists the racks the inventory knows, in sorted order.

func (*Inventory) Resolve

func (inv *Inventory) Resolve(name string) (string, bool)

Resolve returns the name the inventory uses for a host, which may differ from the name given only in padding.

func (*Inventory) Select

func (inv *Inventory) Select(ns *nodeset.NodeSet) (known []*Node, unknown []string)

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.

func (*Inventory) WithAttribute

func (inv *Inventory) WithAttribute(key, value string) *nodeset.NodeSet

WithAttribute returns the nodes whose attribute has the given value. An empty value matches every node that carries the attribute at all, the way a genders attribute without a value did.

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.

func (Node) Attribute

func (n Node) Attribute(key string) (string, bool)

Attribute returns one attribute of the node.

Jump to

Keyboard shortcuts

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