Documentation ¶
Index ¶
- Variables
- func AddVxLanInterface(vxlan VxLAN) (err error)
- func BindIfacesWithTC(if1, if2 string) (err error)
- func GetLinksByNamePrefix(prefix string) ([]netlink.Link, error)
- func SetIngressMirror(src, dst string) (err error)
- func StringInSlice(slice []string, val string) (int, bool)
- type CLab
- func (c *CLab) CheckResources() error
- func (c *CLab) CheckTopologyDefinition(ctx context.Context) error
- func (c *CLab) CreateLinks(ctx context.Context, workers uint, postdeploy bool)
- func (c *CLab) CreateNode(ctx context.Context, node *types.Node, certs *Certificates) error
- func (c *CLab) CreateNodeDirStructure(node *types.Node) (err error)
- func (c *CLab) CreateNodes(ctx context.Context, workers uint)
- func (c *CLab) CreateRootCA() error
- func (c *CLab) CreateVirtualWiring(l *types.Link) (err error)
- func (c *CLab) DeleteNetnsSymlinks() (err error)
- func (c *CLab) ExecPostDeployTasks(ctx context.Context, node *types.Node, lworkers uint) error
- func (c *CLab) GenerateCert(ca string, caKey string, csrJSONTpl *template.Template, input CertInput, ...) (*Certificates, error)
- func (c *CLab) GenerateGraph(topo string) error
- func (c *CLab) GenerateInventories() error
- func (c *CLab) GenerateRootCa(csrRootJsonTpl *template.Template, input CaRootInput) (*Certificates, error)
- func (c *CLab) GetTopology(topo string) error
- func (c *CLab) NewEndpoint(e string) *types.Endpoint
- func (c *CLab) NewLink(l LinkConfig) *types.Link
- func (c *CLab) NewNode(nodeName string, nodeCfg NodeConfig, idx int) error
- func (c *CLab) ParseTopology() error
- func (c *CLab) RetrieveNodeCertData(n *types.Node) (*Certificates, error)
- func (c *CLab) VerifyContainersUniqueness(ctx context.Context) error
- func (c *CLab) VerifyImages(ctx context.Context) error
- type CaRootInput
- type CertInput
- type Certificates
- type ClabOption
- type Config
- type Directory
- type LinkConfig
- type NodeConfig
- type TopoFile
- type Topology
- type VxLAN
Constants ¶
This section is empty.
Variables ¶
var DefaultCredentials = map[string][]string{
"vr-sros": {"admin", "admin"},
"vr-vmx": {"admin", "admin@123"},
"vr-xrv9k": {"clab", "clab@123"},
}
DefaultCredentials holds default username and password per each kind
Functions ¶
func AddVxLanInterface ¶
AddVxLanInterface creates VxLan interface by given vxlan object
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 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]*types.Node Links map[int]*types.Link Runtime runtime.ContainerRuntime Dir *Directory // contains filtered or unexported fields }
func NewContainerLab ¶
func NewContainerLab(opts ...ClabOption) *CLab
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) CreateLinks ¶
CreateLinks creates links using the specified number of workers `postdeploy` indicates the stage of links creation. `postdeploy=true` means the links routine is called after nodes postdeploy tasks
func (*CLab) CreateNode ¶
func (*CLab) CreateNodeDirStructure ¶
CreateNodeDirStructure create the directory structure and files for the lab nodes
func (*CLab) CreateRootCA ¶
CreateRootCA creates RootCA key/certificate if it is needed by the topology
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) ExecPostDeployTasks ¶
ExecPostDeployTasks executes tasks that some nodes might require to boot properly after start
func (*CLab) GenerateCert ¶
func (c *CLab) GenerateCert(ca string, caKey string, csrJSONTpl *template.Template, input CertInput, targetPath string) (*Certificates, error)
GenerateCert generates and signs a certificate passed as input and saves the certificate and generated private key by path CA used to sign the cert is passed as ca and caKey file paths
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) GenerateRootCa ¶
func (c *CLab) GenerateRootCa(csrRootJsonTpl *template.Template, input CaRootInput) (*Certificates, error)
GenerateRootCa function
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) NewEndpoint ¶
NewEndpoint initializes a new endpoint object
func (*CLab) NewLink ¶
func (c *CLab) NewLink(l LinkConfig) *types.Link
NewLink initializes a new link object
func (*CLab) NewNode ¶
func (c *CLab) NewNode(nodeName string, nodeCfg NodeConfig, idx int) error
NewNode initializes a new node object
func (*CLab) ParseTopology ¶
ParseTopology parses the lab topology
func (*CLab) RetrieveNodeCertData ¶
func (c *CLab) RetrieveNodeCertData(n *types.Node) (*Certificates, error)
RetrieveNodeCertData reads the node private key and certificate by the well known paths if either of those files doesn't exist, an error is returned
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 CaRootInput ¶
type CaRootInput struct { CommonName string Country string Locality string Organization string OrganizationUnit string Expiry string Prefix string Names map[string]string // Not used right now // prefix for certificate/key file name NamePrefix string }
CaRootInput struct
type CertInput ¶
type CertInput struct { Hosts []string CommonName string Country string Locality string Organization string OrganizationUnit string Expiry string Name string LongName string Fqdn string Prefix string }
CertInput struct
type Certificates ¶
type ClabOption ¶
type ClabOption func(c *CLab)
func WithDebug ¶
func WithDebug(d bool) ClabOption
func WithGracefulShutdown ¶
func WithGracefulShutdown(gracefulShutdown bool) ClabOption
func WithRuntime ¶ added in v0.14.0
func WithTimeout ¶
func WithTimeout(dur time.Duration) ClabOption
func WithTopoFile ¶
func WithTopoFile(file string) ClabOption
type Config ¶
type Config struct { Name string `json:"name,omitempty"` Mgmt *types.MgmtNet `json:"mgmt,omitempty"` Topology Topology `json:"topology,omitempty"` ConfigPath string `yaml:"config_path,omitempty"` }
Config defines lab configuration as it is provided in the YAML file
type LinkConfig ¶
type NodeConfig ¶
type NodeConfig struct { Kind string `yaml:"kind,omitempty"` Group string `yaml:"group,omitempty"` Type string `yaml:"type,omitempty"` Config string `yaml:"config,omitempty"` Image string `yaml:"image,omitempty"` License string `yaml:"license,omitempty"` Position string `yaml:"position,omitempty"` Cmd string `yaml:"cmd,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"` // 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"` }
NodeConfig represents a configuration a given node can have in the lab definition file
type TopoFile ¶
type TopoFile struct {
// contains filtered or unexported fields
}
TopoFile type is a struct which defines parameters of the topology file
type Topology ¶
type Topology struct { Defaults NodeConfig `yaml:"defaults,omitempty"` Kinds map[string]NodeConfig `yaml:"kinds,omitempty"` Nodes map[string]NodeConfig `yaml:"nodes,omitempty"` Links []LinkConfig `yaml:"links,omitempty"` }
Topology represents a lab topology
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