Documentation ¶
Index ¶
- Constants
- Variables
- func GetDefaultCredentialsForKind(kind string) ([]string, error)
- func LoadStartupConfigFileVr(node Node, configDirName, startupCfgFName string) error
- func Register(names []string, initFn Initializer)
- func SetDefaultCredentials(kindnames []string, user, password string) error
- func SetNonDefaultRuntimePerKind(kindnames []string, runtime string) error
- type DefaultNode
- func (d *DefaultNode) CheckDeploymentConditions(ctx context.Context) error
- func (d *DefaultNode) CheckInterfaceName() error
- func (d *DefaultNode) Config() *types.NodeConfig
- func (d *DefaultNode) Delete(ctx context.Context) error
- func (d *DefaultNode) DeleteNetnsSymlink() error
- func (d *DefaultNode) Deploy(ctx context.Context) error
- func (d *DefaultNode) GenerateConfig(dst, templ string) error
- func (d *DefaultNode) GetContainers(ctx context.Context) ([]types.GenericContainer, error)
- func (d *DefaultNode) GetImages(_ context.Context) map[string]string
- func (d *DefaultNode) GetRuntime() runtime.ContainerRuntime
- func (d *DefaultNode) PostDeploy(_ context.Context, _ map[string]Node) error
- func (d *DefaultNode) PreDeploy(_ context.Context, _, _, _ string) error
- func (d *DefaultNode) PullImage(ctx context.Context) error
- func (d *DefaultNode) RunExec(ctx context.Context, execCmd *exec.ExecCmd) (exec.ExecResultHolder, error)
- func (d *DefaultNode) RunExecTypeWoWait(ctx context.Context, execCmd *exec.ExecCmd) error
- func (d *DefaultNode) RunExecs(ctx context.Context, cmds []string) ([]exec.ExecResultHolder, error)
- func (d *DefaultNode) SaveConfig(_ context.Context) error
- func (d *DefaultNode) UpdateConfigWithRuntimeInfo(ctx context.Context) error
- func (d *DefaultNode) VerifyHostRequirements() error
- func (d *DefaultNode) VerifyStartupConfig(topoDir string) error
- func (d *DefaultNode) WithMgmtNet(mgmt *types.MgmtNet)
- func (d *DefaultNode) WithRuntime(r runtime.ContainerRuntime)
- type Initializer
- type Node
- type NodeOption
- type NodeOverwrites
Constants ¶
const ( // default connection mode for vrnetlab based containers. VrDefConnMode = "tc" // keys for the map returned by GetImages. ImageKey = "image" KernelKey = "kernel" SandboxKey = "sandbox" NodeKindBridge = "bridge" NodeKindHOST = "host" NodeKindOVS = "ovs-bridge" NodeKindSRL = "srl" )
Variables ¶
var ( NodeKind string // a map of node kinds overriding the default global runtime. NonDefaultRuntimes = map[string]string{} // Nodes is a map of all supported kinds and their init functions. Nodes = map[string]Initializer{} DefaultConfigTemplates = map[string]string{ "vr-sros": "", } // ErrCommandExecError is an error returned when a command is failed to execute on a given node. ErrCommandExecError = errors.New("command execution error") )
Functions ¶
func GetDefaultCredentialsForKind ¶ added in v0.27.0
GetDefaultCredentialsForKind retrieve the default credentials for a certain kind the first element in the slice is the Username, the second is the password.
func LoadStartupConfigFileVr ¶ added in v0.34.0
LoadStartupConfigFileVr templates a startup-config using the file specified for VM-based nodes in the topo and puts the resulting config file by the LabDir/configDirName/startupCfgFName path.
func Register ¶
func Register(names []string, initFn Initializer)
func SetDefaultCredentials ¶ added in v0.27.0
SetDefaultCredentials register default credentials per provided kindname.
func SetNonDefaultRuntimePerKind ¶ added in v0.27.0
SetNonDefaultRuntimePerKind sets a non default runtime for kinds that requires that (see cvx).
Types ¶
type DefaultNode ¶ added in v0.33.0
type DefaultNode struct { Cfg *types.NodeConfig Mgmt *types.MgmtNet Runtime runtime.ContainerRuntime HostRequirements types.HostRequirements // OverwriteNode stores the interface used to overwrite methods defined // for DefaultNode, so that particular nodes can provide custom implementations. OverwriteNode NodeOverwrites }
DefaultNode implements the Node interface and is embedded to the structs of all other nodes. It has common fields and methods that every node should typically have. Nodes can override methods if needed.
func NewDefaultNode ¶ added in v0.34.0
func NewDefaultNode(n NodeOverwrites) *DefaultNode
NewDefaultNode initializes the DefaultNode structure and receives a NodeOverwrites interface which is implemented by the node struct of a particular kind. This allows DefaultNode to access fields of the specific node struct in the methods defined for DefaultNode.
func (*DefaultNode) CheckDeploymentConditions ¶ added in v0.34.0
func (d *DefaultNode) CheckDeploymentConditions(ctx context.Context) error
func (*DefaultNode) CheckInterfaceName ¶ added in v0.34.0
func (d *DefaultNode) CheckInterfaceName() error
CheckInterfaceName checks if a name of the interface referenced in the topology file correct.
func (*DefaultNode) Config ¶ added in v0.33.0
func (d *DefaultNode) Config() *types.NodeConfig
func (*DefaultNode) Delete ¶ added in v0.33.0
func (d *DefaultNode) Delete(ctx context.Context) error
func (*DefaultNode) DeleteNetnsSymlink ¶ added in v0.34.0
func (d *DefaultNode) DeleteNetnsSymlink() error
DeleteNetnsSymlink deletes the symlink file created for the container netns.
func (*DefaultNode) Deploy ¶ added in v0.33.0
func (d *DefaultNode) Deploy(ctx context.Context) error
func (*DefaultNode) GenerateConfig ¶ added in v0.34.0
func (d *DefaultNode) GenerateConfig(dst, templ string) error
GenerateConfig generates configuration for the nodes out of the template based on the node configuration and saves the result to dst.
func (*DefaultNode) GetContainers ¶ added in v0.34.0
func (d *DefaultNode) GetContainers(ctx context.Context) ([]types.GenericContainer, error)
func (*DefaultNode) GetImages ¶ added in v0.33.0
func (d *DefaultNode) GetImages(_ context.Context) map[string]string
func (*DefaultNode) GetRuntime ¶ added in v0.33.0
func (d *DefaultNode) GetRuntime() runtime.ContainerRuntime
func (*DefaultNode) PostDeploy ¶ added in v0.33.0
func (*DefaultNode) PreDeploy ¶ added in v0.33.0
func (d *DefaultNode) PreDeploy(_ context.Context, _, _, _ string) error
func (*DefaultNode) PullImage ¶ added in v0.34.0
func (d *DefaultNode) PullImage(ctx context.Context) error
func (*DefaultNode) RunExec ¶ added in v0.34.0
func (d *DefaultNode) RunExec(ctx context.Context, execCmd *exec.ExecCmd) (exec.ExecResultHolder, error)
RunExec executes a single command for a node.
func (*DefaultNode) RunExecTypeWoWait ¶ added in v0.34.0
RunExecTypeWoWait is the final function that calls the runtime to execute a type.Exec on a container This is to be overriden if the nodes implementation differs.
func (*DefaultNode) RunExecs ¶ added in v0.34.0
func (d *DefaultNode) RunExecs(ctx context.Context, cmds []string) ([]exec.ExecResultHolder, error)
RunExecs executes cmds commands for a node. Commands is a list of strings.
func (*DefaultNode) SaveConfig ¶ added in v0.33.0
func (d *DefaultNode) SaveConfig(_ context.Context) error
func (*DefaultNode) UpdateConfigWithRuntimeInfo ¶ added in v0.34.0
func (d *DefaultNode) UpdateConfigWithRuntimeInfo(ctx context.Context) error
func (*DefaultNode) VerifyHostRequirements ¶ added in v0.34.0
func (d *DefaultNode) VerifyHostRequirements() error
func (*DefaultNode) VerifyStartupConfig ¶ added in v0.34.0
func (d *DefaultNode) VerifyStartupConfig(topoDir string) error
VerifyStartupConfig verifies that startup config files exists on disks.
func (*DefaultNode) WithMgmtNet ¶ added in v0.33.0
func (d *DefaultNode) WithMgmtNet(mgmt *types.MgmtNet)
func (*DefaultNode) WithRuntime ¶ added in v0.33.0
func (d *DefaultNode) WithRuntime(r runtime.ContainerRuntime)
type Initializer ¶
type Initializer func() Node
type Node ¶
type Node interface { Init(*types.NodeConfig, ...NodeOption) error // GetContainers returns a pointer to GenericContainer that the node uses. GetContainers(ctx context.Context) ([]types.GenericContainer, error) DeleteNetnsSymlink() (err error) Config() *types.NodeConfig // Config returns the nodes configuration // CheckDeploymentConditions checks if node-scoped deployment conditions are met. CheckDeploymentConditions(context.Context) error PreDeploy(ctx context.Context, configName, labCADir, labCARoot string) error Deploy(context.Context) error // Deploy triggers the deployment of this node PostDeploy(context.Context, map[string]Node) error WithMgmtNet(*types.MgmtNet) // WithMgmtNet provides the management network for the node WithRuntime(runtime.ContainerRuntime) // WithRuntime provides the runtime for the node // CheckInterfaceName checks if a name of the interface referenced in the topology file correct CheckInterfaceName() error // VerifyStartupConfig checks for existence of the referenced file and maybe performs additional config checks VerifyStartupConfig(topoDir string) error SaveConfig(context.Context) error // SaveConfig saves the nodes configuration to an external file Delete(context.Context) error // Delete triggers the deletion of this node GetImages(context.Context) map[string]string // GetImages returns the images used for this kind GetRuntime() runtime.ContainerRuntime // GetRuntime returns the nodes assigned runtime GenerateConfig(dst, templ string) error // Generate the nodes configuration // UpdateConfigWithRuntimeInfo updates node config with runtime info like IP addresses assgined by runtime UpdateConfigWithRuntimeInfo(context.Context) error // RunExecs executes all exec commands specified for the node. RunExecs(ctx context.Context, cmds []string) ([]exec.ExecResultHolder, error) // RunExec execute a single command for a given node. RunExec(ctx context.Context, execCmd *exec.ExecCmd) (exec.ExecResultHolder, error) }
type NodeOption ¶
type NodeOption func(Node)
func WithMgmtNet ¶
func WithMgmtNet(mgmt *types.MgmtNet) NodeOption
func WithRuntime ¶
func WithRuntime(r runtime.ContainerRuntime) NodeOption
type NodeOverwrites ¶ added in v0.34.0
type NodeOverwrites interface { VerifyStartupConfig(topoDir string) error CheckInterfaceName() error VerifyHostRequirements() error PullImage(ctx context.Context) error GetImages(ctx context.Context) map[string]string }
NodeOverwrites is an interface that every node implementation implements. It is used to enable DefaultNode to get access to the particular node structs and is provided as an argument of the NewDefaultNode function. The methods defined for this interfaces are the methods that particular node has a custom implementation of.