3

我正在尝试让 ryu 运行,尤其是拓扑发现。

现在我正在运行该下的演示应用程序ryu/topology/dumper.py,它应该转储所有拓扑事件。我在ryu/topology目录中并使用ryu-manager dumper.py. ryu-manager 的版本是 2.23.2。

启动后不久,它给了我这个错误:

/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():

对我来说真正奇怪的是它建议使用ryu.topology.switches,但该错误是由该文件的第 478 行触发的!

有问题的功能是这样的:

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)

以前有没有其他人遇到过这个问题?我该如何解决?

4

2 回答 2

1

我以前遇到过这个问题,但我只是忽略了它,到目前为止,一切都按预期工作。

如果您正在尝试学习拓扑,我建议您使用ryu.topology.api. IE

from ryu.topology.api import get_switch, get_link

有这个教程。然而,有些东西不见了。

这是我到目前为止所拥有的: Controller.py

Controller.py中,这两个函数将为您提供链接get_switch(self, None)get_link(self, None)开关列表。

于 2015-07-15T16:18:49.737 回答
1

我遇到了同样的问题(取决于您的应用程序,也许这不是问题,只是一个您可以忽略的警告)。这是我经过find . -type f | xargs grep "ports is kept"

ryu.topology.switches通过调用_get_ports()in class Datapathof 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)

我的理解是,如果警告来自ryu.topology.switchesor ryu.controller.dpset,你可以忽略它;因为这两个类为您处理事件。但是如果Datapath直接使用,端口状态不会自动更新。如果我错了,任何人都可以纠正我。

class Switches(app_manager.RyuApp):
    #......
    @set_ev_cls(ofp_event.EventOFPPortStatus, MAIN_DISPATCHER)
    def port_status_handler(self, ev):
于 2015-09-11T23:04:22.770 回答