hhfab

package
v0.51.5 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: Apache-2.0 Imports: 92 Imported by: 0

README

How to Build OVMF (CODE and VARS) using EDK2

The Open Virtual Machine Firmware (OVMF) project aims to support firmware for Virtual Machines using the edk2 code base.

1 - Getting Started with EDK II

Follow the steps described at https://github.com/tianocore/tianocore.github.io/wiki/Using-EDK-II-with-Native-GCC:

Some dependencies: $ sudo apt install build-essential uuid-dev iasl git nasm python-is-python3

Cloning edk2: $ git clone https://github.com/tianocore/edk2

Initialize submodules:

$ cd edk2
$ git submodule update --init

Compile build tools:

$ make -C BaseTools
$ ./edksetup.sh

Setup build shell environment:

$ export EDK_TOOLS_PATH=$HOME/src/edk2/BaseTools
$ ./edksetup.sh BaseTools

Modify Conf Files - edk2/Conf/target.txt:

ACTIVE_PLATFORM = EmulatorPkg/EmulatorPkg.dsc
TOOL_CHAIN_TAG  = GCC114
TARGET_ARCH     = X64

Modify EmulatorPkg Files - edk2/EmulatorPkg/EmulatorPkg.dsc:

#
# Network definition
#
DEFINE NETWORK_SNP_ENABLE       = FALSE
DEFINE NETWORK_IP6_ENABLE       = FALSE
DEFINE NETWORK_TLS_ENABLE       = FALSE
DEFINE NETWORK_HTTP_BOOT_ENABLE = FALSE
DEFINE NETWORK_HTTP_ENABLE      = FALSE
DEFINE NETWORK_ISCSI_ENABLE     = FALSE
DEFINE SECURE_BOOT_ENABLE       = FALSE

Note:

$gcc --version
gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0

Once you have modified Conf/target.txt and EmulatorPkg/EmulatorPkg.dsc, you can run the build command:

$ cd edk2/OvmfPkg
$ ./build.sh

If successful, you should now have an OVMF.Fd file under the Build sub-directory. The exact directory under the Build directory will depend upon the toolchain, dsc, and processor architecture:

$cd edk2/Build/OvmfX64/DEBUG_GCC5/FV/
$ ls
OVMF.fd
OVMF_VARS.fd

Files used in hhfab/vlab:

OVMF.fd = onie_efi_code.fd
OVMF_VARS.fd = onie_efi_vars.fd
onie-kvm_x86_64.qcow2 - To generate this file, follow the procedure described at https://github.com/githedgehog/onie_kvm.

References: https://github.com/tianocore/tianocore.github.io/wiki/Getting-Started-with-EDK-II https://github.com/tianocore/tianocore.github.io/wiki/How-to-build-OVMF https://github.com/tianocore/edk2/blob/master/OvmfPkg/README http://www.tianocore.org/ovmf/ https://github.com/tianocore/ https://github.com/tianocore/tianocore.github.io/wiki/Training https://github.com/tianocore/tianocore.github.io/wiki/UEFI-EDKII-Learning-Dev

Documentation

Index

Constants

View Source
const (
	RegistryConfigFile = ".registry.yaml"
	FabConfigFile      = "fab.yaml"
	IncludeDir         = "include"
	ResultDir          = "result"
	DefaultRepo        = "ghcr.io"
	DefaultPrefix      = "githedgehog"
	YAMLExt            = ".yaml"
	TmplExt            = ".tmpl"
	TmplYAMLExt        = TmplExt + YAMLExt
	YAMLTmplExt        = YAMLExt + TmplExt
	JoinTokenEnv       = "HHFAB_JOIN_TOKEN" //nolint:gosec
)
View Source
const (
	StaticExternalNH         = "172.31.255.1"
	StaticExternalIP         = "172.31.255.5"
	StaticExternalPL         = "24"
	StaticExternalDummyIface = "10.199.0.100"
)
View Source
const (
	LabelAppInstance   = "app.kubernetes.io/instance"
	AlloyCtrlComponent = "alloy-ctrl"
)
View Source
const (
	ServerNamePrefix        = "server-"
	HashPolicyL2            = "layer2"
	HashPolicyL2And3        = "layer2+3"
	HashPolicyL3And4        = "layer3+4"
	HashPolicyEncap2And3    = "encap2+3"
	HashPolicyEncap3And4    = "encap3+4"
	HashPolicyVLANAndSrcMAC = "vlan+srcmac"
)
View Source
const (
	VLABExtraFabric            = "fabric-b"
	VLABInterconnectAnnotation = "hhfab.githedgehog.com/interconnect"
)

The extra fabric has no gateway or virtual external. An interconnect External, annotated with the name of its peer, connects it to a leaf of the main fabric.

View Source
const (
	GatewayDriverKernel = "kernel"
	GatewayDriverDPDK   = "dpdk"
)
View Source
const (
	VLABDir        = "vlab"
	VLABConfigFile = "config.yaml"
	VLABSSHKeyFile = "sshkey"
	VLABVMsDir     = "vms"

	VLABSwitchMACTmpl = "0c:20:12:ff:%02x:00"
	VLABMACTmpl       = "0c:20:12:fe:%02x:%02x"

	VLABVirtioNet = "virtio-net-pci"
	// VLABVirtioNetSpeed is the link speed, in Mb/s, VLAB's virtio-net NICs report.
	VLABVirtioNetSpeed = "10000"

	HHFabCfgPrefix     = ".hhfab.githedgehog.com"
	HHFabCfgType       = vlabcomp.NodeTypeAnnotation
	HHFabCfgTypeHW     = vlabcomp.NodeTypeHW
	HHFabCfgLinkPrefix = "link" + HHFabCfgPrefix + "/"
	HHFabCfgPCIPrefix  = "pci@"
	HHFabCfgASNPrefix  = "asn"

	ExternalVMName   = "virt-external"
	MaxExternalConns = 48
)
View Source
const (
	VLABPCIBridgePrefix  = "pcibr"
	VLABRootPortPrefix   = "rootport"
	VLABNICsPerPCIBridge = 32
	VLABPCIBridges       = 2
	VLABMaxNICs          = VLABNICsPerPCIBridge * VLABPCIBridges
	VLABBaseSSHPort      = 22000
	VLABBaseDirectPort   = 22100
	VLABUUIDPrefix       = "77924ab4-a93b-41d4-928e-"
	VLABUUIDTmpl         = VLABUUIDPrefix + "%012d"

	// VLABMgmt is the management network bridge, its taps are hhmgmtp0, hhmgmtp1 and so on
	VLABMgmt = "hhmgmt"
	// VLABLink prefixes the links, hhlink0 has taps hhlink0p0 and hhlink0p1
	VLABLink = "hhlink"
	// VLABLegacyMgmt and VLABLegacyMgmtTap are the management network's previous names, kept to clean it up
	VLABLegacyMgmt    = "hhbr"
	VLABLegacyMgmtTap = "hhtap"

	// VLABMaxMgmtTaps caps the management network taps
	VLABMaxMgmtTaps = 100
	// VLABLinkMTU leaves room above the 9100 of the fabric links, a bridge drops frames bigger than the tap they leave by
	VLABLinkMTU = 9216
)
View Source
const (
	NICTypeSep         = ":"
	NICTypeNoop        = "noop"
	NICTypeUsernet     = "usernet"
	NICTypeManagement  = "management"
	NICTypeDirect      = "direct"
	NICTypePassthrough = "passthrough"
)
View Source
const (
	VLABOSImageFile  = "os.img"
	VLABEFICodeFile  = "efi_code.fd"
	VLABEFIVarsFile  = "efi_vars.fd"
	VLABUSBImageFile = "usb.img"
	VLABISOImageFile = "usb.iso"

	VLABSerialLog  = "serial.log"
	VLABSerialSock = "serial.sock"
	VLABMonSock    = "mon.sock"
	VLABQMPSock    = "qmp.sock"

	VLABCmdSudo       = "sudo"
	VLABCmdQemuImg    = "qemu-img"
	VLABCmdQemuSystem = "qemu-system-x86_64"
	VLABCmdSocat      = "socat"
	VLABCmdSSH        = "ssh"
	VLABCmdSCP        = "scp"
	VLABCmdLess       = "less"
	VLABCmdExpect     = "expect"

	VLABButane   = "butane.yaml"
	VLABIgnition = "ignition.json"

	VLABKubeConfig = "kubeconfig"

	VLABEnvPDUUsername    = "HHFAB_VLAB_PDU_USERNAME"
	VLABEnvPDUPassword    = "HHFAB_VLAB_PDU_PASSWORD" //nolint:gosec
	VLABEnvSwitchUsername = "HHFAB_SWITCH_USERNAME"
	VLABEnvSwitchPassword = "HHFAB_SWITCH_PASSWORD" //nolint:gosec
	VLABEnvServerUsername = "HHFAB_SERVER_USERNAME"
	VLABEnvServerPassword = "HHFAB_SERVER_PASSWORD" //nolint:gosec

	VLABEnvExternalUsername = "HHFAB_EXTERNAL_USERNAME"
	VLABEnvExternalPassword = "HHFAB_EXTERNAL_PASSWORD" //nolint:gosec
	VLABEnvExternalMgmtIP   = "HHFAB_EXTERNAL_MGMT_IP"
)
View Source
const ControlPlaneAPIIP = "172.30.0.5"
View Source
const DefaultGatewayWorkers = 4

