testbed

package
v1.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2024 License: MIT Imports: 8 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AlreadyInitCheck

func AlreadyInitCheck(dir string, force bool) error

func NodesFromSpecs

func NodesFromSpecs(specs []*NodeSpec) ([]testbedi.Core, error)

func RegisterPlugin

func RegisterPlugin(plg IptbPlugin, force bool) (bool, error)

RegisterPlugin registers a plugin, the `force` flag can be passed to override any plugin registered under the same IptbPlugin.PluginName

func WriteNodeSpecs

func WriteNodeSpecs(dir string, specs []*NodeSpec) error

Types

type BasicTestbed

type BasicTestbed struct {
	// contains filtered or unexported fields
}

func NewTestbed

func NewTestbed(dir string) BasicTestbed

func (*BasicTestbed) Dir

func (tb *BasicTestbed) Dir() string

func (BasicTestbed) Name

func (tb BasicTestbed) Name() string

func (*BasicTestbed) Node

func (tb *BasicTestbed) Node(n int) (testbedi.Core, error)

func (*BasicTestbed) Nodes

func (tb *BasicTestbed) Nodes() ([]testbedi.Core, error)

func (*BasicTestbed) Spec

func (tb *BasicTestbed) Spec(n int) (*NodeSpec, error)

func (*BasicTestbed) Specs

func (tb *BasicTestbed) Specs() ([]*NodeSpec, error)

type IptbPlugin

type IptbPlugin struct {
	From        string
	NewNode     testbedi.NewNodeFunc
	GetAttrList testbedi.GetAttrListFunc
	GetAttrDesc testbedi.GetAttrDescFunc
	PluginName  string
	BuiltIn     bool
}

IptbPlugin contains exported symbols from loaded plugins

func GetPlugin

func GetPlugin(name string) (IptbPlugin, bool)

GetPlugin returns a plugin registered with RegisterPlugin

func LoadPlugin

func LoadPlugin(path string) (*IptbPlugin, error)

LoadPlugin loads a plugin from `path`

type NodeSpec

type NodeSpec struct {
	Type  string
	Dir   string
	Attrs map[string]string
}

NodeSpec represents a node's specification

func BuildSpecs

func BuildSpecs(base string, count int, typ string, attrs map[string]string) ([]*NodeSpec, error)

func ReadNodeSpecs

func ReadNodeSpecs(dir string) ([]*NodeSpec, error)

func (*NodeSpec) GetAttr

func (ns *NodeSpec) GetAttr(attr string) (string, error)

GetAttr gets an attribute from the NodeSpec

func (*NodeSpec) Load

func (ns *NodeSpec) Load() (testbedi.Core, error)

Load uses plugins registered with RegisterPlugin to construct a Core node from the NodeSpec

func (*NodeSpec) SetAttr

func (ns *NodeSpec) SetAttr(attr string, val string)

SetAttr sets an attribute on the NodeSpec

type Testbed

type Testbed interface {
	Name() string

	// Spec returns a spec for node n
	Spec(n int) (*NodeSpec, error)

	// Specs returns all specs
	Specs() ([]*NodeSpec, error)

	// Node returns node n, specified by spec n
	Node(n int) (testbedi.Core, error)

	// Node returns all nodes, specified by all specs
	Nodes() ([]testbedi.Core, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL