I know how to tell my switches the controller's address but I don't want it to be 127.0.0.1, I want to change it from the controller side.
On 04/12/2017 22:55, Iwase Yusuke wrote: > Hi Alessandro, > > Well... I might misunderstand your situation... > You just want to tell your controller's IP/port to your switches when > starting > your topology up, right? > In other words, it is not required to configure the controller address > dynamically after the topology was created. > > If so, did you try to add the controller address in your Mininet script? > > Example: > ...(snip)... > net = Mininet(controller=RemoteController) > > net.addController('c1', ip='192.168.1.1', port=6653) > net.addController('c2', ip='192.168.1.2', port=6653) > > s1 = net.addSwitch('s1') > s2 = net.addSwitch('s2') > ...(snip)... > > > If you need to configure the controller address dynamically, you need > to get > your switch's names and dpids before calling the APIs on my previous > mail. > > > Thanks, > Iwase > > > On 2017年12月05日 00:32, Alessandro Gaballo wrote: >> Hi, >> the API you suggested regarding the switch name is not what I need >> because it simply returns the datapath object, which I already have >> since I'm saving them when a new packet is received. What I need is the >> name of the switch, the one I'm using in Mininet to be clear. Is that >> simply the id? So s1 is the datapath with id=1 and so on? I also noticed >> the switches with different names such as (si1, sio1) are not able to >> connect to the controller. >> >> Concerning the setting of the controller address I don't get the correct >> flow. >> I thought there was a simply api to use in my ryu application that would >> define the ip and then make all the switches connect to that address >> from mininet. With the examples you gave me I see multiple port and >> addresses, so I'm still not sure. >> >> Thanks, >> Alessandro >> >> >> On 04/12/2017 00:05, Iwase Yusuke wrote: >> >>> 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 >> ------------------------------------------------------------------------------ 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