config

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MAXINSTANCES is the maximum number of instances boxen can allocate.
	MAXINSTANCES = 255
	// MONITORPORTBASE is the starting port ID for qemu monitor ports.
	MONITORPORTBASE = 4000
	// SERIALPORTBASE is the starting port ID for serial ports.
	SERIALPORTBASE = 5000
	// SERIALPORTLOW is the first possible serial port ID.
	SERIALPORTLOW = 5001
	// SERIALPORTHI is the last possible serial port ID.
	SERIALPORTHI = 5999
	// MGMTNATLOW is the first possible "management NAT" port ID.
	MGMTNATLOW = 30001
	// MGMTNATHI is the last possible "management NAT" port ID.
	MGMTNATHI = 39999
	// SOCKETLISTENPORTLOW is the starting port ID for "data plane" listening ports.
	SOCKETLISTENPORTLOW = 40000
	// SOCKETLISTENPORTHI is the last possible port ID for "data plane" listening ports.
	SOCKETLISTENPORTHI = 65535
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Advanced

type Advanced struct {
	Display string       `yaml:"display,omitempty"`
	Machine string       `yaml:"machine,omitempty"`
	CPU     *AdvancedCPU `yaml:"cpu,omitempty"`
}

type AdvancedCPU

type AdvancedCPU struct {
	Emulation string `yaml:"emulation,omitempty"`
	Cores     int    `yaml:"cores,omitempty"`
	Threads   int    `yaml:"threads,omitempty"`
	Sockets   int    `yaml:"sockets,omitempty"`
}

type Bridge

type Bridge struct{}

type Build

type Build struct {
	InstancePath string `yaml:"instance_path,omitempty"`
	SourcePath   string `yaml:"source_path,omitempty"`
}

type Config

type Config struct {
	Options        *GlobalOptions       `yaml:"options,omitempty"`
	Instances      map[string]*Instance `yaml:"instances,omitempty"`
	InstanceGroups map[string][]string  `yaml:"groups,omitempty"`
	Platforms      map[string]*Platform `yaml:"platforms,omitempty"`
	// contains filtered or unexported fields
}

Config is a struct representing boxen configuration data.

func NewConfig

func NewConfig() *Config

NewConfig returns a new instantiated config object.

func NewConfigFromFile

func NewConfigFromFile(f string) (*Config, error)

NewConfigFromFile returns an instantiated Config object loaded from a YAML file.

func NewPackageConfig

func NewPackageConfig() *Config

NewPackageConfig returns a new instantiated config object specifically for use during "packaging" this is mostly the same as normal, but omits the global config options (which include qemu path and available acceleration).

func (*Config) AddInstance

func (c *Config) AddInstance(name string, instance *Instance)

AddInstance safely (with a lock) adds an instance to the config object Instances map.

func (*Config) AllocatedDataPlaneListenPorts

func (c *Config) AllocatedDataPlaneListenPorts() []int

AllocatedDataPlaneListenPorts returns a slice of integers of all currently allocated "listen" ports in the local boxen config. These ports are the ephemeral range ports that get applied to the qemu udp listen ports for the "dataplane" ports of the virtual machines.

func (*Config) AllocatedHostSideNatPorts

func (c *Config) AllocatedHostSideNatPorts() []int

AllocatedHostSideNatPorts returns a slice of integers of all currently allocated "host side" nat ports in the local boxen config. These ports are the ephemeral range ports that get applied to the qemu hostfwd nat directives for the local virtual machines.

func (*Config) AllocatedInstanceIDs

func (c *Config) AllocatedInstanceIDs() []int

AllocatedInstanceIDs returns a slice of integers of all currently allocated instance IDs in the local boxen config.

func (*Config) AllocatedMonitorPorts

func (c *Config) AllocatedMonitorPorts() []int

AllocatedMonitorPorts returns a slice of integers of all currently allocated monitor port IDs in the local boxen config.

func (*Config) AllocatedSerialPorts

func (c *Config) AllocatedSerialPorts() []int

AllocatedSerialPorts returns a slice of integers of all currently allocated serial port IDs in the local boxen config.

func (*Config) DeleteInstance

func (c *Config) DeleteInstance(name string)

DeleteInstance safely (with a lock) deletes an instance from the config object Instances map.

func (*Config) Dump

func (c *Config) Dump(f string) error

Dump the config to disk at path 'f'.

func (*Config) Validate

func (c *Config) Validate() error

Validate provides basic configuration validation -- checking for things like duplicate device IDs and duplicate allocated ports.

type Credentials

type Credentials struct {
	Username string `yaml:"username,omitempty"`
	Password string `yaml:"password,omitempty"`
}

