v0.0.0-...-f58463c Latest Latest

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

Go to latest
Published: Jan 24, 2017 License: Apache-2.0, Apache-2.0 Imports: 10 Imported by: 0



Circle CI Coverage Status

An OVSDB Library written in Go

What is OVSDB?

OVSDB is the Open vSwitch Database Protocol. It's defined in RFC 7047 It's used mainly for managing the configuration of Open vSwitch, but it could also be used to manage your stamp collection. Philatelists Rejoice!

## Running the tests

To run only unit tests:

make test

To run integration tests, you'll need access to docker to run an Open vSwitch container. Mac users can use boot2docker

export DOCKER_IP=
fig up -d
make test-all
fig stop

Dependency Management

We use godep for dependency management with rewritten import paths. This allows the repo to be go getable.

To bump the version of a dependency, follow these instructions




View Source
const DEFAULT_ADDR = ""
View Source
const DEFAULT_PORT = 6640


This section is empty.


func NewCancelArgs

func NewCancelArgs(id interface{}) []interface{}

NewCancelArgs creates a new set of arguments for a cancel RPC

func NewCondition

func NewCondition(column string, function string, value interface{}) []interface{}

NewCondition creates a new condition as specified in RFC7047

func NewGetSchemaArgs

func NewGetSchemaArgs(schema string) []interface{}

NewGetSchemaArgs creates a new set of arguments for a get_schemas RPC

func NewLockArgs

func NewLockArgs(id interface{}) []interface{}

NewLockArgs creates a new set of arguments for a lock, steal or unlock RPC

func NewMonitorArgs

func NewMonitorArgs(database string, value interface{}, requests map[string]MonitorRequest) []interface{}

NewMonitorArgs creates a new set of arguments for a monitor RPC

func NewMonitorCancelArgs

func NewMonitorCancelArgs(value interface{}) []interface{}

NewMonitorCancelArgs creates a new set of arguments for a monitor_cancel RPC

func NewMutation

func NewMutation(column string, mutator string, value interface{}) []interface{}

NewMutation creates a new mutation as specified in RFC7047

func NewTransactArgs

func NewTransactArgs(database string, operations ...Operation) []interface{}

NewTransactArgs creates a new set of arguments for a transact RPC


type ColumnSchema