DefaultGatewayWorkers is the number of dataplane workers of VLAB gateways. DPDK busy-polls each of them, so every worker keeps a host core busy.

View Source
const (
	DefaultVLABGeneratedFile = "vlab.generated.yaml"
)
View Source
const HydrateNumberedLinksAnnotation = "hydrate.hhfab.githedgehog.com/numbered-links"

HydrateNumberedLinksAnnotation set to "true" on a Fabric makes hydration assign /31s to its fabric and mesh links instead of leaving them empty for BGP unnumbered

View Source
const UpgradeFromEnv = "HHFAB_UPGRADE_FROM"

UpgradeFromEnv names the release a work dir is being upgraded from, e.g. 26.04 or 26.04.1. Wiring written for a release from before Fabric objects has no Fabric/default, which validation requires and which the controller creates in the cluster on upgrade. For those releases hhfab injects it when loading the wiring, so the rest of the upgrade sees what the cluster will. VLAB upgrades also skip the config export and import check for releases whose k3s can't start on the current VLAB before the upgrade.

Keyed on the release rather than on the wiring lacking a Fabric, so that it stops applying by itself once those releases are no longer upgraded from.

TODO: remove once upgrades from 26.03 and 26.04 are no longer supported.

View Source
const VLABExtraDomain = "domain-b"

Variables

View Source
var (
	ErrExist    = fmt.Errorf("already exists")
	ErrNotExist = fmt.Errorf("does not exist")
	ErrNotDir   = fmt.Errorf("not a directory")
)
View Source
var (
	ErrConsole = errors.New("connection to console failed")
	ErrLogin   = errors.New("login to switch failed")
	ErrInstall = errors.New("os install failed")
	ErrHHFab   = errors.New("hhfab vlab serial failed")
	ErrUnknown = errors.New("unknown expect error")
)
View Source
var AllZeroPrefix = []string{"0.0.0.0/0"}
View Source
var DefaultSizes = VMSizes{
	Control:  VMSize{CPU: 6, RAM: 6144, Disk: 100},
	Switch:   VMSize{CPU: 4, RAM: 5120, Disk: 50},
	Server:   VMSize{CPU: 2, RAM: 768, Disk: 14},
	Gateway:  VMSize{CPU: 8, RAM: 8192, Disk: 50},
	External: VMSize{CPU: 4, RAM: 5120, Disk: 50},
}
View Source
var ErrExit = fmt.Errorf("exit")
View Source
var SSHQuietFlags = []string{
	"-o", "GlobalKnownHostsFile=/dev/null",
	"-o", "UserKnownHostsFile=/dev/null",
	"-o", "StrictHostKeyChecking=no",
	"-o", "LogLevel=ERROR",
	"-o", "IdentitiesOnly=yes",
}

Functions

func AddrsFrom

func AddrsFrom(prefixes ...netip.Prefix) iter.Seq[netip.Prefix]

func AirGenerate added in v0.44.0

func AirGenerate(ctx context.Context, workDir, cacheDir string, hMode HydrateMode) error

func Build

func Build(ctx context.Context, workDir, cacheDir string, extraCacheDirs []string, opts BuildOpts) error

func CheckStaleVMs

func CheckStaleVMs(ctx context.Context, kill bool) ([]int32, error)

func CollectN

func CollectN[E any](n int, seq iter.Seq[E]) []E

func CollectServerEndpoints added in v0.49.0

func CollectServerEndpoints(ctx context.Context, kube kclient.Client, ssh SSHResolver, servers []string) ([]*Endpoint, []DroppedEndpoint, error)

CollectServerEndpoints observes the live cluster and produces one *Endpoint per (server, vpc, subnet) attachment for each server in the `servers` filter (nil → all servers attached to at least one VPC).

func CreateOrUpdateVpc added in v0.34.0

func CreateOrUpdateVpc(ctx context.Context, kube kclient.Client, vpc *vpcapi.VPC) (bool, error)

func Diagram added in v0.35.0

func Diagram(ctx context.Context, workDir, cacheDir string, live bool, format diagram.Format, style diagram.StyleType, outputPath string) error

func DoSetupPeerings added in v0.34.0

func DoSetupPeerings(ctx context.Context, kube kclient.Client, vpcPeerings map[string]*vpcapi.VPCPeeringSpec,
	externalPeerings map[string]*vpcapi.ExternalPeeringSpec, gwPeerings map[string]*gwapi.PeeringSpec,
	waitReady bool,
) error

func DoShowTech added in v0.34.0

func DoShowTech(ctx context.Context, workDir, cacheDir string) error

func DoSwitchPower added in v0.33.0

func DoSwitchPower(ctx context.Context, workDir, cacheDir string, opts SwitchPowerOpts) error

func DoSwitchReinstall added in v0.33.0

func DoSwitchReinstall(ctx context.Context, workDir, cacheDir string, opts SwitchReinstallOpts) error

func DoVLABBenchAgents added in v0.51.0

func DoVLABBenchAgents(ctx context.Context, workDir, cacheDir string, opts BenchAgentsOpts) error

DoVLABBenchAgents simulates switch agents against the Agent objects in the cluster.

func DoVLABBenchBoots added in v0.51.0

func DoVLABBenchBoots(ctx context.Context, workDir, cacheDir string, opts BenchBootsOpts) error

DoVLABBenchBoots simulates every bench switch reinstalling itself from fabric-boot through ONIE, all at once.

func DoVLABBenchClean added in v0.51.0

func DoVLABBenchClean(ctx context.Context, workDir, cacheDir string, opts BenchCleanOpts) error

DoVLABBenchClean removes everything the benchmark created.

func DoVLABBenchDHCP added in v0.51.0

func DoVLABBenchDHCP(ctx context.Context, workDir, cacheDir string, opts BenchDHCPOpts) error

DoVLABBenchDHCP storms fabric-dhcpd with a fleet of servers booting at once, relayed from a bench leaf's management IP. Binding the relay's port 67 needs root, so without it this fails, or with Sudo runs itself again under sudo.

func DoVLABBenchHealth added in v0.51.0

func DoVLABBenchHealth(ctx context.Context, workDir, cacheDir string, opts BenchHealthOpts) error

DoVLABBenchHealth prints the current state of the control plane.

func DoVLABBenchInit added in v0.51.0

func DoVLABBenchInit(ctx context.Context, workDir, cacheDir string, opts BenchInitOpts) error

DoVLABBenchInit generates the benchmark topology and applies it to the VLAB control node.

func DoVLABBenchSample added in v0.51.0

func DoVLABBenchSample(ctx context.Context, workDir, cacheDir string, opts BenchSampleOpts) error

DoVLABBenchSample records etcd and control node memory over time, to a file bench health reads back.

It is deliberately its own command rather than part of a load generator: what it observes is a property of the cluster, not of any particular load, so it runs alongside agents, users, init, or nothing at all. Unlike health, where the control node is one section of several, it is the whole point here - so a missing one fails rather than quietly producing an empty series.

