From c0590ea903d1fbe40a22e04970d5a8a7e489aa44 Mon Sep 17 00:00:00 2001 From: IWAMOTO Toshihiro Date: Sat, 20 Jun 2015 00:10:26 +0900 Subject: [PATCH] python3: Adapt to new iterator names This patch is generated by "2to3 -f dict" and irrevant parts were hand-removed. Signed-off-by: IWAMOTO Toshihiro Signed-off-by: FUJITA Tomonori --- ryu/app/ofctl_rest.py | 2 +- ryu/app/rest_quantum.py | 2 +- ryu/app/rest_router.py | 2 +- ryu/app/simple_isolation.py | 2 +- ryu/base/app_manager.py | 8 ++++---- ryu/cmd/rpc_cli.py | 2 +- ryu/cmd/ryu_base.py | 2 +- ryu/controller/conf_switch.py | 4 ++-- ryu/controller/dpset.py | 4 ++-- ryu/controller/handler.py | 4 ++-- ryu/controller/network.py | 4 ++-- ryu/lib/bfdlib.py | 4 ++-- ryu/lib/ovs/vsctl.py | 6 +++--- ryu/lib/packet/bgp.py | 2 +- ryu/lib/packet/bmp.py | 2 +- ryu/lib/packet/ospf.py | 2 +- ryu/lib/quantum_ifaces.py | 2 +- ryu/lib/stplib.py | 2 +- ryu/lib/stringify.py | 6 +++--- ryu/ofproto/ofproto_parser.py | 2 +- ryu/ofproto/ofproto_v1_2_parser.py | 10 +++++----- ryu/ofproto/ofproto_v1_3_parser.py | 6 +++--- ryu/ofproto/ofproto_v1_4_parser.py | 10 +++++----- ryu/ofproto/ofproto_v1_5_parser.py | 10 +++++----- ryu/services/protocols/bgp/api/base.py | 2 +- ryu/services/protocols/bgp/api/rtconf.py | 2 +- ryu/services/protocols/bgp/application.py | 2 +- ryu/services/protocols/bgp/bmp.py | 4 ++-- ryu/services/protocols/bgp/core.py | 6 +++--- .../protocols/bgp/core_managers/peer_manager.py | 16 ++++++++-------- .../protocols/bgp/core_managers/table_manager.py | 4 ++-- ryu/services/protocols/bgp/info_base/base.py | 8 ++++---- ryu/services/protocols/bgp/info_base/vrf.py | 6 +++--- ryu/services/protocols/bgp/operator/command.py | 8 ++++---- .../bgp/operator/commands/show/neighbor.py | 2 +- .../protocols/bgp/operator/commands/show/rib.py | 2 +- .../protocols/bgp/operator/commands/show/vrf.py | 6 +++--- .../protocols/bgp/operator/internal_api.py | 10 +++++----- .../protocols/bgp/operator/views/base.py | 16 ++++++++-------- ryu/services/protocols/bgp/peer.py | 16 ++++++++-------- ryu/services/protocols/bgp/rtconf/neighbors.py | 8 ++++---- ryu/services/protocols/bgp/rtconf/vrfs.py | 2 +- ryu/services/protocols/bgp/utils/bgp.py | 2 +- ryu/services/protocols/bgp/utils/dictconfig.py | 4 ++-- ryu/services/protocols/bgp/utils/rtfilter.py | 2 +- ryu/tests/switch/tester.py | 6 +++--- ryu/tests/unit/app/test_tester.py | 2 +- ryu/tests/unit/ofproto/test_parser.py | 2 +- ryu/tests/unit/ofproto/test_parser_compat.py | 2 +- ryu/tests/unit/ofproto/test_parser_ofpmatch.py | 4 ++-- ryu/topology/switches.py | 6 +++--- ryu/utils.py | 2 +- 52 files changed, 126 insertions(+), 126 deletions(-) diff --git a/ryu/app/ofctl_rest.py b/ryu/app/ofctl_rest.py index fe0bf24f..e134cb15 100644 --- a/ryu/app/ofctl_rest.py +++ b/ryu/app/ofctl_rest.py @@ -145,7 +145,7 @@ class StatsController(ControllerBase): self.waiters = data['waiters'] def get_dpids(self, req, **_kwargs): - dps = self.dpset.dps.keys() + dps = list(self.dpset.dps.keys()) body = json.dumps(dps) return Response(content_type='application/json', body=body) diff --git a/ryu/app/rest_quantum.py b/ryu/app/rest_quantum.py index 4aeec530..5bf14800 100644 --- a/ryu/app/rest_quantum.py +++ b/ryu/app/rest_quantum.py @@ -57,7 +57,7 @@ class QuantumController(ControllerBase): self.ifaces = data def list_ifaces(self, _req, **_kwargs): - body = json.dumps(self.ifaces.keys()) + body = json.dumps(list(self.ifaces.keys())) return Response(content_type='application/json', body=body) def delete_iface(self, _req, iface_id, **_kwargs): diff --git a/ryu/app/rest_router.py b/ryu/app/rest_router.py index 5cf2e24c..30812a74 100644 --- a/ryu/app/rest_router.py +++ b/ryu/app/rest_router.py @@ -482,7 +482,7 @@ class Router(dict): vlan_routers = [] if vlan_id == REST_ALL: - vlan_routers = self.values() + vlan_routers = list(self.values()) else: vlan_id = int(vlan_id) if (vlan_id != VLANID_NONE and diff --git a/ryu/app/simple_isolation.py b/ryu/app/simple_isolation.py index d308c4a9..40c490ef 100644 --- a/ryu/app/simple_isolation.py +++ b/ryu/app/simple_isolation.py @@ -108,7 +108,7 @@ class SimpleIsolation(app_manager.RyuApp): self.logger.debug("dpid %s in_port %d src %s dst %s ports %s", datapath.id, msg.in_port, haddr_to_str(src), haddr_to_str(dst), - self.nw.dpids.get(datapath.id, {}).items()) + list(self.nw.dpids.get(datapath.id, {}).items())) for port_no in self.nw.filter_ports(datapath.id, msg.in_port, nw_id, NW_ID_EXTERNAL): self.logger.debug("port_no %s", port_no) diff --git a/ryu/base/app_manager.py b/ryu/base/app_manager.py index e45f9c28..b81e59ce 100644 --- a/ryu/base/app_manager.py +++ b/ryu/base/app_manager.py @@ -147,7 +147,7 @@ class RyuApp(object): """ Return iterator over the (key, contxt class) of application context """ - return cls._CONTEXTS.iteritems() + return iter(cls._CONTEXTS.items()) def __init__(self, *_args, **_kwargs): super(RyuApp, self).__init__() @@ -243,7 +243,7 @@ class RyuApp(object): def get_observers(self, ev, state): observers = [] - for k, v in self.observers.get(ev.__class__, {}).iteritems(): + for k, v in self.observers.get(ev.__class__, {}).items(): if not state or not v or state in v: observers.append(k) @@ -428,7 +428,7 @@ class AppManager(object): for _k, m in inspect.getmembers(i, inspect.ismethod): if not hasattr(m, 'callers'): continue - for ev_cls, c in m.callers.iteritems(): + for ev_cls, c in m.callers.items(): if not c.ev_source: continue @@ -438,7 +438,7 @@ class AppManager(object): c.dispatchers) # allow RyuApp and Event class are in different module - for brick in SERVICE_BRICKS.itervalues(): + for brick in SERVICE_BRICKS.values(): if ev_cls in brick._EVENTS: brick.register_observer(ev_cls, i.name, c.dispatchers) diff --git a/ryu/cmd/rpc_cli.py b/ryu/cmd/rpc_cli.py index f71ec943..38c4ee62 100755 --- a/ryu/cmd/rpc_cli.py +++ b/ryu/cmd/rpc_cli.py @@ -182,7 +182,7 @@ class Cmd(cmd.Cmd): self._peek_notification() def _peek_notification(self): - for k, p in peers.iteritems(): + for k, p in peers.items(): if p.client: try: p.client.peek_notification() diff --git a/ryu/cmd/ryu_base.py b/ryu/cmd/ryu_base.py index b153dfce..05b6cd18 100644 --- a/ryu/cmd/ryu_base.py +++ b/ryu/cmd/ryu_base.py @@ -43,7 +43,7 @@ base_conf = cfg.ConfigOpts() base_conf.register_cli_opt(cfg.StrOpt('subcommand', positional=True, required=True, help='[%s]' % '|'.join( - subcommands.keys()))) + list(subcommands.keys())))) base_conf.register_cli_opt(RemainderOpt('subcommand_args', default=[], positional=True, help='subcommand specific arguments')) diff --git a/ryu/controller/conf_switch.py b/ryu/controller/conf_switch.py index 9668b8ef..d714ac3d 100644 --- a/ryu/controller/conf_switch.py +++ b/ryu/controller/conf_switch.py @@ -62,14 +62,14 @@ class ConfSwitchSet(app_manager.RyuApp): self.confs = {} def dpids(self): - return self.confs.keys() + return list(self.confs.keys()) def del_dpid(self, dpid): del self.confs[dpid] self.send_event_to_observers(EventConfSwitchDelDPID(dpid)) def keys(self, dpid): - return self.confs[dpid].keys() + return list(self.confs[dpid].keys()) def set_key(self, dpid, key, value): conf = self.confs.setdefault(dpid, {}) diff --git a/ryu/controller/dpset.py b/ryu/controller/dpset.py index 71aa24db..304658dc 100644 --- a/ryu/controller/dpset.py +++ b/ryu/controller/dpset.py @@ -166,7 +166,7 @@ class DPSet(app_manager.RyuApp): [ (dpid_A, Datapath_A), (dpid_B, Datapath_B), ... ] """ - return self.dps.items() + return list(self.dps.items()) def _port_added(self, datapath, port): self.port_state[datapath.id].add(port.port_no, port) @@ -239,7 +239,7 @@ class DPSet(app_manager.RyuApp): instances for the given Datapath ID. Raises KeyError if no such a datapath connected to this controller. """ - return self.port_state[dpid].values() + return list(self.port_state[dpid].values()) handler.register_service('ryu.controller.dpset') diff --git a/ryu/controller/handler.py b/ryu/controller/handler.py index 66adf52e..b3d40aed 100644 --- a/ryu/controller/handler.py +++ b/ryu/controller/handler.py @@ -82,7 +82,7 @@ def register_instance(i): for _k, m in inspect.getmembers(i, inspect.ismethod): # LOG.debug('instance %s k %s m %s', i, _k, m) if _has_caller(m): - for ev_cls, c in m.callers.iteritems(): + for ev_cls, c in m.callers.items(): i.register_handler(ev_cls, m) @@ -90,7 +90,7 @@ def get_dependent_services(cls): services = [] for _k, m in inspect.getmembers(cls, inspect.ismethod): if _has_caller(m): - for ev_cls, c in m.callers.iteritems(): + for ev_cls, c in m.callers.items(): service = getattr(sys.modules[ev_cls.__module__], '_SERVICE_NAME', None) if service: diff --git a/ryu/controller/network.py b/ryu/controller/network.py index 93fed29e..ac247ffd 100644 --- a/ryu/controller/network.py +++ b/ryu/controller/network.py @@ -62,7 +62,7 @@ class Networks(dict): self.send_event = f def list_networks(self): - return self.keys() + return list(self.keys()) def has_network(self, network_id): return network_id in self @@ -183,7 +183,7 @@ class DPIDs(dict): def get_ports(self, dpid, network_id=None, mac_address=None): if network_id is None: - return self.get(dpid, {}).values() + return list(self.get(dpid, {}).values()) if mac_address is None: return [p for p in self.get(dpid, {}).values() if p.network_id == network_id] diff --git a/ryu/lib/bfdlib.py b/ryu/lib/bfdlib.py index 465ea9ad..c34e6a46 100644 --- a/ryu/lib/bfdlib.py +++ b/ryu/lib/bfdlib.py @@ -426,8 +426,8 @@ class BFDSession(object): # Authentication Section auth_cls = None if self._auth_type: - auth_key_id = self._auth_keys.keys()[ - random.randint(0, len(self._auth_keys.keys()) - 1)] + auth_key_id = list(self._auth_keys.keys())[ + random.randint(0, len(list(self._auth_keys.keys())) - 1)] auth_key = self._auth_keys[auth_key_id] if self._auth_type == bfd.BFD_AUTH_SIMPLE_PASS: diff --git a/ryu/lib/ovs/vsctl.py b/ryu/lib/ovs/vsctl.py index a2e3c422..2714f64e 100644 --- a/ryu/lib/ovs/vsctl.py +++ b/ryu/lib/ovs/vsctl.py @@ -716,7 +716,7 @@ class VSCtlContext(object): else: key = None if value is not None: - LOG.debug("columns %s", table_schema.columns.keys()) + LOG.debug("columns %s", list(table_schema.columns.keys())) type_ = table_schema.columns[column].type value = datum_from_string(type_, value) LOG.debug("column %s value %s", column, value) @@ -752,7 +752,7 @@ class VSCtlContext(object): if not vsctl_row_id.name_column: if record_id != '.': return None - values = self.idl.tables[vsctl_row_id.table].rows.values() + values = list(self.idl.tables[vsctl_row_id.table].rows.values()) if not values or len(values) > 2: return None referrer = values[0] @@ -940,7 +940,7 @@ class VSCtl(object): txn.add_comment('ovs-vsctl') # TODO:XXX add operation name. args ovs_rows = idl_.tables[vswitch_idl.OVSREC_TABLE_OPEN_VSWITCH].rows if ovs_rows: - ovs_ = ovs_rows.values()[0] + ovs_ = list(ovs_rows.values())[0] else: # XXX add verification that table is empty ovs_ = txn.insert( diff --git a/ryu/lib/packet/bgp.py b/ryu/lib/packet/bgp.py index 03147486..3de15676 100644 --- a/ryu/lib/packet/bgp.py +++ b/ryu/lib/packet/bgp.py @@ -218,7 +218,7 @@ class _TypeDisp(object): @classmethod def _rev_lookup_type(cls, targ_cls): if cls._REV_TYPES is None: - rev = dict((v, k) for k, v in cls._TYPES.iteritems()) + rev = dict((v, k) for k, v in cls._TYPES.items()) cls._REV_TYPES = rev return cls._REV_TYPES[targ_cls] diff --git a/ryu/lib/packet/bmp.py b/ryu/lib/packet/bmp.py index eda9c933..06d4fb24 100644 --- a/ryu/lib/packet/bmp.py +++ b/ryu/lib/packet/bmp.py @@ -96,7 +96,7 @@ class _TypeDisp(object): @classmethod def _rev_lookup_type(cls, targ_cls): if cls._REV_TYPES is None: - rev = dict((v, k) for k, v in cls._TYPES.iteritems()) + rev = dict((v, k) for k, v in cls._TYPES.items()) cls._REV_TYPES = rev return cls._REV_TYPES[targ_cls] diff --git a/ryu/lib/packet/ospf.py b/ryu/lib/packet/ospf.py index 1637e2db..99ef6bfc 100644 --- a/ryu/lib/packet/ospf.py +++ b/ryu/lib/packet/ospf.py @@ -119,7 +119,7 @@ class _TypeDisp(object): @classmethod def _rev_lookup_type(cls, targ_cls): if cls._REV_TYPES is None: - rev = dict((v, k) for k, v in cls._TYPES.iteritems()) + rev = dict((v, k) for k, v in cls._TYPES.items()) cls._REV_TYPES = rev return cls._REV_TYPES[targ_cls] diff --git a/ryu/lib/quantum_ifaces.py b/ryu/lib/quantum_ifaces.py index d7a99e14..2dfd8f00 100644 --- a/ryu/lib/quantum_ifaces.py +++ b/ryu/lib/quantum_ifaces.py @@ -61,7 +61,7 @@ class QuantumIfaces(app_manager.RyuApp, dict): return self[iface_id] def list_keys(self, iface_id): - return self[iface_id].keys() + return list(self[iface_id].keys()) def get_key(self, iface_id, key): return self[iface_id][key] diff --git a/ryu/lib/stplib.py b/ryu/lib/stplib.py index 9fbdece0..fd17b2ae 100644 --- a/ryu/lib/stplib.py +++ b/ryu/lib/stplib.py @@ -387,7 +387,7 @@ class Bridge(object): values = self._DEFAULT_VALUE for key, value in bridge_conf.items(): values[key] = value - system_id = dp.ports.values()[0].hw_addr + system_id = list(dp.ports.values())[0].hw_addr self.bridge_id = BridgeId(values['priority'], values['sys_ext_id'], diff --git a/ryu/lib/stringify.py b/ryu/lib/stringify.py index 96a83a6d..816c7a00 100644 --- a/ryu/lib/stringify.py +++ b/ryu/lib/stringify.py @@ -153,7 +153,7 @@ class StringifyMixin(object): assert isinstance(dict_, dict) if len(dict_) != 1: return False - k = dict_.keys()[0] + k = list(dict_.keys())[0] if not isinstance(k, (bytes, unicode)): return False for p in cls._class_prefixes: @@ -167,7 +167,7 @@ class StringifyMixin(object): @classmethod def _get_type(cls, k): if hasattr(cls, '_TYPE'): - for t, attrs in cls._TYPE.iteritems(): + for t, attrs in cls._TYPE.items(): if k in attrs: return _types[t] return None @@ -249,7 +249,7 @@ class StringifyMixin(object): @classmethod def obj_from_jsondict(cls, jsondict, **additional_args): assert len(jsondict) == 1 - for k, v in jsondict.iteritems(): + for k, v in jsondict.items(): obj_cls = cls.cls_from_jsondict_key(k) return obj_cls.from_jsondict(v, **additional_args) diff --git a/ryu/ofproto/ofproto_parser.py b/ryu/ofproto/ofproto_parser.py index 8a1cebbe..7bc92141 100644 --- a/ryu/ofproto/ofproto_parser.py +++ b/ryu/ofproto/ofproto_parser.py @@ -104,7 +104,7 @@ def ofp_msg_from_jsondict(dp, jsondict): """ parser = dp.ofproto_parser assert len(jsondict) == 1 - for k, v in jsondict.iteritems(): + for k, v in jsondict.items(): cls = getattr(parser, k) assert issubclass(cls, MsgBase) return cls.from_jsondict(v, datapath=dp) diff --git a/ryu/ofproto/ofproto_v1_2_parser.py b/ryu/ofproto/ofproto_v1_2_parser.py index 333dfa6a..9c1041d1 100644 --- a/ryu/ofproto/ofproto_v1_2_parser.py +++ b/ryu/ofproto/ofproto_v1_2_parser.py @@ -1479,7 +1479,7 @@ class OFPActionSetField(OFPAction): else: # new api assert len(kwargs) == 1 - key = kwargs.keys()[0] + key = list(kwargs.keys())[0] value = kwargs[key] assert isinstance(key, (str, unicode)) assert not isinstance(value, tuple) # no mask @@ -3396,9 +3396,9 @@ class OFPMatch(StringifyMixin): # OFPMatch(eth_src=('ff:ff:ff:00:00:00'), eth_type=0x800, # ipv4_src='10.0.0.1') kwargs = dict(ofproto.oxm_normalize_user(k, v) for - (k, v) in kwargs.iteritems()) + (k, v) in kwargs.items()) fields = [ofproto.oxm_from_user(k, v) for (k, v) - in kwargs.iteritems()] + in kwargs.items()] # assumption: sorting by OXM type values makes fields # meet ordering requirements (eg. eth_type before ipv4_src) fields.sort() @@ -3412,7 +3412,7 @@ class OFPMatch(StringifyMixin): return key in dict(self._fields2) def iteritems(self): - return dict(self._fields2).iteritems() + return iter(dict(self._fields2).items()) def get(self, key, default=None): return dict(self._fields2).get(key, default) @@ -4037,7 +4037,7 @@ class OFPMatchField(StringifyMixin): @classmethod def cls_to_header(cls, cls_, hasmask): # XXX efficiency - inv = dict((v, k) for k, v in cls._FIELDS_HEADERS.iteritems() + inv = dict((v, k) for k, v in cls._FIELDS_HEADERS.items() if (((k >> 8) & 1) != 0) == hasmask) return inv[cls_] diff --git a/ryu/ofproto/ofproto_v1_3_parser.py b/ryu/ofproto/ofproto_v1_3_parser.py index 827c48a9..52cad96d 100644 --- a/ryu/ofproto/ofproto_v1_3_parser.py +++ b/ryu/ofproto/ofproto_v1_3_parser.py @@ -845,7 +845,7 @@ class OFPMatch(StringifyMixin): return key in dict(self._fields2) def iteritems(self): - return dict(self._fields2).iteritems() + return iter(dict(self._fields2).items()) def get(self, key, default=None): return dict(self._fields2).get(key, default) @@ -1533,7 +1533,7 @@ class OFPMatchField(StringifyMixin): @classmethod def cls_to_header(cls, cls_, hasmask): # XXX efficiency - inv = dict((v, k) for k, v in cls._FIELDS_HEADERS.iteritems() + inv = dict((v, k) for k, v in cls._FIELDS_HEADERS.items() if (((k >> 8) & 1) != 0) == hasmask) return inv[cls_] @@ -3061,7 +3061,7 @@ class OFPActionSetField(OFPAction): else: # new api assert len(kwargs) == 1 - key = kwargs.keys()[0] + key = list(kwargs.keys())[0] value = kwargs[key] assert isinstance(key, (str, unicode)) assert not isinstance(value, tuple) # no mask diff --git a/ryu/ofproto/ofproto_v1_4_parser.py b/ryu/ofproto/ofproto_v1_4_parser.py index 95339d8a..21f80bb9 100644 --- a/ryu/ofproto/ofproto_v1_4_parser.py +++ b/ryu/ofproto/ofproto_v1_4_parser.py @@ -714,9 +714,9 @@ class OFPMatch(StringifyMixin): self._fields2 = _ordered_fields else: kwargs = dict(ofproto.oxm_normalize_user(k, v) for - (k, v) in kwargs.iteritems()) + (k, v) in kwargs.items()) fields = [ofproto.oxm_from_user(k, v) for (k, v) - in kwargs.iteritems()] + in kwargs.items()] # assumption: sorting by OXM type values makes fields # meet ordering requirements (eg. eth_type before ipv4_src) fields.sort() @@ -780,7 +780,7 @@ class OFPMatch(StringifyMixin): return key in dict(self._fields2) def iteritems(self): - return dict(self._fields2).iteritems() + return iter(dict(self._fields2).items()) def get(self, key, default=None): return dict(self._fields2).get(key, default) @@ -1086,7 +1086,7 @@ class OFPMatchField(StringifyMixin): @classmethod def cls_to_header(cls, cls_, hasmask): # XXX efficiency - inv = dict((v, k) for k, v in cls._FIELDS_HEADERS.iteritems() + inv = dict((v, k) for k, v in cls._FIELDS_HEADERS.items() if (((k >> 8) & 1) != 0) == hasmask) return inv[cls_] @@ -5355,7 +5355,7 @@ class OFPActionSetField(OFPAction): def __init__(self, field=None, **kwargs): super(OFPActionSetField, self).__init__() assert len(kwargs) == 1 - key = kwargs.keys()[0] + key = list(kwargs.keys())[0] value = kwargs[key] assert isinstance(key, (str, unicode)) assert not isinstance(value, tuple) # no mask diff --git a/ryu/ofproto/ofproto_v1_5_parser.py b/ryu/ofproto/ofproto_v1_5_parser.py index b791c2b6..b8aaa2a6 100644 --- a/ryu/ofproto/ofproto_v1_5_parser.py +++ b/ryu/ofproto/ofproto_v1_5_parser.py @@ -715,9 +715,9 @@ class OFPMatch(StringifyMixin): self._fields2 = _ordered_fields else: kwargs = dict(ofproto.oxm_normalize_user(k, v) for - (k, v) in kwargs.iteritems()) + (k, v) in kwargs.items()) fields = [ofproto.oxm_from_user(k, v) for (k, v) - in kwargs.iteritems()] + in kwargs.items()] # assumption: sorting by OXM type values makes fields # meet ordering requirements (eg. eth_type before ipv4_src) fields.sort() @@ -781,7 +781,7 @@ class OFPMatch(StringifyMixin): return key in dict(self._fields2) def iteritems(self): - return dict(self._fields2).iteritems() + return iter(dict(self._fields2).items()) def get(self, key, default=None): return dict(self._fields2).get(key, default) @@ -1227,7 +1227,7 @@ class OFPMatchField(StringifyMixin): @classmethod def cls_to_header(cls, cls_, hasmask): # XXX efficiency - inv = dict((v, k) for k, v in cls._FIELDS_HEADERS.iteritems() + inv = dict((v, k) for k, v in cls._FIELDS_HEADERS.items() if (((k >> 8) & 1) != 0) == hasmask) return inv[cls_] @@ -5465,7 +5465,7 @@ class OFPActionSetField(OFPAction): def __init__(self, field=None, **kwargs): super(OFPActionSetField, self).__init__() assert len(kwargs) == 1 - key = kwargs.keys()[0] + key = list(kwargs.keys())[0] value = kwargs[key] assert isinstance(key, (str, unicode)) assert not isinstance(value, tuple) # no mask diff --git a/ryu/services/protocols/bgp/api/base.py b/ryu/services/protocols/bgp/api/base.py index eee243bf..aab5fd8f 100644 --- a/ryu/services/protocols/bgp/api/base.py +++ b/ryu/services/protocols/bgp/api/base.py @@ -181,7 +181,7 @@ class RegisterWithArgChecks(object): # Collect optional arguments. opt_items = {} - for opt_arg, opt_value in kwargs.iteritems(): + for opt_arg, opt_value in kwargs.items(): if opt_arg in self._opt_args: opt_items[opt_arg] = opt_value diff --git a/ryu/services/protocols/bgp/api/rtconf.py b/ryu/services/protocols/bgp/api/rtconf.py index cfadcd44..75a26ec9 100644 --- a/ryu/services/protocols/bgp/api/rtconf.py +++ b/ryu/services/protocols/bgp/api/rtconf.py @@ -72,7 +72,7 @@ def update_neighbor_enabled(neigh_ip_address, enabled): req_args=[neighbors.IP_ADDRESS, neighbors.CHANGES]) def update_neighbor(neigh_ip_address, changes): rets = [] - for k, v in changes.iteritems(): + for k, v in changes.items(): if k == neighbors.MULTI_EXIT_DISC: rets.append(_update_med(neigh_ip_address, v)) diff --git a/ryu/services/protocols/bgp/application.py b/ryu/services/protocols/bgp/application.py index 0eb9da4c..ed2454ff 100644 --- a/ryu/services/protocols/bgp/application.py +++ b/ryu/services/protocols/bgp/application.py @@ -207,7 +207,7 @@ class RyuBGPSpeaker(RyuApp): All valid VRFs are loaded. """ vpns_conf = routing_settings.setdefault('vpns', {}) - for vrfname, vrf in vpns_conf.iteritems(): + for vrfname, vrf in vpns_conf.items(): try: vrf[vrfs.VRF_NAME] = vrfname call('vrf.create', **vrf) diff --git a/ryu/services/protocols/bgp/bmp.py b/ryu/services/protocols/bgp/bmp.py index 8b9c8c87..7d123dc9 100644 --- a/ryu/services/protocols/bgp/bmp.py +++ b/ryu/services/protocols/bgp/bmp.py @@ -160,7 +160,7 @@ class BMPClient(Activity): def _construct_update(self, path): # Get copy of path's path attributes. - new_pathattr = [attr for attr in path.pathattr_map.itervalues()] + new_pathattr = [attr for attr in path.pathattr_map.values()] if path.is_withdraw: if isinstance(path, Ipv4Path): @@ -220,7 +220,7 @@ class BMPClient(Activity): msg = self._construct_peer_up_notification(peer) self._send(msg) - for path in peer._adj_rib_in.itervalues(): + for path in peer._adj_rib_in.values(): msg = self._construct_route_monitoring(peer, path) self._send(msg) diff --git a/ryu/services/protocols/bgp/core.py b/ryu/services/protocols/bgp/core.py index f62509a6..59a37aa2 100644 --- a/ryu/services/protocols/bgp/core.py +++ b/ryu/services/protocols/bgp/core.py @@ -282,7 +282,7 @@ class CoreService(Factory, Activity): - `new_rts`: (set) of new RTs that peer is interested in. - `old_rts`: (set) of RTs that peers is no longer interested in. """ - for table in self._table_manager._global_tables.itervalues(): + for table in self._table_manager._global_tables.values(): if table.route_family == RF_RTC_UC: continue self._spawn('rt_filter_chg_%s' % peer, @@ -313,7 +313,7 @@ class CoreService(Factory, Activity): # Check if we have to use all paths or just best path if self._common_config.max_path_ext_rtfilter_all: # We have to look at all paths for a RtDest - for rtcdest in self._table_manager.get_rtc_table().itervalues(): + for rtcdest in self._table_manager.get_rtc_table().values(): known_path_list = rtcdest.known_path_list for path in known_path_list: neigh = path.source @@ -328,7 +328,7 @@ class CoreService(Factory, Activity): # We iterate over all destination of the RTC table and for iBGP # peers we use all known paths' RTs for RT filter and for eBGP # peers we only consider best-paths' RTs for RT filter - for rtcdest in self._table_manager.get_rtc_table().itervalues(): + for rtcdest in self._table_manager.get_rtc_table().values(): path = rtcdest.best_path # If this destination does not have any path, we continue if not path: diff --git a/ryu/services/protocols/bgp/core_managers/peer_manager.py b/ryu/services/protocols/bgp/core_managers/peer_manager.py index 3e309157..9e8543d7 100644 --- a/ryu/services/protocols/bgp/core_managers/peer_manager.py +++ b/ryu/services/protocols/bgp/core_managers/peer_manager.py @@ -36,7 +36,7 @@ class PeerManager(object): @property def iterpeers(self): - return self._peers.itervalues() + return iter(self._peers.values()) def set_peer_to_rtfilter_map(self, new_map): self._peer_to_rtfilter_map = new_map @@ -69,7 +69,7 @@ class PeerManager(object): def _get_non_rtc_peers(self): non_rtc_peer_list = set() - for peer in self._peers.itervalues(): + for peer in self._peers.values(): if (peer.in_established() and not peer.is_mpbgp_cap_valid(RF_RTC_UC)): non_rtc_peer_list.add(peer) @@ -81,7 +81,7 @@ class PeerManager(object): def get_peers_in_established(self): """Returns list of peers in established state.""" est_peers = [] - for peer in self._peers.itervalues(): + for peer in self._peers.values(): if peer.in_established: est_peers.append(peer) return est_peers @@ -107,7 +107,7 @@ class PeerManager(object): route_family ) - for destination in table.itervalues(): + for destination in table.values(): # Check if this destination's sent - routes include this peer. # i.e. check if this destinations was advertised and enqueue # the path only if it was. If the current best-path has not been @@ -139,7 +139,7 @@ class PeerManager(object): Skips making request to peer that have valid RTC capability. """ assert route_family != RF_RTC_UC - for peer in self._peers.itervalues(): + for peer in self._peers.values(): # First check if peer is in established state if (peer.in_established and # Check if peer has valid capability for given address @@ -199,7 +199,7 @@ class PeerManager(object): peer_rtc_as = neigh_conf.rtc_as # Iterate over all RT_NLRI destination communicate qualifying RT_NLRIs rtc_table = self._table_manager.get_rtc_table() - for dest in rtc_table.itervalues(): + for dest in rtc_table.values(): best_path = dest.best_path # Ignore a destination that currently does not have best path if not best_path: @@ -231,7 +231,7 @@ class PeerManager(object): if route_family == RF_RTC_UC: continue if peer.is_mbgp_cap_valid(route_family): - for dest in table.itervalues(): + for dest in table.values(): if dest.best_path: peer.communicate_path(dest.best_path) @@ -290,7 +290,7 @@ class PeerManager(object): # Peers that have RTC capability and have common RT with the path # also qualify peer_to_rtfilter_map = self._peer_to_rtfilter_map - for peer, rt_filter in peer_to_rtfilter_map.iteritems(): + for peer, rt_filter in peer_to_rtfilter_map.items(): # Ignore Network Controller (its not a BGP peer) if peer is None: continue diff --git a/ryu/services/protocols/bgp/core_managers/table_manager.py b/ryu/services/protocols/bgp/core_managers/table_manager.py index 8de4f535..fafbd2aa 100644 --- a/ryu/services/protocols/bgp/core_managers/table_manager.py +++ b/ryu/services/protocols/bgp/core_managers/table_manager.py @@ -85,7 +85,7 @@ class TableCoreManager(object): # Withdraw the best-path whose source was NC since it may have been # exported to VPN table. - for destination in vrf_table.itervalues(): + for destination in vrf_table.values(): best_path = destination.best_path if best_path and best_path.source is None: vpn_clone = best_path.clone_to_vpn(vrf_conf.route_dist, @@ -294,7 +294,7 @@ class TableCoreManager(object): adds new path with path attributes as per current VRF configuration. """ assert vrf_table - for dest in vrf_table.itervalues(): + for dest in vrf_table.values(): for path in dest.known_path_list: if path.source is None: vrf_table.insert_vrf_path( diff --git a/ryu/services/protocols/bgp/info_base/base.py b/ryu/services/protocols/bgp/info_base/base.py index 1b4189ae..b332b0f3 100644 --- a/ryu/services/protocols/bgp/info_base/base.py +++ b/ryu/services/protocols/bgp/info_base/base.py @@ -81,7 +81,7 @@ class Table(object): raise NotImplementedError() def itervalues(self): - return self._destinations.itervalues() + return iter(self._destinations.values()) def insert(self, path): self._validate_path(path) @@ -124,7 +124,7 @@ class Table(object): version number. Also removes sent paths to this peer. """ LOG.debug('Cleaning paths from table %s for peer %s', self, peer) - for dest in self.itervalues(): + for dest in self.values(): # Remove paths learned from this source paths_deleted = dest.remove_old_paths_from_source(peer) # Remove sent paths to this peer @@ -146,7 +146,7 @@ class Table(object): LOG.debug('Cleaning table %s for given interested RTs %s', self, interested_rts) uninteresting_dest_count = 0 - for dest in self.itervalues(): + for dest in self.values(): added_withdraw = \ dest.withdraw_unintresting_paths(interested_rts) if added_withdraw: @@ -343,7 +343,7 @@ class Destination(object): @property def sent_routes(self): - return self._sent_routes.values() + return list(self._sent_routes.values()) def add_new_path(self, new_path): self._validate_path(new_path) diff --git a/ryu/services/protocols/bgp/info_base/vrf.py b/ryu/services/protocols/bgp/info_base/vrf.py index 57e8259d..fe6c3d65 100644 --- a/ryu/services/protocols/bgp/info_base/vrf.py +++ b/ryu/services/protocols/bgp/info_base/vrf.py @@ -102,7 +102,7 @@ class VrfTable(Table): remote_route_count = 0 local_route_count = 0 - for dest in self.itervalues(): + for dest in self.values(): for path in dest.known_path_list: if (hasattr(path.source, 'version_num') or path.source == VPN_TABLE): @@ -115,7 +115,7 @@ class VrfTable(Table): LOCAL_ROUTES: local_route_count} def import_vpn_paths_from_table(self, vpn_table, import_rts=None): - for vpn_dest in vpn_table.itervalues(): + for vpn_dest in vpn_table.values(): vpn_path = vpn_dest.best_path if not vpn_path: continue @@ -187,7 +187,7 @@ class VrfTable(Table): def apply_import_maps(self): changed_dests = [] - for dest in self.itervalues(): + for dest in self.values(): assert isinstance(dest, VrfDest) for import_map in self._import_maps: for path in dest.known_path_list: diff --git a/ryu/services/protocols/bgp/operator/command.py b/ryu/services/protocols/bgp/operator/command.py index 5afa5b0f..6d271d3e 100644 --- a/ryu/services/protocols/bgp/operator/command.py +++ b/ryu/services/protocols/bgp/operator/command.py @@ -117,7 +117,7 @@ class Command(object): if not isinstance(val, list): val = [val] for line in val: - for k, v in line.iteritems(): + for k, v in line.items(): if isinstance(v, dict): ret += cls.cli_resp_line_template.format( k, '\n' + pprint.pformat(v) @@ -194,7 +194,7 @@ class Command(object): ret.append(self._quick_help()) if len(self.subcommands) > 0: - for k, _ in sorted(self.subcommands.iteritems()): + for k, _ in sorted(self.subcommands.items()): command_path, param_help, cmd_help = \ self._instantiate_subcommand(k)._quick_help(nested=True) if command_path or param_help or cmd_help: @@ -245,7 +245,7 @@ class TextFilter(object): iterator = enumerate(action_resp_value) else: resp = dict(action_resp_value) - iterator = action_resp_value.iteritems() + iterator = iter(action_resp_value.items()) remove = [] @@ -258,7 +258,7 @@ class TextFilter(object): if key not in remove] else: resp = dict([(key, value) - for key, value in resp.iteritems() + for key, value in resp.items() if key not in remove]) return resp diff --git a/ryu/services/protocols/bgp/operator/commands/show/neighbor.py b/ryu/services/protocols/bgp/operator/commands/show/neighbor.py index 4f9199e8..8cd4af45 100644 --- a/ryu/services/protocols/bgp/operator/commands/show/neighbor.py +++ b/ryu/services/protocols/bgp/operator/commands/show/neighbor.py @@ -166,7 +166,7 @@ class Neighbor(Command): [{'ip_addr': k, 'as_num': str(v['remote_as']), 'bgp_state': v['stats']['bgp_state']} - for k, v in ret.iteritems()]) + for k, v in ret.items()]) @classmethod def cli_resp_formatter(cls, resp): diff --git a/ryu/services/protocols/bgp/operator/commands/show/rib.py b/ryu/services/protocols/bgp/operator/commands/show/rib.py index a865a08f..440234ce 100644 --- a/ryu/services/protocols/bgp/operator/commands/show/rib.py +++ b/ryu/services/protocols/bgp/operator/commands/show/rib.py @@ -63,7 +63,7 @@ class Rib(RibBase): if resp.status == STATUS_ERROR: return RibBase.cli_resp_formatter(resp) ret = cls._format_family_header() - for family, data in resp.value.iteritems(): + for family, data in resp.value.items(): ret += 'Family: {0}\n'.format(family) ret += cls._format_family(data) return ret diff --git a/ryu/services/protocols/bgp/operator/commands/show/vrf.py b/ryu/services/protocols/bgp/operator/commands/show/vrf.py index 2938e9fd..b78a7cf5 100644 --- a/ryu/services/protocols/bgp/operator/commands/show/vrf.py +++ b/ryu/services/protocols/bgp/operator/commands/show/vrf.py @@ -70,7 +70,7 @@ class Routes(Command, RouteFormatterMixin): if resp.status == STATUS_ERROR: return Command.cli_resp_formatter(resp) ret = cls._format_family_header() - for family, data in resp.value.iteritems(): + for family, data in resp.value.items(): ret += 'VPN: {0}\n'.format(family) ret += cls._format_family(data) return ret @@ -130,7 +130,7 @@ class Summary(Command, CountRoutesMixin): vrf_confs = self.api.get_vrfs_conf() view = ConfDictView(vrf_confs) encoded = view.encode() - for vrf_key, conf in encoded.iteritems(): + for vrf_key, conf in encoded.items(): vrf_name, vrf_rf = vrf_key conf['routes_count'] = self._count_routes( vrf_name, @@ -138,7 +138,7 @@ class Summary(Command, CountRoutesMixin): ) encoded = dict([(str(k), v) - for k, v in encoded.iteritems()]) + for k, v in encoded.items()]) return CommandsResponse( STATUS_OK, encoded diff --git a/ryu/services/protocols/bgp/operator/internal_api.py b/ryu/services/protocols/bgp/operator/internal_api.py index 524cdd26..70543d21 100644 --- a/ryu/services/protocols/bgp/operator/internal_api.py +++ b/ryu/services/protocols/bgp/operator/internal_api.py @@ -47,7 +47,7 @@ class InternalApi(object): vrf_name = vrf_name.encode('ascii', 'ignore') route_count = \ - len([d for d in vrf.itervalues() if d.best_path]) + len([d for d in vrf.values() if d.best_path]) return {str((vrf_name, vrf_rf)): route_count} def get_vrfs_conf(self): @@ -56,7 +56,7 @@ class InternalApi(object): def get_all_vrf_routes(self): vrfs = self._get_vrf_tables() ret = {} - for (vrf_id, vrf_rf), table in sorted(vrfs.iteritems()): + for (vrf_id, vrf_rf), table in sorted(vrfs.items()): ret[str((vrf_id, vrf_rf))] = self._get_single_vrf_routes(table) return ret @@ -64,10 +64,10 @@ class InternalApi(object): vrf = self._get_vrf_table(vrf_id, vrf_rf) if not vrf: raise WrongParamError('wrong vpn name %s' % str((vrf_id, vrf_rf))) - return [self._dst_to_dict(d) for d in vrf.itervalues()] + return [self._dst_to_dict(d) for d in vrf.values()] def _get_single_vrf_routes(self, vrf_table): - return [self._dst_to_dict(d) for d in vrf_table.itervalues()] + return [self._dst_to_dict(d) for d in vrf_table.values()] def _get_vrf_table(self, vrf_name, vrf_rf): return CORE_MANAGER.get_core_service()\ @@ -92,7 +92,7 @@ class InternalApi(object): gtable = table_manager.get_global_table_by_route_family(rf) if gtable is not None: return [self._dst_to_dict(dst) - for dst in sorted(gtable.itervalues())] + for dst in sorted(gtable.values())] else: return [] diff --git a/ryu/services/protocols/bgp/operator/views/base.py b/ryu/services/protocols/bgp/operator/views/base.py index 2916df61..c25ddfd2 100644 --- a/ryu/services/protocols/bgp/operator/views/base.py +++ b/ryu/services/protocols/bgp/operator/views/base.py @@ -122,7 +122,7 @@ class OperatorDetailView(OperatorAbstractView): def encode(self): return {field_name: field.get(self._obj) - for field_name, field in self._fields.iteritems() + for field_name, field in self._fields.items() if isinstance(field, fields.DataField)} def rel(self, field_name): @@ -153,7 +153,7 @@ class OperatorListView(OperatorAbstractView): def encode(self): return RdyToFlattenList( [{field_name: field.get(obj) - for field_name, field in self._fields.iteritems() + for field_name, field in self._fields.items() if isinstance(field, fields.DataField)} for obj in self.model] ) @@ -175,28 +175,28 @@ class OperatorDictView(OperatorAbstractView): def combine_related(self, field_name): f = self._fields[field_name] return CombinedViewsWrapper(RdyToFlattenList( - map(lambda obj: f.retrieve_and_wrap(obj), self.model.itervalues())) + map(lambda obj: f.retrieve_and_wrap(obj), self.model.values())) ) def get_field(self, field_name): f = self._fields[field_name] return RdyToFlattenDict( - {key: f.get(obj) for key, obj in self.model.iteritems()} + {key: f.get(obj) for key, obj in self.model.items()} ) def encode(self): return RdyToFlattenDict( {key: {field_name: field.get(obj) - for field_name, field in self._fields.iteritems() + for field_name, field in self._fields.items() if isinstance(field, fields.DataField)} - for key, obj in self.model.iteritems()} + for key, obj in self.model.items()} ) @property def model(self): if self._filter_func is not None: new_model = RdyToFlattenDict() - for k, v in self._obj.iteritems(): + for k, v in self._obj.items(): if self._filter_func(k, v): new_model[k] = v return new_model @@ -282,7 +282,7 @@ def create_dict_view_class(detail_view_class, name): if 'encode' in dir(detail_view_class): def encode(self): return RdyToFlattenDict({key: detail_view_class(obj).encode() - for key, obj in self.model.iteritems()}) + for key, obj in self.model.items()}) return _create_collection_view( detail_view_class, name, encode, OperatorDictView diff --git a/ryu/services/protocols/bgp/peer.py b/ryu/services/protocols/bgp/peer.py index 86863ea9..f08ac1e8 100644 --- a/ryu/services/protocols/bgp/peer.py +++ b/ryu/services/protocols/bgp/peer.py @@ -175,7 +175,7 @@ class PeerState(object): def _remember_last_bgp_error(self, identifier, data): self._last_bgp_error = dict([(k, v) - for k, v in data.iteritems() + for k, v in data.items() if k != 'peer']) @property @@ -584,7 +584,7 @@ class Peer(Source, Sink, NeighborConfListener, Activity): def on_update_in_filter(self): LOG.debug('on_update_in_filter fired') - for received_path in self._adj_rib_in.itervalues(): + for received_path in self._adj_rib_in.values(): LOG.debug('received_path: %s', received_path) path = received_path.path nlri_str = path.nlri.formatted_nlri_str @@ -606,7 +606,7 @@ class Peer(Source, Sink, NeighborConfListener, Activity): def on_update_out_filter(self): LOG.debug('on_update_out_filter fired') - for sent_path in self._adj_rib_out.itervalues(): + for sent_path in self._adj_rib_out.values(): LOG.debug('sent_path: %s', sent_path) path = sent_path.path nlri_str = path.nlri.formatted_nlri_str @@ -631,7 +631,7 @@ class Peer(Source, Sink, NeighborConfListener, Activity): def on_update_attribute_maps(self): # resend sent_route in case of filter matching LOG.debug('on_update_attribute_maps fired') - for sent_path in self._adj_rib_out.itervalues(): + for sent_path in self._adj_rib_out.values(): LOG.debug('resend path: %s', sent_path) path = sent_path.path self.enque_outgoing_msg(OutgoingRoute(path)) @@ -837,7 +837,7 @@ class Peer(Source, Sink, NeighborConfListener, Activity): new_pathattr.append(mpunreach_attr) elif self.is_route_server_client: nlri_list = [path.nlri] - for pathattr in path.pathattr_map.itervalues(): + for pathattr in path.pathattr_map.values(): new_pathattr.append(pathattr) else: # Supported and un-supported/unknown attributes. @@ -1204,7 +1204,7 @@ class Peer(Source, Sink, NeighborConfListener, Activity): else: yield L opts = list(flatten( - self._neigh_conf.get_configured_capabilites().values())) + list(self._neigh_conf.get_configured_capabilites().values()))) open_msg = BGPOpen( my_as=asnum, bgp_identifier=bgpid, @@ -1844,11 +1844,11 @@ class Peer(Source, Sink, NeighborConfListener, Activity): LOG.debug('Communicating current best path for all afi/safi except' ' 1/132') # We will enqueue best path from all global destination. - for route_family, table in global_tables.iteritems(): + for route_family, table in global_tables.items(): if route_family == RF_RTC_UC: continue if self.is_mbgp_cap_valid(route_family): - for dest in table.itervalues(): + for dest in table.values(): if dest.best_path: self.communicate_path(dest.best_path) diff --git a/ryu/services/protocols/bgp/rtconf/neighbors.py b/ryu/services/protocols/bgp/rtconf/neighbors.py index 2e10c81f..5efe383c 100644 --- a/ryu/services/protocols/bgp/rtconf/neighbors.py +++ b/ryu/services/protocols/bgp/rtconf/neighbors.py @@ -121,7 +121,7 @@ def validate_enabled(enabled): @validate(name=CHANGES) def validate_changes(changes): - for k, v in changes.iteritems(): + for k, v in changes.items(): if k not in (MULTI_EXIT_DISC, ENABLED, CONNECT_MODE): raise ConfigValueError(desc="Unknown field to change: %s" % k) @@ -219,7 +219,7 @@ def valid_filter(filter_): raise ConfigTypeError(desc='Invalid filter type: %s, supported filter' ' types are %s' % (filter_['type'], - SUPPORTED_FILTER_VALIDATORS.keys())) + list(SUPPORTED_FILTER_VALIDATORS.keys()))) return SUPPORTED_FILTER_VALIDATORS[filter_['type']](filter_) @@ -627,7 +627,7 @@ class NeighborsConf(BaseConf): """Returns current RTC AS configured for current neighbors. """ rtc_as_set = set() - for neigh in self._neighbors.itervalues(): + for neigh in self._neighbors.values(): rtc_as_set.add(neigh.rtc_as) return rtc_as_set @@ -670,7 +670,7 @@ class NeighborsConf(BaseConf): @property def settings(self): return [neighbor.settings for _, neighbor in - self._neighbors.iteritems()] + self._neighbors.items()] class NeighborConfListener(ConfWithIdListener, ConfWithStatsListener): diff --git a/ryu/services/protocols/bgp/rtconf/vrfs.py b/ryu/services/protocols/bgp/rtconf/vrfs.py index 9cbfe998..ea9c695c 100644 --- a/ryu/services/protocols/bgp/rtconf/vrfs.py +++ b/ryu/services/protocols/bgp/rtconf/vrfs.py @@ -404,7 +404,7 @@ class VrfsConf(BaseConf): def vrf_confs(self): """Returns a list of configured `VrfConf`s """ - return self._vrfs_by_rd_rf.values() + return list(self._vrfs_by_rd_rf.values()) @property def vrf_interested_rts(self): diff --git a/ryu/services/protocols/bgp/utils/bgp.py b/ryu/services/protocols/bgp/utils/bgp.py index ab254d97..3ba87f94 100644 --- a/ryu/services/protocols/bgp/utils/bgp.py +++ b/ryu/services/protocols/bgp/utils/bgp.py @@ -110,7 +110,7 @@ def get_unknow_opttrans_attr(path): """ path_attrs = path.pathattr_map unknown_opt_tran_attrs = {} - for _, attr in path_attrs.iteritems(): + for _, attr in path_attrs.items(): if (isinstance(attr, BGPPathAttributeUnknown) and attr.is_optional_transitive()): unknown_opt_tran_attrs[attr.type_code] = attr diff --git a/ryu/services/protocols/bgp/utils/dictconfig.py b/ryu/services/protocols/bgp/utils/dictconfig.py index 9eb4cd22..d3a5650a 100644 --- a/ryu/services/protocols/bgp/utils/dictconfig.py +++ b/ryu/services/protocols/bgp/utils/dictconfig.py @@ -257,7 +257,7 @@ class BaseConfigurator(object): kwargs = dict([(k, config[k]) for k in config if valid_ident(k)]) result = c(**kwargs) if props: - for name, value in props.items(): + for name, value in list(props.items()): setattr(result, name, value) return result @@ -366,7 +366,7 @@ class DictConfigurator(BaseConfigurator): # which were in the previous configuration but # which are not in the new configuration. root = logging.root - existing = root.manager.loggerDict.keys() + existing = list(root.manager.loggerDict.keys()) # The list needs to be sorted so that we can # avoid disabling child loggers of explicitly # named loggers. With a sorted list it is easier diff --git a/ryu/services/protocols/bgp/utils/rtfilter.py b/ryu/services/protocols/bgp/utils/rtfilter.py index b0173909..10e2b38d 100644 --- a/ryu/services/protocols/bgp/utils/rtfilter.py +++ b/ryu/services/protocols/bgp/utils/rtfilter.py @@ -140,7 +140,7 @@ class RouteTargetManager(object): def on_rt_filter_chg_sync_peer(self, peer, new_rts, old_rts, table): LOG.debug('RT Filter changed for peer %s, new_rts %s, old_rts %s ', peer, new_rts, old_rts) - for dest in table.itervalues(): + for dest in table.values(): # If this destination does not have best path, we ignore it if not dest.best_path: continue diff --git a/ryu/tests/switch/tester.py b/ryu/tests/switch/tester.py index 2c966242..885f29f4 100644 --- a/ryu/tests/switch/tester.py +++ b/ryu/tests/switch/tester.py @@ -30,7 +30,7 @@ from ryu import cfg # import all packet libraries. PKT_LIB_PATH = 'ryu.lib.packet' -for modname, moddef in sys.modules.iteritems(): +for modname, moddef in sys.modules.items(): if not modname.startswith(PKT_LIB_PATH) or not moddef: continue for (clsname, clsdef, ) in inspect.getmembers(moddef): @@ -882,7 +882,7 @@ class OfTester(app_manager.RyuApp): 'ipv6_flabel': 20, 'ipv6_exthdr': 9} match_fields = list() - for key, united_value in match.iteritems(): + for key, united_value in match.items(): if isinstance(united_value, tuple): (value, mask) = united_value # look up oxm_fields.TypeDescr to get mask length. @@ -1308,7 +1308,7 @@ class TestFile(stringify.StringifyMixin): if v[k] == port_name: v[k] = CONF['test-switch'][port_name] if isinstance(val, dict): - for k, v in val.iteritems(): + for k, v in val.items(): if k == "OFPActionOutput": if 'port' in v: __replace_port_name("port", v) diff --git a/ryu/tests/unit/app/test_tester.py b/ryu/tests/unit/app/test_tester.py index 1248fa7a..3bba9867 100644 --- a/ryu/tests/unit/app/test_tester.py +++ b/ryu/tests/unit/app/test_tester.py @@ -35,7 +35,7 @@ from ryu import cfg # import all packet libraries. PKT_LIB_PATH = 'ryu.lib.packet' -for modname, moddef in sys.modules.iteritems(): +for modname, moddef in sys.modules.items(): if not modname.startswith(PKT_LIB_PATH) or not moddef: continue for (clsname, clsdef, ) in inspect.getmembers(moddef): diff --git a/ryu/tests/unit/ofproto/test_parser.py b/ryu/tests/unit/ofproto/test_parser.py index 5d5d1ea8..8ff2f5a6 100644 --- a/ryu/tests/unit/ofproto/test_parser.py +++ b/ryu/tests/unit/ofproto/test_parser.py @@ -206,7 +206,7 @@ class Test_Parser(unittest.TestCase): return map(f, d) if isinstance(d, dict): d2 = {} - for k, v in d.iteritems(): + for k, v in d.items(): if k in names: continue d2[k] = f(v) diff --git a/ryu/tests/unit/ofproto/test_parser_compat.py b/ryu/tests/unit/ofproto/test_parser_compat.py index cacae58b..4e7236b0 100644 --- a/ryu/tests/unit/ofproto/test_parser_compat.py +++ b/ryu/tests/unit/ofproto/test_parser_compat.py @@ -131,7 +131,7 @@ class Test_Parser_Compat(unittest.TestCase): # a parsed object can be inspected by old and new api check(ofpp.OFPMatch.parser(buffer(new_buf), 0)) - check(ofpp.OFPMatch.from_jsondict(new_jsondict.values()[0])) + check(ofpp.OFPMatch.from_jsondict(list(new_jsondict.values())[0])) def _add_tests(): diff --git a/ryu/tests/unit/ofproto/test_parser_ofpmatch.py b/ryu/tests/unit/ofproto/test_parser_ofpmatch.py index 86da2895..80590779 100644 --- a/ryu/tests/unit/ofproto/test_parser_ofpmatch.py +++ b/ryu/tests/unit/ofproto/test_parser_ofpmatch.py @@ -51,12 +51,12 @@ class Test_Parser_OFPMatch(unittest.TestCase): if domask: d = dict(self._ofp[ofpp].oxm_normalize_user(k, uv) for (k, uv) - in d.iteritems()) + in d.items()) match = ofpp.OFPMatch(**d) b = bytearray() match.serialize(b, 0) match2 = match.parser(buffer(b), 0) - for k, v in d.iteritems(): + for k, v in d.items(): ok_(k in match) ok_(k in match2) eq_(match[k], v) diff --git a/ryu/topology/switches.py b/ryu/topology/switches.py index 63335f2a..cbb26594 100644 --- a/ryu/topology/switches.py +++ b/ryu/topology/switches.py @@ -288,7 +288,7 @@ class PortDataState(dict): curr = curr[self._NEXT] def clear(self): - for node in self._map.itervalues(): + for node in self._map.values(): del node[:] root = self._root root[:] = [root, root, None] @@ -486,7 +486,7 @@ class Switches(app_manager.RyuApp): def _get_switch(self, dpid): if dpid in self.dps: switch = Switch(self.dps[dpid]) - for ofpport in self.port_state[dpid].itervalues(): + for ofpport in self.port_state[dpid].values(): switch.add_port(ofpport) return switch @@ -843,7 +843,7 @@ class Switches(app_manager.RyuApp): switches = [] if dpid is None: # reply all list - for dp in self.dps.itervalues(): + for dp in self.dps.values(): switches.append(self._get_switch(dp.id)) elif dpid in self.dps: switches.append(self._get_switch(dpid)) diff --git a/ryu/utils.py b/ryu/utils.py index ee004b80..76ea189f 100644 --- a/ryu/utils.py +++ b/ryu/utils.py @@ -65,7 +65,7 @@ def _likely_same(a, b): def _find_loaded_module(modpath): # copy() to avoid RuntimeError: dictionary changed size during iteration - for k, m in sys.modules.copy().iteritems(): + for k, m in sys.modules.copy().items(): if k == '__main__': continue if not hasattr(m, '__file__'):