Hi,

"get_switch()" returns a list of "Switch" instances.
You don't need to instantiate them from the returned value.

e.g.)
    switches = topology_api.get_switch(self)
    for sw in switches:
        self.logger.info("*** sw.dp.id = %d", sw.dp.id)

Thanks,
Iwase


On 2018年03月27日 01:20, Soliman Awad Alshra´a Abdullah TU Ilmenau wrote:
Thanks Iwase,

I use the simple _switch_13 code  with some modifications as follows:

I added

from ryu.topology.switches import Switch
from ryu.topology.api import get_switch, get_link

and I added into the def _packet_in_handler(self, ev):

B = get_switch(self, None)
obj = Switch(B)
A = obj.to_dict()

and I get the next error :

Traceback (most recent call last):
   File "/home/mininet/ryu/ryu/base/app_manager.py", line 290, in _event_loop
     handler(ev)
   File "/home/mininet/ryu/ryu/app/C2.py", line 85, in _packet_in_handler
     A = obj.to_dict()
   File "/home/mininet/ryu/ryu/topology/switches.py", line 124, in to_dict
     d = {'dpid': dpid_to_str(self.dp.id),
AttributeError: 'list' object has no attribute 'id'

any solution ?

-----Original Message-----
From: Iwase Yusuke [mailto:iwase.yusu...@gmail.com]
Sent: Friday, March 23, 2018 8:34 AM
To: Soliman Awad Alshra´a Abdullah TU Ilmenau <abdullah.alsh...@tu-ilmenau.de>
Cc: ryu-devel@lists.sourceforge.net
Subject: Re: [Ryu-devel] Informing the controller about the first switch 
Datapath and port number which connected to the host.

Hi Soliman,

"ryu.topology" provides such feature, I guess.
How about the following APIs and events?
https://github.com/osrg/ryu/blob/master/ryu/topology/api.py#L38-L44
https://github.com/osrg/ryu/blob/e6773539b546576c13f7397769d2001c46bbfdaa/ryu/topology/event.py#L169-L186

If you want to implement your own host detection logic, the following app might 
be helpful for you.
https://github.com/osrg/ryu/blob/master/ryu/topology/switches.py

Thanks,
Iwase


On 2018年03月22日 03:45, Soliman Awad Alshra´a Abdullah TU Ilmenau wrote:
Hello Dears,

In my topology, I should send packets from the host to a Ryu
controller through many switches. I need to inform the controller
about the first switch Datapath and port number which connected to the host.



Any idea or advice ?

Thanks in advance



----------------------------------------------------------------------
-------- 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

Reply via email to