ovsdb

package module
v0.0.0-...-c84bb51 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2017 License: Apache-2.0 Imports: 9 Imported by: 0

README

ovsdb

Build Status codecov

A libovsdb wrapper for operating Open vSwitch via Go.

This library is a fork of the ovsdbDriver functionality in contiv/ofnet and makes modifications for supporting Unix domain socket to connect OVSDB.

Install

$ go get -u github.com/John-Lin/ovsdb

Usage with ovsdb-server

You might need to create OVS bridge on given IP and TCP port, please make sure that you have set OVSDB listener.

$ ovs-vsctl set-manager ptcp:6640

Create bridge should assign IP and TCP port.

ovsDriver = ovsdb.NewOvsDriver("ovsbr", "127.0.0.1", 6640)

Otherwise, ovsdb-server connects to the Unix domain server socket and the default path is unix:/var/run/openvswitch/db.sock .

ovsDriver = ovsdb.NewOvsDriverWithUnix("br0")

Example

package main

import "github.com/John-Lin/ovsdb"

var ovsDriver *ovsdb.OvsDriver

func main() {
    // Create an OVS bridge to the Unix domain server socket.
    ovsDriver = ovsdb.NewOvsDriverWithUnix("br0")

    // Create an OVS bridge to the given IP and TCP port.
    // ovsDriver = ovsdb.NewOvsDriver("br0", "127.0.0.1", 6640)

    // Add br0 as a internal port without vlan tag (0)
    ovsDriver.CreatePort("br0", "internal", 0)
}

Use ovs-vsctl show to check bridge information.

root@dev:~# ovs-vsctl show
82040598-7050-4320-b946-1d4380fabc73
    Bridge "br0"
        Port "br0"
            Interface "br0"
                type: internal
    ovs_version: "2.5.2"
  • libovsdb is an OVSDB library which is originally developed by SocketPlane.
  • contiv/ofnet is openflow networking library.

Documentation

Index

Constants

View Source
const DefaultAddress = "127.0.0.1"

DefaultAddress is the default IPV4 address that is used for a connection

View Source
const DefaultPort = 6640

DefaultPort is the default port used for a connection

Variables

This section is empty.

Functions

This section is empty.

Types

type OvsDriver

type OvsDriver struct {

	// Name of the OVS bridge
	OvsBridgeName string
	// contains filtered or unexported fields
}

OVS driver state

func NewOvsDriver

func NewOvsDriver(bridgeName string, ipAddr string, port int) *OvsDriver

Create a new OVS driver

func NewOvsDriverWithUnix

func NewOvsDriverWithUnix(bridgeName string) *OvsDriver

Create a new OVS driver with Unix socket

func (*OvsDriver) AddController

func (self *OvsDriver) AddController(ipAddr string, portNo uint16) error

Add controller configuration to OVS

func (*OvsDriver) CreateBridge

func (self *OvsDriver) CreateBridge(bridgeName string, failMode string, stp bool) error

**************** OVS driver API ********************

func (*OvsDriver) CreatePort

func (self *OvsDriver) CreatePort(intfName, intfType string, vlanTag uint) error

Create an internal port in OVS

func (*OvsDriver) CreateVtep

func (self *OvsDriver) CreateVtep(intfName string, vtepRemoteIP string) error

Create a VTEP port on the OVS

func (*OvsDriver) Delete

func (d *OvsDriver) Delete() error

Delete : Cleanup the ovsdb driver. delete the bridge we created.

func (*OvsDriver) DeleteBridge

func (self *OvsDriver) DeleteBridge(bridgeName string) error

Delete a bridge from ovs

func (*OvsDriver) DeletePort

func (self *OvsDriver) DeletePort(intfName string) error

Delete a port from OVS

func (*OvsDriver) DeleteVtep

func (self *OvsDriver) DeleteVtep(intfName string) error

Delete a VTEP port

func (*OvsDriver) Disconnected

func (self *OvsDriver) Disconnected(ovsClient *libovsdb.OvsdbClient)

func (*OvsDriver) Echo

func (self *OvsDriver) Echo([]interface{})

func (*OvsDriver) GetOfpPortNo

func (self *OvsDriver) GetOfpPortNo(intfName string) (uint32, error)

Return OFP port number for an interface

func (*OvsDriver) IsBridgePresent

func (self *OvsDriver) IsBridgePresent(bridgeName string) bool

Check if the bridge entry already exists

func (*OvsDriver) IsControllerPresent

func (self *OvsDriver) IsControllerPresent(ipAddr string, portNo uint16) bool

Check if Controller already exists

func (*OvsDriver) IsPortNamePresent

func (self *OvsDriver) IsPortNamePresent(intfName string) bool

Check the local cache and see if the portname is taken already HACK alert: This is used to pick next port number instead of managing

port number space actively across agent restarts

func (*OvsDriver) IsVtepPresent

func (self *OvsDriver) IsVtepPresent(remoteIP string) (bool, string)

Check if VTEP already exists

func (*OvsDriver) Locked

func (self *OvsDriver) Locked([]interface{})

func (*OvsDriver) PrintCache

func (self *OvsDriver) PrintCache()

Dump the contents of the cache into stdout

func (*OvsDriver) RemoveController

func (self *OvsDriver) RemoveController(target string) error

func (*OvsDriver) Stolen

func (self *OvsDriver) Stolen([]interface{})

func (*OvsDriver) Update

func (self *OvsDriver) Update(context interface{}, tableUpdates libovsdb.TableUpdates)

************************ Notification handler for OVS DB changes ****************

Jump to

Keyboard shortcuts

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