library_ovsdb_manager: Descriptions for OVS configs

To connect OVSDB Manager library to OVS, some additional configurations
on OVS is required, but currently no description about these
configurations.

This patch adds descriptions for OVS configurations and includes some
improvements of sample application.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
IWASE Yusuke 2017-11-02 09:11:26 +09:00 committed by FUJITA Tomonori
parent 92730dc7e9
commit eda4940eb8

View File

@ -2,6 +2,8 @@
OVSDB Manager library OVSDB Manager library
********************* *********************
Path: ``ryu.services.protocols.ovsdb``
Introduction Introduction
============ ============
@ -9,11 +11,40 @@ Ryu OVSDB Manager library allows your code to interact with devices
speaking the OVSDB protocol. This enables your code to perform remote speaking the OVSDB protocol. This enables your code to perform remote
management of the devices and react to topology changes on them. management of the devices and react to topology changes on them.
Please note this library will spawn a server listening on the port 6640 (the
IANA registered for OVSDB protocol), but does not initiate connections from
controller side.
Then, to make your devices connect to Ryu, you need to tell the controller IP
address and port to your devices.
.. code-block:: bash
# Show current configuration
$ ovs-vsctl get-manager
# Set manager (controller) address
$ ovs-vsctl set-manager "tcp:127.0.0.1:6640"
# If you want to specify IPv6 address, wrap ip with brackets
$ ovs-vsctl set-manager "tcp:[::1]:6640"
Also this library identifies the devices by "system-id" which should be unique,
persistent identifier among all devices connecting to a single controller.
Please make sure "system-id" is configured before connecting.
.. code-block:: bash
# Show current configuration
$ ovs-vsctl get Open_vSwitch . external_ids:system-id
# Set system-id manually
$ ovs-vsctl set Open_vSwitch . external_ids:system-id=<SYSTEM-ID>
Example Example
======= =======
The following logs all new OVSDB connections and allows creating a port The following logs all new OVSDB connections in "handle_new_ovsdb_connection"
on a bridge. and also provides the API "create_port" for creating a port on a bridge.
.. code-block:: python .. code-block:: python
@ -29,11 +60,14 @@ on a bridge.
@set_ev_cls(ovsdb_event.EventNewOVSDBConnection) @set_ev_cls(ovsdb_event.EventNewOVSDBConnection)
def handle_new_ovsdb_connection(self, ev): def handle_new_ovsdb_connection(self, ev):
system_id = ev.system_id system_id = ev.system_id
addr = ev.client.address address = ev.client.address
self.logger.info('New OVSDB connection from system id %s', self.logger.info(
system_id) 'New OVSDB connection from system-id=%s, address=%s',
self.logger.info('The connection address id %s', system_id, address)
addr)
# Example: If device has bridge "s1", add port "s1-eth99"
if ovsdb.bridge_exists(self, system_id, "s1"):
self.create_port(system_id, "s1", "s1-eth99")
def create_port(self, system_id, bridge_name, name): def create_port(self, system_id, bridge_name, name):
new_iface_uuid = uuid.uuid4() new_iface_uuid = uuid.uuid4()
@ -42,7 +76,6 @@ on a bridge.
bridge = ovsdb.row_by_name(self, system_id, bridge_name) bridge = ovsdb.row_by_name(self, system_id, bridge_name)
def _create_port(tables, insert): def _create_port(tables, insert):
iface = insert(tables['Interface'], new_iface_uuid) iface = insert(tables['Interface'], new_iface_uuid)
iface.name = name iface.name = name
iface.type = 'internal' iface.type = 'internal'
@ -53,7 +86,7 @@ on a bridge.
bridge.ports = bridge.ports + [port] bridge.ports = bridge.ports + [port]
return (new_port_uuid, new_iface_uuid) return new_port_uuid, new_iface_uuid
req = ovsdb_event.EventModifyRequest(system_id, _create_port) req = ovsdb_event.EventModifyRequest(system_id, _create_port)
rep = self.send_request(req) rep = self.send_request(req)