rvn

package
v0.6.7 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2020 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultDiskBootOrder is used when one is not explicitly specified
	DefaultDiskBootOrder = 10

	TopoFile = "topo.json"

	RavenDir = "/.rvn"
)

Variables

View Source
var Version = "undefined"

Version holds the raven version string

Functions

func BuildRvnDisks

func BuildRvnDisks(topo Topo) error

BuildRvnDisks fills in missing disks, adding disks that do not exist.

func Configure

func Configure(withUserConfig bool)

Configure runs the base and user level configurations over all nodes in a topology.

func ConfigureNode

func ConfigureNode(topo Topo, node string)

ConfigureNode runs the base and user level configuration for the specified node.

func ConfigureNodes

func ConfigureNodes(topo Topo, nodes []string)

ConfigureNodes configures a specified set of nodes.

func CopyLocalFile

func CopyLocalFile(src, dst string) error

CopyLocalFile copies a file from point a to point b.

func Create

func Create()

Create creates a libvirt definition for the supplied topology. It does not launch the system. For that functionality use the Launch function. If a topology with the same name as the topology provided as an argument exists, that topology will be overwritten by the system generated from the argument.

func CreateNetbootImage

func CreateNetbootImage() error

CreateNetbootImage creates a netboot image

func Destroy

func Destroy()

Destroy completely wipes out a topology with the given name. If the system is running within libvirt it is torn down. The entire definition of the system is also removed from libvirt.

func DomainInfo

func DomainInfo(topo, name string) (*xlibvirt.Domain, error)

DomainInfo fetches the libvirt domain information about host within a raven topology

func DownloadFile

func DownloadFile(filepath string, url string) error

DownloadFile downloads a file from a URL to the spefified path

func DownloadURL

func DownloadURL(parsedURL *url.URL, downloadPath string, imageName string) error

DownloadURL downloads an image from the specified URL

func ExportNFS

func ExportNFS(topo Topo) error

ExportNFS exports all of the mount points specified by a topology.

func GenConfig

func GenConfig(h Host, topo Topo)

GenConfig generates a base configuration for the specified node.

func GenConfigAll

func GenConfigAll(topo Topo)

GenConfigAll generates base configurations for all nodes in a topology.

func Launch

func Launch() []string

Launch brings up the system with the given name. This system must exist visa-vis the create function before calling Launch. The return value is a list of diagnostic strings that were provided by libvirt when launching the system. The existence of diagnostics does not necessarily indicate an error in launching. This function is asynchronous, when it returns the system is still launching. Use the Status function to check up on a the launch process.

func ListTopo

func ListTopo()

func ParseURL

func ParseURL(parsedURL *url.URL) (path string, image string, err error)

ParseURL returns a path, which we will create a directory tree with path[0]/path[1]/.../path[n]/image

func Powerdown

func Powerdown(nodes []string) error

Powerdown turns off a VM

func Powerup

func Powerup(nodes []string) error

Powerup turns on a VM

func Reboot

func Reboot(rr RebootRequest) error

Reboot attempts to gracefully reboot a raven host

func RecordTopo

func RecordTopo()

func RemoveTopo

func RemoveTopo()

func RunModel

func RunModel() error

RunModel executes a users raven model. Required images are downloaded. Libvirt specs are generated. Virtual disks are created. Table allocations are made.

func Rvn2Xir

func Rvn2Xir(t *Topo) *xir.Net

Rvn2Xir transforms a raven topology into a MergeTB XIR topology.

func SaveTopo

func SaveTopo(t Topo) error

SaveTopo persists the json representation of a topo to the .rvn dir.

func Shutdown

func Shutdown() []error

Shutdown turns of a virtual machine gracefully

func SrcDir

func SrcDir() (string, error)

SrcDir returns the source dir of a raven topology

func Status

func Status() map[string]interface{}

Status returns the runtime status of a topology, node by node and network by network.

func UnexportNFS

func UnexportNFS(topoName string) error

