types

package
v0.32.1 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2022 License: BSD-3-Clause Imports: 13 Imported by: 3

Documentation

Index

Constants

View Source
const (
	// env var containing the expected number of interfaces injected into every container.
	CLAB_ENV_INTFS = "CLAB_INTFS"
)

Variables

This section is empty.

Functions

func DisableTxOffload added in v0.15.0

func DisableTxOffload(n *NodeConfig) error

Types

type ConfigDispatcher added in v0.15.0

type ConfigDispatcher struct {
	Vars map[string]interface{} `yaml:"vars,omitempty"`
}

ConfigDispatcher represents the config of a configuration machine that is responsible to execute configuration commands on the nodes after they started.

func (*ConfigDispatcher) GetVars added in v0.15.0

func (cd *ConfigDispatcher) GetVars() map[string]interface{}

type ContainerDetails added in v0.25.0

type ContainerDetails struct {
	LabName     string `json:"lab_name,omitempty"`
	LabPath     string `json:"labPath,omitempty"`
	Name        string `json:"name,omitempty"`
	ContainerID string `json:"container_id,omitempty"`
	Image       string `json:"image,omitempty"`
	Kind        string `json:"kind,omitempty"`
	Group       string `json:"group,omitempty"`
	State       string `json:"state,omitempty"`
	IPv4Address string `json:"ipv4_address,omitempty"`
	IPv6Address string `json:"ipv6_address,omitempty"`
}

ContainerDetails contains information that is commonly outputted to tables or graphs.

type ContainerMount added in v0.31.0

type ContainerMount struct {
	Source      string
	Destination string
}

type Endpoint

type Endpoint struct {
	Node *NodeConfig
	// e1-x, eth, etc
	EndpointName string
	// mac address
	MAC string
}

Endpoint is a struct that contains information of a link endpoint.

type Extras added in v0.18.0

type Extras struct {
	SRLAgents []string `yaml:"srl-agents,omitempty"`
	// Nokia SR Linux agents. As of now just the agents spec files can be provided here
	MysocketProxy string `yaml:"mysocket-proxy,omitempty"`
	// Proxy address that mysocketctl will use
	CeosCopyToFlash []string `yaml:"ceos-copy-to-flash,omitempty"`
}

Extras contains extra node parameters which are not entitled to be part of a generic node config.

type GenericContainer

type GenericContainer struct {
	Names           []string
	ID              string
	ShortID         string // trimmed ID for display purposes
	Image           string
	State           string
	Status          string
	Labels          map[string]string
	Pid             int
	NetworkSettings GenericMgmtIPs
	Mounts          []ContainerMount
}

GenericContainer stores generic container data.

func (*GenericContainer) GetContainerIPv4 added in v0.25.0

func (ctr *GenericContainer) GetContainerIPv4() string

func (*GenericContainer) GetContainerIPv6 added in v0.25.0

func (ctr *GenericContainer) GetContainerIPv6() string

type GenericFilter added in v0.15.0

type GenericFilter struct {
	// defined by now "label"
	FilterType string
	// defines e.g. the label name for FilterType "label"
	Field string
	// = | != | exists
	Operator string
	// match value
	Match string
}

func FilterFromLabelStrings added in v0.15.0

func FilterFromLabelStrings(labels []string) []*GenericFilter

type GenericMgmtIPs

type GenericMgmtIPs struct {
	IPv4addr string
	IPv4pLen int
	IPv4Gw   string
	IPv6addr string
	IPv6pLen int
	IPv6Gw   string
}

type HostRequirements added in v0.26.0

type HostRequirements struct {
	SSE3         bool `json:"sse3,omitempty"`          // sse3 cpu instruction
	VirtRequired bool `json:"virt-required,omitempty"` // indicates that KVM virtualization is required for this node to run
}

type LabData added in v0.31.0

