Datapath port # supported for compatibility
I am trying to get ryu running, especially topology detection.
I am now running a demo application for this in ryu/topology/dumper.py
, which should reset all topology events. I am in the directory ryu/topology
and run it with ryu-manager dumper.py
. The ryu-manager version is 2.23.2.
Shortly after starting it gives me this error:
/usr/local/lib/python2.7/dist-packages/ryu/topology/switches.py:478: UserWarning:
Datapath#ports is kept for compatibility with the previous openflow versions (< 1.3).
This not be updated by EventOFPPortStatus message. If you want to be updated,
you can use 'ryu.controller.dpset' or 'ryu.topology.switches'.
for port in dp.ports.values():
What's really strange to me is what he recommends to use ryu.topology.switches
, but this error is triggered on line 478 of this very file!
The corresponding function is this:
class Switches(app_manager.RyuApp):
OFP_VERSIONS = [ofproto_v1_0.OFP_VERSION, ofproto_v1_2.OFP_VERSION,
ofproto_v1_3.OFP_VERSION, ofproto_v1_4.OFP_VERSION]
_EVENTS = [event.EventSwitchEnter, event.EventSwitchLeave,
event.EventPortAdd, event.EventPortDelete,
event.EventPortModify,
event.EventLinkAdd, event.EventLinkDelete]
DEFAULT_TTL = 120 # unused. ignored.
LLDP_PACKET_LEN = len(LLDPPacket.lldp_packet(0, 0, DONTCARE_STR, 0))
LLDP_SEND_GUARD = .05
LLDP_SEND_PERIOD_PER_PORT = .9
TIMEOUT_CHECK_PERIOD = 5.
LINK_TIMEOUT = TIMEOUT_CHECK_PERIOD * 2
LINK_LLDP_DROP = 5
#...
def _register(self, dp):
assert dp.id is not None
self.dps[dp.id] = dp
if dp.id not in self.port_state:
self.port_state[dp.id] = PortState()
for port in dp.ports.values(): # THIS LINE
self.port_state[dp.id].add(port.port_no, port)
Has anyone else encountered this problem before? How can I fix this?
source to share
I ran into the same problem (depending on your application, maybe this is not a problem, just a warning that can be ignored). Here's what I realized afterfind . -type f | xargs grep "ports is kept"
This warning is triggered ryu.topology.switches
by a call _get_ports()
to a class Datapath
file ryu/controller/controller.py
.
class Datapath(ofproto_protocol.ProtocolDesc):
#......
def _get_ports(self):
if (self.ofproto_parser is not None and
self.ofproto_parser.ofproto.OFP_VERSION >= 0x04):
message = (
'Datapath#ports is kept for compatibility with the previous '
'openflow versions (< 1.3). '
'This not be updated by EventOFPPortStatus message. '
'If you want to be updated, you can use '
'\'ryu.controller.dpset\' or \'ryu.topology.switches\'.'
)
warnings.warn(message, stacklevel=2)
return self._ports
def _set_ports(self, ports):
self._ports = ports
# To show warning when Datapath#ports is read
ports = property(_get_ports, _set_ports)
I understand that if the warning is from ryu.topology.switches
or ryu.controller.dpset
, you can ignore it; because these two classes handle the event for you. But if you use Datapath
directly, the port status is not automatically updated. Someone will correct me if I am wrong.
class Switches(app_manager.RyuApp):
#......
@set_ev_cls(ofp_event.EventOFPPortStatus, MAIN_DISPATCHER)
def port_status_handler(self, ev):
source to share
I ran into this problem before, but I just ignored it and it still works as expected.
If you are trying to learn topology, I would recommend using ryu.topology.api
. those.
from ryu.topology.api import get_switch, get_link
There is a tutorial . However, there are some missing things.
Here's what I have so far: Controller.py
There are two functions in Controller.pyget_switch(self, None)
and get_link(self, None)
will give you a list of links and radio buttons.
source to share