Documentation ¶
Index ¶
- Constants
- Variables
- func BindIfacesWithTC(if1, if2 string) (err error)
- func FindTopoFileByPath(path string) (string, error)
- func RetrieveSSHAgentKeys() ([]ssh.PublicKey, error)
- func RetrieveSSHPubKeysFromFiles() ([]ssh.PublicKey, error)
- func RuntimeInitializer(name string) (string, runtime.Initializer, error)
- func SetIngressMirror(src, dst string) (err error)
- type AnsibleInventory
- type AnsibleInventoryNode
- type CLab
- func (c *CLab) BuildGraphFromDeployedLab(g *GraphTopo, containers []runtime.GenericContainer)
- func (c *CLab) BuildGraphFromTopo(g *GraphTopo)
- func (c *CLab) CreateNetwork(ctx context.Context) error
- func (c *CLab) DeleteEntriesFromHostsFile() error
- func (c *CLab) Deploy(ctx context.Context, options *DeployOptions) ([]runtime.GenericContainer, error)
- func (c *CLab) Destroy(ctx context.Context, maxWorkers uint, keepMgmtNet bool) error
- func (c *CLab) Exec(ctx context.Context, cmds []string, options *ExecOptions) (*exec.ExecCollection, error)
- func (c *CLab) GenerateDotGraph() error
- func (c *CLab) GenerateDrawioDiagram(version string) error
- func (c *CLab) GenerateExports(ctx context.Context, f io.Writer, p string) error
- func (c *CLab) GenerateInventories() error
- func (c *CLab) GenerateMermaidGraph(direction string) error
- func (c *CLab) GetNode(name string) (nodes.Node, error)
- 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) ListNodesContainersIgnoreNotFound(ctx context.Context) ([]runtime.GenericContainer, error)
- func (c *CLab) LoadOrGenerateCA(caCertInput *cert.CACSRInput) error
- func (c *CLab) LoadTopologyFromFile(topo, varsFile string) error
- func (c *CLab) NewNode(nodeName, nodeRuntime string, nodeDef *types.NodeDefinition, idx int) error
- func (c *CLab) ProcessTopoPath(path string) (string, error)
- func (c *CLab) RegisterNodes()
- func (c *CLab) RemoveSSHConfig(topoPaths *types.TopoPaths) error
- func (c *CLab) ResolveLinks() error
- func (c *CLab) RetrieveSSHPubKeys() ([]ssh.PublicKey, error)
- func (c *CLab) ServeTopoGraph(tmpl, staticDir, srv string, topoD TopoData) error
- type ClabOption
- func WithDebug(debug bool) ClabOption
- func WithDependencyManager(dm depMgr.DependencyManager) ClabOption
- func WithKeepMgmtNet() ClabOption
- func WithLabName(n string) ClabOption
- func WithManagementIpv4Subnet(s string) ClabOption
- func WithManagementIpv6Subnet(s string) ClabOption
- func WithManagementNetworkName(n string) ClabOption
- func WithNodeFilter(nodeFilter []string) ClabOption
- func WithRuntime(name string, rtconfig *runtime.RuntimeConfig) ClabOption
- func WithTimeout(dur time.Duration) ClabOption
- func WithTopoPath(path, varsFile string) ClabOption
- type Config
- type DeployOptions
- func (d *DeployOptions) ExportTemplate() string
- func (d *DeployOptions) Graph() bool
- func (d *DeployOptions) MaxWorkers() uint
- func (d *DeployOptions) Reconfigure() bool
- func (d *DeployOptions) SetExportTemplate(templatePath string) *DeployOptions
- func (d *DeployOptions) SetGraph(b bool) *DeployOptions
- func (d *DeployOptions) SetMaxWorkers(i uint) *DeployOptions
- func (d *DeployOptions) SetReconfigure(b bool) *DeployOptions
- func (d *DeployOptions) SetSkipLabDirFileACLs(b bool) *DeployOptions
- func (d *DeployOptions) SetSkipPostDeploy(b bool) *DeployOptions
- func (d *DeployOptions) SkipPostDeploy() bool
- type ExecOptions
- type GraphTopo
- type KindProps
- type Link
- type SSHConfigNodeTmpl
- type SSHConfigTmpl
- type TopoData
- type TopologyExport
Constants ¶
const (
// veth link mtu.
DefaultVethLinkMTU = 9500
)
Variables ¶
var ErrNodeNotFound = errors.New("node not found")
Functions ¶
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 FindTopoFileByPath ¶ added in v0.48.5
FindTopoFileByPath takes a topology path, which might be the path to a directory and returns the topology file name if found.
func RetrieveSSHAgentKeys ¶ added in v0.44.0
RetrieveSSHAgentKeys retrieves public keys registered with the ssh-agent.
func RetrieveSSHPubKeysFromFiles ¶ added in v0.44.0
RetrieveSSHPubKeysFromFiles retrieves public keys from the ~/.ssh/*.authorized_keys and ~/.ssh/*.pub files.
func RuntimeInitializer ¶ added in v0.44.0
func RuntimeInitializer(name string) (string, runtime.Initializer, error)
RuntimeInitializer returns a runtime initializer function for a provided runtime name.
func SetIngressMirror ¶
SetIngressMirror sets TC to mirror ingress from given port as MirrorIngress.
Types ¶
type AnsibleInventory ¶ added in v0.50.0
type AnsibleInventory struct { // clab node kinds Kinds map[string]*KindProps // clab nodes aggregated by their kind Nodes map[string][]*AnsibleInventoryNode // clab nodes aggregated by user-defined groups Groups map[string][]*AnsibleInventoryNode }
AnsibleInventory represents the data structure used to generate the ansible inventory file.
type AnsibleInventoryNode ¶ added in v0.50.0
type AnsibleInventoryNode struct {
*types.NodeConfig
}
AnsibleInventoryNode represents the data structure used to generate the ansible inventory file. It embeds the NodeConfig struct and adds the Username and Password fields extracted from the node registry.
type CLab ¶
type CLab struct { Config *Config `json:"config,omitempty"` TopoPaths *types.TopoPaths Nodes map[string]nodes.Node `json:"nodes,omitempty"` Links map[int]links.Link `json:"links,omitempty"` Endpoints []links.Endpoint Runtimes map[string]runtime.ContainerRuntime `json:"runtimes,omitempty"` // reg is a registry of node kinds Reg *nodes.NodeRegistry Cert *cert.Cert // List of SSH public keys extracted from the ~/.ssh/authorized_keys file // and ~/.ssh/*.pub files. // The keys are used to enable key-based SSH access for the nodes. SSHPubKeys []ssh.PublicKey // 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) CreateNetwork ¶ added in v0.24.0
func (*CLab) DeleteEntriesFromHostsFile ¶ added in v0.53.0
func (*CLab) Deploy ¶ added in v0.53.0
func (c *CLab) Deploy(ctx context.Context, options *DeployOptions) ([]runtime.GenericContainer, error)
Deploy the given topology. skipcq: GO-R1005
func (*CLab) Exec ¶
func (c *CLab) Exec(ctx context.Context, cmds []string, options *ExecOptions) (*exec.ExecCollection, error)
Exec execute commands on running topology nodes.
func (*CLab) GenerateDotGraph ¶ added in v0.43.0
GenerateDotGraph generates a graph of the lab topology.
func (*CLab) GenerateDrawioDiagram ¶ added in v0.53.0
func (*CLab) GenerateExports ¶ added in v0.26.0
GenerateExports generates various export files and writes it to a lab location.
func (*CLab) GenerateInventories ¶
GenerateInventories generate various inventory files and writes it to a lab location.
func (*CLab) GenerateMermaidGraph ¶ added in v0.43.0
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) ListNodesContainersIgnoreNotFound ¶ added in v0.44.0
func (c *CLab) ListNodesContainersIgnoreNotFound(ctx context.Context) ([]runtime.GenericContainer, error)
ListNodesContainersIgnoreNotFound lists all containers based on the nodes stored in clab instance, ignoring errors for non found containers.
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) LoadTopologyFromFile ¶ added in v0.53.0
LoadTopologyFromFile loads a topology by the topo file path parses the topology file into c.Conf structure as well as populates the TopoFile structure with the topology file related information.
func (*CLab) ProcessTopoPath ¶ added in v0.48.5
ProcessTopoPath takes a topology path, which might be the path to a directory or a file or stdin or a URL and returns the topology file name if found.
func (*CLab) RegisterNodes ¶ added in v0.35.0
func (c *CLab) RegisterNodes()
RegisterNodes registers all the nodes/kinds supported by containerlab.
func (*CLab) RemoveSSHConfig ¶ added in v0.47.0
RemoveSSHConfig removes the lab specific ssh config file.
func (*CLab) ResolveLinks ¶ added in v0.44.0
ResolveLinks resolves raw links to the actual link types and stores them in the CLab.Links map.
func (*CLab) RetrieveSSHPubKeys ¶ added in v0.44.0
RetrieveSSHPubKeys retrieves the PubKeys from the different sources SSHAgent as well as all home dir based /.ssh/*.pub files.
type ClabOption ¶
func WithDependencyManager ¶ added in v0.51.0
func WithDependencyManager(dm depMgr.DependencyManager) ClabOption
WithDependencyManager adds Dependency Manager.
func WithKeepMgmtNet ¶ added in v0.15.0
func WithKeepMgmtNet() ClabOption
func WithLabName ¶ added in v0.53.0
func WithLabName(n string) ClabOption
WithLabName sets the name of the lab to the provided string.
func WithManagementIpv4Subnet ¶ added in v0.53.0
func WithManagementIpv4Subnet(s string) ClabOption
WithManagementIpv4Subnet defined the IPv4 subnet that will be used for the mgmt network.
func WithManagementIpv6Subnet ¶ added in v0.53.0
func WithManagementIpv6Subnet(s string) ClabOption
WithManagementIpv6Subnet defined the IPv6 subnet that will be used for the mgmt network.
func WithManagementNetworkName ¶ added in v0.53.0
func WithManagementNetworkName(n string) ClabOption
WithManagementNetworkName sets the name of the management network that is to be used.
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
WithRuntime option sets a container runtime to be used by containerlab.
func WithTimeout ¶
func WithTimeout(dur time.Duration) ClabOption
func WithTopoPath ¶ added in v0.45.0
func WithTopoPath(path, varsFile string) ClabOption
type Config ¶
type Config struct { Name string `json:"name,omitempty"` Prefix *string `json:"prefix,omitempty"` Mgmt *types.MgmtNet `json:"mgmt,omitempty"` Settings *types.Settings `json:"settings,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 DeployOptions ¶ added in v0.53.0
type DeployOptions struct {
// contains filtered or unexported fields
}
DeployOptions represents the options for deploying a lab.
func NewDeployOptions ¶ added in v0.53.0
func NewDeployOptions(maxWorkers uint) (*DeployOptions, error)
NewDeployOptions creates a new DeployOptions instance with the specified maxWorkers value.
func (*DeployOptions) ExportTemplate ¶ added in v0.53.0
func (d *DeployOptions) ExportTemplate() string
ExportTemplate returns the exportTemplate option value.
func (*DeployOptions) Graph ¶ added in v0.53.0
func (d *DeployOptions) Graph() bool
Graph returns the graph option value.
func (*DeployOptions) MaxWorkers ¶ added in v0.53.0
func (d *DeployOptions) MaxWorkers() uint
MaxWorkers returns the maxWorkers option value.
func (*DeployOptions) Reconfigure ¶ added in v0.53.0
func (d *DeployOptions) Reconfigure() bool
Reconfigure returns the reconfigure option value.
func (*DeployOptions) SetExportTemplate ¶ added in v0.53.0
func (d *DeployOptions) SetExportTemplate(templatePath string) *DeployOptions
SetExportTemplate sets the exportTemplate option and returns the updated DeployOptions instance.
func (*DeployOptions) SetGraph ¶ added in v0.53.0
func (d *DeployOptions) SetGraph(b bool) *DeployOptions
SetGraph sets the graph option and returns the updated DeployOptions instance.
func (*DeployOptions) SetMaxWorkers ¶ added in v0.53.0
func (d *DeployOptions) SetMaxWorkers(i uint) *DeployOptions
SetMaxWorkers sets the maxWorkers option and returns the updated DeployOptions instance.
func (*DeployOptions) SetReconfigure ¶ added in v0.53.0
func (d *DeployOptions) SetReconfigure(b bool) *DeployOptions
SetReconfigure sets the reconfigure option and returns the updated DeployOptions instance.
func (*DeployOptions) SetSkipLabDirFileACLs ¶ added in v0.55.0
func (d *DeployOptions) SetSkipLabDirFileACLs(b bool) *DeployOptions
SetSkipLabDirFileACLs sets the skipLabDirFileACLs deployment option.
func (*DeployOptions) SetSkipPostDeploy ¶ added in v0.53.0
func (d *DeployOptions) SetSkipPostDeploy(b bool) *DeployOptions
SetSkipPostDeploy sets the skipPostDeploy option and returns the updated DeployOptions instance.
func (*DeployOptions) SkipPostDeploy ¶ added in v0.53.0
func (d *DeployOptions) SkipPostDeploy() bool
SkipPostDeploy returns the skipPostDeploy option value.
type ExecOptions ¶ added in v0.53.0
type ExecOptions struct {
// contains filtered or unexported fields
}
func NewExecOptions ¶ added in v0.53.0
func NewExecOptions(filters []*types.GenericFilter) *ExecOptions
func (*ExecOptions) AddFilters ¶ added in v0.53.0
func (e *ExecOptions) AddFilters(f ...*types.GenericFilter)
type GraphTopo ¶ added in v0.25.0
type GraphTopo struct { Nodes []types.ContainerDetails `json:"nodes,omitempty"` Links []Link `json:"links,omitempty"` }
type KindProps ¶ added in v0.50.0
KindProps is the kind properties structure used to generate the ansible inventory file.
type SSHConfigNodeTmpl ¶ added in v0.47.0
SSHConfigNodeTmpl represents values for a single node in the sshconfig template.
type SSHConfigTmpl ¶ added in v0.47.0
type SSHConfigTmpl struct { Nodes []SSHConfigNodeTmpl TopologyName string }
SSHConfigTmpl is the top-level data structure for the sshconfig template.
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.