ovs

package
v3.6.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2017 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package ovs provides a wrapper around ovs-vsctl and ovs-ofctl

Index

Constants

View Source
const (
	OVS_OFCTL = "ovs-ofctl"
	OVS_VSCTL = "ovs-vsctl"
)

Variables

This section is empty.

Functions

func FlowMatches

func FlowMatches(flow, match *OvsFlow, exact bool) bool

flowMatches tests if flow matches match. If exact is true, then the table, priority, and all fields much match. If exact is false, then the table and any fields specified in match must match, but priority is not checked, and there can be additional fields in flow that are not in match.

Types

type Interface added in v1.4.0

type Interface interface {
	// AddBridge creates the bridge associated with the interface, optionally setting
	// properties on it (as with "ovs-vsctl set Bridge ..."). If the bridge already
	// existed, it will be destroyed and recreated.
	AddBridge(properties ...string) error

	// DeleteBridge deletes the bridge associated with the interface. (It is an
	// error if the bridge does not exist.)
	DeleteBridge() error

	// AddPort adds an interface to the bridge, requesting the indicated port
	// number, and optionally setting properties on it (as with "ovs-vsctl set
	// Interface ..."). Returns the allocated port number (or an error).
	AddPort(port string, ofportRequest int, properties ...string) (int, error)

	// DeletePort removes an interface from the bridge. (It is not an
	// error if the interface is not currently a bridge port.)
	DeletePort(port string) error

	// GetOFPort returns the OpenFlow port number of a given network interface
	// attached to a bridge.
	GetOFPort(port string) (int, error)

	// SetFrags sets the fragmented-packet-handling mode (as with
	// "ovs-ofctl set-frags")
	SetFrags(mode string) error

	// Create creates a record in the OVS database, as with "ovs-vsctl create" and
	// returns the UUID of the newly-created item.
	// NOTE: This only works for QoS; for all other tables the created object will
	// immediately be garbage-collected; we'd need an API that calls "create" and "set"
	// in the same "ovs-vsctl" call.
	Create(table string, values ...string) (string, error)

	// Destroy deletes the indicated record in the OVS database. It is not an error if
	// the record does not exist
	Destroy(table, record string) error

	// Get gets the indicated value from the OVS database. For multi-valued or
	// map-valued columns, the data is returned in the same format as "ovs-vsctl get".
	Get(table, record, column string) (string, error)

	// Set sets one or more columns on a record in the OVS database, as with
	// "ovs-vsctl set"
	Set(table, record string, values ...string) error

	// Clear unsets the indicated columns in the OVS database. It is not an error if
	// the value is already unset
	Clear(table, record string, columns ...string) error

	// DumpFlows dumps the flow table for the bridge and returns it as an array of
	// strings, one per flow.
	DumpFlows() ([]string, error)

	// NewTransaction begins a new OVS transaction. If an error occurs at
	// any step in the transaction, it will be recorded until
	// EndTransaction(), and any further calls on the transaction will be
	// ignored.
	NewTransaction() Transaction
}

Interface represents an interface to OVS

func New added in v1.4.0

func New(execer exec.Interface, bridge string, minVersion string) (Interface, error)

New returns a new ovs.Interface

func NewFake

func NewFake(bridge string) Interface

NewFake returns a new ovs.Interface

type OvsField

type OvsField struct {
	Name  string
	Value string
}

type OvsFlow

type OvsFlow struct {
	Table    int
	Priority int
	Created  time.Time
	Cookie   string
	Fields   []OvsField
	Actions  []OvsField
}

ovsFlow represents an OVS flow

func ParseFlow

func ParseFlow(cmd ParseCmd, flow string, args ...interface{}) (*OvsFlow, error)

func (*OvsFlow) FindAction

func (of *OvsFlow) FindAction(name string) (*OvsField, bool)

func (*OvsFlow) FindField

func (of *OvsFlow) FindField(name string) (*OvsField, bool)

func (*OvsFlow) NoteHasPrefix

func (of *OvsFlow) NoteHasPrefix(prefix string) bool

type ParseCmd

type ParseCmd string
const (
	ParseForAdd    ParseCmd = "add-flow"
	ParseForDelete ParseCmd = "del-flows"
	ParseForDump   ParseCmd = "dump-flows"
)

type Transaction

type Transaction interface {
	// AddFlow adds a flow to the bridge. The arguments are passed to fmt.Sprintf().
	AddFlow(flow string, args ...interface{})

	// DeleteFlows deletes all matching flows from the bridge. The arguments are
	// passed to fmt.Sprintf().
	DeleteFlows(flow string, args ...interface{})

	// EndTransaction ends an OVS transaction and returns any error that occurred
	// during the transaction. You should not use the transaction again after
	// calling this function.
	EndTransaction() error
}

Transaction manages a single set of OVS flow modifications

Jump to

Keyboard shortcuts

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