type LabData struct {
	Containers []ContainerDetails `json:"containers"`
	MySocketIo []*MySocketIoEntry `json:"mysocketio"`
}
type Link struct {
	A      *Endpoint
	B      *Endpoint
	MTU    int
	Labels map[string]string
	Vars   map[string]interface{}
}

Link is a struct that contains the information of a link between 2 containers.

func (*Link) String added in v0.15.0

func (link *Link) String() string

type LinkConfig added in v0.15.0

type LinkConfig struct {
	Endpoints []string
	Labels    map[string]string      `yaml:"labels,omitempty"`
	Vars      map[string]interface{} `yaml:"vars,omitempty"`
}

type MgmtNet

type MgmtNet struct {
	Network string `yaml:"network,omitempty" json:"network,omitempty"` // container runtime network name
	Bridge  string `yaml:"bridge,omitempty" json:"bridge,omitempty"`
	// linux bridge backing the runtime network
	IPv4Subnet     string `yaml:"ipv4_subnet,omitempty" json:"ipv4-subnet,omitempty"`
	IPv4Gw         string `yaml:"ipv4-gw,omitempty" json:"ipv4-gw,omitempty"`
	IPv6Subnet     string `yaml:"ipv6_subnet,omitempty" json:"ipv6-subnet,omitempty"`
	IPv6Gw         string `yaml:"ipv6-gw,omitempty" json:"ipv6-gw,omitempty"`
	MTU            string `yaml:"mtu,omitempty" json:"mtu,omitempty"`
	ExternalAccess *bool  `yaml:"external-access,omitempty" json:"external-access,omitempty"`
}

MgmtNet struct defines the management network options.

type MySocketIoEntry added in v0.31.0

type MySocketIoEntry struct {
	SocketId  *string `json:"socket_id,omitempty"`
	DnsName   *string `json:"dns_name,omitempty"`
	Ports     []int   `json:"ports,omitempty"`
	Type      *string `json:"type,omitempty"`
	CloudAuth bool    `json:"cloud_auth,omitempty"`
	Name      *string `json:"name,omitempty"`
	LabName   *string `json:"lab_name,omitempty"`
}

type NodeConfig added in v0.15.0