func DoVLABBenchUsers added in v0.51.0

func DoVLABBenchUsers(ctx context.Context, workDir, cacheDir string, opts BenchUsersOpts) error

DoVLABBenchUsers simulates operators changing objects and running inspect.

func DoVLABInspect added in v0.34.0

func DoVLABInspect(ctx context.Context, workDir, cacheDir string, opts InspectOpts) error

func DoVLABInspectPods added in v0.50.3

func DoVLABInspectPods(ctx context.Context, workDir, cacheDir string, opts InspectPodsOpts) error

func DoVLABReleaseTest added in v0.35.0

func DoVLABReleaseTest(ctx context.Context, workDir, cacheDir string, opts ReleaseTestOpts) error

func DoVLABSCP added in v0.47.0

func DoVLABSCP(ctx context.Context, workDir, cacheDir, name, username string, args []string) error

func DoVLABSSH

func DoVLABSSH(ctx context.Context, workDir, cacheDir, name, username string, args []string) error

func DoVLABSerial

func DoVLABSerial(ctx context.Context, workDir, cacheDir, name string, args []string) error

func DoVLABSerialLog

func DoVLABSerialLog(ctx context.Context, workDir, cacheDir, name string, args []string) error

func DoVLABSetupPeerings

func DoVLABSetupPeerings(ctx context.Context, workDir, cacheDir string, opts SetupPeeringsOpts) error

func DoVLABSetupVPCs

func DoVLABSetupVPCs(ctx context.Context, workDir, cacheDir string, opts SetupVPCsOpts) ([]*Endpoint, []DroppedEndpoint, error)

func DoVLABTestConnectivity

func DoVLABTestConnectivity(ctx context.Context, workDir, cacheDir string, opts TestConnectivityOpts) error

func DoVLABTestConnectivityWithMatrix added in v0.49.0

func DoVLABTestConnectivityWithMatrix(ctx context.Context, workDir, cacheDir string, opts TestConnectivityOpts, matrix *ConnectivityMatrix) error

func DoVLABWait added in v0.34.0

func DoVLABWait(ctx context.Context, workDir, cacheDir string) error

func GetServerNetconfCmd added in v0.41.0

func GetServerNetconfCmd(conn *wiringapi.Connection, opts ServerNetconfOpts) (string, error)

func Init

func Init(ctx context.Context, c InitConfig) error

func IsSameEndpointNode added in v0.49.0

func IsSameEndpointNode(a, b *Endpoint) bool

func LoadTemplateValues added in v0.51.0

func LoadTemplateValues(valuesFiles, sets []string) (map[string]any, error)

LoadTemplateValues builds the template values used to render the imported config and wiring files. Values files are merged left-to-right, then the k=v entries from sets are applied on top. The result is never nil.

func OverlayMatrixNAT added in v0.49.0

func OverlayMatrixNAT(
	matrix *ConnectivityMatrix,
	srcPred, dstPred EndpointPredicate,
	mutator NATMutator,
) error

func Precache added in v0.44.0

func Precache(ctx context.Context, workDir, cacheDir string, extraCacheDirs []string, opts PrecacheOpts) error

func PrecacheVLABOCI added in v0.44.0

func PrecacheVLABOCI(cfg fabapi.Fabricator) (comp.OCIArtifacts, error)

PrecacheVLABOCI returns a list of OCI artifacts that are required for building the VLAB

func PrecacheVLABORAS added in v0.44.0

func PrecacheVLABORAS(cfg fabapi.Fabricator) (comp.OCIArtifacts, error)

PrecacheVLABORAS returns a list of ORAS artifacts that are required for building the VLAB

func PreparePassthrough

func PreparePassthrough(ctx context.Context, devs []string) error

func ReleaseTest added in v0.48.0

func ReleaseTest(ctx context.Context, c *Config, vlab *VLAB, opts ReleaseTestOpts) error

func ResolveDefaultServerMTU added in v0.47.0

func ResolveDefaultServerMTU(ctx context.Context, kube kclient.Client, opts *SetupVPCsOpts) error

ResolveDefaultServerMTU sets opts.InterfaceMTU to a sensible default when left at 0, based on the switch profiles present in the cluster:

  • SONiC VS: 1500 when DNS/NTP options are set (forces a non-jumbo advertisement via DHCP to avoid the API webhook defaulting to 9036); left at 0 otherwise so no MTU is advertised.
  • Otherwise: fabcomp.ServerFacingMTU (jumbo).

Idempotent: no-op when opts.InterfaceMTU is already non-zero. Callers that need the resolved value back in their own SetupVPCsOpts (e.g. release-test drivers that later read testCtx.setupOpts.InterfaceMTU) must invoke this before constructing that context, since SetupVPCs receives opts by value.

func RunReleaseTestSuites added in v0.35.0

func RunReleaseTestSuites(ctx context.Context, vlabCfg *Config, vlab *VLAB, rtOpts ReleaseTestOpts) error

func SetupVLABNet added in v0.51.0

func SetupVLABNet(_ context.Context, nets []VLABNet) error

SetupVLABNet makes the host match the nets given: creates the missing bridges and taps, recreates the ones set up differently and deletes all the others VLAB owns, the management network's legacy names included

func SubPrefixesFrom

func SubPrefixesFrom(bits int, prefixes ...netip.Prefix) iter.Seq[netip.Prefix]

func VLABGenerate

func VLABGenerate(ctx context.Context, workDir, cacheDir string, builder VLABBuilder, target string) error

func VLABUp

func VLABUp(ctx context.Context, workDir, cacheDir string, extraCacheDirs []string, opts VLABUpOpts) error

func VLANsFrom

func VLANsFrom(ranges ...meta.VLANRange) iter.Seq[uint16]

func Validate

func Validate(ctx context.Context, workDir, cacheDir string, hMode HydrateMode) error

func Versions

func Versions(ctx context.Context, workDir, cacheDir string, hMode HydrateMode) error

func WaitReady added in v0.41.0

func WaitReady(ctx context.Context, kube kclient.Reader, opts WaitReadyOpts) error

Types

type AirServersIn added in v0.44.0

type AirServersIn struct {
	Servers map[string]AirServersInServer
}

type AirServersInServer added in v0.44.0

type AirServersInServer struct {
	Ifaces map[string]AirServersInServerIface
	Routes map[string]AirServersInServerRoute
}

type AirServersInServerIface added in v0.44.0

type AirServersInServerIface struct {
	IP string
}

type AirServersInServerRoute added in v0.44.0

type AirServersInServerRoute struct {
	NextHops []string
}

type AirTopoIn added in v0.44.0

type AirTopoIn struct {
	Nodes []AirTopoNode
	Links []AirTopoLink
}
type AirTopoLink struct {
	Endpoints []AirTopoLinkEndpoint
}

type AirTopoLinkEndpoint added in v0.44.0

type AirTopoLinkEndpoint struct {
	Interface string
	Node      string
	MAC       string
}

type AirTopoNode added in v0.44.0

type AirTopoNode struct {
	Name    string
	NIC     string
	CPU     uint
	Memory  uint
	Storage uint
	OS      string
	IP      string
	MAC     string
}

type AttachedServerInfo added in v0.44.0

type AttachedServerInfo struct {
	ServerName string
	Interface  string
	VPCName    string
	SubnetName string
	VPC        *vpcapi.VPC
	Subnet     *vpcapi.VPCSubnet
	Connection *wiringapi.Connection
}

AttachedServerInfo contains information about a server attached to a VPC subnet.

type BenchAgentsOpts added in v0.51.0

type BenchAgentsOpts struct {
	Duration       time.Duration
	Interval       time.Duration
	ApplyDelay     time.Duration
	Agents         []string
	APIVia         string
	SyncHeartbeats bool
	PadSize        string
	QPS            float32
	Burst          int
}

BenchAgentsOpts configures `hhfab vlab bench agents`.

type BenchBootsOpts added in v0.51.0

type BenchBootsOpts struct {
	Rounds      int
	Switches    []string
	LogLines    int
	InstallTime time.Duration
	RetryDelay  time.Duration
	MaxFailures int
	QPS         float32
	Burst       int
}

