vlab

package
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: Apache-2.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HHFAB_CFG_PREFIX               = ".hhfab.fabric.githedgehog.com"
	HHFAB_CFG_TYPE                 = "type" + HHFAB_CFG_PREFIX
	HHFAB_CFG_SERIAL               = "serial" + HHFAB_CFG_PREFIX
	HHFAB_CFG_LINK_PREFIX          = "link" + HHFAB_CFG_PREFIX + "/"
	HHFAB_CFG_PCI_PREFIX           = "pci@"
	HHFAB_CFG_SERIAL_SCHEME_SSH    = "ssh://"
	HHFAB_CFG_SERIAL_SCHEME_TELNET = "telnet://"
)
View Source
const (
	VPCSetupTypeVPCPerServer       = "vpc-per-server"
	VPCSetupTypeSingleVPC          = "single-vpc"
	VPCSetupTypeVPCSubnetPerServer = "subnet-per-server"
)
View Source
const (
	MAC_ADDR_TMPL        = "0c:20:12:fe:%02d:%02d" // if changing update onie-qcow2-eeprom-edit config too
	KUBE_PORT            = 6443
	REGISTRY_PORT        = 31000
	SSH_PORT_BASE        = 22000
	IF_PORT_BASE         = 30000
	IF_PORT_NULL         = IF_PORT_BASE + 9000
	IF_PORT_VM_ID_MULT   = 100
	IF_PORT_PORT_ID_MULT = 1
)
View Source
const (
	VM_SELECTOR_SSH = "ssh"
	VM_SELECTOR_ALL = "all"
)
View Source
const (
	VM_SIZE_DEFAULT = "default" // meaningful VM sizes for dev & testing
	VM_SIZE_COMPACT = "compact" // minimal working setup, applied on top of default
	VM_SIZE_FULL    = "full"    // full setup as specified in requirements and more real switch resources, applied on top of default
	VM_SIZE_HUGE    = "huge"    // full setup with more resources for servers, applied on top of default

	VIRTUAL_EDGE_ANNOTATION = "external.hhfab.fabric.githedgehog.com/dest" // HHFAB annotation to specify destination for external connection
)
View Source
const (
	IFACES_PER_PCI_BRIDGE = 32
)

Variables

View Source
var CompactControlVM = VMConfig{
	CPU:  4,
	RAM:  4096,
	Disk: 50,
}
View Source
var CompactServerVM = VMConfig{
	CPU: 1,
}
View Source
var CompactSwitchVM = VMConfig{
	CPU:  3,
	RAM:  3584,
	Disk: 30,
}
View Source
var DefaultControlVM = VMConfig{
	CPU:  6,
	RAM:  6144,
	Disk: 100,
}
View Source
var DefaultServerVM = VMConfig{
	CPU:  2,
	RAM:  768,
	Disk: 10,
}
View Source
var DefaultSwitchVM = VMConfig{
	CPU:  4,
	RAM:  5120,
	Disk: 50,
}
View Source
var FullControlVM = VMConfig{
	CPU:  8,
	RAM:  16384,
	Disk: 250,
}
View Source
var FullServerVM = VMConfig{
	RAM: 2048,
}
View Source
var FullSwitchVM = VMConfig{
	RAM: 8192,
}
View Source
var HugeControlVM = VMConfig{
	CPU:  8,
	RAM:  16384,
	Disk: 250,
}
View Source
var HugeServerVM = VMConfig{
	CPU: 4,
	RAM: 8192,
}
View Source
var HugeSwitchVM = VMConfig{
	RAM: 8192,
}
View Source
var RequiredCommands = []string{
	"qemu-system-x86_64",
	"qemu-img",
	"tpm2",
	"swtpm_setup",
	"ssh",
	"scp",
	"sudo",
}
View Source
var SSH_QUIET_FLAGS = []string{
	"-o", "GlobalKnownHostsFile=/dev/null",
	"-o", "UserKnownHostsFile=/dev/null",
	"-o", "StrictHostKeyChecking=no",
	"-o", "LogLevel=ERROR",
}
View Source
var VPCSetupTypes = []string{
	VPCSetupTypeVPCPerServer,
}

Functions

func InitTPMConfig

func InitTPMConfig(ctx context.Context, svcCfg *ServiceConfig) error

Makes sure that swtpm config is initialized before we start VMs

Types

type Config

type Config struct {
	VMs      VMsConfig               `json:"vms,omitempty"`
	Switches map[string]SwitchConfig `json:"switches,omitempty"`
	Links    map[string]LinkConfig   `json:"links,omitempty"`
}

type ConfigSwitchType added in v0.6.0

type ConfigSwitchType string
const (
	ConfigSwitchTypeVS ConfigSwitchType = "vs"
	ConfigSwitchTypeHW ConfigSwitchType = "hw"
)

type Iperf3Report added in v0.6.18

type Iperf3Report struct {
	Intervals []Iperf3ReportInterval `json:"intervals"`
	End       Iperf3ReportEnd        `json:"end"`
}

type Iperf3ReportEnd added in v0.6.18

type Iperf3ReportEnd struct {
	SumSent     Iperf3ReportSum `json:"sum_sent"`
	SumReceived Iperf3ReportSum `json:"sum_received"`
}

type Iperf3ReportInterval added in v0.6.18

type Iperf3ReportInterval struct {
	Sum Iperf3ReportSum `json:"sum"`
}

type Iperf3ReportSum added in v0.6.18

type Iperf3ReportSum struct {
	Bytes         int64   `json:"bytes"`
	BitsPerSecond float64 `json:"bits_per_second"`
}

type LinkConfig added in v0.6.0