type NodeConfig struct {
	// name of the Node inside topology YAML
	ShortName string `json:"shortname,omitempty"`
	// containerlab-prefixed unique container name
	LongName string `json:"longname,omitempty"`
	Fqdn     string `json:"fqdn,omitempty"`
	// LabDir is a directory related to the node, it contains config items and/or other persistent state
	LabDir string `json:"labdir,omitempty"`
	Index  int    `json:"index,omitempty"`
	Group  string `json:"group,omitempty"`
	Kind   string `json:"kind,omitempty"`
	// path to config template file that is used for startup config generation
	StartupConfig string `json:"startup-config,omitempty"`
	// optional delay (in seconds) to wait before creating this node
	StartupDelay uint `json:"startup-delay,omitempty"`
	// when set to true will enforce the use of startup-config, even when config is present in the lab directory
	EnforceStartupConfig bool `json:"enforce-startup-config,omitempty"`
	// path to config file that is actually mounted to the container and is a result of templation
	ResStartupConfig string            `json:"startup-config-abs-path,omitempty"`
	Config           *ConfigDispatcher `json:"config,omitempty"`
	// path to config file that is actually mounted to the container and is a result of templation
	ResConfig  string            `json:"config-abs-path,omitempty"`
	NodeType   string            `json:"type,omitempty"`
	Position   string            `json:"position,omitempty"`
	License    string            `json:"license,omitempty"`
	Image      string            `json:"image,omitempty"`
	Sysctls    map[string]string `json:"sysctls,omitempty"`
	User       string            `json:"user,omitempty"`
	Entrypoint string            `json:"entrypoint,omitempty"`
	Cmd        string            `json:"cmd,omitempty"`
	Exec       []string          `json:"exec,omitempty"`
	Env        map[string]string `json:"env,omitempty"`
	// Bind mounts strings (src:dest:options).
	Binds []string `json:"binds,omitempty"`
	// PortBindings define the bindings between the container ports and host ports
	PortBindings nat.PortMap `json:"portbindings,omitempty"`
	// PortSet define the ports that should be exposed on a container
	PortSet nat.PortSet `json:"portset,omitempty"`
	// NetworkMode defines container networking mode.
	// If set to `host` the host networking will be used for this node, else bridged network
	NetworkMode string `json:"networkmode,omitempty"`
	// MgmtNet is the name of the docker network this node is connected to with its first interface
	MgmtNet string `json:"mgmt-net,omitempty"`
	// MgmtIntf can be used to be rendered by the default node template
	MgmtIntf             string `json:"mgmt-intf,omitempty"`
	MgmtIPv4Address      string `json:"mgmt-ipv4-address,omitempty"`
	MgmtIPv4PrefixLength int    `json:"mgmt-ipv4-prefix-length,omitempty"`
	MgmtIPv6Address      string `json:"mgmt-ipv6-address,omitempty"`
	MgmtIPv6PrefixLength int    `json:"mgmt-ipv6-prefix-length,omitempty"`
	MgmtIPv4Gateway      string `json:"mgmt-ipv4-gateway,omitempty"`
	MgmtIPv6Gateway      string `json:"mgmt-ipv6-gateway,omitempty"`
	MacAddress           string `json:"mac-address,omitempty"`
	ContainerID          string `json:"containerid,omitempty"`
	TLSCert              string `json:"tls-cert,omitempty"`
	TLSKey               string `json:"-"` // Do not marshal into JSON - highly sensitive data
	TLSAnchor            string `json:"tls-anchor,omitempty"`
	NSPath               string `json:"nspath,omitempty"` // network namespace path for this node
	// list of ports to publish with mysocketctl
	Publish []string `json:"publish,omitempty"`
	// Extra /etc/hosts entries for all nodes.
	ExtraHosts []string          `json:"extra-hosts,omitempty"`
	Labels     map[string]string `json:"labels,omitempty"` // container labels
	// Slice of pointers to local endpoints, DO NOT marshal into JSON as it creates a cyclical error
	Endpoints []Endpoint `json:"-"`
	// List of Subject Alternative Names (SAN) to be added to the node's TLS certificate
	SANs []string `json:"SANs,omitempty"`
	// Ignite sandbox and kernel imageNames
	Sandbox string `json:"sandbox,omitempty"`
	Kernel  string `json:"kernel,omitempty"`
	// Configured container runtime
	Runtime string `json:"runtime,omitempty"`
	// Resource limits
	CPU    float64 `json:"cpu,omitempty"`
	CPUSet string  `json:"cpuset,omitempty"`
	Memory string  `json:"memory,omitempty"`
	// Host requirements
	HostRequirements HostRequirements `json:"host-requirements,omitempty"`

	// status that is set by containerlab to indicate deployment stage
	DeploymentStatus string `json:"deployment-status,omitempty"`

	// Extras
	Extras  *Extras  `json:"extras,omitempty"` // Extra node parameters
	WaitFor []string `json:"wait-for,omitempty"`
}

NodeConfig is a struct that contains the information of a container element.

func (*NodeConfig) GenerateConfig added in v0.15.0

func (node *NodeConfig) GenerateConfig(dst, templ string) error

GenerateConfig generates configuration for the nodes out of the template based on the node configuration and saves the result to dst.

type NodeDefinition added in v0.15.0

