Documentation
¶
Index ¶
- Constants
- type Bind
- type Binds
- type CertificateAuthority
- type CertificateConfig
- type Component
- type ConfigDispatcher
- type ContainerDetails
- type ContainerInterfaceDetails
- type ContainerInterfaces
- type DNSConfig
- type Endpoint
- type Exec
- type ExecPhase
- type ExecTarget
- type Execs
- type Extras
- type FailBehaviour
- type GenericFilter
- type GenericPortBinding
- type HealthcheckConfig
- type HostEntries
- type HostEntry
- type HostRequirements
- type ImpairmentData
- type IpVersion
- type K8sKindDeployExtras
- type K8sKindExtras
- type LabData
- type LicensePolicy
- type Link
- type MDA
- type MDAS
- type MgmtNet
- type NodeConfig
- type NodeDefinition
- type PubkeyAuthValue
- type PullPolicyValue
- type SSHConfig
- type Settings
- type StageBase
- type StageConfigure
- type StageCreate
- type StageCreateLinks
- type StageExit
- type StageHealthy
- type Stages
- type TopoPaths
- func (t *TopoPaths) AnsibleInventoryFileAbsPath() string
- func (t *TopoPaths) AuthorizedKeysFilename() string
- func (t *TopoPaths) CaCSRAbsFilename() string
- func (t *TopoPaths) CaCertAbsFilename() string
- func (t *TopoPaths) CaKeyAbsFilename() string
- func (t *TopoPaths) ClabBakDir() string
- func (*TopoPaths) ClabTmpDir() string
- func (t *TopoPaths) GraphDir() string
- func (t *TopoPaths) GraphFilename(ext string) string
- func (t *TopoPaths) NodeCertAbsFilename(nodeName string) string
- func (t *TopoPaths) NodeCertCSRAbsFilename(nodeName string) string
- func (t *TopoPaths) NodeCertKeyAbsFilename(nodeName string) string
- func (t *TopoPaths) NodeDir(nodeName string) string
- func (t *TopoPaths) NodeTLSDir(nodename string) string
- func (t *TopoPaths) NornirSimpleInventoryFileAbsPath() string
- func (t *TopoPaths) SSHConfigPath() string
- func (t *TopoPaths) SetExternalCaFiles(certFile, keyFile string) error
- func (t *TopoPaths) SetLabDir(p string) (err error)
- func (t *TopoPaths) SetLabDirByPrefix(topologyName string) (err error)
- func (t *TopoPaths) SetTopologyFilePath(topologyFile string) error
- func (t *TopoPaths) SetTopologyVarsFilePath(varsFile string) error
- func (t *TopoPaths) StartupConfigDownloadFileAbsPath(node, postfix string) string
- func (t *TopoPaths) TLSBaseDir() string
- func (t *TopoPaths) TopoExportFile() string
- func (t *TopoPaths) TopologyBakFileAbsPath() string
- func (t *TopoPaths) TopologyFileDir() string
- func (t *TopoPaths) TopologyFileExt() string
- func (t *TopoPaths) TopologyFileIsSet() bool
- func (t *TopoPaths) TopologyFilenameAbsPath() string
- func (t *TopoPaths) TopologyFilenameBase() string
- func (t *TopoPaths) TopologyFilenameWithoutExt() string
- func (t *TopoPaths) TopologyLabDir() string
- func (t *TopoPaths) VarsFilenameAbsPath() string
- type Topology
- func (t *Topology) GetCertificateConfig(nodeName string) *CertificateConfig
- func (t *Topology) GetComponents(nodeName string) []*Component
- func (t *Topology) GetDefaults() *NodeDefinition
- func (t *Topology) GetGroup(group string) *NodeDefinition
- func (t *Topology) GetGroups() map[string]*NodeDefinition
- func (t *Topology) GetHealthCheckConfig(nodeName string) *HealthcheckConfig
- func (t *Topology) GetKind(kind string) *NodeDefinition
- func (t *Topology) GetKinds() map[string]*NodeDefinition
- func (t *Topology) GetNodeAliases(nodeName string) []string
- func (t *Topology) GetNodeAutoRemove(nodeName string) bool
- func (t *Topology) GetNodeBinds(nodeName string) ([]string, error)
- func (t *Topology) GetNodeCPU(nodeName string) float64
- func (t *Topology) GetNodeCPUSet(nodeName string) string
- func (t *Topology) GetNodeCapAdd(nodeName string) []string
- func (t *Topology) GetNodeCmd(nodeName string) string
- func (t *Topology) GetNodeConfigDispatcher(nodeName string) *ConfigDispatcher
- func (t *Topology) GetNodeDevices(nodeName string) []string
- func (t *Topology) GetNodeDns(nodeName string) *DNSConfig
- func (t *Topology) GetNodeEnforceStartupConfig(nodeName string) bool
- func (t *Topology) GetNodeEntrypoint(nodeName string) string
- func (t *Topology) GetNodeEnv(nodeName string) map[string]string
- func (t *Topology) GetNodeEnvFiles(nodeName string) []string
- func (t *Topology) GetNodeExec(nodeName string) []string
- func (t *Topology) GetNodeExtras(nodeName string) *Extras
- func (t *Topology) GetNodeGroup(nodeName string) string
- func (t *Topology) GetNodeImage(nodeName string) string
- func (t *Topology) GetNodeImagePullPolicy(nodeName string) PullPolicyValue
- func (t *Topology) GetNodeKernel(nodeName string) string
- func (t *Topology) GetNodeKind(nodeName string) string
- func (t *Topology) GetNodeLabels(nodeName string) map[string]string
- func (t *Topology) GetNodeLicense(nodeName string) string
- func (t *Topology) GetNodeMemory(nodeName string) string
- func (t *Topology) GetNodeNetworkMode(nodeName string) string
- func (t *Topology) GetNodePorts(nodeName string) (nat.PortSet, nat.PortMap, error)
- func (t *Topology) GetNodePosition(nodeName string) string
- func (t *Topology) GetNodeRuntime(nodeName string) string
- func (t *Topology) GetNodeSandbox(nodeName string) string
- func (t *Topology) GetNodeShmSize(nodeName string) string
- func (t *Topology) GetNodeStartupConfig(nodeName string) string
- func (t *Topology) GetNodeStartupDelay(nodeName string) uint
- func (t *Topology) GetNodeSuppressStartupConfig(nodeName string) bool
- func (t *Topology) GetNodeType(nodeName string) string
- func (t *Topology) GetNodeUser(nodeName string) string
- func (t *Topology) GetRestartPolicy(nodeName string) string
- func (t *Topology) GetStages(nodeName string) (*Stages, error)
- func (t *Topology) GetSysCtl(nodeName string) map[string]string
- func (t *Topology) ImportEnvs()
- type WaitFor
- type WaitForList
- type WaitForStage
- type XIOM
- type XIOMS
Constants ¶
const ( // LicensePolicyRequired means a node should exit if no license provided. LicensePolicyRequired = "required" // LicensePolicyWarn means a node should warn (but not exit) if no license provided. LicensePolicyWarn = "warn" // LicensePolicyNone means a node doesn't care about a license. LicensePolicyNone = "none" )
const ( CertFileSuffix = ".pem" KeyFileSuffix = ".key" CSRFileSuffix = ".csr" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bind ¶ added in v0.43.0
type Bind struct {
// contains filtered or unexported fields
}
Bind represents a bind mount.
func NewBindFromString ¶ added in v0.69.0
NewBindFromString creates a new Bind instance from the string representation.
type Binds ¶ added in v0.69.0
type Binds []*Bind
Binds represent a list of bind mounts.
func (Binds) ToStringSlice ¶ added in v0.69.0
ToStringSlice returns a slice of strings representing the bind mounts.
type CertificateAuthority ¶ added in v0.44.0
type CertificateAuthority struct {
// Cert is the path to the CA certificate file in the External CA mode of operation.
Cert string `yaml:"cert"`
// Key is the path to the CA private key file in the External CA mode of operation.
Key string `yaml:"key"`
// KeySize is the size of the CA private key in bits
// when containerlab is in charge of the CA generation.
KeySize int `yaml:"key-size"`
// ValidityDuration is the duration of the CA certificate validity
// when containerlab is in charge of the CA generation.
ValidityDuration time.Duration `yaml:"validity-duration"`
}
CertificateAuthority is the structure for global containerlab certificate authority settings.
type CertificateConfig ¶ added in v0.39.0
type CertificateConfig struct {
// default false value indicates that the node does not use TLS
Issue *bool `yaml:"issue,omitempty"`
// KeySize is the size of the key in bits
KeySize int `yaml:"key-size,omitempty"`
// ValidityDuration is the duration of the certificate validity
ValidityDuration time.Duration `yaml:"validity-duration"`
// list of subject Alternative Names (SAN) to be added to the node's certificate
SANs []string `yaml:"sans,omitempty"`
}
CertificateConfig represents TLS parameters set for a node.
func (*CertificateConfig) Merge ¶ added in v0.44.0
func (c *CertificateConfig) Merge(x *CertificateConfig) *CertificateConfig
Merge merges the given CertificateConfig into the current one.
type ConfigDispatcher ¶ added in v0.15.0
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]any
type ContainerDetails ¶ added in v0.25.0
type ContainerDetails struct {
LabName string `json:"lab_name,omitempty"`
LabPath string `json:"labPath,omitempty"`
AbsLabPath string `json:"absLabPath,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"`
// Status is the container's status, such as "Up"/"Exited"
// and if health is available it shows "(healthy)" or "(unhealthy)" instead.
Status string `json:"status,omitempty"`
IPv4Address string `json:"ipv4_address,omitempty"`
IPv6Address string `json:"ipv6_address,omitempty"`
Ports []*GenericPortBinding `json:"ports,omitempty"`
Owner string `json:"owner,omitempty"`
}
ContainerDetails contains information that is commonly outputted to tables or graphs.
type ContainerInterfaceDetails ¶ added in v0.64.0
type ContainerInterfaceDetails struct {
InterfaceName string `json:"name"`
InterfaceAlias string `json:"alias"`
InterfaceMAC string `json:"mac"`
InterfaceIndex int `json:"ifindex"`
InterfaceMTU int `json:"mtu"`
InterfaceType string `json:"type"`
InterfaceState string `json:"state"`
}
ContainerInterfaceDetails contains information about a specific container's network interfaces.
type ContainerInterfaces ¶ added in v0.64.0
type ContainerInterfaces struct {
ContainerName string `json:"name"`
Interfaces []*ContainerInterfaceDetails `json:"interfaces"`
}
ContainerInterfaces contains information about a container's network interfaces.
type DNSConfig ¶ added in v0.35.0
type DNSConfig struct {
// DNS servers
Servers []string `yaml:"servers,omitempty"`
// DNS options
Options []string `yaml:"options,omitempty"`
// DNS Search Domains
Search []string `yaml:"search,omitempty"`
}
DNSConfig represents DNS configuration options a node has.
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 Exec ¶ added in v0.59.0
type Exec struct {
Command string `yaml:"command,omitempty"`
Target ExecTarget `yaml:"target,omitempty"`
Phase ExecPhase `yaml:"phase,omitempty"`
}
func (*Exec) InitDefaults ¶ added in v0.59.0
func (c *Exec) InitDefaults()
InitDefaults sets default values for Exec.
type ExecPhase ¶ added in v0.59.0
type ExecPhase string
const ( // CommandExecutionPhaseEnter represents a command to be executed when the node enters the // stage. CommandExecutionPhaseEnter ExecPhase = "on-enter" // CommandExecutionPhaseExit represents a command to be executed when the node exits the stage. CommandExecutionPhaseExit ExecPhase = "on-exit" )
type ExecTarget ¶ added in v0.59.0
type ExecTarget string
const ( // CommandTargetContainer determines that the commands are meant to be executed within the // container. CommandTargetContainer ExecTarget = "container" // CommandTargetHost determines that the commands are meant to be executed on the host system. CommandTargetHost ExecTarget = "host" )
type Execs ¶ added in v0.52.0
type Execs []*Exec
Execs represents a list of Exec configurations.
func (Execs) HasCommands ¶ added in v0.52.0
HasCommands returns true if the Execs contains at least one command.
func (Execs) InitDefaults ¶ added in v0.59.0
func (execs Execs) InitDefaults()
InitDefaults sets default values for Execs.
type Extras ¶ added in v0.18.0
type Extras struct {
// Nokia SR Linux agents. As of now just the agents spec files can be provided here
SRLAgents []string `yaml:"srl-agents,omitempty"`
// Proxy address that mysocketctl will use
MysocketProxy string `yaml:"mysocket-proxy,omitempty"`
// paths to files which are to be copied to ceos flash dir
CeosCopyToFlash []string `yaml:"ceos-copy-to-flash,omitempty"`
// k8s-kind node specific options
K8sKind *K8sKindExtras `yaml:"k8s_kind,omitempty"`
}
Extras contains extra node parameters which are not entitled to be part of a generic node config.
type FailBehaviour ¶ added in v0.36.0
type FailBehaviour int
const ( FailBehaviourLog FailBehaviour = iota FailBehaviourError )
type GenericFilter ¶ added in v0.15.0
type GenericPortBinding ¶ added in v0.43.0
type GenericPortBinding struct {
HostIP string `json:"host_ip,omitempty"`
HostPort int `json:"host_port,omitempty"`
ContainerPort int `json:"port,omitempty"`
Protocol string `json:"protocol,omitempty"`
}
GenericPortBinding represents a port binding.
func (*GenericPortBinding) String ¶ added in v0.43.0
func (p *GenericPortBinding) String() string
type HealthcheckConfig ¶ added in v0.49.0
type HealthcheckConfig struct {
// Test is the command to run to check the health of the container
Test []string `yaml:"test,omitempty"`
// Interval is the time to wait between checks in seconds
Interval int `yaml:"interval,omitempty"`
// Timeout is the time in seconds to wait before considering the check to have hung
Timeout int `yaml:"timeout,omitempty"`
// Retries is the number of consecutive failures needed to consider a container as unhealthy
Retries int `yaml:"retries,omitempty"`
// StartPeriod is the time to wait for the container to initialize
// before starting health-retries countdown in seconds
StartPeriod int `yaml:"start-period,omitempty"`
}
HealthcheckConfig represents healthcheck parameters set for a container.
func (*HealthcheckConfig) GetIntervalDuration ¶ added in v0.49.0
func (h *HealthcheckConfig) GetIntervalDuration() time.Duration
GetIntervalDuration returns the interval as time.Duration.
func (*HealthcheckConfig) GetStartPeriodDuration ¶ added in v0.49.0
func (h *HealthcheckConfig) GetStartPeriodDuration() time.Duration
GetStartPeriodDuration returns the start period as time.Duration.
func (*HealthcheckConfig) GetTimeoutDuration ¶ added in v0.49.0
func (h *HealthcheckConfig) GetTimeoutDuration() time.Duration
GetTimeoutDuration returns the timeout as time.Duration.
type HostEntries ¶ added in v0.69.2
type HostEntries []*HostEntry //nolint: recvcheck
func (*HostEntries) Merge ¶ added in v0.69.2
func (h *HostEntries) Merge(other HostEntries)
func (HostEntries) ToHostsConfig ¶ added in v0.69.2
func (h HostEntries) ToHostsConfig(ipv IpVersion) string
type HostEntry ¶ added in v0.69.2
type HostEntry struct {
// contains filtered or unexported fields
}
func NewHostEntry ¶ added in v0.69.2
func (*HostEntry) SetDescription ¶ added in v0.69.2
func (*HostEntry) ToHostEntryString ¶ added in v0.69.2
type HostRequirements ¶ added in v0.26.0
type HostRequirements struct {
SSSE3 bool `json:"ssse3,omitempty"` // ssse3 cpu instruction
// indicates that KVM virtualization is required for this node to run
VirtRequired bool `json:"virt-required,omitempty"`
// the minimum amount of vcpus this node requires
MinVCPU int `json:"min-vcpu,omitempty"`
MinVCPUFailAction FailBehaviour `json:"min-vcpu-fail-action,omitempty"`
// The minimum amount of memory this node requires
MinAvailMemoryGb int `json:"min-free-memory,omitempty"`
MinAvailMemoryGbFailAction FailBehaviour `json:"min-free-memory-fail-action,omitempty"`
}
func NewHostRequirements ¶ added in v0.36.0
func NewHostRequirements() *HostRequirements
NewHostRequirements is the constructor for new HostRequirements structs.
func (*HostRequirements) Verify ¶ added in v0.34.0
func (h *HostRequirements) Verify(kindName, nodeName string) error
Verify runs verification checks against the host requirements set for a node.
type ImpairmentData ¶ added in v0.65.0
type K8sKindDeployExtras ¶ added in v0.52.0
type K8sKindDeployExtras struct {
Wait *string `yaml:"wait,omitempty"`
}
K8sKindDeployExtras represents the options used for the kind cluster creation. It is aligned with the `kind create cluster` command options, but exposes only the ones that are relevant for containerlab.
type K8sKindExtras ¶ added in v0.52.0
type K8sKindExtras struct {
Deploy *K8sKindDeployExtras `yaml:"deploy,omitempty"`
}
K8sKindExtras represents the k8s-kind-specific extra options.
type LabData ¶ added in v0.31.0
type LabData struct {
Containers []ContainerDetails `json:"containers"`
}
type LicensePolicy ¶ added in v0.40.0
type LicensePolicy string
LicensePolicy is a value of LicensePolicy.
type MgmtNet ¶
type MgmtNet struct {
// container runtime network name
Network string `json:"network,omitempty" yaml:"network,omitempty"`
Bridge string `json:"bridge,omitempty" yaml:"bridge,omitempty"`
// linux bridge backing the runtime network
IPv4Subnet string `json:"ipv4-subnet,omitempty" yaml:"ipv4-subnet,omitempty"`
IPv4Gw string `json:"ipv4-gw,omitempty" yaml:"ipv4-gw,omitempty"`
IPv4Range string `json:"ipv4-range,omitempty" yaml:"ipv4-range,omitempty"`
IPv6Subnet string `json:"ipv6-subnet,omitempty" yaml:"ipv6-subnet,omitempty"`
IPv6Gw string `json:"ipv6-gw,omitempty" yaml:"ipv6-gw,omitempty"`
IPv6Range string `json:"ipv6-range,omitempty" yaml:"ipv6-range,omitempty"`
MTU int `json:"mtu,omitempty" yaml:"mtu,omitempty"`
ExternalAccess *bool `json:"external-access,omitempty" yaml:"external-access,omitempty"`
DriverOpts map[string]string `json:"driver-opts,omitempty" yaml:"driver-opts,omitempty"`
}
MgmtNet struct defines the management network options.
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"`
// when set to true will prevent creation of a startup-config, for auto-provisioning testing
// (ZTP)
SuppressStartupConfig bool `json:"suppress-startup-config,omitempty"`
// when set to true will auto-remove a stopped/failed container
AutoRemove bool `json:"auto-remove,omitempty"`
RestartPolicy string `json:"restart-policy,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"`
NodeType string `json:"type,omitempty"`
Position string `json:"position,omitempty"`
License string `json:"license,omitempty"`
Image string `json:"image,omitempty"`
ImagePullPolicy PullPolicyValue `json:"image-pull-policy,omitempty"`
Sysctls map[string]string `json:"sysctls,omitempty"`
User string `json:"user,omitempty"`
Entrypoint string `json:"entrypoint,omitempty"`
Cmd string `json:"cmd,omitempty"`
// Exec is a list of commands to execute inside the container backing the node.
Exec []string `json:"exec,omitempty"`
Env map[string]string `json:"env,omitempty"`
// Bind mounts strings (src:dest:options).
Binds []string `json:"binds,omitempty"`
// Devices to map in the container
Devices []string `json:"devices,omitempty"`
// Capabilities required by the container (if not run in privileged mode)
CapAdd []string `json:"cap-add,omitempty"`
// Size of the shared memory allocated to the container
ShmSize string `json:"shm-size,omitempty"`
// PortBindings define the bindings between the container ports and host ports
PortBindings nat.PortMap `json:"portbindings,omitempty"`
// ResultingPortBindings is a list of port bindings that are actually applied to the container
ResultingPortBindings []*GenericPortBinding `json:"port-bindings,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"`
PidMode string `json:"pidmode,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"`
// TLS Certificate configuration
Certificate *CertificateConfig
// Healthcheck configuration parameters
Healthcheck *HealthcheckConfig
// Network aliases
Aliases []string `json:"aliases,omitempty"`
// Extra /etc/hosts entries for all nodes.
ExtraHosts []string `json:"extra-hosts,omitempty"`
Labels map[string]string `json:"labels,omitempty"` // container labels
// 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"`
// Extra node parameters
Extras *Extras `json:"extras,omitempty"`
Stages *Stages `json:"stages,omitempty"`
DNS *DNSConfig `json:"dns,omitempty"`
// Kind parameters
//
// IsRootNamespaceBased flag indicates that a certain nodes network
// namespace (usually based on the kind) is the root network namespace
IsRootNamespaceBased bool
// SkipUniquenessCheck prevents the pre-deploy uniqueness check, where
// we check, that the given node name is not already present on the host.
// Introduced to prevent the check from running with ext-containers, since
// they should be present by definition.
SkipUniquenessCheck bool
Components []*Component
}
NodeConfig contains information of a container element.
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"`
SuppressStartupConfig *bool `yaml:"suppress-startup-config,omitempty"`
AutoRemove *bool `yaml:"auto-remove,omitempty"`
RestartPolicy string `yaml:"restart-policy,omitempty"`
Config *ConfigDispatcher `yaml:"config,omitempty"`
Image string `yaml:"image,omitempty"`
ImagePullPolicy string `yaml:"image-pull-policy,omitempty"`
License string `yaml:"license,omitempty"`
Position string `yaml:"position,omitempty"`
Entrypoint string `yaml:"entrypoint,omitempty"`
Cmd string `yaml:"cmd,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 devices to map in the container
Devices []string `yaml:"devices,omitempty"`
// List of capabilities to add for the container
CapAdd []string `yaml:"cap-add,omitempty"`
// Set the shared memory size allocated to the container
ShmSize string `yaml:"shm-size,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"`
// 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"`
// Deployment stages
Stages *Stages `yaml:"stages,omitempty"`
// DNS configuration
DNS *DNSConfig `yaml:"dns,omitempty"`
// Certificate configuration
Certificate *CertificateConfig `yaml:"certificate,omitempty"`
// Healthcheck configuration
HealthCheck *HealthcheckConfig `yaml:"healthcheck,omitempty"`
// Network aliases
Aliases []string `yaml:"aliases,omitempty"`
Components []*Component `yaml:"components,omitempty"`
}
NodeDefinition represents a configuration a given node can have in the lab definition file.
func (*NodeDefinition) ImportEnvs ¶ added in v0.17.0
func (n *NodeDefinition) ImportEnvs()
ImportEnvs imports all environment variables defined in the shell if __IMPORT_ENVS is set to true.
func (*NodeDefinition) UnmarshalYAML ¶ added in v0.41.1
func (n *NodeDefinition) UnmarshalYAML(unmarshal func(any) error) error
UnmarshalYAML is a custom unmarshaler for NodeDefinition type that allows to map old attributes to new ones.
type PubkeyAuthValue ¶ added in v0.48.0
type PubkeyAuthValue string
const ( PubkeyAuthValueYes PubkeyAuthValue = "yes" PubkeyAuthValueNo PubkeyAuthValue = "no" PubkeyAuthValueHostBound PubkeyAuthValue = "host-bound" PubkeyAuthValueUnbound PubkeyAuthValue = "unbound" )
func (PubkeyAuthValue) String ¶ added in v0.48.0
func (p PubkeyAuthValue) String() string
type PullPolicyValue ¶ added in v0.36.0
type PullPolicyValue string
PullPolicyValue represents Image pull policy values.
const ( PullPolicyAlways PullPolicyValue = "Always" PullPolicyNever PullPolicyValue = "Never" PullPolicyIfNotPresent PullPolicyValue = "IfNotPresent" )
func ParsePullPolicyValue ¶ added in v0.36.0
func ParsePullPolicyValue(s string) PullPolicyValue
ParsePullPolicyValue parses the given string and tries to map it to a valid PullPolicyValue. Defaults to PullPolicyIfNotPresent.
type SSHConfig ¶ added in v0.48.0
type SSHConfig struct {
PubkeyAuthentication PubkeyAuthValue
}
SSHConfig is the SSH client configuration that a clab node requires.
func NewSSHConfig ¶ added in v0.48.0
func NewSSHConfig() *SSHConfig
type Settings ¶ added in v0.44.0
type Settings struct {
CertificateAuthority *CertificateAuthority `yaml:"certificate-authority"`
}
Settings is the structure for global containerlab settings.
type StageBase ¶ added in v0.51.0
type StageBase struct {
WaitFor WaitForList `yaml:"wait-for,omitempty"`
Execs Execs `yaml:"exec,omitempty"`
}
StageBase represents a common configuration stage. Other stages embed this type to inherit its configuration options.
type StageConfigure ¶ added in v0.51.0
type StageConfigure struct {
StageBase `yaml:",inline"`
}
StageConfigure represents a stage of a given node when it enters configuration workflow.
func (*StageConfigure) Merge ¶ added in v0.52.0
func (s *StageConfigure) Merge(other *StageConfigure) error
type StageCreate ¶ added in v0.51.0
type StageCreate struct {
StageBase `yaml:",inline"`
}
StageCreate represents a creation stage of a given node.
func (*StageCreate) Merge ¶ added in v0.52.0
func (s *StageCreate) Merge(other *StageCreate) error
type StageCreateLinks ¶ added in v0.51.0
type StageCreateLinks struct {
StageBase `yaml:",inline"`
}
StageCreateLinks represents a stage of a given node when links are getting added to it.
func (*StageCreateLinks) Merge ¶ added in v0.52.0
func (s *StageCreateLinks) Merge(other *StageCreateLinks) error
type StageExit ¶ added in v0.51.0
type StageExit struct {
StageBase `yaml:",inline"`
}
StageExit represents a stage of a given node when the node reaches exit state.
type StageHealthy ¶ added in v0.51.0
type StageHealthy struct {
StageBase `yaml:",inline"`
}
StageHealthy represents a stage of a given node when it reaches healthy status.
func (*StageHealthy) Merge ¶ added in v0.52.0
func (s *StageHealthy) Merge(other *StageHealthy) error
type Stages ¶ added in v0.51.0
type Stages struct {
Create *StageCreate `yaml:"create"`
CreateLinks *StageCreateLinks `yaml:"create-links"`
Configure *StageConfigure `yaml:"configure"`
Healthy *StageHealthy `yaml:"healthy"`
Exit *StageExit `yaml:"exit"`
}
Stages represents a configuration of a given node deployment stage.
func (*Stages) GetWaitFor ¶ added in v0.51.0
func (s *Stages) GetWaitFor() map[WaitForStage]WaitForList
GetWaitFor returns lists of nodes that need to be waited for in a map that is indexed by the state for which this dependency is to be evaluated.
func (*Stages) InitDefaults ¶ added in v0.59.0
func (s *Stages) InitDefaults()
InitDefaults set defaults for the stages.
type TopoPaths ¶ added in v0.37.0
type TopoPaths struct {
// contains filtered or unexported fields
}
TopoPaths creates all the required absolute paths and filenames for a topology. generally all these paths are deduced from two main paths. The topology file path and the lab dir path.
func NewTopoPaths ¶ added in v0.37.0
NewTopoPaths constructs a new TopoPaths instance.
func (*TopoPaths) AnsibleInventoryFileAbsPath ¶ added in v0.37.0
AnsibleInventoryFileAbsPath returns the absolute path to the ansible-inventory file.
func (*TopoPaths) AuthorizedKeysFilename ¶ added in v0.37.0
AuthorizedKeysFilename returns the path for the generated AuthorizedKeysFile.
func (*TopoPaths) CaCSRAbsFilename ¶ added in v0.44.0
func (*TopoPaths) CaCertAbsFilename ¶ added in v0.44.0
CaCertAbsFilename returns the path to the CA cert file. If external CA is used, the path to the external CA cert file is returned. Otherwise the path to the generated CA cert file is returned.
func (*TopoPaths) CaKeyAbsFilename ¶ added in v0.44.0
CaKeyAbsFilename returns the path to the CA key file. If external CA is used, the path to the external CA key file is returned. Otherwise the path to the generated CA key file is returned.
func (*TopoPaths) ClabBakDir ¶ added in v0.69.0
ClabBakDir returns the absolute path to the directory where clab stores backup files. Creates the directory if it does not exist.
func (*TopoPaths) ClabTmpDir ¶ added in v0.38.0
ClabTmpDir returns the path to the temporary directory where clab stores temporary and/or downloaded files. Creates the directory if it does not exist.
func (*TopoPaths) GraphFilename ¶ added in v0.37.0
GraphFilename returns the filename for a given graph file with the provided extension.
func (*TopoPaths) NodeCertAbsFilename ¶ added in v0.37.0
NodeCertAbsFilename returns the path to a cert file for the given identifier.
func (*TopoPaths) NodeCertCSRAbsFilename ¶ added in v0.37.0
NodeCertCSRAbsFilename returns the path to a csr file for the given identifier.
func (*TopoPaths) NodeCertKeyAbsFilename ¶ added in v0.37.0
NodeCertKeyAbsFilename returns the path to a key file for the given identifier.
func (*TopoPaths) NodeDir ¶ added in v0.37.0
NodeDir returns the directory in the labDir for the provided node.
func (*TopoPaths) NodeTLSDir ¶ added in v0.37.0
NodeTLSDir returns the directory that contains the certificat data for the given node.
func (*TopoPaths) NornirSimpleInventoryFileAbsPath ¶ added in v0.67.0
NornirSimpleInventoryFileAbsPath returns the absolute path to the ansible-inventory file.
func (*TopoPaths) SSHConfigPath ¶ added in v0.47.0
SSHConfigPath returns the topology dependent ssh config file name.
func (*TopoPaths) SetExternalCaFiles ¶ added in v0.44.0
SetExternalCaFiles sets the paths for the cert and key files if externally generated should be used.
func (*TopoPaths) SetLabDirByPrefix ¶ added in v0.48.4
SetLabDirByPrefix sets the labDir foldername (no abs path, but the last element) usually the topology name.
func (*TopoPaths) SetTopologyFilePath ¶ added in v0.37.0
SetTopologyFilePath sets the topology file path.
func (*TopoPaths) SetTopologyVarsFilePath ¶ added in v0.70.0
SetTopologyVarsFilePath sets the topology vars path.
func (*TopoPaths) StartupConfigDownloadFileAbsPath ¶ added in v0.38.0
StartupConfigDownloadFileAbsPath returns the absolute path to the startup-config file when it is downloaded from a remote location to the clab temp directory.
func (*TopoPaths) TLSBaseDir ¶ added in v0.37.0
TLSBaseDir returns the path of the TLS directory structure.
func (*TopoPaths) TopoExportFile ¶ added in v0.37.0
TopoExportFile returns the path for the topology-export file.
func (*TopoPaths) TopologyBakFileAbsPath ¶ added in v0.37.0
TopologyBakFileAbsPath returns the backup topology file name in /tmp/.clab directory with a timestamp prefix.
func (*TopoPaths) TopologyFileDir ¶ added in v0.37.0
TopologyFileDir returns the abs path to the topology file directory.
func (*TopoPaths) TopologyFileExt ¶ added in v0.69.0
TopologyFileExt returns the file extension of the topology file, including the dot.
func (*TopoPaths) TopologyFileIsSet ¶ added in v0.37.0
func (*TopoPaths) TopologyFilenameAbsPath ¶ added in v0.37.0
TopologyFilenameAbsPath returns the absolute path to the topology file.
func (*TopoPaths) TopologyFilenameBase ¶ added in v0.37.0
TopologyFilenameBase returns the full filename of the topology file without any additional paths.
func (*TopoPaths) TopologyFilenameWithoutExt ¶ added in v0.37.0
TopologyFilenameWithoutExt returns the topology file name without the file extension.
func (*TopoPaths) TopologyLabDir ¶ added in v0.37.0
TopologyLabDir returns the lab directory.
func (*TopoPaths) VarsFilenameAbsPath ¶ added in v0.70.0
VarsFilenameAbsPath returns the absolute path to the topology vars file.
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"`
Groups map[string]*NodeDefinition `yaml:"groups,omitempty"`
Links []*clablinks.LinkDefinition `yaml:"links,omitempty"`
}
Topology represents a lab topology.
func NewTopology ¶ added in v0.15.0
func NewTopology() *Topology
NewTopology creates a new Topology instance with initialized fields.
func (*Topology) GetCertificateConfig ¶ added in v0.39.0
func (t *Topology) GetCertificateConfig(nodeName string) *CertificateConfig
GetCertificateConfig returns the certificate configuration for the given node.
func (*Topology) GetComponents ¶ added in v0.69.0
func (*Topology) GetDefaults ¶ added in v0.15.0
func (t *Topology) GetDefaults() *NodeDefinition
GetDefaults returns the default node definition.
func (*Topology) GetGroup ¶ added in v0.69.0
func (t *Topology) GetGroup(group string) *NodeDefinition
func (*Topology) GetGroups ¶ added in v0.69.0
func (t *Topology) GetGroups() map[string]*NodeDefinition
func (*Topology) GetHealthCheckConfig ¶ added in v0.49.0
func (t *Topology) GetHealthCheckConfig(nodeName string) *HealthcheckConfig
func (*Topology) GetKind ¶ added in v0.15.0
func (t *Topology) GetKind(kind string) *NodeDefinition
GetKind returns the node definition for the given kind.
func (*Topology) GetKinds ¶ added in v0.15.0
func (t *Topology) GetKinds() map[string]*NodeDefinition
GetKinds returns all kinds defined in the topology. If no kinds are defined, it returns an empty map.
func (*Topology) GetNodeAliases ¶ added in v0.60.0
func (*Topology) GetNodeAutoRemove ¶ added in v0.32.2
func (*Topology) GetNodeBinds ¶ added in v0.15.0
func (*Topology) GetNodeCPU ¶ added in v0.16.2
func (*Topology) GetNodeCPUSet ¶ added in v0.20.0
func (*Topology) GetNodeCapAdd ¶ added in v0.68.0
func (*Topology) GetNodeCmd ¶ added in v0.15.0
func (*Topology) GetNodeConfigDispatcher ¶ added in v0.15.0
func (t *Topology) GetNodeConfigDispatcher(nodeName string) *ConfigDispatcher
func (*Topology) GetNodeDevices ¶ added in v0.68.0
func (*Topology) GetNodeDns ¶ added in v0.35.0
func (*Topology) GetNodeEnforceStartupConfig ¶ added in v0.17.0
func (*Topology) GetNodeEntrypoint ¶ added in v0.18.0
func (*Topology) GetNodeEnv ¶ added in v0.15.0
func (*Topology) GetNodeEnvFiles ¶ added in v0.26.0
func (*Topology) GetNodeExec ¶ added in v0.18.0
func (*Topology) GetNodeExtras ¶ added in v0.18.0
GetNodeExtras returns the 'extras' section for the given node.
func (*Topology) GetNodeGroup ¶ added in v0.15.0
func (*Topology) GetNodeImage ¶ added in v0.15.0
func (*Topology) GetNodeImagePullPolicy ¶ added in v0.36.0
func (t *Topology) GetNodeImagePullPolicy(nodeName string) PullPolicyValue
func (*Topology) GetNodeKernel ¶ added in v0.15.0
func (*Topology) GetNodeKind ¶ added in v0.15.0
func (*Topology) GetNodeLabels ¶ added in v0.15.0
func (*Topology) GetNodeLicense ¶ added in v0.15.0
func (*Topology) GetNodeMemory ¶ added in v0.20.0
func (*Topology) GetNodeNetworkMode ¶ added in v0.15.0
func (*Topology) GetNodePorts ¶ added in v0.15.0
func (*Topology) GetNodePosition ¶ added in v0.15.0
func (*Topology) GetNodeRuntime ¶ added in v0.15.0
func (*Topology) GetNodeSandbox ¶ added in v0.15.0
func (*Topology) GetNodeShmSize ¶ added in v0.68.0
func (*Topology) GetNodeStartupConfig ¶ added in v0.15.0
func (*Topology) GetNodeStartupDelay ¶ added in v0.17.0
func (*Topology) GetNodeSuppressStartupConfig ¶ added in v0.45.0
func (*Topology) GetNodeType ¶ added in v0.15.0
func (*Topology) GetNodeUser ¶ added in v0.15.0
func (*Topology) GetRestartPolicy ¶ added in v0.59.0
func (*Topology) GetStages ¶ added in v0.51.0
GetStages return the configuration stages set for the given node. It merges the default, kind and node stages into a single Stages struct with node stages taking precedence over kind stages and default stages.
func (*Topology) GetSysCtl ¶ added in v0.26.0
GetSysCtl return the Sysctl configuration for the given node.
func (*Topology) ImportEnvs ¶ added in v0.17.0
func (t *Topology) ImportEnvs()
type WaitFor ¶ added in v0.51.0
type WaitFor struct {
Node string `json:"node"` // the node that is to be waited for
Stage WaitForStage `json:"stage,omitempty"` // the stage that the node must have completed
}
WaitFor represents the wait-for configuration for a node deployment stage.
type WaitForList ¶ added in v0.51.0
type WaitForList []*WaitFor
WaitForList is a list of WaitFor configurations.
type WaitForStage ¶ added in v0.51.0
type WaitForStage string
WaitForStage defines the stages that nodes go through during the deployment process. They are used to define and enforce dependencies between nodes.
const ( // WaitForCreate is the wait stage name for a node creation stage. WaitForCreate WaitForStage = "create" // WaitForCreateLinks is the wait stage name for a node create-links stage. WaitForCreateLinks WaitForStage = "create-links" // WaitForConfigure is the wait stage name for a node configure stage. WaitForConfigure WaitForStage = "configure" // WaitForHealthy is the wait stage name for a node healthy stage. WaitForHealthy WaitForStage = "healthy" // WaitForExit is the wait stage name for a node exit stage. WaitForExit WaitForStage = "exit" )
func GetWaitForStages ¶ added in v0.51.0
func GetWaitForStages() []WaitForStage
GetWaitForStages returns list of wait for stages that are used to init Waitgroups for all the states.