type ColumnSchema struct {
	Name      string      `json:"name"`
	Type      interface{} `json:"type"`
	Ephemeral bool        `json:"ephemeral,omitempty"`
	Mutable   bool        `json:"mutable,omitempty"`

type DatabaseSchema

type DatabaseSchema struct {
	Name    string                 `json:"name"`
	Version string                 `json:"version"`
	Tables  map[string]TableSchema `json:"tables"`

func (DatabaseSchema) Print

func (schema DatabaseSchema) Print(w io.Writer)

type MonitorRequest

type MonitorRequest struct {
	Columns []string      `json:"columns,omitempty"`
	Select  MonitorSelect `json:"select,omitempty"`

MonitorRequest represents a monitor request according to RFC7047

type MonitorRequests

type MonitorRequests struct {
	Requests map[string]MonitorRequest `json:"requests,overflow"`

type MonitorSelect

type MonitorSelect struct {
	Initial bool `json:"initial,omitempty"`
	Insert  bool `json:"insert,omitempty"`
	Delete  bool `json:"delete,omitempty"`
	Modify  bool `json:"modify,omitempty"`

MonitorSelect represents a monitor select according to RFC7047

type NotificationHandler

type NotificationHandler interface {
	// RFC 7047 section 4.1.6 Update Notification
	Update(context interface{}, tableUpdates TableUpdates)

	// RFC 7047 section 4.1.9 Locked Notification

	// RFC 7047 section 4.1.10 Stolen Notification

	// RFC 7047 section 4.1.11 Echo Notification


type Operation

type Operation struct {
	Op        string                   `json:"op"`
	Table     string                   `json:"table"`
	Row       map[string]interface{}   `json:"row,omitempty"`
	Rows      []map[string]interface{} `json:"rows,omitempty"`
	Columns   []string                 `json:"columns,omitempty"`
	Mutations []interface{}            `json:"mutations,omitempty"`
	Timeout   int                      `json:"timeout,omitempty"`
	Where     []interface{}            `json:"where,omitempty"`
	Until     string                   `json:"until,omitempty"`
	UUIDName  string                   `json:"uuid-name,omitempty"`

Operation represents an operation according to RFC7047 section 5.2

type OperationResult

type OperationResult struct {
	Count   int                      `json:"count,omitempty"`
	Error   string                   `json:"error,omitempty"`
	Details string                   `json:"details,omitempty"`
	UUID    UUID                     `json:"uuid,omitempty"`
	Rows    []map[string]interface{} `json:"rows,omitempty"`

type OvsMap

type OvsMap struct {
	GoMap map[interface{}]interface{}

func NewOvsMap

func NewOvsMap(goMap interface{}) (*OvsMap, error)

<map> notation requires special marshaling

func (OvsMap) MarshalJSON

func (o OvsMap) MarshalJSON() ([]byte, error)

<map> notation requires special handling

func (*OvsMap) UnmarshalJSON

func (o *OvsMap) UnmarshalJSON(b []byte) (err error)

type OvsSet

type OvsSet struct {
	GoSet []interface{}

func NewOvsSet

func NewOvsSet(goSlice interface{}) (*OvsSet, error)

<set> notation requires special handling

func (OvsSet) MarshalJSON

func (o OvsSet) MarshalJSON() ([]byte, error)

<set> notation requires special marshaling

func (*OvsSet) UnmarshalJSON

func (o *OvsSet) UnmarshalJSON(b []byte) (err error)

type OvsdbClient

type OvsdbClient struct {
	Schema map[string]DatabaseSchema
	// contains filtered or unexported fields

func Connect

func Connect(ipAddr string, port int) (*OvsdbClient, error)

func (OvsdbClient) Disconnect

func (ovs OvsdbClient) Disconnect()

func (OvsdbClient) GetSchema

func (ovs OvsdbClient) GetSchema(dbName string) (*DatabaseSchema, error)

RFC 7047 : get_schema

func (OvsdbClient) ListDbs

func (ovs OvsdbClient) ListDbs() ([]string, error)

RFC 7047 : list_dbs

func (OvsdbClient) Monitor

func (ovs OvsdbClient) Monitor(database string, jsonContext interface{}, requests map[string]MonitorRequest) (*TableUpdates, error)

RFC 7047 : monitor

func (OvsdbClient) MonitorAll

func (ovs OvsdbClient) MonitorAll(database string, jsonContext interface{}) (*TableUpdates, error)

Convenience method to monitor every table/column

func (*OvsdbClient) Register

func (ovs *OvsdbClient) Register(handler NotificationHandler)

func (OvsdbClient) Transact

func (ovs OvsdbClient) Transact(database string, operation ...Operation) ([]OperationResult, error)

type OvsdbError

type OvsdbError struct {
	Error   string `json:"error"`
	Details string `json:"details,omitempty"`

OvsdbError is an OVS Error Condition

type Row

type Row struct {
	Fields map[string]interface{}

func (*Row) UnmarshalJSON

func (r *Row) UnmarshalJSON(b []byte) (err error)

type RowUpdate

type RowUpdate struct {
	Uuid UUID `json:"-,omitempty"`
	New  Row  `json:"new,omitempty"`
	Old  Row  `json:"old,omitempty"`

type TableSchema

type TableSchema struct {
	Columns map[string]ColumnSchema `json:"columns"`
	Indexes [][]string              `json:"indexes,omitempty"`

type TableUpdate

type TableUpdate struct {
	Rows map[string]RowUpdate `json:"rows,overflow"`

type TableUpdates

type TableUpdates struct {
	Updates map[string]TableUpdate `json:"updates,overflow"`

* We cannot use TableUpdates directly by json encoding by inlining the TableUpdate Map * structure till GoLang issue #6213 makes it. * * The only option is to go with raw map[string]map[string]interface{} option :-( that sucks ! * Refer to client.go : MonitorAll() function for more details

type TransactResponse

type TransactResponse struct {
	Result []OperationResult `json:"result"`
	Error  string            `json:"error"`

type UUID

type UUID struct {
	GoUuid string `json:"uuid"`

func (UUID) MarshalJSON

func (u UUID) MarshalJSON() ([]byte, error)

<set> notation requires special marshaling

func (*UUID) UnmarshalJSON

func (u *UUID) UnmarshalJSON(b []byte) (err error)


Path Synopsis

Jump to

Keyboard shortcuts

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