vlab

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2023 License: Apache-2.0 Imports: 23 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 (
	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
)
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: 1024,
}
View Source
var FullSwitchVM = 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",
}

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 LinkConfig added in v0.6.0

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

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

func (svc *Service) StartServer(killStaleVMs bool, installComplete bool, runComplete string) 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
	InstallComplete   bool
	RunComplete       string
	Basedir           string
	Wiring            *wiring.Data
	ControlIgnition   string
	ServerIgnitionDir string
	ControlInstaller  string
	ServerInstaller   string
	FilesDir          string
	SshKey            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, svcCfg *ServiceConfig)

func (*VM) RunInstall

func (vm *VM) RunInstall(ctx context.Context, svcCfg *ServiceConfig) 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) (*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