goovn

package module
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

README

GO OVN License GoDoc Travis CI Go Report Card

A Go library for OVN DB access using native OVSDB protocol. It is based on the OVSDB Library, but used own fork https://github.com/ebay/libovsdb.git with patches.

What is OVN?

OVN (Open Virtual Network) is a SDN solution built on top of OVS (Open vSwitch). The interface of OVN is its northbound DB which is an OVSDB database.

What is OVSDB?

OVSDB is a protocol for managing the configuration of OVS. It's defined in RFC 7047.

Why native OVSDB protocol?

There are projects accessing OVN DB based on the ovn-nbctl CLI, which has some problems. Here are the majors ones and how native OVSDB protocol based approach solves them:

  • Performance problem. Every CLI command would trigger a separate OVSDB connection setup/teardown, initial OVSDB client cache population, etc., which would impact performance significantly. This library uses OVSDB protocol directly so that the overhead happens only once for all OVSDB operations.

  • Caching problem. When there is a change in desired state, which requires updates in OVN, we need to figure out first what's the current state in OVN, which requires either maintaining a client cache or executing a "list" command everytime. This library maintains an internal cache and ensures it is always up to date with the remote DB with the help of native OVSDB support.

  • String parsing problem. CLI based implementation needs extra conversion from the string output to Go internal data types, while it is not necessary with this library since OVSDB JSON RPC takes care of it.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrorOption used when invalid args specified
	ErrorOption = errors.New("invalid option specified")
	// ErrorSchema used when something wrong in ovnnb
	ErrorSchema = errors.New("table schema error")
	// ErrorNotFound used when object not found in ovnnb
	ErrorNotFound = errors.New("object not found")
	// ErrorExist used when object already exists in ovnnb
	ErrorExist = errors.New("object exist")
)

Functions

This section is empty.

Types

type ACL

type ACL struct {
	UUID       string
	Action     string
	Direction  string
	Match      string
	Priority   int
	Log        bool
	ExternalID map[interface{}]interface{}
}

ACL ovnnb item

type AddressSet

type AddressSet struct {
	UUID       string
	Name       string
	Addresses  []string
	ExternalID map[interface{}]interface{}
}

AddressSet ovnnb item

type Client

