Documentation ¶
Index ¶
- Constants
- Variables
- func GetDefaultCredentialsForKind(kind string) ([]string, error)
- func LoadStartupConfigFileVr(node Node, configDirName, startupCfgFName string) error
- func SetDefaultCredentials(kindnames []string, user, password string) error
- func SetNonDefaultRuntimePerKind(kindnames []string, runtime string) error
- type Credentials
- 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) GetContainerName() string
- func (d *DefaultNode) GetContainers(ctx context.Context) ([]runtime.GenericContainer, error)
- func (d *DefaultNode) GetImages(_ context.Context) map[string]string
- func (d *DefaultNode) GetRuntime() runtime.ContainerRuntime
- func (*DefaultNode) PostDeploy(_ context.Context, _ map[string]Node) error
- func (*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.ExecResult, error)
- func (d *DefaultNode) RunExecNotWait(ctx context.Context, execCmd *exec.ExecCmd) 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
- type NodeRegistry
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{} 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 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 Credentials ¶ added in v0.35.0
type Credentials struct {
// contains filtered or unexported fields
}
Credentials defines NOS SSH credentials.
func NewCredentials ¶ added in v0.35.0
func NewCredentials(username, password string) *Credentials
NewCredentials constructor for the Credentials struct.
func (*Credentials) GetPassword ¶ added in v0.35.0
func (c *Credentials) GetPassword() string
func (*Credentials) GetUsername ¶ added in v0.35.0
func (c *Credentials) GetUsername() string
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
CheckDeploymentConditions wraps individual functions that check if a node satisfies deployment requirements.
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) GetContainerName ¶ added in v0.35.0
func (d *DefaultNode) GetContainerName() string
GetContainerName returns the name used by the runtime to identify the container e.g. ext-container nodes use the name as defined in the topo file, while most other containers use long (prefixed) name.
func (*DefaultNode) GetContainers ¶ added in v0.34.0
func (d *DefaultNode) GetContainers(ctx context.Context) ([]runtime.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 (*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.ExecResult, error)
RunExec executes a single command for a node.
func (*DefaultNode) RunExecNotWait ¶ added in v0.35.0
RunExecNotWait executes a command for a node, and doesn't block waiting for the output. Should be overriden if the nodes implementation differs.
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) ([]runtime.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 is correct for this node 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 assigned by runtime UpdateConfigWithRuntimeInfo(context.Context) error // RunExec execute a single command for a given node. RunExec(ctx context.Context, execCmd *exec.ExecCmd) (*exec.ExecResult, 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 GetContainers(ctx context.Context) ([]runtime.GenericContainer, error) GetContainerName() 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.
type NodeRegistry ¶ added in v0.35.0
type NodeRegistry struct {
// contains filtered or unexported fields
}
func NewNodeRegistry ¶ added in v0.35.0
func NewNodeRegistry() *NodeRegistry
NewNodeRegistry constructs a new Registry.
func (*NodeRegistry) GetRegisteredNodeKindNames ¶ added in v0.35.0
func (r *NodeRegistry) GetRegisteredNodeKindNames() []string
GetRegisteredNodeKindNames returns a sorted slice of all the registered node kind names in the registry.
func (*NodeRegistry) NewNodeOfKind ¶ added in v0.35.0
func (r *NodeRegistry) NewNodeOfKind(nodeKindName string) (Node, error)
NewNodeOfKind return a new Node of the given Node Kind.
func (*NodeRegistry) Register ¶ added in v0.35.0
func (r *NodeRegistry) Register(names []string, initf Initializer, credentials *Credentials) error
Register registers the node' init function for all provided names.