func NewDefaultCredentials

func NewDefaultCredentials() *Credentials

NewDefaultCredentials returns a Credentials object with the boxen default creds set.

type DataPlaneIntf

type DataPlaneIntf struct {
	SocketConnectMap map[int]*SocketConnectPair `yaml:"socket_connect_map,omitempty"`
}

type GlobalOptions

type GlobalOptions struct {
	Credentials *Credentials `yaml:"credentials,omitempty"`
	Qemu        *Qemu        `yaml:"qemu,omitempty"`
	Build       *Build       `yaml:"build,omitempty"`
}

type Hardware

type Hardware struct {
	Memory       int      `yaml:"memory,omitempty"`
	Acceleration []string `yaml:"acceleration,omitempty"`
	MonitorPort  int      `yaml:"monitor_port,omitempty"`
	SerialPorts  []int    `yaml:"serial_ports,omitempty"`
	NicType      string   `yaml:"nic_type,omitempty"`
	NicCount     int      `yaml:"nic_count,omitempty"`
	NicPerBus    int      `yaml:"nic_per_bus,omitempty"`
}

type Instance

type Instance struct {
	Name          string         `yaml:"name"`
	PlatformType  string         `yaml:"platform_type"`
	Disk          string         `yaml:"source_disk"`
	ID            int            `yaml:"id,omitempty"`
	PID           int            `yaml:"pid,omitempty"`
	Profile       string         `yaml:"profile,omitempty"`
	Credentials   *Credentials   `yaml:"credentials,omitempty"`
	Hardware      *Hardware      `yaml:"hardware,omitempty"`
	MgmtIntf      *MgmtIntf      `yaml:"mgmt_interface,omitempty"`
	DataPlaneIntf *DataPlaneIntf `yaml:"data_plane_interfaces,omitempty"`
	Advanced      *Advanced      `yaml:"advanced,omitempty"`
	BootDelay     int            `yaml:"boot-delay,omitempty"`
	StartupConfig string         `yaml:"startup-config,omitempty"`
}

Instance is a struct that represents a qemu virtual machine instance in the boxen configuration.

type MgmtIntf

type MgmtIntf struct {
	Nat    *Nat
	Bridge *Bridge
}

type Nat

type Nat struct {
	TCP []*NatPortPair `yaml:"tcp,omitempty"`
	UDP []*NatPortPair `yaml:"udp,omitempty"`
}

type NatPortPair

type NatPortPair struct {
	InstanceSide int `yaml:"instance_side,omitempty"`
	HostSide     int `yaml:"host_side,omitempty"`
}

func (*NatPortPair) String added in v0.0.4

func (n *NatPortPair) String() string

type Platform

type Platform struct {
	SourceDisks []string            `yaml:"source_disks,omitempty"`
	Profiles    map[string]*Profile `yaml:"profiles,omitempty"`
}

Platform contains information about a given platform -- i.e. Arista vEOS -- that is stored in the boxen configuration this includes the available hardware profiles and source disks that have been "installed".

func NewPlatform

func NewPlatform() *Platform

NewPlatform returns an empty Platform object.

type Profile

type Profile struct {
	Hardware    *ProfileHardware `yaml:"hardware,omitempty"`
	Advanced    *Advanced        `yaml:"advanced,omitempty"`
	TPCNatPorts []int            `yaml:"tcp_nat_ports,omitempty"`
	UDPNatPorts []int            `yaml:"udp_nat_ports,omitempty"`
}

Profile is a struct containing information about the virtual machine hardware and port allocation as stored in the boxen configuration.

type ProfileHardware

type ProfileHardware struct {
	Memory          int      `yaml:"memory,omitempty"`
	Acceleration    []string `yaml:"acceleration,omitempty"`
	SerialPortCount int      `yaml:"serial_port_count,omitempty"`
	NicType         string   `yaml:"nic_type,omitempty"`
	NicCount        int      `yaml:"nic_count,omitempty"`
	NicPerBus       int      `yaml:"nic_per_bus,omitempty"`
}

func (*ProfileHardware) ToHardware

func (p *ProfileHardware) ToHardware() *Hardware

type Qemu

type Qemu struct {
	Acceleration []string `yaml:"acceleration,omitempty"`
	Binary       string   `yaml:"binary,omitempty"`
	// UseThickDisks copies full disks instead of creating qemu disks with a backing chain
	UseThickDisks bool `yaml:"use_thick_disks,omitempty"`
}

type SocketConnectPair

type SocketConnectPair struct {
	Connect int `yaml:"connect,omitempty"`
	Listen  int `yaml:"listen,omitempty"`
}

Jump to

Keyboard shortcuts

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