type Client interface {
	// Get logical switch by name
	LSGet(ls string) ([]*LogicalSwitch, error)
	// Create ls named SWITCH
	LSAdd(ls string) (*OvnCommand, error)
	// Del ls and all its ports
	LSDel(ls string) (*OvnCommand, error)
	// Get all logical switches
	LSList() ([]*LogicalSwitch, error)
	// Add external_ids to logical switch
	LSExtIdsAdd(ls string, external_ids map[string]string) (*OvnCommand, error)
	// Del external_ids from logical_switch
	LSExtIdsDel(ls string, external_ids map[string]string) (*OvnCommand, error)

	// Get logical port PORT by name
	LSPGet(lsp string) (*LogicalSwitchPort, error)
	// Add logical port PORT on SWITCH
	LSPAdd(ls string, lsp string) (*OvnCommand, error)
	// Delete PORT from its attached switch
	LSPDel(lsp string) (*OvnCommand, error)
	// Set addressset per lport
	LSPSetAddress(lsp string, addresses ...string) (*OvnCommand, error)
	//LSPGetAddress(lsp string) ([]string, error)
	// Set port security per lport
	LSPSetPortSecurity(lsp string, security ...string) (*OvnCommand, error)
	// Get all lport by lswitch
	LSPList(ls string) ([]*LogicalSwitchPort, error)

	// Add LB to LSW
	LSLBAdd(ls string, lb string) (*OvnCommand, error)
	// Delete LB from LSW
	LSLBDel(ls string, lb string) (*OvnCommand, error)
	// List Load balancers for a LSW
	LSLBList(ls string) ([]*LoadBalancer, error)

	// Add ACL
	ACLAdd(ls, direct, match, action string, priority int, external_ids map[string]string, logflag bool, meter string) (*OvnCommand, error)
	// Delete acl
	ACLDel(ls, direct, match string, priority int, external_ids map[string]string) (*OvnCommand, error)
	// Get all acl by lswitch
	ACLList(ls string) ([]*ACL, error)

	// Get AS
	ASGet(name string) (*AddressSet, error)
	// Update address set
	ASUpdate(name string, addrs []string, external_ids map[string]string) (*OvnCommand, error)
	// Add addressset
	ASAdd(name string, addrs []string, external_ids map[string]string) (*OvnCommand, error)
	// Delete addressset
	ASDel(name string) (*OvnCommand, error)
	// Get all AS
	ASList() ([]*AddressSet, error)

	// Get LR with given name
	LRGet(name string) ([]*LogicalRouter, error)
	// Add LR with given name
	LRAdd(name string, external_ids map[string]string) (*OvnCommand, error)
	// Delete LR with given name
	LRDel(name string) (*OvnCommand, error)
	// Get LRs
	LRList() ([]*LogicalRouter, error)

	// Add LRP with given name on given lr
	LRPAdd(lr string, lrp string, mac string, network []string, peer string, external_ids map[string]string) (*OvnCommand, error)
	// Delete LRP with given name on given lr
	LRPDel(lr string, lrp string) (*OvnCommand, error)
	// Get all lrp by lr
	LRPList(lr string) ([]*LogicalRouterPort, error)

	// Add LRSR with given ip_prefix on given lr
	LRSRAdd(lr string, ip_prefix string, nexthop string, output_port []string, policy []string, external_ids map[string]string) (*OvnCommand, error)
	// Delete LRSR with given ip_prefix on given lr
	LRSRDel(lr string, ip_prefix string) (*OvnCommand, error)
	// Get all LRSRs by lr
	LRSRList(lr string) ([]*LogicalRouterStaticRoute, error)

	// Add LB to LR
	LRLBAdd(lr string, lb string) (*OvnCommand, error)
	// Delete LB from LR
	LRLBDel(lr string, lb string) (*OvnCommand, error)
	// List Load balancers for a LR
	LRLBList(lr string) ([]*LoadBalancer, error)

	// Get LB with given name
	LBGet(name string) ([]*LoadBalancer, error)
	// Add LB
	LBAdd(name string, vipPort string, protocol string, addrs []string) (*OvnCommand, error)
	// Delete LB with given name
	LBDel(name string) (*OvnCommand, error)
	// Update existing LB
	LBUpdate(name string, vipPort string, protocol string, addrs []string) (*OvnCommand, error)

	// Set dhcp4_options uuid on lsp
	LSPSetDHCPv4Options(lsp string, options string) (*OvnCommand, error)
	// Get dhcp4_options from lsp
	LSPGetDHCPv4Options(lsp string) (*DHCPOptions, error)
	// Set dhcp6_options uuid on lsp
	LSPSetDHCPv6Options(lsp string, options string) (*OvnCommand, error)
	// Get dhcp6_options from lsp
	LSPGetDHCPv6Options(lsp string) (*DHCPOptions, error)
	// Set options in LSP
	LSPSetOptions(lsp string, options map[string]string) (*OvnCommand, error)

	// Add dhcp options for cidr and provided external_ids
	DHCPOptionsAdd(cidr string, options map[string]string, external_ids map[string]string) (*OvnCommand, error)
	// Set dhcp options and set external_ids for specific uuid
	DHCPOptionsSet(uuid string, options map[string]string, external_ids map[string]string) (*OvnCommand, error)
	// Del dhcp options via provided external_ids
	DHCPOptionsDel(uuid string) (*OvnCommand, error)
	// Get single dhcp via provided uuid
	DHCPOptionsGet(uuid string) (*DHCPOptions, error)
	// List dhcp options
	DHCPOptionsList() ([]*DHCPOptions, error)

	// Add qos rule
	QoSAdd(ls string, direction string, priority int, match string, action map[string]int, bandwidth map[string]int, external_ids map[string]string) (*OvnCommand, error)
	// Del qos rule, to delete wildcard specify priority -1 and string options as ""
	QoSDel(ls string, direction string, priority int, match string) (*OvnCommand, error)
	// Get qos rules by logical switch
	QoSList(ls string) ([]*QoS, error)

	//Add NAT to Logical Router
	LRNATAdd(lr string, ntype string, externalIp string, logicalIp string, external_ids map[string]string, logicalPortAndExternalMac ...string) (*OvnCommand, error)
	//Del NAT from Logical Router
	LRNATDel(lr string, ntype string, ip ...string) (*OvnCommand, error)
	// Get NAT List by Logical Router
	LRNATList(lr string) ([]*NAT, error)

	// Exec command, support mul-commands in one transaction.
	Execute(cmds ...*OvnCommand) error
	ExecuteWithResult(cmds ...*OvnCommand) ([]libovsdb.OperationResult, error)

	// Close connection to OVN
	Close() error
}

Client ovnnb client

func NewClient

func NewClient(cfg *Config) (Client, error)

type Config

type Config struct {
	Addr         string
	TLSConfig    *tls.Config
	SignalCB     OVNSignal
	DisconnectCB OVNDisconnectedCallback
}

Config ovnnb client config

type DHCPOptions

type DHCPOptions struct {
	UUID       string
	CIDR       string
	Options    map[interface{}]interface{}
	ExternalID map[interface{}]interface{}
}

DHCPOptions ovnnb item

type Execution

type Execution interface {
	//Excute multi-commands
	Execute(cmds ...*OvnCommand) error
}

Execution executes multiple ovnnb commands

type GatewayChassis

type GatewayChassis struct {
	UUID        string
	Name        string
	ChassisName string
	Priority    int
	Options     map[interface{}]interface{}
	ExternalID  map[interface{}]interface{}
}