UnexportNFS removes all the NFS mount points created by a topology.

func ValidateURL

func ValidateURL(input string) (*url.URL, error)

ValidateURL wraps url validation with error reporting

func WipeNode

func WipeNode(topo Topo, name string) error

WipeNode deletes a nodes virtual hard disk, create's a new one, and re-launches the VM.

func WkDir

func WkDir() (string, error)

WkDir returns the working dir of a raven topology

Types

type Alias added in v0.6.7

type Alias struct {
	Name  string `json:"name"`
	Alias string `json:"alias"`
}

type CPU

type CPU struct {
	Sockets  int    `json:"sockets"`
	Cores    int    `json:"cores"`
	Threads  int    `json:"threads"`
	Model    string `json:"arch"`
	Passthru bool   `json:"passthru"`
}

CPU describes the processor in a VM.

type Disktype

type Disktype struct {
	Bus    string `json:"bus"`
	Dev    string `json:"dev"`
	Size   string `json:"size"`
	Source string `json:"source"`
}

Disktype describes a VM disk.

type DomStatus

type DomStatus struct {
	Name        string
	State       string
	ConfigState string
	IP          string
	Macs        []string
	VNC         int
}

DomStatus encapsulates various information about a libvirt domain for purposes of serialization and presentation.

func DomainStatus

func DomainStatus(topo, name string) (DomStatus, error)

DomainStatus returns the current state of a domain (host) within a libvirt topology.

type Endpoint

type Endpoint struct {
	Name string `json:"name"`
	Port int    `json:"port"`
}

Endpoint describes a VM connection point.

type Export

type Export struct {
	Dir, Subnet string
}

Export encapsulates info about an NFS export

type Host

type Host struct {
	Name            string      `json:"name"`
	Arch            string      `json:"arch"`
	Platform        string      `json:"platform"`
	Machine         string      `json:"machine"`
	Kernel          string      `json:"kernel"`
	Cmdline         string      `json:"cmdline"`
	Initrd          string      `json:"initrd"`
	Image           string      `json:"image"`
	OS              string      `json:"os"`
	Disks           []*Disktype `json:"disks"`
	NoTestNet       bool        `json:"no-testnet"`
	EBPF            bool        `json:"ebpf"`
	Mounts          []Mount     `json:"mounts"`
	CPU             *CPU        `json:"cpu,omitempty"`
	Memory          *Memory     `json:"memory,omitempty"`
	DefaultNic      string      `json:"defaultnic"`
	DefaultDisktype *Disktype   `json:"defaultdisktype"`
	SysFirmware     string      `json:"firmware,omitempty"`
	Emulator        string      `json:"emulator"`
	Iommu           bool        `json:"iommu"`
	Video           string      `json:"video"`
	DedicatedDisk   bool        `json:"dedicateddisk"`
	DiskCache       string      `json:"diskcache"`
	VirtualClock    bool        `json:"vclock"`

	TelnetPort int
	// contains filtered or unexported fields
}

Host describes a VM.

type Link struct {
	Name      string                 `json:"name"`
	Endpoints [2]Endpoint            `json:"endpoints"`
	Props     map[string]interface{} `json:"props"`
	AllowLACP bool                   `json:"lacp"`
	NoJumbo   bool                   `json:"nojumbo"`
	V2V       bool                   `json:"v2v"`
}

Link descrbes a P2P link between VMs.

func (*Link) GetBridge added in v0.6.6

func (l *Link) GetBridge() (string, error)

func (*Link) IsExternal

func (l *Link) IsExternal() bool

func (*Link) IsTap added in v0.6.6

func (l *Link) IsTap() bool

type LinkStatus

type LinkStatus struct {
	State  string
	Bridge string
	Device string
	Link   Link
}

LinkStatus holds the status of a link.

type Memory

type Memory struct {
	Capacity UnitValue `json:"capacity"`
}

Memory describes the memory capacity of a VM.

type Mount

