Documentation ¶
Index ¶
- Constants
- func AddVxLanInterface(vxlan VxLAN) (err error)
- func AppendHostsFileEntries(containers []runtime.GenericContainer, labname string) error
- func BindIfacesWithTC(if1, if2 string) (err error)
- func DeleteEntriesFromHostsFile(labname string) error
- func GetLinksByNamePrefix(prefix string) ([]netlink.Link, error)
- func SetIngressMirror(src, dst string) (err error)
- type CLab
- func (c *CLab) BuildGraphFromDeployedLab(g *GraphTopo, containers []runtime.GenericContainer)
- func (c *CLab) BuildGraphFromTopo(g *GraphTopo)
- func (c *CLab) CheckTopologyDefinition(ctx context.Context) error
- func (c *CLab) CreateAuthzKeysFile() error
- func (c *CLab) CreateLinks(ctx context.Context, workers uint)
- func (c *CLab) CreateNetwork(ctx context.Context) error
- func (c *CLab) CreateNodes(ctx context.Context, maxWorkers uint) (*sync.WaitGroup, error)
- func (c *CLab) CreateVirtualWiring(l *types.Link) (err error)
- func (c *CLab) DeleteNodes(ctx context.Context, workers uint, serialNodes map[string]struct{})
- func (c *CLab) GenerateExports(f io.Writer, p string) error
- func (c *CLab) GenerateGraph(_ string) error
- func (c *CLab) GenerateInventories() error
- func (c *CLab) GetNodeRuntime(contName string) (runtime.ContainerRuntime, error)
- func (c *CLab) GetTopology(topo, varsFile string) error
- func (c *CLab) GlobalRuntime() runtime.ContainerRuntime
- func (c *CLab) HasKind(k string) bool
- func (c *CLab) ListContainers(ctx context.Context, filter []*types.GenericFilter) ([]runtime.GenericContainer, error)
- func (c *CLab) ListNodesContainers(ctx context.Context) ([]runtime.GenericContainer, error)
- func (c *CLab) LoadOrGenerateCA(caCertInput *cert.CACSRInput) error
- func (c *CLab) NewEndpoint(e string) *types.Endpoint
- func (c *CLab) NewLink(l *types.LinkConfig) *types.Link
- func (c *CLab) NewNode(nodeName, nodeRuntime string, nodeDef *types.NodeDefinition, idx int) error
- func (c *CLab) RegisterNodes()
- func (c *CLab) RemoveHostOrBridgeVeth(l *types.Link) (err error)
- func (c *CLab) ServeTopoGraph(tmpl, staticDir, srv string, topoD TopoData) error
- func (c *CLab) VerifyContainersUniqueness(ctx context.Context) error
- func (c *CLab) VethCleanup(_ context.Context) error
- func (c *CLab) WaitForExternalNodeDependencies(ctx context.Context, nodeName string)
- type ClabOption
- type Config
- type DependencyManager
- type GraphTopo
- type Link
- type TopoData
- type TopologyExport
- type VxLAN
Constants ¶
const ( // veth link mtu. DefaultVethLinkMTU = 9500 // containerlab's reserved OUI. ClabOUI = "aa:c1:ab" )
Variables ¶
This section is empty.
Functions ¶
func AddVxLanInterface ¶
AddVxLanInterface creates VxLan interface by given vxlan object.
func AppendHostsFileEntries ¶ added in v0.16.2
func AppendHostsFileEntries(containers []runtime.GenericContainer, labname string) error
func BindIfacesWithTC ¶
BindIfacesWithTC creates TC ingress mirred redirection between a pair of interfaces to make them virtually form a kind of a veth pair see https://netdevops.me/2021/transparently-redirecting-packets/frames-between-interfaces/#4-tc-to-the-rescue used https://github.com/redhat-nfvpe/koko/blob/bd156c82bf25837545fb109c69c7b91c3457b318/api/koko_api.go#L224 and https://gist.github.com/mcastelino/7d85f4164ffdaf48242f9281bb1d0f9b#gistcomment-2734521
func DeleteEntriesFromHostsFile ¶ added in v0.16.2
func GetLinksByNamePrefix ¶ added in v0.14.0
GetLinksByNamePrefix returns a list of links whose name matches a prefix.
func SetIngressMirror ¶
SetIngressMirror sets TC to mirror ingress from given port as MirrorIngress.
Types ¶
type CLab ¶
type CLab struct { Config *Config `json:"config,omitempty"` TopoPaths *types.TopoPaths Nodes map[string]nodes.Node `json:"nodes,omitempty"` Links map[int]*types.Link `json:"links,omitempty"` Runtimes map[string]runtime.ContainerRuntime `json:"runtimes,omitempty"` // reg is a registry of node kinds Reg *nodes.NodeRegistry Cert *cert.Cert // contains filtered or unexported fields }
func NewContainerLab ¶
func NewContainerLab(opts ...ClabOption) (*CLab, error)
NewContainerLab function defines a new container lab.
func (*CLab) BuildGraphFromDeployedLab ¶ added in v0.25.0
func (c *CLab) BuildGraphFromDeployedLab(g *GraphTopo, containers []runtime.GenericContainer)
func (*CLab) BuildGraphFromTopo ¶ added in v0.25.0
func (*CLab) CheckTopologyDefinition ¶
CheckTopologyDefinition runs topology checks and returns any errors found.
func (*CLab) CreateAuthzKeysFile ¶ added in v0.22.0
CreateAuthzKeysFile creats the authorized_keys file in the lab directory if any files ~/.ssh/*.pub found.
func (*CLab) CreateLinks ¶
CreateLinks creates links using the specified number of workers.
func (*CLab) CreateNetwork ¶ added in v0.24.0
func (*CLab) CreateNodes ¶
CreateNodes schedules nodes creation and returns a waitgroup for all nodes. Nodes interdependencies are created in this function.
func (*CLab) CreateVirtualWiring ¶
CreateVirtualWiring creates the virtual topology between the containers.
func (*CLab) DeleteNodes ¶ added in v0.15.0
func (*CLab) GenerateExports ¶ added in v0.26.0
GenerateExports generates various export files and writes it to a lab location.
func (*CLab) GenerateGraph ¶
GenerateGraph generates a graph of the lab topology.
func (*CLab) GenerateInventories ¶
GenerateInventories generate various inventory files and writes it to a lab location.
func (*CLab) GetNodeRuntime ¶ added in v0.15.0
func (c *CLab) GetNodeRuntime(contName string) (runtime.ContainerRuntime, error)
func (*CLab) GetTopology ¶
GetTopology parses the topology file into c.Conf structure as well as populates the TopoFile structure with the topology file related information.
func (*CLab) GlobalRuntime ¶ added in v0.15.0
func (c *CLab) GlobalRuntime() runtime.ContainerRuntime
func (*CLab) HasKind ¶ added in v0.25.0
HasKind returns true if kind k is found in the list of nodes.
func (*CLab) ListContainers ¶
func (c *CLab) ListContainers(ctx context.Context, filter []*types.GenericFilter) ([]runtime.GenericContainer, error)
ListContainers lists all containers using provided filter.
func (*CLab) ListNodesContainers ¶ added in v0.34.0
ListNodesContainers lists all containers based on the nodes stored in clab instance.
func (*CLab) LoadOrGenerateCA ¶ added in v0.37.0
func (c *CLab) LoadOrGenerateCA(caCertInput *cert.CACSRInput) error
LoadOrGenerateCA loads the CA certificate from the storage, or generates a new one if it does not exist.
func (*CLab) NewEndpoint ¶
NewEndpoint initializes a new endpoint object.
func (*CLab) NewLink ¶
func (c *CLab) NewLink(l *types.LinkConfig) *types.Link
NewLink initializes a new link object.
func (*CLab) RegisterNodes ¶ added in v0.35.0
func (c *CLab) RegisterNodes()
RegisterNodes registers all the nodes/kinds supported by containerlab.
func (*CLab) RemoveHostOrBridgeVeth ¶ added in v0.32.4
RemoveHostOrBridgeVeth tries to remove veths connected to the host network namespace or a linux bridge and does nothing in case they are not found.
func (*CLab) ServeTopoGraph ¶ added in v0.25.0
func (*CLab) VerifyContainersUniqueness ¶
VerifyContainersUniqueness ensures that nodes defined in the topology do not have names of the existing containers additionally it checks that the lab name is unique and no containers are currently running with the same lab name label.
func (*CLab) VethCleanup ¶ added in v0.26.0
VethCleanup iterates over links found in clab topology to initiate removal of dangling veths in host networking namespace or attached to linux bridge. See https://github.com/srl-labs/containerlab/issues/842 for the reference.
func (*CLab) WaitForExternalNodeDependencies ¶ added in v0.32.0
WaitForExternalNodeDependencies makes nodes that have a reference to an external container network-namespace (network-mode: container:<NAME>) to wait until the referenced container is in started status. The wait time is 15 minutes by default.
type ClabOption ¶
func WithKeepMgmtNet ¶ added in v0.15.0
func WithKeepMgmtNet() ClabOption
func WithNodeFilter ¶ added in v0.39.0
func WithNodeFilter(nodeFilter []string) ClabOption
WithNodeFilter option sets a filter for nodes to be deployed. A filter is a list of node names to be deployed, names are provided exactly as they are listed in the topology file. Since this is altering the clab.config.Topology.[Nodes,Links] it must only be called after WithTopoFile.
func WithRuntime ¶ added in v0.14.0
func WithRuntime(name string, rtconfig *runtime.RuntimeConfig) ClabOption
func WithTimeout ¶
func WithTimeout(dur time.Duration) ClabOption
func WithTopoFile ¶
func WithTopoFile(file, varsFile string) ClabOption
type Config ¶
type Config struct { Name string `json:"name,omitempty"` Prefix *string `json:"prefix,omitempty"` Mgmt *types.MgmtNet `json:"mgmt,omitempty"` Topology *types.Topology `json:"topology,omitempty"` // the debug flag value as passed via cli // may be used by other packages to enable debug logging Debug bool `json:"debug"` }
Config defines lab configuration as it is provided in the YAML file.
type DependencyManager ¶ added in v0.32.0
type DependencyManager interface { // AddNode adds a node to the dependency manager. AddNode(name string) // AddDependency adds a dependency between depender and dependee. // The depender will effectively wait for the dependee to finish. AddDependency(dependee, depender string) error // WaitForNodeDependencies is called by a node that is meant to be created. // This call will bock until all the nodes that this node depends on are created. WaitForNodeDependencies(nodeName string) error // SignalDone is called by a node that has finished the creation process. // internally the dependent nodes will be "notified" that an additional (if multiple exist) dependency is satisfied. SignalDone(nodeName string) // CheckAcyclicity checks if dependencies contain cycles. CheckAcyclicity() error // String returns a string representation of dependencies recorded with dependency manager. String() string }
func NewDependencyManager ¶ added in v0.32.0
func NewDependencyManager() DependencyManager
type GraphTopo ¶ added in v0.25.0
type GraphTopo struct { Nodes []types.ContainerDetails `json:"nodes,omitempty"` Links []Link `json:"links,omitempty"` }
type TopologyExport ¶ added in v0.26.0
type TopologyExport struct { Name string `json:"name"` Type string `json:"type"` Clab *CLab `json:"clab,omitempty"` NodeConfigs map[string]*types.NodeConfig `json:"nodeconfigs,omitempty"` }
TopologyExport holds a combination of CLab structure and map of NodeConfig types, which expands Node definitions with dynamically created values.
type VxLAN ¶
type VxLAN struct { Name string // interface name ParentIf string // parent interface name ID int // VxLan ID Remote net.IP // VxLan destination address MTU int // VxLan Interface MTU (with VxLan encap), used mirroring UDPPort int // VxLan UDP port (src/dest, no range, single value) }
VxLAN is a structure to describe vxlan endpoint adopted from https://github.com/redhat-nfvpe/koko/blob/bd156c82bf25837545fb109c69c7b91c3457b318/api/koko_api.go#L46