GatewayChassis ovnnb item

type LoadBalancer

type LoadBalancer struct {
	UUID string
	Name string

	ExternalID map[interface{}]interface{}
	// contains filtered or unexported fields
}

LoadBalancer ovnnb item

type LogicalRouter

type LogicalRouter struct {
	UUID    string
	Name    string
	Enabled bool

	Ports        []string
	StaticRoutes []string
	NAT          []string
	LoadBalancer []string

	Options    map[interface{}]interface{}
	ExternalID map[interface{}]interface{}
}

LogicalRouter ovnnb item

type LogicalRouterPort

type LogicalRouterPort struct {
	UUID           string
	Name           string
	GatewayChassis []string
	Networks       []string
	MAC            string
	Enabled        bool
	IPv6RAConfigs  map[interface{}]interface{}
	Options        map[interface{}]interface{}
	Peer           string
	ExternalID     map[interface{}]interface{}
}

LogicalRouterPort ovnnb item

type LogicalRouterStaticRoute

type LogicalRouterStaticRoute struct {
	UUID       string
	IPPrefix   string
	Nexthop    string
	OutputPort []string
	Policy     []string
	ExternalID map[interface{}]interface{}
}

LogicalRouterStaticRoute ovnnb item

type LogicalSwitch

type LogicalSwitch struct {
	UUID         string
	Name         string
	Ports        []string
	LoadBalancer []string
	ACLs         []string
	QoSRules     []string
	DNSRecords   []string
	OtherConfig  map[interface{}]interface{}
	ExternalID   map[interface{}]interface{}
}

LogicalSwitch ovnnb item

type LogicalSwitchPort

type LogicalSwitchPort struct {
	UUID          string
	Name          string
	Type          string
	Options       map[interface{}]interface{}
	Addresses     []string
	PortSecurity  []string
	DHCPv4Options string
	DHCPv6Options string
	ExternalID    map[interface{}]interface{}
}

LogicalSwitchPort ovnnb item

type NAT

type NAT struct {
	UUID        string
	Type        string
	ExternalIP  string
	ExternalMAC string
	LogicalIP   string
	LogicalPort string
	ExternalID  map[interface{}]interface{}
}

NAT ovnnb item

type OVNDisconnectedCallback

type OVNDisconnectedCallback func()

OVNDisconnectedCallback executed when ovn client disconnects

type OVNNotifier

type OVNNotifier interface {
	Update(context interface{}, tableUpdates libovsdb.TableUpdates)
	Locked([]interface{})
	Stolen([]interface{})
	Echo([]interface{})
	Disconnected(client *libovsdb.OvsdbClient)
}

OVNNotifier ovnnb notifier

type OVNRow

type OVNRow map[string]interface{}

OVNRow ovnnb row

type OVNSignal

type OVNSignal interface {
	OnLogicalSwitchCreate(ls *LogicalSwitch)
	OnLogicalSwitchDelete(ls *LogicalSwitch)

	OnLogicalPortCreate(lp *LogicalSwitchPort)
	OnLogicalPortDelete(lp *LogicalSwitchPort)

	OnLogicalRouterCreate(lr *LogicalRouter)
	OnLogicalRouterDelete(lr *LogicalRouter)

	OnLogicalRouterPortCreate(lrp *LogicalRouterPort)
	OnLogicalRouterPortDelete(lrp *LogicalRouterPort)

	OnLogicalRouterStaticRouteCreate(lrsr *LogicalRouterStaticRoute)
	OnLogicalRouterStaticRouteDelete(lrsr *LogicalRouterStaticRoute)

	OnACLCreate(acl *ACL)
	OnACLDelete(acl *ACL)

	OnDHCPOptionsCreate(dhcp *DHCPOptions)
	OnDHCPOptionsDelete(dhcp *DHCPOptions)

	OnQoSCreate(qos *QoS)
	OnQoSDelete(qos *QoS)

	OnLoadBalancerCreate(ls *LoadBalancer)
	OnLoadBalancerDelete(ls *LoadBalancer)
}

OVNSignal notifies on changes to ovnnb

type OvnCommand

type OvnCommand struct {
	Operations []libovsdb.Operation
	Exe        Execution
	Results    [][]map[string]interface{}
}

OvnCommand ovnnb command

func (*OvnCommand) Execute

func (ocmd *OvnCommand) Execute() error

Execute sends command to ovnnb

type PortGroup

type PortGroup struct {
	UUID       string
	Name       string
	Ports      []string
	ACLs       []string
	ExternalID map[interface{}]interface{}
}

PortGroup ovnnb item

type QoS

type QoS struct {
	UUID       string
	Priority   int
	Direction  string
	Match      string
	Action     map[interface{}]interface{}
	Bandwidth  map[interface{}]interface{}
	ExternalID map[interface{}]interface{}
}

QoS ovnnb item

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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