boxen

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: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Version = "0.0.0" //nolint: gochecknoglobals

Functions

func GetDefaultProfile

func GetDefaultProfile(pt string) (*config.Profile, error)

GetDefaultProfile fetches the default instance profile for a given platform type 'pt'.

func ZipPlatformProfileNats added in v0.0.4

func ZipPlatformProfileNats(
	platformTCPPorts, platformUDPPorts []int,
) (tcpNats, udpNats []*config.NatPortPair)

ZipPlatformProfileNats receives the lists of TCP and UDP ports that are defined in a platform profile yaml. For each received tcp/udp instance port a host port is allocated sequentially from the hostPortBase port number. These port mappings are used in packaging workflow (e.g. when building for containerlab).

Types

type Boxen

type Boxen struct {
	ConfigPath string
	Config     *config.Config

	Instances map[string]platforms.Platform

	Logger *logging.Instance
	// contains filtered or unexported fields
}

Boxen is the main "manager"/instance containing all the configuration data and maps of instances.

func NewBoxen

func NewBoxen(opts ...Option) (*Boxen, error)

NewBoxen returns an instance of Boxen with any provided Option applied.

func (*Boxen) DeProvision

func (b *Boxen) DeProvision(instance string) error

DeProvision does what it says -- it "deprovisions" an instance from the Boxen configuration. This is only useful/relevant for "local" boxen operations, i.e. VMs not containerized/packaged as you would use with Containerlab.

func (*Boxen) GetGroupInstances

func (b *Boxen) GetGroupInstances(group string) ([]string, error)

GetGroupInstances returns a slice of instance names for a provided group.

func (*Boxen) Init

func (b *Boxen) Init(d string) error

Init initializes a boxen directory structure.

func (*Boxen) Install

func (b *Boxen) Install(
	disk, username, password, vendor, platform, version string,
) error

Install "installs" a disk as a source disk which local instances can be provisioned to boot from. This is only useful/relevant in the local VM (not Containerlab) mode of operation. Install handles disabling initial config dialogs/prompts, setting base credentials, and then storing the image for use for later provisioned instances.

func (*Boxen) PackageBuild

func (b *Boxen) PackageBuild(
	disk, username, password, repo, tag, vendor, platform, version string,
) error

PackageBuild is the initial entrypoint for "packaging" an instance as a container image. This function will create a copy of the provided disk, build an install container image, then run that image which will kick off the PackageInstall function. After installation (dealing with the initial prompts and installing a base config and such) is complete, the disk image is copied out of the install container, the install container is then destroyed, with the initial build image. Finally, this function will build a final container image, copying in the provisioned disk into the final image.

func (*Boxen) PackageInstall

func (b *Boxen) PackageInstall() error

PackageInstall is the function that is run *in* the initially built container image. This function handles the initial provisioning of the instance.

func (*Boxen) PackageStart

func (b *Boxen) PackageStart(username, password, hostname, config string) error

PackageStart starts the qemu instance vm inside a packaged boxen container.

func (*Boxen) Provision

func (b *Boxen) Provision(instance, vendor, platform, sourceDisk, profile string) error

Provision creates all the required config objects/port allocation/etc. for a local boxen instance.

func (*Boxen) RenderInitialConfig

func (b *Boxen) RenderInitialConfig(
	name string,
) ([]string, error)

RenderInitialConfig renders the initial installation config template.

func (*Boxen) Start

func (b *Boxen) Start(name string) error

Start starts a local boxen instance.

func (*Boxen) Stop

func (b *Boxen) Stop(name string) error

Stop stops a local boxen instance.

func (*Boxen) UnInstall

func (b *Boxen) UnInstall(pT, disk string) error

UnInstall removes an installed source disk from the local boxen config.

type Disk

type Disk struct {
	Disk         string
	Vendor       string
	Platform     string
	PlatformType string
	Version      string
}

type Option

type Option func(*args) error

func WithConfig

func WithConfig(f string) Option

WithConfig allows for passing a config file path f to the NewBoxen function.

func WithLogger

func WithLogger(l *logging.Instance) Option

WithLogger allows for passing a boxen logging.Instance l to the NewBoxen function.

Jump to

Keyboard shortcuts

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