Documentation ¶
Index ¶
- Constants
- func AddVxLanInterface(vxlan VxLAN) (err error)
- func AppendHostsFileEntries(containers []types.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 (*CLab) CheckResources() error
- 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) CreateNodes(ctx context.Context, maxWorkers uint, serialNodes map[string]struct{}) (*sync.WaitGroup, *sync.WaitGroup)
- func (c *CLab) CreateVirtualWiring(l *types.Link) (err error)
- func (c *CLab) DeleteNetnsSymlinks() (err error)
- func (c *CLab) DeleteNodes(ctx context.Context, workers uint, serialNodes map[string]struct{})
- func (c *CLab) GenerateGraph(_ string) error
- func (c *CLab) GenerateInventories() error
- func (c *CLab) GetNodeRuntime(query string) (runtime.ContainerRuntime, error)
- func (c *CLab) GetTopology(topo, varsFile string) error
- func (c *CLab) GlobalRuntime() runtime.ContainerRuntime
- func (c *CLab) ListContainers(ctx context.Context, labels []*types.GenericFilter) ([]types.GenericContainer, 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) VerifyContainersUniqueness(ctx context.Context) error
- func (c *CLab) VerifyImages(ctx context.Context) error
- type ClabOption
- type Config
- type Directory
- type TopoFile
- type VxLAN
Constants ¶
const ( // veth link mtu DefaultVethLinkMTU = 9500 // containerlab's reserved OUI ClabOUI = "aa:c1:ab" // label names ContainerlabLabel = "containerlab" NodeNameLabel = "clab-node-name" NodeKindLabel = "clab-node-kind" NodeTypeLabel = "clab-node-type" NodeGroupLabel = "clab-node-group" NodeLabDirLabel = "clab-node-lab-dir" TopoFileLabel = "clab-topo-file" )
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 []types.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 TopoFile *TopoFile Nodes map[string]nodes.Node Links map[int]*types.Link Runtimes map[string]runtime.ContainerRuntime Dir *Directory // contains filtered or unexported fields }
func NewContainerLab ¶
func NewContainerLab(opts ...ClabOption) (*CLab, error)
NewContainerLab function defines a new container lab
func (*CLab) CheckResources ¶
CheckResources runs container host resources check
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) CreateNodes ¶
func (c *CLab) CreateNodes(ctx context.Context, maxWorkers uint, serialNodes map[string]struct{}) (*sync.WaitGroup, *sync.WaitGroup)
CreateNodes will schedule nodes creation returns waitgroups for nodes with static and dynamic IPs, since static nodes are scheduled first
func (*CLab) CreateVirtualWiring ¶
CreateVirtualWiring creates the virtual topology between the containers
func (*CLab) DeleteNetnsSymlinks ¶
DeleteNetnsSymlinks deletes the symlink file created for each container netns
func (*CLab) DeleteNodes ¶ added in v0.15.0
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(query 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) ListContainers ¶
func (c *CLab) ListContainers(ctx context.Context, labels []*types.GenericFilter) ([]types.GenericContainer, error)
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) 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
type ClabOption ¶
func WithKeepMgmtNet ¶ added in v0.15.0
func WithKeepMgmtNet() ClabOption
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"` ConfigPath string }
Config defines lab configuration as it is provided in the YAML file
type TopoFile ¶
type TopoFile struct {
// contains filtered or unexported fields
}
TopoFile type is a struct which defines parameters of the topology file
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