type LinkConfig struct {
	PCIAddress string `json:"pci,omitempty"`
}

type Server added in v0.6.18

type Server struct {
	Name string
	VM   *VM

	ConnectedTo    []string
	ConnectionType string

	Server          *wiringapi.Server
	Connection      *wiringapi.Connection
	VPCAttachment   *vpcapi.VPCAttachment
	VPC             *vpcapi.VPC
	Subnet          string
	ExternalPeering *vpcapi.ExternalPeering

	InVPCPeers []string
	VPCPeers   []string
	Externals  []string

	IP string
}

type ServerConnectivityTestConfig added in v0.6.18

type ServerConnectivityTestConfig struct {
	AgentCheck bool

	InVPC         bool
	VPC           bool
	VPCPing       uint
	VPCIperf      uint
	VPCIperfSpeed uint

	Ext     bool
	ExtCurl bool
}

type Service

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

func Load

func Load(cfg *ServiceConfig) (*Service, error)

func (*Service) List

func (svc *Service) List() error

func (*Service) SSH

func (svc *Service) SSH(name string, args []string) error

func (*Service) Serial

func (svc *Service) Serial(name string) error

func (*Service) SetupPeerings added in v0.7.1

func (svc *Service) SetupPeerings(ctx context.Context, cfg SetupPeeringsConfig) error

TODO move vpc creation to here, just have flag --vpc-per-server

func (*Service) SetupVPCs added in v0.7.1

func (svc *Service) SetupVPCs(ctx context.Context, cfg SetupVPCsConfig) error

func (*Service) StartServer

func (svc *Service) StartServer(killStaleVMs bool, charNBDDev string, installComplete bool, runComplete string, onReady []string) error

func (*Service) TestConnectivity added in v0.7.1

func (svc *Service) TestConnectivity(ctx context.Context, cfg ServerConnectivityTestConfig) error

func (*Service) VFIOPCIBindAll added in v0.6.0

func (svc *Service) VFIOPCIBindAll() error

type ServiceConfig added in v0.6.0

type ServiceConfig struct {
	DryRun            bool
	Size              string
	SudoSwtpm         bool
	CharNBDDev        string
	InstallComplete   bool
	RunComplete       string
	OnReady           []string
	RestrictServers   bool
	Basedir           string
	Wiring            *wiring.Data
	ControlIgnition   string
	ServerIgnitionDir string
	ControlInstaller  string
	ServerInstaller   string
	FilesDir          string
	SshKey            string
}

type SetupPeeringsConfig added in v0.7.1

type SetupPeeringsConfig struct {
	AgentCheck bool
	DryRun     bool
	CleanupAll bool
	Requests   []string
}

type SetupVPCsConfig added in v0.7.1

type SetupVPCsConfig struct {
	Type string
}

type SwitchConfig added in v0.6.0

type SwitchConfig struct {
	Type   ConfigSwitchType `json:"type,omitempty"`
	Serial string           `json:"serial,omitempty"`
}

type VM

type VM struct {
	ID         int
	Name       string
	Type       VMType
	Basedir    string
	Config     VMConfig
	Interfaces map[int]VMInterface

	Ready     fileMarker
	Installed fileMarker
}

func (*VM) OnieEepromConfig added in v0.6.0

func (vm *VM) OnieEepromConfig() (string, error)

func (*VM) Prepare

func (vm *VM) Prepare(ctx context.Context, svcCfg *ServiceConfig) error

func (*VM) Run

func (vm *VM) Run(ctx context.Context, eg *errgroup.Group, svc *Service)

func (*VM) RunInstall

func (vm *VM) RunInstall(ctx context.Context, svc *Service) func() error

func (*VM) RunTPM

func (vm *VM) RunTPM(ctx context.Context, svcCfg *ServiceConfig) func() error

func (*VM) RunVM

func (vm *VM) RunVM(ctx context.Context, svcCfg *ServiceConfig) func() error

func (*VM) UUID

func (vm *VM) UUID() string

type VMConfig added in v0.6.0

type VMConfig struct {
	CPU  int `json:"cpu,omitempty"`  // in cores
	RAM  int `json:"ram,omitempty"`  // in MB
	Disk int `json:"disk,omitempty"` // in GB
}

func (VMConfig) DefaultsFrom added in v0.6.0

func (cfg VMConfig) DefaultsFrom(def VMConfig) VMConfig

func (VMConfig) OverrideBy added in v0.6.0

func (cfg VMConfig) OverrideBy(def VMConfig) VMConfig

type VMInterface added in v0.6.0

type VMInterface struct {
	Connection  string
	Netdev      string
	Passthrough string
}

type VMManager added in v0.6.0

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

func NewVMManager added in v0.6.0

func NewVMManager(cfg *Config, data *wiring.Data, basedir string, size string, restrictServers bool) (*VMManager, error)
func (mngr *VMManager) AddLink(local wiringapi.IPort, dest wiringapi.IPort, conn string) error

func (*VMManager) LogOverview added in v0.6.0

func (mngr *VMManager) LogOverview()

type VMType added in v0.6.0

type VMType string
const (
	VMTypeControl  VMType = "control"
	VMTypeServer   VMType = "server"
	VMTypeSwitchVS VMType = "switch-vs"
	VMTypeSwitchHW VMType = "switch-hw" // fake VM to simplify calculations
)

type VMsConfig added in v0.6.0

type VMsConfig struct {
	Control VMConfig `json:"control,omitempty"`
	Server  VMConfig `json:"server,omitempty"`
	Switch  VMConfig `json:"switch,omitempty"`
}

Jump to

Keyboard shortcuts

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