summaryrefslogtreecommitdiffhomepage
path: root/doc
diff options
context:
space:
mode:
authorJason Kölker <jason@koelker.net>2015-07-24 17:58:02 +0000
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-07-30 16:54:46 +0900
commitaa198d6900e2044ad940f4a1e89b3e7e0174c8c1 (patch)
tree3f0df4154e88a9380a659000a08280bf43524dab /doc
parent0de43f7b6038a0045c3f5f46fa74a6b2a394c112 (diff)
Add OVSDB manager protocol application
Allows listening on a socket for OVSDB clients, reacting to their events and modifying their database. Co-Authored-By: Chris Hansen <chris.hansen.career@gmail.com> Co-Authored-By: Ravi Kamachi <ravi.kamachi@rackspace.com> Signed-off-by: Jason Kölker <jason@koelker.net> Signed-off-by: Chris Hansen <chris.hansen.career@gmail.com> Signed-off-by: Ravi Kamachi <ravi.kamachi@rackspace.com> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'doc')
-rw-r--r--doc/source/library.rst1
-rw-r--r--doc/source/library_ovsdb_manager.rst61
2 files changed, 62 insertions, 0 deletions
diff --git a/doc/source/library.rst b/doc/source/library.rst
index 38cc3872..bc8ff67f 100644
--- a/doc/source/library.rst
+++ b/doc/source/library.rst
@@ -12,3 +12,4 @@ Ryu provides some useful library for your network applications.
library_of_config.rst
library_bgp_speaker.rst
library_bgp_speaker_ref.rst
+ library_ovsdb_manager.rst
diff --git a/doc/source/library_ovsdb_manager.rst b/doc/source/library_ovsdb_manager.rst
new file mode 100644
index 00000000..b23ae81d
--- /dev/null
+++ b/doc/source/library_ovsdb_manager.rst
@@ -0,0 +1,61 @@
+*********************
+OVSDB Manager library
+*********************
+
+Introduction
+============
+
+Ryu OVSDB Manager library allows your code to interact with devices
+speaking the OVSDB protocol. This enables your code to perform remote
+management of the devices and react to topology changes on them.
+
+Example
+=======
+
+The following logs all new OVSDB connections and allows creating a port
+on a bridge.
+
+.. code-block:: python
+
+ import uuid
+
+ from ryu.base import app_manager
+ from ryu.services.protocols.ovsdb import api as ovsdb
+ from ryu.services.protocols.ovsdb import event as ovsdb_event
+
+
+ class MyApp(app_manager.RyuApp):
+ @set_ev_cls(ovsdb_event.EventNewOVSDBConnection)
+ def handle_new_ovsdb_connection(self, ev):
+ system_id = ev.system_id
+ self.logger.info('New OVSDB connection from system id %s',
+ systemd_id)
+
+ def create_port(self, systemd_id, bridge_name, name):
+ new_iface_uuid = uuid.uuid4()
+ new_port_uuid = uuid.uuid4()
+
+ def _create_port(tables, insert):
+ bridge = ovsdb.row_by_name(self, system_id, bridge_name)
+
+ iface = insert(tables['Interface'], new_iface_uuid)
+ iface.name = name
+ iface.type = 'internal'
+
+ port = insert(tables['Port'], new_port_uuid)
+ port.name = name
+ port.interfaces = [iface]
+
+ brdige.ports = bridfe.ports + [port]
+
+ return (new_port_uuid, new_iface_uuid)
+
+ req = ovsdb_event.EventModifyRequest(system_id, _create_port)
+ rep = self.send_request(req)
+
+ if rep.status != 'success':
+ self.logger.error('Error creating port %s on bridge %s: %s',
+ name, bridge, rep.status)
+ return None
+
+ return reply.insert_uuid[new_port_uuid]