BenchBootsOpts configures `hhfab vlab bench boots`.

type BenchCleanOpts added in v0.51.0

type BenchCleanOpts struct {
	Fabrics []string
	QPS     float32
	Burst   int
}

BenchCleanOpts configures `hhfab vlab bench clean`.

type BenchDHCPOpts added in v0.51.0

type BenchDHCPOpts struct {
	Servers          int
	Subnets          int
	VPCs             int
	MaxSubnetServers int
	Rounds           int
	Repeats          int
	RepeatInterval   time.Duration
	Spread           time.Duration
	RoundTimeout     time.Duration
	PXE              bool
	Relay            string
	Sudo             bool
	QPS              float32
	Burst            int
}

BenchDHCPOpts configures `hhfab vlab bench dhcp`.

type BenchHealthOpts added in v0.51.0

type BenchHealthOpts struct {
	Stats bool
	QPS   float32
	Burst int
}

BenchHealthOpts configures `hhfab vlab bench health`.

type BenchInitOpts added in v0.51.0

type BenchInitOpts struct {
	Fabrics []string
	Workers int
	QPS     float32
	Burst   int
	Phase   string
	Force   bool
	DryRun  bool
	Out     string
	// SkipValidate bypasses the local check, leaving it to the admission
	// webhooks. Worth it on a large run, where validating locally costs more
	// than the apply.
	SkipValidate bool
	// DefaultFabric puts every switch in the default fabric, without Fabric
	// objects or fabric and domain fields, so the topology can be created on a
	// release from before them and carried through the upgrade.
	DefaultFabric bool
}

BenchInitOpts configures `hhfab vlab bench init`.

type BenchSampleOpts added in v0.51.0

type BenchSampleOpts struct {
	Duration time.Duration
	Interval time.Duration
}

BenchSampleOpts configures `hhfab vlab bench sample`.

type BenchUsersOpts added in v0.51.0

type BenchUsersOpts struct {
	Duration         time.Duration
	UpdateWorkers    int
	UpdateSleep      time.Duration
	InspectWorkers   int
	InspectSleep     time.Duration
	Kinds            []string
	Inspects         []string
	Fabrics          []string
	OpTimeout        time.Duration
	InspectOneSwitch bool
	QPS              float32
	Burst            int
}

BenchUsersOpts configures `hhfab vlab bench users`.

type BuildOpts

type BuildOpts struct {
	HydrateMode          HydrateMode
	BuildMode            recipe.BuildMode
	BuildControls        bool
	BuildGateways        bool
	SetJoinToken         string
	ObservabilityTargets string
}

type Config

type Config struct {
	WorkDir        string
	CacheDir       string
	ExtraCacheDirs []string
	RegistryConfig
	Fab      fabapi.Fabricator
	Controls []fabapi.ControlNode
	Nodes    []fabapi.FabNode
	Client   kclient.Client // all resources (fab, fabric and gateway)
	Shutdown atomic.Int32
}

func (*Config) AirGenerate added in v0.44.0

func (c *Config) AirGenerate(ctx context.Context) error

func (*Config) CollectVLABDebug added in v0.41.2

func (c *Config) CollectVLABDebug(ctx context.Context, vlab *VLAB, opts VLABRunOpts, forceShowTech bool)

func (*Config) Inspect added in v0.34.0

func (c *Config) Inspect(ctx context.Context, vlab *VLAB, opts InspectOpts) error

func (*Config) InspectPods added in v0.50.3

func (c *Config) InspectPods(ctx context.Context, opts InspectPodsOpts) error

func (*Config) PrepareVLAB

func (c *Config) PrepareVLAB(ctx context.Context, opts VLABUpOpts) (*VLAB, error)

func (*Config) SSH added in v0.43.0

func (c *Config) SSH(ctx context.Context, vlab *VLAB, target string) (*sshutil.Config, error)

func (*Config) SSHVM added in v0.43.0

func (c *Config) SSHVM(ctx context.Context, vlab *VLAB, vm VM) (*sshutil.Config, error)

func (*Config) SetupPeerings

func (c *Config) SetupPeerings(ctx context.Context, vlab *VLAB, opts SetupPeeringsOpts) error

SetupPeerings creates/updates peerings per opts.Requests. It is matrix- agnostic: callers that want a post-peering connectivity expectation map invoke BuildConnectivityMatrix separately. See matrix.go for the model.

func (*Config) SetupVPCs

func (c *Config) SetupVPCs(ctx context.Context, vlab *VLAB, opts SetupVPCsOpts) ([]*Endpoint, []DroppedEndpoint, error)

SetupVPCs creates VPCs and VPC attachments per opts, configures servers, and returns one Endpoint per (server, vpc, subnet) attachment with the discovered IP and HostBGP flag populated.

func (*Config) TestConnectivity

func (c *Config) TestConnectivity(ctx context.Context, vlab *VLAB, opts TestConnectivityOpts) error

func (*Config) TestConnectivityWithMatrix added in v0.49.0

func (c *Config) TestConnectivityWithMatrix(ctx context.Context, vlab *VLAB, opts TestConnectivityOpts, matrix *ConnectivityMatrix) error

func (*Config) VLABAccess

func (c *Config) VLABAccess(ctx context.Context, vlab *VLAB, t VLABAccessType, name, username string, inArgs []string) error

func (*Config) VLABRun

func (c *Config) VLABRun(ctx context.Context, vlab *VLAB, opts VLABRunOpts) error

func (*Config) VLABShowTech added in v0.34.0

func (c *Config) VLABShowTech(ctx context.Context, vlab *VLAB, opts ShowTechOpts) error

func (*Config) VLABSwitchPower added in v0.33.0

func (c *Config) VLABSwitchPower(ctx context.Context, opts SwitchPowerOpts) error

func (*Config) VLABSwitchReinstall added in v0.33.0

func (c *Config) VLABSwitchReinstall(ctx context.Context, opts SwitchReinstallOpts) error

func (*Config) Wait added in v0.34.0

func (c *Config) Wait(ctx context.Context, vlab *VLAB) error

type ConnectivityExpectation added in v0.49.0

type ConnectivityExpectation struct {
	Pair EndpointPair

	Verdict ConnectivityVerdict

	NAT *TranslatedAddress

	Reason ReachabilityReason

	Peering string

	// free-form context for Reason: why a VerdictUnknown entry could not be
	// evaluated, or what withholds a VerdictDeny (e.g. an ACL on the peering)
	Detail string

	ProtoPort ProtoPort
}

ConnectivityExpectation describes what should happen on a directional path.

type ConnectivityMatrix added in v0.49.0

type ConnectivityMatrix struct {
	// Canonical, ordered list of all endpoints in the matrix.
	AllEndpoints []*Endpoint
	// contains filtered or unexported fields
}

func BuildConnectivityMatrix added in v0.49.0

func BuildConnectivityMatrix(ctx context.Context, kube kclient.Client, serverEndpoints []*Endpoint, dropped []DroppedEndpoint) (*ConnectivityMatrix, error)

func BuildConnectivityMatrixFromCluster added in v0.49.0

func BuildConnectivityMatrixFromCluster(ctx context.Context, kube kclient.Client, ssh SSHResolver) (*ConnectivityMatrix, error)

func NewConnectivityMatrix added in v0.49.0

func NewConnectivityMatrix() *ConnectivityMatrix

func (*ConnectivityMatrix) Add added in v0.49.0

Add inserts or replaces the expectation for (Pair, ProtoPort).

func (*ConnectivityMatrix) HasProtoPortEntries added in v0.49.0

func (m *ConnectivityMatrix) HasProtoPortEntries(src, dst *Endpoint) bool

func (*ConnectivityMatrix) Lookup added in v0.49.0

func (*ConnectivityMatrix) ProtoPortEntries added in v0.49.0

func (m *ConnectivityMatrix) ProtoPortEntries(src, dst *Endpoint) []ConnectivityExpectation

func (*ConnectivityMatrix) ReplaceServerDrops added in v0.49.0

func (m *ConnectivityMatrix) ReplaceServerDrops(name string, dropped []DroppedEndpoint)

