topo

package
v0.0.0-...-33e3a13 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Link struct {
	Name  string
	Type  LinkType
	Nodes [2]*Node
	MACs  [2]string
	IPs   [2]string
}

Link is a link between nodes in a topology

func NewLink() *Link

NewLink returns a new Link

func (*Link) String

func (l *Link) String() string

String returns the link as string

type LinkType

type LinkType uint8

LinkType is the type of a link

const (
	LinkTypeVeth LinkType = iota
	LinkTypeInvalid
)

Link types

func ParseLinkType

func ParseLinkType(s string) LinkType

ParseLinkType parses the link type in s

func (*LinkType) String

func (lt *LinkType) String() string

String returns the link type as string

type Node

type Node struct {
	Name   string
	Type   NodeType
	Routes []*Route
	Run    []string
}

Node is a node in a topology

func NewNode

func NewNode() *Node

NewNode returns a new Node

func (*Node) String

func (n *Node) String() string

String returns the node as string

type NodeType

type NodeType uint8

NodeType is the type of a node

const (
	NodeTypeNode NodeType = iota
	NodeTypeBridge
	NodeTypeRouter
	NodeTypeInvalid
)

Node types

func ParseNodeType

func ParseNodeType(s string) NodeType

ParseNodeType parses the node type in s

func (*NodeType) String

func (nt *NodeType) String() string

String returns the node type as string

type Route

type Route struct {
	Route string
	Via   string
}

Route is a routing table entry on a node

func (*Route) String

func (r *Route) String() string

String returns the route as string

type Run

type Run struct {
	Node     string // TODO: use *Node?
	Commands []string
}

Run is a list of command to run on a node

func NewRun

func NewRun() *Run

NewRun returns a new Run

func (*Run) String

func (r *Run) String() string

String returns run as string

type Topology

type Topology struct {
	Name  string
	Nodes []*Node
	Links []*Link
	Run   []*Run
}

Topology is a network topology

func GetTopologies

func GetTopologies() []*Topology

GetTopologies returns all topologies

func GetTopology

func GetTopology(name string) *Topology

GetTopology returns the topology identified by name

func NewTopology

func NewTopology() *Topology

NewTopology returns a new Topology

func NewTopologyYAML

func NewTopologyYAML(b []byte) *Topology

NewTopologyYAML parses and returns the yaml topology in b

func NewTopologyYAMLFile

func NewTopologyYAMLFile(file string) *Topology

NewTopologyYAMLFile returns a new topology parsed from yaml file

func ParseYAMLTopology

func ParseYAMLTopology(b []byte) *Topology

ParseYAMLTopology parses and returns the yaml topology in b

func (t *Topology) AddLink(link *Link)

AddLink adds a link to the topology

func (*Topology) AddNode

func (t *Topology) AddNode(node *Node)

AddNode adds a node to the topology

func (*Topology) AddRun

func (t *Topology) AddRun(run *Run)

AddRun adds a list of commands to run to the topology

func (*Topology) GetNode

func (t *Topology) GetNode(name string) *Node

GetNode returns the first node with name

func (*Topology) RemoveTopologyFile

func (t *Topology) RemoveTopologyFile()

RemoveTopologyFile removes the topology from the topologies directory

func (*Topology) SaveTopologyFile

func (t *Topology) SaveTopologyFile()

SaveTopologyFile saves the topology in the topologies directory

func (*Topology) String

func (t *Topology) String() string

String returns the topology as string

func (*Topology) YAML

func (t *Topology) YAML() []byte

YAML returns the topology as yaml

type YAMLLink struct {
	Name  string
	Type  YAMLLinkType
	Nodes [2]string
	MACs  [2]string
	IPs   [2]string
}

YAMLLink is a yaml representation of a link

func NewYAMLLink(l *Link) *YAMLLink

NewYAMLLink returns a new YAMLLink

type YAMLLinkType

type YAMLLinkType string

YAMLLinkType is a yaml representation of a link type

type YAMLNode

type YAMLNode struct {
	Name   string
	Type   YAMLNodeType
	Routes []*Route
	Run    []string
}

YAMLNode is a yaml representation of a node

func NewYAMLNode

func NewYAMLNode(n *Node) *YAMLNode

NewYAMLNode returns a new YAMLNode

type YAMLNodeType

type YAMLNodeType string

YAMLNodeType is a yaml representation of a node type

type YAMLRoute

type YAMLRoute Route

YAMLRoute is a yaml representation of a route on a node

type YAMLRun

type YAMLRun struct {
	Node     string
	Commands []string
}

YAMLRun is a yaml representation of commands to run on a node

func NewYAMLRun

func NewYAMLRun(r *Run) *YAMLRun

NewYAMLRun returns a new YAMLRun

type YAMLTopology

type YAMLTopology struct {
	Name  string
	Nodes []*YAMLNode
	Links []*YAMLLink
	Run   []*YAMLRun
}

YAMLTopology is a yaml representation of a topology

func NewYAMLTopology

func NewYAMLTopology(t *Topology) *YAMLTopology

NewYAMLTopology returns a new YAMLTopology

func (*YAMLTopology) YAML

func (t *YAMLTopology) YAML() []byte

YAML returns the topology as yaml

Jump to

Keyboard shortcuts

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