topology

package
v0.0.0-...-e279674 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2021 License: GPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var WithAutoMgmtNetwork = func(t *T) {
	t.autoMgmt = true
}

WithAutoMgmtNetwork enables an out-of-band management network. The topology is augmented with a management switch and server, with the latter running DHCP and DNS services for all devices. Devices are automatically attached to the management switch unless they have the no_mgmt node attribute set.

Functions

func HasFunction

func HasFunction(d *Device, fs ...DeviceFunction) bool

HasFunction returns whether d.Function() is in fs.

Types

type Device

type Device struct {
	Name string
	// contains filtered or unexported fields
}

A Device corresponds to a node in the parsed topology.

func (*Device) Attr

func (d *Device) Attr(key string) string

Attr returns the node attribute associated with key, if any.

func (*Device) DiskSize

func (d *Device) DiskSize() int64

DiskSize returns the device's disk size in bytes.

func (*Device) Function

func (d *Device) Function() DeviceFunction

Function returns the DeviceFunction associated with d.

func (d *Device) Links() []Link

Links returns all connections involving d as an endpoint.

func (*Device) Memory

func (d *Device) Memory() int64

Memory returns the device's memory size in bytes.

func (*Device) MgmtIP

func (d *Device) MgmtIP() *net.IPAddr

MgmtIP returns the management IP address assigned to d (only when AutoMgmtNetwork is configured).

func (*Device) OSImage

func (d *Device) OSImage() string

OSImage returns the URL to an operating system image from the 'os' node attribute, falling back to a builtin default if necessary.

func (*Device) VCPUs

func (d *Device) VCPUs() int

VCPUs returns the number of CPUs requested for a device ('cpu' node attribute) or a function-specific default.

type DeviceFunction

type DeviceFunction int

DeviceFunction describes a device's role in the topology and is used for startup ordering as well as determining default OS images.

const (
	Fake       DeviceFunction = iota // fake
	OOBServer                        // oob-server
	OOBSwitch                        // oob-switch
	Exit                             // exit
	SuperSpine                       // superspine
	Spine                            // spine
	Leaf                             // leaf
	TOR                              // tor
	Host                             // host
	NoFunction
)

func (DeviceFunction) String

func (i DeviceFunction) String() string
type Link struct {
	From     string
	FromPort string
	To       string
	ToPort   string
	// contains filtered or unexported fields
}

A Link corresponds to an edge in the input graph and describes a point-to-point connection between two devices.

func (*Link) Attr

func (l *Link) Attr(key string) string

Attr returns the value associated with the attribute key.

func (*Link) FromMAC

func (l *Link) FromMAC() (net.HardwareAddr, bool)

FromMAC returns the MAC address corresponding to FromPort. If the topology does not specify such address, the boolean return value is false.

func (*Link) String

func (l *Link) String() string

String returns a string representation of l.

func (*Link) ToMAC

func (l *Link) ToMAC() (net.HardwareAddr, bool)

ToMAC returns the MAC address corresponding to ToPort. If the topology does not specify such address, the boolean return value is false.

type Option

type Option func(*T)

Option may be passed to Parse to customize topology processing.

type T

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

T represents a parsed network topology graph.

func Parse

func Parse(dotBytes []byte, opts ...Option) (*T, error)

Parse unmarshals a DOT graph. It returns the topology described by it or an error, if any.

func ParseFile

func ParseFile(path string, opts ...Option) (*T, error)

ParseFile is like Parse but reads the DOT graph description from the file located by path.

func (*T) DOT

func (t *T) DOT() []byte

DOT returns the original input DOT file.

func (*T) Devices

func (t *T) Devices() []Device

Devices returns the set of devices defined in the topology.

func (t *T) Links() []Link

Links returns the connections between devices, as defined in the topology.

Jump to

Keyboard shortcuts

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