func (*ConnectivityMatrix) ReplaceServerEndpoints added in v0.49.0

func (m *ConnectivityMatrix) ReplaceServerEndpoints(name string, newEPs []*Endpoint)

ReplaceServerEndpoints reconciles the matrix's endpoints for one server against newEPs:

  • Existing endpoints whose (vpc, subnet) match an entry in newEPs are updated in place
  • Existing endpoints with no (vpc, subnet) match in newEPs are dropped
  • newEPs that don't match any existing endpoint are appended

func (*ConnectivityMatrix) Repopulate added in v0.49.0

func (m *ConnectivityMatrix) Repopulate(ctx context.Context, kube kclient.Client) error

Repopulate clears the matrix's expectation entries and refills Allow entries by querying the live cluster for reachability between every (src, dst) endpoint pair in AllEndpoints.

func (*ConnectivityMatrix) Validate added in v0.49.0

func (m *ConnectivityMatrix) Validate() error

type ConnectivityVerdict added in v0.49.0

type ConnectivityVerdict string
const (
	VerdictAllow   ConnectivityVerdict = "allow"
	VerdictDeny    ConnectivityVerdict = "deny"
	VerdictUnknown ConnectivityVerdict = "unknown"
)

type CurlError added in v0.43.0

type CurlError struct {
	Source   string
	Expected bool
	Output   string
	Msg      string
	Why      string // what made Expected what it is
}

func (*CurlError) Error added in v0.43.0

func (ce *CurlError) Error() string

type DHCPLeaseInfo added in v0.44.0

type DHCPLeaseInfo struct {
	ValidLifetime     int
	PreferredLifetime int
	HasLease          bool
	LeaseText         string
}

type DroppedEndpoint added in v0.49.0

type DroppedEndpoint struct {
	Server string
	VPC    string
	Subnet string
	Reason string
}

DroppedEndpoint records an attachment or address that endpoint discovery could not turn into a testable *Endpoint. ConnectivityMatrix.Validate() refuses to run a test against a matrix that carries any of these.

func (DroppedEndpoint) String added in v0.49.0

func (d DroppedEndpoint) String() string

type Endpoint added in v0.49.0

type Endpoint struct {
	Server   *ServerEndpoint
	External *ExternalEndpoint
}

Endpoint is a tagged union; exactly one of Server, External is non-nil.

type EndpointPair added in v0.49.0

type EndpointPair struct {
	Source      *Endpoint
	Destination *Endpoint
}

type EndpointPredicate added in v0.49.0

type EndpointPredicate func(*Endpoint) bool

func ExternalNamed added in v0.49.0

func ExternalNamed(name string) EndpointPredicate

func ServerInVPC added in v0.49.0

func ServerInVPC(vpc string) EndpointPredicate

type ExternalAttachCfg added in v0.37.0

type ExternalAttachCfg struct {
	IsStatic    bool   `json:"isStatic"`    // whether this is a static attachment (as opposed to a BGP speaker)
	Prefix      string `json:"prefix"`      // IP prefix to configure on the NIC
	NeighborIP  string `json:"neighborIP"`  // IP address of the BGP neighbor or static external
	NeighborASN string `json:"neighborASN"` // ASN of the BGP neighbor (only for BGP externals)
	Vlan        uint16 `json:"vlan"`        // VLAN ID to configure on the NIC, 0 is untagged
	VRF         string `json:"vrf"`         // VRF name to configure on the NIC (name of the external)
}

type ExternalBGPVRFCfg added in v0.44.0

type ExternalBGPVRFCfg struct {
	ASN          uint32 `json:"asn"`          // the ASN of the BGP external
	InCommunity  string `json:"inCommunity"`  // the inbound community for the BGP external
	OutCommunity string `json:"outCommunity"` // the outbound community for the BGP external
}

type ExternalEndpoint added in v0.49.0

type ExternalEndpoint struct {
	ExternalName string
	Prefixes     []netip.Prefix
	SourceIP     netip.Addr
}

type ExternalNICCfg added in v0.37.0

type ExternalNICCfg struct {
	Attachments []ExternalAttachCfg `json:"attachments"` // the external attachments for this NIC, one per VLAN
	Untagged    bool                `json:"untagged"`    // whether there's an untagged attachment. Separate to simplify ignition template
	UntaggedCfg ExternalAttachCfg   `json:"untaggedCfg"` // if untagged, the configuration for the untagged attachment
}

type ExternalStaticVrfCfg added in v0.44.0

type ExternalStaticVrfCfg struct {
	Prefixes             []string `json:"prefixes"`             // the prefixes reachable via this external
	GatewayIPs           []string `json:"gatewayIPs"`           // the addresses that can be used on the gateway to connect to this external
	SwitchIP             string   `json:"switchIP"`             // the address on the switch on the other side of the attachment
	NICName              string   `json:"nicName"`              // name of the NIC attachment
	NATPoolCIDR          string   `json:"natPoolCIDR"`          // NAT pool CIDR that the gateway source-NATs into; installs a return route toward the switch
	IPv4NamespaceSubnets []string `json:"ipv4NamespaceSubnets"` // subnets of the IPv4 namespaces in the external's fabric; each gets a return route toward the switch
}

type ExternalVRFCfg added in v0.37.0

type ExternalVRFCfg struct {
	IsStatic  bool                 `json:"isStatic"` // whether this is a static external (as opposed to a BGP speaker)
	TableID   uint32               `json:"tableID"`  // the VRF table ID
	BGPCfg    ExternalBGPVRFCfg    `json:"bgpCfg"`
	StaticCfg ExternalStaticVrfCfg `json:"staticCfg"`
}

type ExternalsCfg added in v0.37.0

type ExternalsCfg struct {
	NICs map[string]ExternalNICCfg `json:"nics"` // the key is the external connection NIC name
	VRFs map[string]ExternalVRFCfg `json:"vrfs"` // a VRF associated with an external. The key is the external name
}

type Failure added in v0.35.0

type Failure struct {
	XMLName xml.Name `xml:"failure"`
	Message string   `xml:"message,attr"`
	Type    string   `xml:"type,attr"`
}

type GwExtPeeringOptions added in v0.47.0

type GwExtPeeringOptions struct {
	// VPCSubnets specifies which subnets from VPC to expose (if empty, all subnets are used)
	VPCSubnets []string
	// VPCNATCIDR specifies the NAT CIDR ranges for VPC
	VPCNATCIDR []string
	// VPCNATMode specifies the NAT mode for VPC (default: static)
	VPCNATMode NATMode
	// VPCPortForwardRules specifies port-forwarding rules for VPC
	VPCPortForwardRules []gwapi.PeeringNATPortForwardEntry
}

GwExtPeeringOptions contains optional parameters for gateway external peering configuration

type GwPeeringOptions added in v0.44.0

type GwPeeringOptions struct {
	// VPC1Subnets specifies which subnets from VPC1 to expose (if empty, all subnets are used)
	VPC1Subnets []string
	// VPC2Subnets specifies which subnets from VPC2 to expose (if empty, all subnets are used)
	VPC2Subnets []string
	// VPC1NATCIDR specifies the NAT CIDR ranges for VPC1
	VPC1NATCIDR []string
	// VPC2NATCIDR specifies the NAT CIDR ranges for VPC2
	VPC2NATCIDR []string
	// VPC1NATMode specifies the NAT mode for VPC1 (default: static)
	VPC1NATMode NATMode
	// VPC2NATMode specifies the NAT mode for VPC2 (default: static)
	VPC2NATMode NATMode
	// VPC1PortForwardRules specifies port-forwarding rules for VPC1
	VPC1PortForwardRules []gwapi.PeeringNATPortForwardEntry
	// VPC2PortForwardRules specifies port-forwarding rules for VPC2
	VPC2PortForwardRules []gwapi.PeeringNATPortForwardEntry
	// ACL is an optional peering-scoped ACL applied to the gateway peering.
	ACL *gwapi.PeeringACL
	// VPC1NotCIDRs specifies CIDRs to exclude from VPC1's exposed prefixes
	VPC1NotCIDRs []string
	// VPC2NotCIDRs specifies CIDRs to exclude from VPC2's exposed prefixes
	VPC2NotCIDRs []string
}

