README written
[vsorcdistro/.git] / ryu / doc / source / library_ovsdb.rst
1 *************
2 OVSDB library
3 *************
4
5 Path: ``ryu.lib.ovs``
6
7 Similar to the :doc:`library_ovsdb_manager`, this library enables your
8 application to speak the OVSDB protocol (RFC7047_), but differ from the
9 :doc:`library_ovsdb_manager`, this library will initiate connections from
10 controller side as ovs-vsctl_ command does.
11 Please make sure that your devices are listening on either the Unix domain
12 socket or TCP/SSL port before calling the APIs of this library.
13
14 .. code-block:: bash
15
16     # Show current configuration
17     $ ovs-vsctl get-manager
18
19     # Set TCP listen address
20     $ ovs-vsctl set-manager "ptcp:6640"
21
22 See manpage of ovs-vsctl_ command for more details.
23
24 .. _RFC7047: https://tools.ietf.org/html/rfc7047
25 .. _ovs-vsctl: http://openvswitch.org/support/dist-docs/ovs-vsctl.8.txt
26
27 Basic Usage
28 ===========
29
30 1. Instantiate :py:mod:`ryu.lib.ovs.vsctl.VSCtl`.
31
32 2. Construct commands with :py:mod:`ryu.lib.ovs.vsctl.VSCtlCommand`.
33    The syntax is almost the same as ovs-vsctl_ command.
34
35 3. Execute commands via :py:mod:`ryu.lib.ovs.vsctl.VSCtl.run_command`.
36
37 Example
38 -------
39
40 .. code-block:: python
41
42     from ryu.lib.ovs import vsctl
43
44     OVSDB_ADDR = 'tcp:127.0.0.1:6640'
45     ovs_vsctl = vsctl.VSCtl(OVSDB_ADDR)
46
47     # Equivalent to
48     # $ ovs-vsctl show
49     command = vsctl.VSCtlCommand('show')
50     ovs_vsctl.run_command([command])
51     print(command)
52     # >>> VSCtlCommand(args=[],command='show',options=[],result='830d781f-c3c8-4b4f-837e-106e1b33d058\n    ovs_version: "2.8.90"\n')
53
54     # Equivalent to
55     # $ ovs-vsctl list Port s1-eth1
56     command = vsctl.VSCtlCommand('list', ('Port', 's1-eth1'))
57     ovs_vsctl.run_command([command])
58     print(command)
59     # >>> VSCtlCommand(args=('Port', 's1-eth1'),command='list',options=[],result=[<ovs.db.idl.Row object at 0x7f525fb682e8>])
60     print(command.result[0].name)
61     # >>> s1-eth1
62
63 API Reference
64 =============
65
66 ryu.lib.ovs.vsctl
67 -----------------
68
69 .. automodule:: ryu.lib.ovs.vsctl
70     :members:
71
72 ryu.lib.ovs.bridge
73 ------------------
74
75 .. automodule:: ryu.lib.ovs.bridge
76     :members: