Python 2.7 保留数据路径#端口以实现兼容性

Python 2.7 保留数据路径#端口以实现兼容性,python-2.7,ryu,Python 2.7,Ryu,我正在尝试让ryu运行,特别是拓扑发现 现在,我在ryu/topology/dumper.py下运行这个演示应用程序,它应该转储所有拓扑事件。我在ryu/topologydirecory中,并使用ryu-manager-dumper.py运行它。ryu manager的版本是2.23.2 启动后不久,它会出现以下错误: /usr/local/lib/python2.7/dist-packages/ryu/topology/switches.py:478: UserWarning: Datapa

我正在尝试让ryu运行,特别是拓扑发现

现在,我在
ryu/topology/dumper.py
下运行这个演示应用程序,它应该转储所有拓扑事件。我在
ryu/topology
direcory中,并使用
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.api
。i、 e

from ryu.topology.api import get_switch, get_link
有这个。然而,有一些东西丢失了

以下是我到目前为止的情况:

在中,两个函数
get\u开关(self,None)
get\u链接(self,None)
将为您提供链接和开关的列表

我遇到了同样的问题(取决于您的应用程序,这可能不是问题,只是一个可以忽略的警告)。以下是我在
查找后得出的结论-类型f | xargs grep“保留端口”

在文件
ryu/controller/controller.py
类数据路径中调用
\u get\u port()
,在
ryu.topology.switches
中触发此警告

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)

让我知道下面的答案是否有用。谢谢你的回答!我现在不能测试它。等我能测试出来的时候再给你回复。看起来很有帮助!
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)
class Switches(app_manager.RyuApp):
    #......
    @set_ev_cls(ofp_event.EventOFPPortStatus, MAIN_DISPATCHER)
    def port_status_handler(self, ev):