GwPeeringOptions contains optional parameters for gateway peering configuration

type HostBGPParams added in v0.49.0

type HostBGPParams struct {
	VPCLabel     string
	Connections  []*wiringapi.Connection
	VLAN         uint16
	Subnet       netip.Prefix
	ServerOffset int
}

type HydrateMode

type HydrateMode string
const (
	HydrateModeNever        HydrateMode = "never"
	HydrateModeIfNotPresent HydrateMode = "if-not-present"
	HydrateModeOverride     HydrateMode = "override"
)

type HydrationStatus

type HydrationStatus string
const (
	HydrationStatusNone    HydrationStatus = "none"
	HydrationStatusPartial HydrationStatus = "partial"
	HydrationStatusFull    HydrationStatus = "full"
)

type InitConfig

type InitConfig struct {
	WorkDir            string
	CacheDir           string
	Repo               string
	Prefix             string
	ImportConfig       string
	Force              bool
	Wiring             []string
	Values             []string
	Set                []string
	ImportHostUpstream bool
	fab.InitConfigInput
}

type InspectOpts added in v0.34.0

type InspectOpts struct {
	WaitAppliedFor time.Duration
	Strict         bool
	Attempts       int
}

type InspectPodsOpts added in v0.50.3

type InspectPodsOpts struct {
	Namespace string
	Strict    bool
}

type IperfError added in v0.43.0

type IperfError struct {
	Source          string
	Destination     string
	Why             string // what made the expectation what it is
	MinSpeed        string
	SentSpeed       string
	RcvdSpeed       string
	ClientMsg       string
	ServerMsg       string
	SendSpeedTooLow bool
}

func (*IperfError) Error added in v0.43.0

func (ie *IperfError) Error() string

type JUnitReport added in v0.35.0

type JUnitReport struct {
	XMLName xml.Name         `xml:"testsuites"`
	Suites  []JUnitTestSuite `xml:"testsuite"`
}

type JUnitTestCase added in v0.35.0

type JUnitTestCase struct {
	XMLName   xml.Name  `xml:"testcase"`
	ClassName string    `xml:"classname,attr"`
	Name      string    `xml:"name,attr"`
	Time      float64   `xml:"time,attr"`
	Failure   *Failure  `xml:"failure,omitempty"`
	Skipped   *Skipped  `xml:"skipped,omitempty"`
	F         TestFunc  `xml:"-"` // function to run
	SkipFlags SkipFlags `xml:"-"` // flags to determine whether to skip the test
}

type JUnitTestSuite added in v0.35.0

type JUnitTestSuite struct {
	XMLName   xml.Name        `xml:"testsuite"`
	Name      string          `xml:"name,attr"`
	Tests     int             `xml:"tests,attr"`
	Failures  int             `xml:"failures,attr"`
	Skipped   int             `xml:"skipped,attr"`
	Time      float64         `xml:"time,attr"`
	TimeHuman time.Duration   `xml:"-"`
	TestCases []JUnitTestCase `xml:"testcase"`
}

type MultiHomedServer added in v0.49.0

type MultiHomedServer struct {
	Server      *wiringapi.Server
	Connections []*wiringapi.Connection
	SwitchConns map[string][]*wiringapi.Connection
}

type NATMode added in v0.44.0

type NATMode int

NATMode specifies the type of NAT to use

const (
	// NATModeStatic uses static (1:1) NAT mapping
	NATModeStatic NATMode = iota
	// NATModeMasquerade uses masquerade (many:1) NAT with connection tracking
	NATModeMasquerade
	// NATModePortForward uses port-forwarding NAT
	NATModePortForward
	// NATModeMasqueradePortForward uses combined masquerade and port-forwarding NAT (two separate expose entries)
	NATModeMasqueradePortForward
)

type NATMutator added in v0.49.0

type NATMutator func(src, dst *Endpoint, nat *TranslatedAddress) error

type ObsEndpoint added in v0.43.0

type ObsEndpoint struct {
	URL      string
	Username string
	Password string
}

Structure to hold observability endpoint details

type OnReady

type OnReady string
const (
	OnReadyExit             OnReady = "exit"
	OnReadySetupVPCs        OnReady = "setup-vpcs"
	OnReadySetupPeerings    OnReady = "setup-peerings"
	OnReadySwitchReinstall  OnReady = "switch-reinstall"
	OnReadyTestConnectivity OnReady = "test-connectivity"
	OnReadyWait             OnReady = "wait"
	OnReadyInspect          OnReady = "inspect"
	OnReadyInspectPods      OnReady = "inspect-pods"
	OnReadyReleaseTest      OnReady = "release-test"
)

func FromShortOnReady added in v0.43.0

func FromShortOnReady(short string) OnReady

type PingError added in v0.43.0

type PingError struct {
	Source      string
	Destination string
	Expected    bool
	Why         string // what made the expectation what it is
	Sent        int
	Received    int
	Lost        []int
	CmdOutput   string
	Msg         string
}

func (*PingError) Error added in v0.43.0

func (pe *PingError) Error() string

type PrecacheOpts added in v0.44.0

type PrecacheOpts struct {
	All  bool
	VLAB bool
}

type ProtoPort added in v0.49.0

type ProtoPort struct {
	Protocol string // "tcp", "udp", "icmp"
	Port     uint16
}

type Reachability added in v0.41.0

type Reachability struct {
	Reachable bool
	Reason    ReachabilityReason
	Peering   string
	Detail    string
	// Ranges a gateway peering subtracts from the source's and the destination's own
	// expose via `Not`. Reachable above is subnet-level, so callers that know the
	// endpoint addresses narrow it with Excludes.
	SourceExclusions []netip.Prefix
	DestExclusions   []netip.Prefix
}

func IsExternalSubnetReachable added in v0.43.0

func IsExternalSubnetReachable(ctx context.Context, kube kclient.Reader, sourceServer, destSubnet string, checkGateway bool) (Reachability, error)

func IsServerReachable added in v0.39.0

func IsServerReachable(ctx context.Context, kube kclient.Reader, sourceServer, destServer string, checkGateway bool) (Reachability, error)

func IsSubnetReachable added in v0.39.0

func IsSubnetReachable(ctx context.Context, kube kclient.Reader, source, dest string, checkGateway bool) (Reachability, error)

func IsSubnetReachableWithGatewayPeering added in v0.41.0

func IsSubnetReachableWithGatewayPeering(ctx context.Context, kube kclient.Reader, vpc1Name, vpc1Subnet, vpc2Name, vpc2Subnet string) (Reachability, error)

It's just a temporary function for simple check only supporting whole VPC subnet CIDRs

func IsSubnetReachableWithSwitchPeering added in v0.41.0

func IsSubnetReachableWithSwitchPeering(ctx context.Context, kube kclient.Reader, vpc1Name, vpc1Subnet, vpc2Name, vpc2Subnet string) (Reachability, error)

func (Reachability) Excludes added in v0.50.2

func (r Reachability) Excludes(sourceAddr, destAddr netip.Addr) bool

Excludes reports whether a gateway peering `Not` takes this pair of addresses out of an otherwise reachable peering. Both directions: traffic to an excluded host is dropped, and its own traffic has no return path.

type ReachabilityReason added in v0.41.0

type ReachabilityReason string
const (
	ReachabilityReasonIntraVPC       ReachabilityReason = "intra-vpc"
	ReachabilityReasonSwitchPeering  ReachabilityReason = "switch-peering"
	ReachabilityReasonGatewayPeering ReachabilityReason = "gateway-peering"
)

type RegistryConfig

type RegistryConfig struct {
	Repo   string `json:"repo,omitempty"`
	Prefix string `json:"prefix,omitempty"`
}

type ReleaseTestOpts added in v0.35.0

type ReleaseTestOpts struct {
	Regexes        []string
	InvertRegex    bool
	ResultsFile    string
	Extended       bool
	FailFast       bool
	PauseOnFailure bool
	HashPolicy     string
	VPCMode        vpcapi.VPCMode
	ListTests      bool
	ShowTechDump   bool
	IPerfsMinSpeed float64
	OnReadyTest    bool
}