type NodeDefinition struct {
	Kind                 string            `yaml:"kind,omitempty"`
	Group                string            `yaml:"group,omitempty"`
	Type                 string            `yaml:"type,omitempty"`
	StartupConfig        string            `yaml:"startup-config,omitempty"`
	StartupDelay         uint              `yaml:"startup-delay,omitempty"`
	EnforceStartupConfig bool              `yaml:"enforce-startup-config,omitempty"`
	Config               *ConfigDispatcher `yaml:"config,omitempty"`
	Image                string            `yaml:"image,omitempty"`
	License              string            `yaml:"license,omitempty"`
	Position             string            `yaml:"position,omitempty"`
	Entrypoint           string            `yaml:"entrypoint,omitempty"`
	Cmd                  string            `yaml:"cmd,omitempty"`
	// list of subject Alternative Names (SAN) to be added to the node's certificate
	SANs []string `yaml:"SANs,omitempty"`
	// list of commands to run in container
	Exec []string `yaml:"exec,omitempty"`
	// list of bind mount compatible strings
	Binds []string `yaml:"binds,omitempty"`
	// list of port bindings
	Ports []string `yaml:"ports,omitempty"`
	// user-defined IPv4 address in the management network
	MgmtIPv4 string `yaml:"mgmt_ipv4,omitempty"`
	// user-defined IPv6 address in the management network
	MgmtIPv6 string `yaml:"mgmt_ipv6,omitempty"`
	// list of ports to publish with mysocketctl
	Publish []string `yaml:"publish,omitempty"`
	// environment variables
	Env map[string]string `yaml:"env,omitempty"`
	// external file containing environment variables
	EnvFiles []string `yaml:"env-files,omitempty"`
	// linux user used in a container
	User string `yaml:"user,omitempty"`
	// container labels
	Labels map[string]string `yaml:"labels,omitempty"`
	// container networking mode. if set to `host` the host networking will be used for this node, else bridged network
	NetworkMode string `yaml:"network-mode,omitempty"`
	// Ignite sandbox and kernel imageNames
	Sandbox string `yaml:"sandbox,omitempty"`
	Kernel  string `yaml:"kernel,omitempty"`
	// Override container runtime
	Runtime string `yaml:"runtime,omitempty"`
	// Set node CPU (cgroup or hypervisor)
	CPU float64 `yaml:"cpu,omitempty"`
	// Set node CPUs to use
	CPUSet string `yaml:"cpu-set,omitempty"`
	// Set node Memory (cgroup or hypervisor)
	Memory string `yaml:"memory,omitempty"`
	// Set the nodes Sysctl
	Sysctls map[string]string `yaml:"sysctls,omitempty"`
	// Extra options, may be kind specific
	Extras *Extras `yaml:"extras,omitempty"`
	// List of node names to wait for before satarting this particular node
	WaitFor []string `yaml:"wait-for,omitempty"`
}

NodeDefinition represents a configuration a given node can have in the lab definition file.

func (*NodeDefinition) GetBinds added in v0.15.0

func (n *NodeDefinition) GetBinds() []string

func (*NodeDefinition) GetCmd added in v0.15.0

func (n *NodeDefinition) GetCmd() string

func (*NodeDefinition) GetConfigDispatcher added in v0.15.0

func (n *NodeDefinition) GetConfigDispatcher() *ConfigDispatcher

func (*NodeDefinition) GetEnforceStartupConfig added in v0.17.0

func (n *NodeDefinition) GetEnforceStartupConfig() bool

func (*NodeDefinition) GetEntrypoint added in v0.18.0

func (n *NodeDefinition) GetEntrypoint() string

func (*NodeDefinition) GetEnv added in v0.15.0

func (n *NodeDefinition) GetEnv() map[string]string

func (*NodeDefinition) GetEnvFiles added in v0.26.0

func (n *NodeDefinition) GetEnvFiles() []string

func (*NodeDefinition) GetExec added in v0.18.0

func (n *NodeDefinition) GetExec() []string

func (*NodeDefinition) GetExtras added in v0.18.0

func (n *NodeDefinition) GetExtras() *Extras

func (*NodeDefinition) GetGroup added in v0.15.0

func (n *NodeDefinition) GetGroup() string

func (*NodeDefinition) GetImage added in v0.15.0

func (n *NodeDefinition) GetImage() string

func (*NodeDefinition) GetKind added in v0.15.0

func (n *NodeDefinition) GetKind() string

