os-ken/doc/source/library_ovsdb.rst
IWASE Yusuke 09d2811569 doc: Document for ryu.lib.ovs
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2018-02-10 18:45:58 +09:00

2.0 KiB

OVSDB library

Path: ryu.lib.ovs

Similar to the library_ovsdb_manager, this library enables your application to speak the OVSDB protocol (RFC7047), but differ from the library_ovsdb_manager, this library will initiate connections from controller side as ovs-vsctl command does. Please make sure that your devices are listening on either the Unix domain socket or TCP/SSL port before calling the APIs of this library.

# Show current configuration
$ ovs-vsctl get-manager

# Set TCP listen address
$ ovs-vsctl set-manager "ptcp:6640"

See manpage of ovs-vsctl command for more details.

Basic Usage

  1. Instantiate :pyryu.lib.ovs.vsctl.VSCtl.
  2. Construct commands with :pyryu.lib.ovs.vsctl.VSCtlCommand. The syntax is almost the same as ovs-vsctl command.
  3. Execute commands via :pyryu.lib.ovs.vsctl.VSCtl.run_command.

Example

from ryu.lib.ovs import vsctl

OVSDB_ADDR = 'tcp:127.0.0.1:6640'
ovs_vsctl = vsctl.VSCtl(OVSDB_ADDR)

# Equivalent to
# $ ovs-vsctl show
command = vsctl.VSCtlCommand('show')
ovs_vsctl.run_command([command])
print(command)
# >>> VSCtlCommand(args=[],command='show',options=[],result='830d781f-c3c8-4b4f-837e-106e1b33d058\n    ovs_version: "2.8.90"\n')

# Equivalent to
# $ ovs-vsctl list Port s1-eth1
command = vsctl.VSCtlCommand('list', ('Port', 's1-eth1'))
ovs_vsctl.run_command([command])
print(command)
# >>> VSCtlCommand(args=('Port', 's1-eth1'),command='list',options=[],result=[<ovs.db.idl.Row object at 0x7f525fb682e8>])
print(command.result[0].name)
# >>> s1-eth1

API Reference

ryu.lib.ovs.vsctl

ryu.lib.ovs.vsctl

ryu.lib.ovs.bridge

ryu.lib.ovs.bridge