Documentation
¶
Overview ¶
Package hostnetwork validates a declared Metalman host network topology and renders it for the local installer (runtime description), netplan, and systemd-networkd. See designs/metalman-host-network.md.
Index ¶
- Constants
- func MediaCPIO(n *v1alpha3.HostNetworkSpec, lease v1alpha3.DHCPLease) ([]byte, error)
- func RenderNetplan(n *v1alpha3.HostNetworkSpec) ([]byte, error)
- func RenderNetplanConfig(n *v1alpha3.HostNetworkSpec) ([]byte, error)
- func RenderRuntime(n *v1alpha3.HostNetworkSpec, lease v1alpha3.DHCPLease) ([]byte, error)
- func Validate(n *v1alpha3.HostNetworkSpec, lease v1alpha3.DHCPLease) error
- func WriteCPIO(w io.Writer, files []CPIOFile) error
- type CPIOFile
- type File
Constants ¶
const ( MediaRuntimePath = "unbounded/media/network" MediaNetplanPath = "unbounded/media/netplan.yaml" MediaNetworkdPath = "unbounded/media/networkd" )
Media archive paths, relative to the initramfs root.
Variables ¶
This section is empty.
Functions ¶
func MediaCPIO ¶
MediaCPIO assembles the per-operation media.cpio archive: the runtime description, the netplan document, and the networkd files under unbounded/media/. It validates n against lease first.
func RenderNetplan ¶
func RenderNetplan(n *v1alpha3.HostNetworkSpec) ([]byte, error)
RenderNetplan renders a netplan v2 document with a top-level "network:" key, for /etc/netplan/99-unbounded-metal.yaml. The renderer key is omitted so the image default (networkd) applies.
func RenderNetplanConfig ¶
func RenderNetplanConfig(n *v1alpha3.HostNetworkSpec) ([]byte, error)
RenderNetplanConfig renders the same document without the "network:" wrapper, matching the shape of the NoCloud network-config template (images/netboot/assets/network-config.tmpl), which starts at "version: 2".
func RenderRuntime ¶
RenderRuntime renders the line-oriented runtime description consumed by the local installer. It validates n against lease first.
func Validate ¶
func Validate(n *v1alpha3.HostNetworkSpec, lease v1alpha3.DHCPLease) error
Validate checks the topology and its consistency with the provisioning lease. Errors name the offending field path, for example "network.bonds[0].interfaces[1]".
func WriteCPIO ¶
WriteCPIO writes a deterministic newc ("070701") archive of files. Every entry has uid/gid 0, mtime 0, nlink 1 (2 for directories), and sequential inode numbers starting at 1. Parent directories that are not listed are synthesized with mode 0755 and emitted once, before their first child. Paths must be relative, slash-separated, and free of empty, "." and ".." components; duplicates are rejected.
Types ¶
type CPIOFile ¶
CPIOFile is one entry of a newc archive. Mode carries the permission bits and, for directories, fs.ModeDir. Only regular files and directories are supported.
type File ¶
File is a rendered configuration file, named relative to its target directory.
func RenderNetworkd ¶
func RenderNetworkd(n *v1alpha3.HostNetworkSpec) ([]File, error)
RenderNetworkd renders systemd-networkd configuration for the topology: 10-unbounded-<name>.link for ethernets, 20-unbounded-<name>.netdev for bonds and VLANs, and 30-unbounded-<name>.network for every interface. The result is sorted by name.
Bonds get no MACAddress=: systemd-networkd then assigns the bond a stable MAC derived from the machine ID and interface name (systemd.netdev(5), MACAddress=), so the bond MAC does not depend on member enslavement order. Static addressing makes the bond MAC irrelevant to the lease, which keys on a member's permanent MAC.