Hi,

Thank you for your reports.

On 2016年03月11日 20:03, Martin Zeller wrote:
> Hello,
> 
> The rest_topology app does not currently work with python3, due to
> problems in topology/switches.py:
> 
> switches: Exception occurred during handler processing. Backtrace from 
> offending handler [lldp_packet_in_handler] servicing event [EventOFPPacketIn] 
> follows.
> Traceback (most recent call last):
>   File "/usr/lib/python3.5/site-packages/ryu/base/app_manager.py", line 290, 
> in _event_loop
>     handler(ev)
>   File "/usr/lib/python3.5/site-packages/ryu/topology/switches.py", line 775, 
> in lldp_packet_in_handler
>     src_dpid, src_port_no = LLDPPacket.lldp_parse(msg.data)
>   File "/usr/lib/python3.5/site-packages/ryu/topology/switches.py", line 480, 
> in lldp_parse
>     if not chassis_id.startswith(LLDPPacket.CHASSIS_ID_PREFIX):
> TypeError: startswith first arg must be bytes or a tuple of bytes, not str
> 
> It appears that CHASSIS_ID_PREFIX is a string, yet the actual ID is a
> 'bytes', causing a type conflict.
> I think this problem occurs in multiple locations in the file, but
> cannot confirm it at this time.

Does the following workaround fix this problem?
Could you test this in your environment?
(This is only a partial solution, though...)


$ git diff ryu/topology/switches.py
diff --git a/ryu/topology/switches.py b/ryu/topology/switches.py
index d429eff..3b2b9bd 100644
--- a/ryu/topology/switches.py
+++ b/ryu/topology/switches.py
@@ -87,7 +87,7 @@ class Port(object):
         return {'dpid': dpid_to_str(self.dpid),
                 'port_no': port_no_to_str(self.port_no),
                 'hw_addr': self.hw_addr,
-                'name': self.name.rstrip('\0')}
+                'name': self.name.rstrip(b'\0').decode('utf-8')}
 
     # for Switch.del_port()
     def __eq__(self, other):
@@ -476,7 +476,7 @@ class LLDPPacket(object):
         if tlv_chassis_id.subtype != lldp.ChassisID.SUB_LOCALLY_ASSIGNED:
             raise LLDPPacket.LLDPUnknownFormat(
                 msg='unknown chassis id subtype %d' % tlv_chassis_id.subtype)
-        chassis_id = tlv_chassis_id.chassis_id
+        chassis_id = tlv_chassis_id.chassis_id.decode('utf-8')
         if not chassis_id.startswith(LLDPPacket.CHASSIS_ID_PREFIX):
             raise LLDPPacket.LLDPUnknownFormat(
                 msg='unknown chassis id format %s' % chassis_id)


Thanks,
Iwase

> 
> 
> 
> ------------------------------------------------------------------------------
> Transform Data into Opportunity.
> Accelerate data analysis in your applications with
> Intel Data Analytics Acceleration Library.
> Click to learn more.
> http://pubads.g.doubleclick.net/gampad/clk?id=278785111&iu=/4140
> 
> 
> 
> _______________________________________________
> Ryu-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/ryu-devel
> 

------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785231&iu=/4140
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to