type RenewalResult added in v0.44.0

type RenewalResult struct {
	Server   string
	Duration time.Duration
	Error    error
}

type RevertFunc added in v0.35.0

type RevertFunc func(context.Context) error

A revert function is a function that undoes a step taken by the test. It is meant to be run after the test is done, regardless of whether it succeeded or failed.

type SSHResolver added in v0.49.0

type SSHResolver func(server string) (*sshutil.Config, error)

func SSHResolverFromMap added in v0.49.0

func SSHResolverFromMap(m map[string]*sshutil.Config) SSHResolver

type ServerAttachState added in v0.42.0

type ServerAttachState struct {
	ServerName string
	Attached   bool
	ESLAG      bool
	L3VNI      bool
}

type ServerEndpoint added in v0.49.0

type ServerEndpoint struct {
	Name    string // e.g. "server-1"
	VPC     string // e.g. "vpc-01"
	Subnet  string // e.g. "default"
	HostBGP bool
	IP      netip.Addr
}

type ServerNetconfOpts added in v0.44.0

type ServerNetconfOpts struct {
	VLAN       uint16
	HashPolicy string
	P2P        string
	MTU        uint16
}

type ServerWithInterface added in v0.44.0

type ServerWithInterface struct {
	Name      string
	Interface string
}

type SetupPeeringsOpts

type SetupPeeringsOpts struct {
	WaitSwitchesReady bool
	Requests          []string
}

type SetupVPCsOpts

type SetupVPCsOpts struct {
	WaitSwitchesReady bool
	ForceCleanup      bool
	VLANNamespace     string
	IPv4Namespace     string
	ServersPerSubnet  int
	SubnetsPerVPC     int
	DNSServers        []string
	TimeServers       []string
	InterfaceMTU      uint16
	HashPolicy        string
	VPCMode           vpcapi.VPCMode
	KeepPeerings      bool
	HostBGPSubnet     bool
	P2P               bool
}

type ShowTechOpts added in v0.44.0

type ShowTechOpts struct {
	// If empty, defaults to WorkDir/show-tech-output.
	OutputDir string
}

type ShowTechScript added in v0.34.0

type ShowTechScript struct {
	Scripts map[VMType][]byte
}

func DefaultShowTechScript added in v0.34.0

func DefaultShowTechScript() ShowTechScript

type ShutdownType added in v0.44.0

type ShutdownType int32
const (
	ShutdownTypeError ShutdownType = iota
	ShutdownTypeGraceful
)

type SkipFlags added in v0.35.0

type SkipFlags struct {
	VirtualSwitch     bool `xml:"-"` // skip if there's any virtual switch in the vlab
	NoBGPExternals    bool `xml:"-"` // skip if there are no viable BGP externals
	NoStaticExternals bool `xml:"-"` // skip if there are no viable static externals
	ExtendedOnly      bool `xml:"-"` // skip if extended tests are not enabled
	RoCE              bool `xml:"-"` // skip if RoCE is not supported by any of the leaf switches
	SubInterfaces     bool `xml:"-"` // skip if subinterfaces are not supported by some of the switches
	NoFabricLink      bool `xml:"-"` // skip if there's no fabric (i.e. spine-leaf) link between the switches
	NoMeshLink        bool `xml:"-"` // skip if there's no mesh (i.e. leaf-leaf) link between the switches
	NoGateway         bool `xml:"-"` // skip if gateway is not enabled or no gateways available
	NoLoki            bool `xml:"-"` // skip if Loki is not configured or available
	NoProm            bool `xml:"-"` // skip if Prometheus is not configured or available
	NoServers         bool `xml:"-"` // skip if there are no servers in the fabric

}

func (*SkipFlags) PrettyPrint added in v0.43.0

func (sf *SkipFlags) PrettyPrint() string

type Skipped added in v0.35.0

type Skipped struct {
	XMLName xml.Name `xml:"skipped"`
	Message string   `xml:"message,attr,omitempty"`
}

type SwitchPowerOpts added in v0.33.0

type SwitchPowerOpts struct {
	Switches    []string   // All switches if empty
	Action      pdu.Action // Power action (e.g., on, off, cycle)
	PDUUsername string
	PDUPassword string
}

type SwitchReinstallMode added in v0.33.0

type SwitchReinstallMode string
const (
	ReinstallModeReboot    SwitchReinstallMode = "reboot"
	ReinstallModeHardReset SwitchReinstallMode = "hard-reset"
)

type SwitchReinstallOpts added in v0.33.0

type SwitchReinstallOpts struct {
	Switches       []string            // All switches if empty
	Mode           SwitchReinstallMode // "reboot" or "hard-reset"
	SwitchUsername string              // Username for switch access (reboot mode only )
	SwitchPassword string              // Password for switch access (reboot mode only)
	PDUUsername    string              // (hard-reset mode only)
	PDUPassword    string              // (hard-reset mode only)
	WaitReady      bool                // Wait for the switch to be ready
}

type TemplateData added in v0.51.0

type TemplateData struct {
	// Values is what --values and --set produced
	Values map[string]any
	// Version is the hhfab version, component versions live under Fab.Status.Versions
	Version string
	// Release is the user-facing release version of the whole project, e.g. "26.04.0"
	Release string
	// Fab is the fabricator, with defaults merged in and versions calculated. For the config
	// it only holds the defaults, for the wiring it's the config after evaluation.
	Fab fabapi.Fabricator
	// Controls and Nodes are the control and fab nodes from the same config, keyed by name,
	// and empty for the config itself. Look one up with `index .Controls "control-1"` and
	// iterate with `range $name, $c := .Controls` -- text/template ranges maps in key order,
	// so the iteration is deterministic.
	Controls map[string]fabapi.ControlNode
	Nodes    map[string]fabapi.FabNode
}

TemplateData is the context available to a templated config or wiring file. Values is a map, so referencing an absent key yields an empty string (Helm-like); the rest are Go structs, where an unknown field is a template error.

type TestConnectivityOpts

type TestConnectivityOpts struct {
	WaitSwitchesReady bool
	PingsCount        int
	IPerfsSeconds     int
	IPerfsMinSpeed    float64
	IPerfsMaxSpeed    float64
	IPerfsDSCP        uint8
	IPerfsTOS         uint8
	CurlsCount        int
	Sources           []string
	Destinations      []string
	RequireAllServers bool
}

type TestFunc added in v0.35.0

A test function is a function that runs a test. It takes a go context, a test context, and a connectivity matrix, and returns a boolean indicating whether the test was skipped (e.g. due to missing resources), a list of revert functions to be run after the test, and an error if the test failed. note that the error contains the reason for the skip if the test was skipped.

type TranslatedAddress added in v0.49.0

type TranslatedAddress struct {
	// SourcePool: CIDR from which the destination may observe any source IP
	SourcePool netip.Prefix

	// DestinationIP: IP the source must target to reach the destination
	DestinationIP netip.Addr

	// DestinationPort: port the destination actually listens on, when
	// different from the source-facing port. Zero means no port translation.
	DestinationPort uint16
}

TranslatedAddress describes NAT translation expected on a path. Each field is optional; an unset field means "no translation on that axis".

type VLAB

type VLAB struct {
	SSHKey       string
	VMs          []VM
	Nets         []VLABNet
	Passthroughs []string
	Externals    ExternalsCfg
}

type VLABAccessInfo

type VLABAccessInfo struct {
	SSHPort      uint // local ssh port
	SerialSock   string
	SerialLog    string
	IsSwitch     bool // ssh through control node only
	IsControl    bool // Needed to distinguish VM type in show-tech
	IsServer     bool
	IsNode       bool // ssh through control node only
	IsExternal   bool
	RemoteSerial string // ssh to get serial
}

type VLABAccessType

type VLABAccessType string
const (
	VLABAccessSSH       VLABAccessType = "ssh"
	VLABAccessSCP       VLABAccessType = "scp"
	VLABAccessSerial    VLABAccessType = "serial"
	VLABAccessSerialLog VLABAccessType = "serial log"

	// ShowTechOutputDir is the default directory name for show-tech output
	ShowTechOutputDir = "show-tech-output"
)

