goffr

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2018 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InstanceZebra = "zebra"
	InstanceRIP   = "ripd"
	InstanceRIPng = "ripngd"
	InstanceBGP   = "bgpd"
	InstanceOSPF  = "ospfd"
	InstanceOSPF6 = "ospf6d"
	InstanceISIS  = "isisd"
	InstancePIM   = "pimd"
)

These constants represent an 'Enum' for all available FRRouting daemon names.

Variables

This section is empty.

Functions

This section is empty.

Types

type Instance

type Instance interface {
	Execute(command string) (string, error)
	ExecuteJSON(command string) (string, error)
}

Instance represents an instance of an API session, where typically one instance is assigned to each active daemon.

type Session

type Session interface {
	GetInstance(name string) (Instance, error)
}

Session represents a generic interface for controlling API sessions to the FRRouting daemon.

type TelnetInstance added in v0.1.6

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

TelnetInstance represents a goffr telnet instance, which is a lightweight wrapper around goexpect and a telnet session to the according daemon of FRRouting. This structure should never be instantiated directly and gets created by the TelnetSession.GetInstance() method.

func (*TelnetInstance) Execute added in v0.1.6

func (i *TelnetInstance) Execute(command string) (string, error)

Execute tries to execute a command against the FRRouting daemon for which this instance was created. Please note that errors spewed out by the FRRouting daemon are not being handled, only connection/transmission errors. It is the callers duty to manually parse the output according to the FRRouting specifications.

func (*TelnetInstance) ExecuteJSON added in v0.1.6

func (i *TelnetInstance) ExecuteJSON(command string) (string, error)

ExecuteJSON is a lightweight wrapper against 'Execute()', which will try to parse and compact the output of the given command as JSON. In case the output does not represent valid JSON (e.g. an error occurred during the execution of the command), an error will be returned instead.

type TelnetSession added in v0.1.6

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

TelnetSession represents a goffr telnet session to one or more instances of the FRRouting daemon

func NewTelnetSession added in v0.1.6

func NewTelnetSession(hostname string, password string) *TelnetSession

NewTelnetSession instantiates a new 'TelnetSession' without any instances.

func (*TelnetSession) GetInstance added in v0.1.6

func (s *TelnetSession) GetInstance(name string) (Instance, error)

GetInstance returns the instance with the given (daemon) name if already requested in a previous call. If no such instance was instantiated so far, a new instance gets automatically created, which tries connecting to the target daemon.

type VtyshInstance added in v0.1.6

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

VtyshInstance represents a goffr dummy instance for a vtysh session. As the concept of instances does not exist for the vtysh implementation, this structure should only contain a reference to the session.

func (*VtyshInstance) Execute added in v0.1.6

func (i *VtyshInstance) Execute(frrCommand string) (string, error)

Execute tries to execute a command against the FRRouting daemon by spawning a new vtysh process. Please note that errors spewed out by the FRRouting daemon are not being handled, only vtysh execution errors. It is the callers duty to manually parse the output according to the FRRouting specifications. Any captured output, both stdout and stderr, still gets returned to the caller even when an error has occurred.

func (*VtyshInstance) ExecuteJSON added in v0.1.6

func (i *VtyshInstance) ExecuteJSON(frrCommand string) (string, error)

ExecuteJSON is a lightweight wrapper against 'Execute()', which will try to parse and compact the output of the given command as JSON. In case the output does not represent valid JSON (e.g. an error occurred during the execution of the command), an error will be returned instead.

type VtyshSession added in v0.1.6

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

VtyshSession represents a goffr vtysh session containing exactly one fake instance. As vtysh is stateless by design, no actual session to the FRR daemon gets established and always the same dummy instance is being returned.

func NewVtyshSession added in v0.1.6

func NewVtyshSession(binaryPath string) *VtyshSession

NewVtyshSession instantiates a new 'VtyshSession'.

func (*VtyshSession) GetInstance added in v0.1.6

func (s *VtyshSession) GetInstance(name string) (Instance, error)

GetInstance returns always the same dummy instance for 'VtyshSession', no matter which daemon was requested. This method was implemented to achieve compatibility with the telnet API, however vtysh handles selecting the correct daemon by itself.

Jump to

Keyboard shortcuts

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