Hi again,

> - how do I set the IP address of the controller?

You are using Open vSwitch, right?
If so, you need to configure your switches via OVSDB (like "ovs-vsctl" command),
and Ryu provide some options to use OVSDB.

First, it might be the easiest way I guess, you can use the APIs of
"ryu.lib.ovs".
The usage and arguments are very similar to "ovs-vsctl" command.
https://github.com/osrg/ryu/blob/63f81837fd73cc31edbfe9ba6814ae3f38e34a16/ryu/lib/ovs/bridge.py#L133

In this case, you need to set the OVSDB manager address to your OVS before
Ryu connect to your switches like;
$ ovs-vsctl set-manager "ptcp:6640"

Example code:
===
from ryu.cfg import CONF
from ryu.lib.ovs import bridge

ovs_bridge = bridge.OVSBridge(CONF, 1, "tcp:127.0.0.1:6640")
ovs_bridge.set_controller(["tcp:127.0.0.1:6653"])
===

The similar to the first way, the OVSDB Manager library provides the reactive
connection to OVS.
"reactive" means Ryu will wait for the incoming OVSDB connections from the
switch side (on the other hand, "proactive" way is using "ryu.lib.ovs" and it
will connect to switches from the controller side)
http://ryu.readthedocs.io/en/latest/library_ovsdb_manager.html

Example code:
===
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
        address = ev.client.address
        self.logger.info(
            'New OVSDB connection from system-id=%s, address=%s',
            system_id, address)

        ovsdb.set_controller(self, system_id, "s1", "tcp:127.0.0.1:6633")
===

The third way, this way might be not answer for your original question tough,
Ryu can connect to your switches from the controller side with
"--ofp-switch-address-list" option.

Example:
$ ryu-manager --help
...(snip)...
  --ofp-switch-address-list OFP_SWITCH_ADDRESS_LIST
                        list of IP address and port pairs (default empty).
                        e.g., "127.0.0.1:6653,[::1]:6653"
...(snip)...

Mostly, OVS instances on Mininet will listen on 6653+increment like;
mininet> sh ovs-vsctl show
c8fb2af7-1088-4f3e-92f7-fc09d20f7d40
    Bridge "s1"
        Controller "tcp:127.0.0.1:6653"
        Controller "ptcp:6654"  # <--- waiting for controller on 6653+1
...(snip)...
    Bridge "s2"
        Controller "tcp:127.0.0.1:6653"
        Controller "ptcp:6655"  # <--- waiting for controller on 6653+2
...(snip)...


> - how do I get the list of the connected switches? Is there a simple api
> or do I need to explicitly save the various datapath? Also how do I map
> a datapath to the switch name?

You can use "ryu.app.ofctl.app" for such purpose.
Please refer to the following mail for the usage example.
https://www.mail-archive.com/ryu-devel@lists.sourceforge.net/msg09357.html


Thanks,
Iwase


On 2017年12月02日 01:41, Alessandro Gaballo wrote:
Hi, I have 2 questions:

- how do I set the IP address of the controller?
- how do I get the list of the connected switches? Is there a simple api
or do I need to explicitly save the various datapath? Also how do I map
a datapath to the switch name?

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Ryu-devel mailing list
Ryu-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ryu-devel


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Ryu-devel mailing list
Ryu-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to