Documentation ¶
Index ¶
- Constants
- func FullPathFor(cmd string) string
- func HostName(n ...int) string
- func RunCommand(cmd string, args ...string) (string, error)
- func SwitchName(n ...int) string
- type Cgroup
- type Controller
- type Host
- func (h *Host) AddLink(l Link) error
- func (h Host) GetCidr(peer Peer) string
- func (h Host) GetHwAddr(peer Peer) string
- func (h Host) GetLinks() Links
- func (h Host) GetState(peer Peer) string
- func (h Host) LinksCount() int
- func (h Host) NetNs() *NetNs
- func (h Host) NodeName() string
- func (h Host) Release() error
- func (h Host) RunCommand(args ...string) (string, error)
- func (h *Host) RunProcess(args ...string) (*Process, error)
- func (h Host) String() string
- func (h *Host) UnmarshalJSON(b []byte) error
- type Link
- func (l Link) ApplyCidr() error
- func (l Link) ApplyMac() error
- func (l Link) ApplyRoutes() error
- func (l Link) Exists() bool
- func (l Link) IP() string
- func (l Link) MoveToNs(netns string) error
- func (l Link) Release()
- func (l Link) SetCidr() Link
- func (l Link) SetHwAddr() Link
- func (l Link) SetName(n Node, prefix string) Link
- func (l Link) SetNetNs(n Node) Link
- func (l Link) SetNodeName(n Node) Link
- func (l Link) SetPatch() Link
- func (l Link) SetPeer(in Link) Link
- func (l Link) SetRoute() Link
- func (l Link) SetState(s string) Link
- func (l Link) Up() error
- type Links
- type NetNs
- type Node
- type Pair
- type Peer
- type Process
- type Procs
- type Route
- type Scheme
- func (s *Scheme) AddNode(n interface{}) *Scheme
- func (s Scheme) Export() string
- func (s *Scheme) GetHost(name string) (*Host, bool)
- func (s *Scheme) GetNode(name string) (Node, bool)
- func (s *Scheme) GetSwitch(name string) (*Switch, bool)
- func (s *Scheme) Nodes() chan Node
- func (s Scheme) Recover() error
- func (s *Scheme) Release()
- func (s Scheme) String() string
- type Set
- type Switch
- func (s *Switch) AddLink(l Link) error
- func (s *Switch) AddPatchPort(l Link) error
- func (s *Switch) AddPort(l Link) error
- func (s *Switch) Create() error
- func (s *Switch) Exists() bool
- func (s Switch) GetCidr(peer Peer) string
- func (s Switch) GetHwAddr(peer Peer) string
- func (s Switch) GetLinks() Links
- func (s Switch) GetState(peer Peer) string
- func (s Switch) LinksCount() int
- func (s Switch) NetNs() *NetNs
- func (s Switch) NodeName() string
- func (s Switch) Release() error
- func (s *Switch) SetController(addr string) error
- func (s Switch) String() string
- func (s *Switch) UnmarshalJSON(b []byte) error
Constants ¶
const NetnsRunDir = "/var/run/netns"
NetnsRunDir default netns run dir
Variables ¶
This section is empty.
Functions ¶
func FullPathFor ¶
FullPathFor generated full path for provided command, based on user's PATH environment variable
func RunCommand ¶
RunCommand is just a wrapper for exec.Command() function
func SwitchName ¶
SwitchName returns generated name, based on user input or random number
Types ¶
type Cgroup ¶
type Cgroup struct { *cgroup.Cgroup Name string Controllers []Controller }
Cgroup structure
func NewCgroup ¶
NewCgroup initialise Cgroup instance and does following: 1. Init 2. Init Cgroup struct 3. Set controllers 4. Physically create cgroup 5. Set controllers values
func (*Cgroup) CgExecCommand ¶
CgExecCommand prepares cgexec command
func (*Cgroup) SetControllers ¶
func (c *Cgroup) SetControllers(controllers []Controller) error
SetControllers add controller into Controllers collection
func (*Cgroup) SetParams ¶
func (c *Cgroup) SetParams(controllers []Controller) error
SetParams sets controller parameters
func (*Cgroup) UnmarshalJSON ¶
UnmarshalJSON satisfies Unarshller
type Host ¶
type Host struct { Cgroup *Cgroup Name string Links Links Procs Procs // contains filtered or unexported fields }
Host structure
func (Host) RunCommand ¶
RunCommand prepares ip command to run
func (*Host) RunProcess ¶
RunProcess Exported wrapper for run process
func (*Host) UnmarshalJSON ¶
UnmarshalJSON satisfies Mashaller
type Link ¶
type Link struct { Cidr string HwAddr string Name string NodeName string NetNs string State string Routes []Route PeerName string Peer Peer ForceRoot bool `json:"-"` // contains filtered or unexported fields }
Link definition
func (Link) ApplyRoutes ¶
ApplyRoutes adds routing rule to the link
type NetNs ¶
type NetNs struct {
// contains filtered or unexported fields
}
NetNs definition
type Node ¶
type Node interface { NodeName() string NetNs() *NetNs LinksCount() int GetCidr(peer Peer) string GetHwAddr(peer Peer) string GetState(peer Peer) string Release() error AddLink(Link) error GetLinks() Links }
Node interface
type Pair ¶
Pair defenition
type Process ¶
type Process struct { *os.Process Command string Args []string Output string // contains filtered or unexported fields }
Process definition
type Scheme ¶
Scheme defenition
func NewSchemeFromJSON ¶
NewSchemeFromJSON create scheme from json file
type Switch ¶
Switch model
func (*Switch) AddPatchPort ¶
AddPatchPort adds type to path
func (Switch) LinksCount ¶
LinksCount returns count of available links
func (*Switch) SetController ¶
SetController sets Controller name and address
func (*Switch) UnmarshalJSON ¶
UnmarshalJSON implements unmarshaller