netplan

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: May 26, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package netplan parses netplan YAML and FRR configuration files from provisioner file-system overlays, enabling BOOTy to auto-detect network settings supplied by upstream orchestrators (e.g. t-co).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HasNetplanFiles

func HasNetplanFiles(dir string) bool

HasNetplanFiles returns true if the given directory contains .yaml files.

func ToNetworkConfig

func ToNetworkConfig(np *Config, frr *FRRParams) *network.Config

ToNetworkConfig converts a parsed netplan Config (and optional FRR params) into the BOOTy network.Config used by the networking stack.

Types

type BondConfig

type BondConfig struct {
	Interfaces    []string        `yaml:"interfaces,omitempty"`
	MTU           int             `yaml:"mtu,omitempty"`
	AcceptRA      *bool           `yaml:"accept-ra,omitempty"`
	IgnoreCarrier *bool           `yaml:"ignore-carrier,omitempty"`
	Addresses     []string        `yaml:"addresses,omitempty"`
	Parameters    *BondParameters `yaml:"parameters,omitempty"`
}

BondConfig describes a network bond.

type BondParameters

type BondParameters struct {
	Mode               string `yaml:"mode,omitempty"`
	LACPRate           string `yaml:"lacp-rate,omitempty"`
	TransmitHashPolicy string `yaml:"transmit-hash-policy,omitempty"`
	MIIMonitorInterval int    `yaml:"mii-monitor-interval,omitempty"`
}

BondParameters holds bond tuning parameters.

type BridgeConfig

type BridgeConfig struct {
	Interfaces    []string      `yaml:"interfaces,omitempty"`
	Addresses     []string      `yaml:"addresses,omitempty"`
	MTU           int           `yaml:"mtu,omitempty"`
	LinkLocal     []string      `yaml:"link-local,omitempty"`
	Parameters    *BridgeParams `yaml:"parameters,omitempty"`
	MACAddress    string        `yaml:"macaddress,omitempty"`
	AcceptRA      *bool         `yaml:"accept-ra,omitempty"`
	IgnoreCarrier *bool         `yaml:"ignore-carrier,omitempty"`
}

BridgeConfig describes a network bridge.

type BridgeParams

type BridgeParams struct {
	STP *bool `yaml:"stp,omitempty"`
}

BridgeParams holds bridge-specific parameters.

type Config

type Config struct {
	Network NetworkSection `yaml:"network"`
}

Config is the top-level netplan YAML structure.

func ParseDir

func ParseDir(dir string) (*Config, error)

ParseDir reads all .yaml files from dir (sorted lexicographically) and returns a merged Config. Later files override earlier ones at the top-level map key level (ethernets, tunnels, bridges, etc.).

func ParseFile

func ParseFile(path string) (*Config, error)

ParseFile reads a single netplan YAML file.

type DNSConfig

type DNSConfig struct {
	Addresses []string `yaml:"addresses,omitempty"`
	Search    []string `yaml:"search,omitempty"`
}

DNSConfig holds nameserver configuration.

type DummyConfig

type DummyConfig struct {
	Addresses []string `yaml:"addresses,omitempty"`
	MTU       int      `yaml:"mtu,omitempty"`
}

DummyConfig describes a dummy (virtual loopback) device.

type EthernetConfig

type EthernetConfig struct {
	Match                       *MatchConfig  `yaml:"match,omitempty"`
	DHCP4                       *bool         `yaml:"dhcp4,omitempty"`
	DHCP6                       *bool         `yaml:"dhcp6,omitempty"`
	Addresses                   []string      `yaml:"addresses,omitempty"`
	Nameservers                 *DNSConfig    `yaml:"nameservers,omitempty"`
	MTU                         int           `yaml:"mtu,omitempty"`
	LinkLocal                   []string      `yaml:"link-local,omitempty"`
	AcceptRA                    *bool         `yaml:"accept-ra,omitempty"`
	EmitLLDP                    *bool         `yaml:"emit-lldp,omitempty"`
	IgnoreCarrier               *bool         `yaml:"ignore-carrier,omitempty"`
	Routes                      []RouteConfig `yaml:"routes,omitempty"`
	VirtualFunctionCount        int           `yaml:"virtual-function-count,omitempty"`
	EmbeddedSwitchMode          string        `yaml:"embedded-switch-mode,omitempty"`
	DelayVirtualFunctionsRebind *bool         `yaml:"delay-virtual-functions-rebind,omitempty"`
	IPv6AddressGeneration       string        `yaml:"ipv6-address-generation,omitempty"`
}