func (*NodeDefinition) GetLabels added in v0.15.0

func (n *NodeDefinition) GetLabels() map[string]string

func (*NodeDefinition) GetLicense added in v0.15.0

func (n *NodeDefinition) GetLicense() string

func (*NodeDefinition) GetMgmtIPv4 added in v0.15.0

func (n *NodeDefinition) GetMgmtIPv4() string

func (*NodeDefinition) GetMgmtIPv6 added in v0.15.0

func (n *NodeDefinition) GetMgmtIPv6() string

func (*NodeDefinition) GetNetworkMode added in v0.15.0

func (n *NodeDefinition) GetNetworkMode() string

func (*NodeDefinition) GetNodeCPU added in v0.16.2

func (n *NodeDefinition) GetNodeCPU() float64

func (*NodeDefinition) GetNodeCPUSet added in v0.20.0

func (n *NodeDefinition) GetNodeCPUSet() string

func (*NodeDefinition) GetNodeKernel added in v0.15.0

func (n *NodeDefinition) GetNodeKernel() string

func (*NodeDefinition) GetNodeMemory added in v0.20.0

func (n *NodeDefinition) GetNodeMemory() string

func (*NodeDefinition) GetNodeRuntime added in v0.15.0

func (n *NodeDefinition) GetNodeRuntime() string

func (*NodeDefinition) GetNodeSandbox added in v0.15.0

func (n *NodeDefinition) GetNodeSandbox() string

func (*NodeDefinition) GetPorts added in v0.15.0

func (n *NodeDefinition) GetPorts() []string

func (*NodeDefinition) GetPostion added in v0.15.0

func (n *NodeDefinition) GetPostion() string

func (*NodeDefinition) GetPublish added in v0.15.0

func (n *NodeDefinition) GetPublish() []string

func (*NodeDefinition) GetSANs added in v0.31.0

func (n *NodeDefinition) GetSANs() []string

func (*NodeDefinition) GetStartupConfig added in v0.15.0

func (n *NodeDefinition) GetStartupConfig() string

func (*NodeDefinition) GetStartupDelay added in v0.17.0

func (n *NodeDefinition) GetStartupDelay() uint

func (*NodeDefinition) GetSysctls added in v0.26.0

func (n *NodeDefinition) GetSysctls() map[string]string

func (*NodeDefinition) GetType added in v0.15.0

func (n *NodeDefinition) GetType() string

func (*NodeDefinition) GetUser added in v0.15.0

func (n *NodeDefinition) GetUser() string

func (*NodeDefinition) GetWaitFor added in v0.32.0

func (n *NodeDefinition) GetWaitFor() []string

func (*NodeDefinition) ImportEnvs added in v0.17.0

func (n *NodeDefinition) ImportEnvs()

ImportEnvs imports all environment variales defined in the shell if __IMPORT_ENVS is set to true.

type Topology added in v0.15.0

type Topology struct {
	Defaults *NodeDefinition            `yaml:"defaults,omitempty"`
	Kinds    map[string]*NodeDefinition `yaml:"kinds,omitempty"`
	Nodes    map[string]*NodeDefinition `yaml:"nodes,omitempty"`
	Links    []*LinkConfig              `yaml:"links,omitempty"`
}

Topology represents a lab topology.

func NewTopology added in v0.15.0

func NewTopology() *Topology

func (*Topology) GetDefaults added in v0.15.0

func (t *Topology) GetDefaults() *NodeDefinition

func (*Topology) GetKind added in v0.15.0

func (t *Topology) GetKind(kind string) *NodeDefinition

func (*Topology) GetKinds added in v0.15.0

func (t *Topology) GetKinds() map[string]*NodeDefinition

func (*Topology) GetNodeBinds added in v0.15.0

func (t *Topology) GetNodeBinds(name string) []string

func (*Topology) GetNodeCPU added in v0.16.2

func (t *Topology) GetNodeCPU(name string) float64