type VLABBuilder

type VLABBuilder interface {
	Build(ctx context.Context, l *apiutil.Loader, f fabapi.Fabricator, nodes []fabapi.FabNode) error
}

type VLABBuilderBase added in v0.44.0

type VLABBuilderBase struct {
	// Helpers to build topologies based on non-default or mixed profiles
	DefaultSwitchProfile   string            // default switch profile to use for switches
	SwitchProfileOverrides map[string]string // switch profile overrides to use for switches
	ServerPortBase         string            // base for server port interfaces (e.g. enp2s for ports like enp2s1, enp2s2, etc.)
	NumberedLinks          bool              // annotate fabrics to hydrate fabric and mesh links with /31s instead of BGP unnumbered
	// contains filtered or unexported fields
}

type VLABBuilderDefault added in v0.44.0

type VLABBuilderDefault struct {
	SpinesCount         uint8             // number of spines to generate
	FabricLinksCount    uint8             // number of links for each spine <> leaf pair
	MeshLinksCount      uint8             // number of mesh links for each leaf <> leaf pair
	ESLAGLeafGroups     string            // eslag leaf groups - comma separated list of number of ESLAG switches in each group, should be 2-4 per group, e.g. 2,4,2 for 3 groups with 2, 4 and 2 switches
	OrphanLeafsCount    uint8             // number of non-MCLAG server-leafs to generate
	ESLAGServers        uint8             // number of ESLAG servers to generate for ESLAG switches
	UnbundledServers    uint8             // number of unbundled servers to generate for switches (only for one of the first switch in the redundancy group or orphan switch)
	BundledServers      uint8             // number of bundled servers to generate for switches (only for one of the second switch in the redundancy group or orphan switch)
	MultiHomedServers   uint8             // number of multi-homed servers (2 connections to 2 different leaves, preferably orphans)
	NoSwitches          bool              // do not generate any switches
	GatewayUplinks      uint8             // number of uplinks for gateway node to the spines
	GatewayDriver       string            // gateway driver to use for gateway node
	GatewayWorkers      uint8             // number of workers for gateway node
	GatewayLogLevel     string            // initial log level for gateway
	GatewayTags         map[string]string // tracing targets for gateway
	ExtBGPCount         uint8             // number of BGP externals to generate
	ExtStaticCount      uint8             // number of static externals to generate (no proxy)
	ExtStaticProxyCount uint8             // number of static externals to generate (with proxy)
	ExtESLAGConnCount   uint8             // number of external connections to generate from ESLAG leaves
	ExtOrphanConnCount  uint8             // number of external connections to generate from orphan leaves
	ExtraDomain         bool              // add a second domain of as many spines, orphan leaves move to it (2 orphans by default)
	SharedLeafsCount    uint8             // number of orphan leaves in both domains, the last ones (default 1 with ExtraDomain)
	ExtraFabric         bool              // generate a second fabric of two mesh leaves with a server each
	InterconnectFabrics bool              // connect a leaf of each fabric with an External on both sides
	YesFlag             bool

	VLABBuilderBase
}

func (*VLABBuilderDefault) Build added in v0.44.0

type VLABBuilderGPURail added in v0.44.0

type VLABBuilderGPURail struct {
	ScalableUnits        uint
	VPCs                 uint
	ServersPerVPCPerUnit uint
	P2P                  bool

	VLABBuilderBase
}

func (*VLABBuilderGPURail) Build added in v0.44.0

type VLABConfig

type VLABConfig struct {
	SSHKey    string              `json:"-"`
	Sizes     VMSizes             `json:"sizes"`
	VMs       map[string]VMConfig `json:"vms"`
	Externals ExternalsCfg        `json:"externals"`
}

type VLABNet added in v0.51.0

type VLABNet struct {
	Name string
	Kind VLABNetKind
	Taps int
	// Queues has the queue count of each tap QEMU opens with more than one, the kernel refuses that unless it's
	// created as a multi-queue tap
	Queues map[int]int
	// Ifaces are the host interfaces to add to the management network
	Ifaces []string
}

VLABNet is a host network VMs attach to over the taps named after it, set up by the setup-vlab-net helper

func ParseVLABNet added in v0.51.0

func ParseVLABNet(spec string) (VLABNet, error)

func (VLABNet) String added in v0.51.0

func (n VLABNet) String() string

String formats the net the way the setup-vlab-net helper takes it: name=kind[,key=value]..., e.g. "hhmgmt=mgmt,taps=12,iface=enp2s1" or "hhlink0=link,p1.queues=8"

func (VLABNet) TapName added in v0.51.0

func (n VLABNet) TapName(idx int) string

type VLABNetKind added in v0.51.0

type VLABNetKind string
const (
	// VLABNetKindMgmt is a bridge with the management taps and the host interfaces to reach hardware over
	VLABNetKindMgmt VLABNetKind = "mgmt"
	// VLABNetKindLink connects its two taps to each other as transparently as a cable would
	VLABNetKindLink VLABNetKind = "link"
)

type VLABRunOpts

type VLABRunOpts struct {
	KillStale                bool
	ControlsRestricted       bool
	ServersRestricted        bool
	BuildMode                recipe.BuildMode
	AutoUpgrade              bool
	FailFast                 bool
	OnReady                  []OnReady
	OOBMgmtIface             string
	CollectShowTech          bool
	ForceCollectShowTech     bool
	VPCMode                  vpcapi.VPCMode
	PauseOnFailure           bool
	ReleaseTestRegexes       []string
	ReleaseTestRegexesInvert bool
	ReleaseTestOnReadyOnly   bool
	InterfaceMTU             uint16
	InspectPodsStrict        bool
}

type VLABUpOpts

type VLABUpOpts struct {
	HydrateMode          HydrateMode
	NoCreate             bool
	ReCreate             bool
	BuildMode            recipe.BuildMode
	SetJoinToken         string
	ObservabilityTargets string
	VMSizesOverrides     VMSizes
	VLABRunOpts
}

type VM

type VM struct {
	ID            uint
	Name          string
	Type          VMType
	SwitchMode    VMSwitchMode
	SwitchProfile string
	Restricted    bool
	NICs          []string
	Size          VMSize
}

type VMConfig

type VMConfig struct {
	Type          VMType       `json:"type"`
	SwitchMode    VMSwitchMode `json:"switchMode,omitempty"`
	SwitchProfile string       `json:"switchProfile,omitempty"`
	// Queues is the queue pairs of the gateway's NICs on links, taken from the wiring on each run and never saved, so
	// the VLAB configs of other releases keep working for both of them
	Queues uint8             `json:"-"`
	NICs   map[string]string `json:"nics"`
}

type VMSize

type VMSize struct {
	CPU  uint `json:"cpu"`  // in cores
	RAM  uint `json:"ram"`  // in MB
	Disk uint `json:"disk"` // in GB
}

type VMSizes

type VMSizes struct {
	Control  VMSize `json:"control"`
	Switch   VMSize `json:"switch"`
	Server   VMSize `json:"server"`
	Gateway  VMSize `json:"gateway"`
	External VMSize `json:"external"`
}

type VMSwitchMode added in v0.44.0

type VMSwitchMode string
const (
	VMSwitchModeONIE  VMSwitchMode = ""
	VMSwitchModeImage VMSwitchMode = "image"
)

type VMType

type VMType string
const (
	VMTypeControl  VMType = "control"
	VMTypeSwitch   VMType = "switch"
	VMTypeServer   VMType = "server"
	VMTypeGateway  VMType = "gateway"
	VMTypeExternal VMType = "external"
)

type VPCPeeringTestCtx added in v0.35.0

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

type WaitReadyOpts added in v0.41.0

type WaitReadyOpts struct {
	AppliedFor   time.Duration
	Timeout      time.Duration
	PollInterval time.Duration
	PrintEvery   int
}

Directories

Path Synopsis
Package bench generates and drives synthetic Fabric topologies against a running VLAB control node in order to find the scalability limits of the Fabric/Fabricator control plane.
Package bench generates and drives synthetic Fabric topologies against a running VLAB control node in order to find the scalability limits of the Fabric/Fabricator control plane.

Jump to

Keyboard shortcuts

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