vlab

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2023 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

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

Variables

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, cfg *Config) error

Makes sure that swtpm config is initialized before we start VMs

Types

type Config

type Config struct {
	DryRun            bool
	Compact           bool
	InstallComplete   bool
	RunComplete       string
	Basedir           string
	Wiring            *wiring.Data
	ControlIgnition   string
	ServerIgnitionDir string
	ControlInstaller  string
	FilesDir          string
	SshKey            string
}
type Link struct {
	DevID string
	MAC   string

	LocalIfPort   int
	LocalPortName string
	DestName      string
	DestIfPort    int
	DestPortName  string

	// Only for control node for now
	IsHostFwd    bool
	SSHPort      int
	KubePort     int
	RegistryPort int
}

type Service

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

func Load

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

func (*Service) AddConnection

func (svc *Service) AddConnection(conn *wiringapi.Connection) error
func (svc *Service) AddControlHostFwdLink(vm *VM) error
func (svc *Service) AddLink(local wiringapi.IPort, dest wiringapi.IPort) error
func (svc *Service) AddNullLink(local wiringapi.IPort) error

func (*Service) AddVM

func (svc *Service) AddVM(name string, os VMOS, control bool) 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, compact bool, installComplete bool, runComplete string) error

type VM

type VM struct {
	Basedir   string
	ID        int
	Name      string
	OS        VMOS
	IsControl bool

	Links   []*Link
	SSHPort int

	Cfg *Config

	TPMReady chan any // TODO

	Ready     fileMarker
	Installed fileMarker
}

func (*VM) Prepare

func (vm *VM) Prepare(ctx context.Context, cfg *Config) error

func (*VM) Run

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

func (*VM) RunInstall

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

func (*VM) RunTPM

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

func (*VM) RunVM

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

func (*VM) UUID

func (vm *VM) UUID() string

type VMOS

type VMOS string
const (
	VMOS_ONIE    VMOS = "onie"
	VMOS_FLATCAR VMOS = "flatcar"
)

Jump to

Keyboard shortcuts

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