EthernetConfig describes an ethernet interface.

type FRRParams

type FRRParams struct {
	ASN             uint32
	LocalASN        uint32 // local-as override (BM4X uses per-neighbor local-as).
	RouterID        string
	UnnumberedPeers []string // Interface names from "neighbor X interface" lines.
	NumberedPeers   []string // IPv4 addresses from "neighbor X remote-as" lines.
	NumberedPeersV6 []string // IPv6 addresses from "neighbor X remote-as" lines.
	EVPN            bool     // True if "address-family l2vpn evpn" found.
	AdvertiseAllVNI bool     // True if "advertise-all-vni" found.
}

FRRParams holds parameters extracted from an FRR configuration file.

func ParseFRRConfig

func ParseFRRConfig(path string) (*FRRParams, error)

ParseFRRConfig extracts networking parameters from an FRR configuration file.

func ParseFRRConfigBytes

func ParseFRRConfigBytes(data []byte) (*FRRParams, error)

ParseFRRConfigBytes extracts networking parameters from FRR config content.

type MatchConfig

type MatchConfig struct {
	Name string `yaml:"name,omitempty"`
	MAC  string `yaml:"macaddress,omitempty"`
}

MatchConfig matches physical devices by name or MAC.

type NetworkSection

type NetworkSection struct {
	Version      int                       `yaml:"version,omitempty"`
	Ethernets    map[string]EthernetConfig `yaml:"ethernets,omitempty"`
	Bonds        map[string]BondConfig     `yaml:"bonds,omitempty"`
	Tunnels      map[string]TunnelConfig   `yaml:"tunnels,omitempty"`
	Bridges      map[string]BridgeConfig   `yaml:"bridges,omitempty"`
	VLANs        map[string]VLANConfig     `yaml:"vlans,omitempty"`
	DummyDevices map[string]DummyConfig    `yaml:"dummy-devices,omitempty"`
	VRFs         map[string]VRFConfig      `yaml:"vrfs,omitempty"`
}

NetworkSection is the "network:" block inside a netplan YAML file.

type RouteConfig

type RouteConfig struct {
	To     string `yaml:"to"`
	Via    string `yaml:"via,omitempty"`
	From   string `yaml:"from,omitempty"`
	Metric int    `yaml:"metric,omitempty"`
	Scope  string `yaml:"scope,omitempty"`
	Table  int    `yaml:"table,omitempty"`
}

RouteConfig describes a static route.

type TunnelConfig

type TunnelConfig struct {
	Mode            string   `yaml:"mode,omitempty"`
	ID              int      `yaml:"id,omitempty"`
	Local           string   `yaml:"local,omitempty"`
	Remote          string   `yaml:"remote,omitempty"`
	Port            int      `yaml:"port,omitempty"`
	Link            string   `yaml:"link,omitempty"`
	MTU             int      `yaml:"mtu,omitempty"`
	LinkLocal       []string `yaml:"link-local,omitempty"`
	Hairpin         *bool    `yaml:"hairpin,omitempty"`
	MACLearning     *bool    `yaml:"mac-learning,omitempty"`
	ARPProxy        *bool    `yaml:"arp-proxy,omitempty"`
	PortMACLearning *bool    `yaml:"port-mac-learning,omitempty"`
	AcceptRA        *bool    `yaml:"accept-ra,omitempty"`
	IgnoreCarrier   *bool    `yaml:"ignore-carrier,omitempty"`
}

TunnelConfig describes a tunnel (VXLAN, GRE, etc.).

type VLANConfig

type VLANConfig struct {
	ID          int           `yaml:"id,omitempty"`
	Link        string        `yaml:"link,omitempty"`
	DHCP4       *bool         `yaml:"dhcp4,omitempty"`
	Addresses   []string      `yaml:"addresses,omitempty"`
	MTU         int           `yaml:"mtu,omitempty"`
	Nameservers *DNSConfig    `yaml:"nameservers,omitempty"`
	Routes      []RouteConfig `yaml:"routes,omitempty"`
}

VLANConfig describes a VLAN sub-interface.

type VRFConfig

type VRFConfig struct {
	Table      int      `yaml:"table,omitempty"`
	Interfaces []string `yaml:"interfaces,omitempty"`
}

VRFConfig describes a Virtual Routing and Forwarding instance.

Jump to

Keyboard shortcuts

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