type Mount struct {
	Point  string `json:"point"`
	Source string `json:"source"`
}

Mount describes an NFS mount point in a VM.

type Node

type Node struct {
	Host
}

Node is a host, but carries the semantic that it is a regular node.

type Options

type Options struct {
	Display string `json:"display"`
}

Options contains various VM options

type Platform

type Platform struct {
	Name      string
	Arch      string
	Machine   string
	CPU       *CPU
	Memory    *Memory
	Kernel    string
	Image     string
	Cmdline   string
	Initrd    string
	Nic       string
	Disktype  *Disktype
	Emulator  string
	DiskCache string
}

Platform describes the default values for a given platform

type Port

type Port struct {
	Link  string
	Index int
}

Port describes a VM connection point.

type RebootRequest

type RebootRequest struct {
	Topo  string   `json:"topo"`
	Nodes []string `json:"nodes"`
}

RebootRequest is used to reboot nodes.

type Runtime

type Runtime struct {
	SubnetTable        [256]bool
	SubnetReverseTable map[string]int
	TelnetPorts        []int
	Topos              map[string]TopoInfo
}

Runtime tracks raven runtime state.

func LoadRuntime

func LoadRuntime() *Runtime

LoadRuntime loads the runtime from the state file.

func (*Runtime) AllocateSubnet

func (r *Runtime) AllocateSubnet(tag string) int

AllocateSubnet allocates a new subnet for a topology, updating the subnet allocation table.

func (*Runtime) FreeSubnet

func (r *Runtime) FreeSubnet(tag string)

FreeSubnet frees a subnet from the subnet allocation table.

func (*Runtime) FreeTelnetPort

func (r *Runtime) FreeTelnetPort(port int)

FreeTelnetPort frees a telnet port, making it available again.

func (*Runtime) NewTelnetPort

func (r *Runtime) NewTelnetPort() int

NewTelnetPort allocates a new telnet port for a VM.

func (*Runtime) RecordTopology

func (r *Runtime) RecordTopology(info TopoInfo)

func (*Runtime) RemoveTopology

func (r *Runtime) RemoveTopology(name string)

func (*Runtime) Save

func (r *Runtime) Save()

Save persists the runtime to the state file.

type Topo

type Topo struct {
	Name         string   `json:"name"`
	Nodes        []Node   `json:"nodes"`
	Switches     []Zwitch `json:"switches"`
	Links        []Link   `json:"links"`
	Dir          string   `json:"dir"`
	MgmtIP       string   `json:"mgmtip"`
	Options      Options  `json:"options"`
	SubnetOffset int      `json:"subnetoffset"`
	Aliases      []Alias  `json:"aliases"`
}

A Topo is a collection of nodes, switches an links.

func LoadTopo

func LoadTopo() (Topo, error)

LoadTopo loads a topology from the json representation in the .rvn dir.

func LoadTopoFile

func LoadTopoFile(path string) (Topo, error)

LoadTopoFile loads a topology from a json representation file at a specified path.

func ReadTopo

func ReadTopo(src []byte) (Topo, error)

ReadTopo reads the supplied data as a json representation of a raven topology.

func (*Topo) GetHost

func (t *Topo) GetHost(name string) *Host

GetHost gets a host by name from a topology.

func (t *Topo) GetLink(name string) *Link

GetLink gets a link by name from a topology.

func (Topo) QualifyName

func (t Topo) QualifyName(n string) string

QualifyName returns the topology qualified name of a host, link or switch.

func (Topo) String

func (t Topo) String() string

String returns the string representation of a topology.

type TopoInfo

type TopoInfo struct {
	Name string
	Path string
}

type UnitValue

type UnitValue struct {
	Value int    `json:"value"`
	Unit  string `json:"unit"`
}

UnitValue describes a value that has an associated unit of measure.

type Zwitch

type Zwitch struct {
	Host
}

Zwitch is a host, but carries the semantic that it is a switch.

Jump to

Keyboard shortcuts

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