func (*Topology) GetNodeCPUSet added in v0.20.0

func (t *Topology) GetNodeCPUSet(name string) string

func (*Topology) GetNodeCmd added in v0.15.0

func (t *Topology) GetNodeCmd(name string) string

func (*Topology) GetNodeConfigDispatcher added in v0.15.0

func (t *Topology) GetNodeConfigDispatcher(name string) *ConfigDispatcher

func (*Topology) GetNodeEnforceStartupConfig added in v0.17.0

func (t *Topology) GetNodeEnforceStartupConfig(name string) bool

func (*Topology) GetNodeEntrypoint added in v0.18.0

func (t *Topology) GetNodeEntrypoint(name string) string

func (*Topology) GetNodeEnv added in v0.15.0

func (t *Topology) GetNodeEnv(name string) map[string]string

func (*Topology) GetNodeEnvFiles added in v0.26.0

func (t *Topology) GetNodeEnvFiles(name string) []string

func (*Topology) GetNodeExec added in v0.18.0

func (t *Topology) GetNodeExec(name string) []string

func (*Topology) GetNodeExtras added in v0.18.0

func (t *Topology) GetNodeExtras(name string) *Extras

GetNodeExtras returns the 'extras' section for the given node.

func (*Topology) GetNodeGroup added in v0.15.0

func (t *Topology) GetNodeGroup(name string) string

func (*Topology) GetNodeImage added in v0.15.0

func (t *Topology) GetNodeImage(name string) string

func (*Topology) GetNodeKernel added in v0.15.0

func (t *Topology) GetNodeKernel(name string) string

func (*Topology) GetNodeKind added in v0.15.0

func (t *Topology) GetNodeKind(name string) string

func (*Topology) GetNodeLabels added in v0.15.0

func (t *Topology) GetNodeLabels(name string) map[string]string

func (*Topology) GetNodeLicense added in v0.15.0

func (t *Topology) GetNodeLicense(name string) (string, error)

func (*Topology) GetNodeMemory added in v0.20.0

func (t *Topology) GetNodeMemory(name string) string

func (*Topology) GetNodeNetworkMode added in v0.15.0

func (t *Topology) GetNodeNetworkMode(name string) string

func (*Topology) GetNodePorts added in v0.15.0

func (t *Topology) GetNodePorts(name string) (nat.PortSet, nat.PortMap, error)

func (*Topology) GetNodePosition added in v0.15.0

func (t *Topology) GetNodePosition(name string) string

func (*Topology) GetNodePublish added in v0.15.0

func (t *Topology) GetNodePublish(name string) []string

func (*Topology) GetNodeRuntime added in v0.15.0

func (t *Topology) GetNodeRuntime(name string) string

func (*Topology) GetNodeSandbox added in v0.15.0

func (t *Topology) GetNodeSandbox(name string) string

func (*Topology) GetNodeStartupConfig added in v0.15.0

func (t *Topology) GetNodeStartupConfig(name string) (string, error)

func (*Topology) GetNodeStartupDelay added in v0.17.0

func (t *Topology) GetNodeStartupDelay(name string) uint

func (*Topology) GetNodeType added in v0.15.0

func (t *Topology) GetNodeType(name string) string

func (*Topology) GetNodeUser added in v0.15.0

func (t *Topology) GetNodeUser(name string) string

func (*Topology) GetSANs added in v0.31.0

func (t *Topology) GetSANs(name string) []string

GetSANs return the Subject Alternative Name configuration for the given node.

func (*Topology) GetSysCtl added in v0.26.0

func (t *Topology) GetSysCtl(name string) map[string]string

GetSysCtl return the Sysctl configuration for the given node.

func (*Topology) GetWaitFor added in v0.32.0

func (t *Topology) GetWaitFor(name string) []string

GetWaitFor return the wait-for configuration for the given node.

func (*Topology) ImportEnvs added in v0.17.0

func (t *Topology) ImportEnvs()

Jump to

Keyboard shortcuts

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