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 <iwamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
IWAMOTO Toshihiro 2015-06-20 00:10:26 +09:00 committed by FUJITA Tomonori
parent c3c2112cb1
commit c0590ea903
52 changed files with 126 additions and 126 deletions

View File

@ -145,7 +145,7 @@ class StatsController(ControllerBase):
self.waiters = data['waiters'] self.waiters = data['waiters']
def get_dpids(self, req, **_kwargs): def get_dpids(self, req, **_kwargs):
dps = self.dpset.dps.keys() dps = list(self.dpset.dps.keys())
body = json.dumps(dps) body = json.dumps(dps)
return Response(content_type='application/json', body=body) return Response(content_type='application/json', body=body)

View File

@ -57,7 +57,7 @@ class QuantumController(ControllerBase):
self.ifaces = data self.ifaces = data
def list_ifaces(self, _req, **_kwargs): 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) return Response(content_type='application/json', body=body)
def delete_iface(self, _req, iface_id, **_kwargs): def delete_iface(self, _req, iface_id, **_kwargs):

View File

@ -482,7 +482,7 @@ class Router(dict):
vlan_routers = [] vlan_routers = []
if vlan_id == REST_ALL: if vlan_id == REST_ALL:
vlan_routers = self.values() vlan_routers = list(self.values())
else: else:
vlan_id = int(vlan_id) vlan_id = int(vlan_id)
if (vlan_id != VLANID_NONE and if (vlan_id != VLANID_NONE and

View File

@ -108,7 +108,7 @@ class SimpleIsolation(app_manager.RyuApp):
self.logger.debug("dpid %s in_port %d src %s dst %s ports %s", self.logger.debug("dpid %s in_port %d src %s dst %s ports %s",
datapath.id, msg.in_port, datapath.id, msg.in_port,
haddr_to_str(src), haddr_to_str(dst), 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, for port_no in self.nw.filter_ports(datapath.id, msg.in_port,
nw_id, NW_ID_EXTERNAL): nw_id, NW_ID_EXTERNAL):
self.logger.debug("port_no %s", port_no) self.logger.debug("port_no %s", port_no)

View File

@ -147,7 +147,7 @@ class RyuApp(object):
""" """
Return iterator over the (key, contxt class) of application context Return iterator over the (key, contxt class) of application context
""" """
return cls._CONTEXTS.iteritems() return iter(cls._CONTEXTS.items())
def __init__(self, *_args, **_kwargs): def __init__(self, *_args, **_kwargs):
super(RyuApp, self).__init__() super(RyuApp, self).__init__()
@ -243,7 +243,7 @@ class RyuApp(object):
def get_observers(self, ev, state): def get_observers(self, ev, state):
observers = [] 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: if not state or not v or state in v:
observers.append(k) observers.append(k)
@ -428,7 +428,7 @@ class AppManager(object):
for _k, m in inspect.getmembers(i, inspect.ismethod): for _k, m in inspect.getmembers(i, inspect.ismethod):
if not hasattr(m, 'callers'): if not hasattr(m, 'callers'):
continue continue
for ev_cls, c in m.callers.iteritems(): for ev_cls, c in m.callers.items():
if not c.ev_source: if not c.ev_source:
continue continue
@ -438,7 +438,7 @@ class AppManager(object):
c.dispatchers) c.dispatchers)
# allow RyuApp and Event class are in different module # 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: if ev_cls in brick._EVENTS:
brick.register_observer(ev_cls, i.name, brick.register_observer(ev_cls, i.name,
c.dispatchers) c.dispatchers)

View File

@ -182,7 +182,7 @@ class Cmd(cmd.Cmd):
self._peek_notification() self._peek_notification()
def _peek_notification(self): def _peek_notification(self):
for k, p in peers.iteritems(): for k, p in peers.items():
if p.client: if p.client:
try: try:
p.client.peek_notification() p.client.peek_notification()

View File

@ -43,7 +43,7 @@ base_conf = cfg.ConfigOpts()
base_conf.register_cli_opt(cfg.StrOpt('subcommand', positional=True, base_conf.register_cli_opt(cfg.StrOpt('subcommand', positional=True,
required=True, required=True,
help='[%s]' % '|'.join( help='[%s]' % '|'.join(
subcommands.keys()))) list(subcommands.keys()))))
base_conf.register_cli_opt(RemainderOpt('subcommand_args', default=[], base_conf.register_cli_opt(RemainderOpt('subcommand_args', default=[],
positional=True, positional=True,
help='subcommand specific arguments')) help='subcommand specific arguments'))

View File

@ -62,14 +62,14 @@ class ConfSwitchSet(app_manager.RyuApp):
self.confs = {} self.confs = {}
def dpids(self): def dpids(self):
return self.confs.keys() return list(self.confs.keys())
def del_dpid(self, dpid): def del_dpid(self, dpid):
del self.confs[dpid] del self.confs[dpid]
self.send_event_to_observers(EventConfSwitchDelDPID(dpid)) self.send_event_to_observers(EventConfSwitchDelDPID(dpid))
def keys(self, dpid): def keys(self, dpid):
return self.confs[dpid].keys() return list(self.confs[dpid].keys())
def set_key(self, dpid, key, value): def set_key(self, dpid, key, value):
conf = self.confs.setdefault(dpid, {}) conf = self.confs.setdefault(dpid, {})

View File

@ -166,7 +166,7 @@ class DPSet(app_manager.RyuApp):
[ (dpid_A, Datapath_A), (dpid_B, Datapath_B), ... ] [ (dpid_A, Datapath_A), (dpid_B, Datapath_B), ... ]
""" """
return self.dps.items() return list(self.dps.items())
def _port_added(self, datapath, port): def _port_added(self, datapath, port):
self.port_state[datapath.id].add(port.port_no, 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. instances for the given Datapath ID.
Raises KeyError if no such a datapath connected to this controller. 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') handler.register_service('ryu.controller.dpset')

View File

@ -82,7 +82,7 @@ def register_instance(i):
for _k, m in inspect.getmembers(i, inspect.ismethod): for _k, m in inspect.getmembers(i, inspect.ismethod):
# LOG.debug('instance %s k %s m %s', i, _k, m) # LOG.debug('instance %s k %s m %s', i, _k, m)
if _has_caller(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) i.register_handler(ev_cls, m)
@ -90,7 +90,7 @@ def get_dependent_services(cls):
services = [] services = []
for _k, m in inspect.getmembers(cls, inspect.ismethod): for _k, m in inspect.getmembers(cls, inspect.ismethod):
if _has_caller(m): 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 = getattr(sys.modules[ev_cls.__module__],
'_SERVICE_NAME', None) '_SERVICE_NAME', None)
if service: if service:

View File

@ -62,7 +62,7 @@ class Networks(dict):
self.send_event = f self.send_event = f
def list_networks(self): def list_networks(self):
return self.keys() return list(self.keys())
def has_network(self, network_id): def has_network(self, network_id):
return network_id in self return network_id in self
@ -183,7 +183,7 @@ class DPIDs(dict):
def get_ports(self, dpid, network_id=None, mac_address=None): def get_ports(self, dpid, network_id=None, mac_address=None):
if network_id is None: if network_id is None:
return self.get(dpid, {}).values() return list(self.get(dpid, {}).values())
if mac_address is None: if mac_address is None:
return [p for p in self.get(dpid, {}).values() return [p for p in self.get(dpid, {}).values()
if p.network_id == network_id] if p.network_id == network_id]

View File

@ -426,8 +426,8 @@ class BFDSession(object):
# Authentication Section # Authentication Section
auth_cls = None auth_cls = None
if self._auth_type: if self._auth_type:
auth_key_id = self._auth_keys.keys()[ auth_key_id = list(self._auth_keys.keys())[
random.randint(0, len(self._auth_keys.keys()) - 1)] random.randint(0, len(list(self._auth_keys.keys())) - 1)]
auth_key = self._auth_keys[auth_key_id] auth_key = self._auth_keys[auth_key_id]
if self._auth_type == bfd.BFD_AUTH_SIMPLE_PASS: if self._auth_type == bfd.BFD_AUTH_SIMPLE_PASS:

View File

@ -716,7 +716,7 @@ class VSCtlContext(object):
else: else:
key = None key = None
if value is not 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 type_ = table_schema.columns[column].type
value = datum_from_string(type_, value) value = datum_from_string(type_, value)
LOG.debug("column %s value %s", column, value) LOG.debug("column %s value %s", column, value)
@ -752,7 +752,7 @@ class VSCtlContext(object):
if not vsctl_row_id.name_column: if not vsctl_row_id.name_column:
if record_id != '.': if record_id != '.':
return None 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: if not values or len(values) > 2:
return None return None
referrer = values[0] referrer = values[0]
@ -940,7 +940,7 @@ class VSCtl(object):
txn.add_comment('ovs-vsctl') # TODO:XXX add operation name. args txn.add_comment('ovs-vsctl') # TODO:XXX add operation name. args
ovs_rows = idl_.tables[vswitch_idl.OVSREC_TABLE_OPEN_VSWITCH].rows ovs_rows = idl_.tables[vswitch_idl.OVSREC_TABLE_OPEN_VSWITCH].rows
if ovs_rows: if ovs_rows:
ovs_ = ovs_rows.values()[0] ovs_ = list(ovs_rows.values())[0]
else: else:
# XXX add verification that table is empty # XXX add verification that table is empty
ovs_ = txn.insert( ovs_ = txn.insert(

View File

@ -218,7 +218,7 @@ class _TypeDisp(object):
@classmethod @classmethod
def _rev_lookup_type(cls, targ_cls): def _rev_lookup_type(cls, targ_cls):
if cls._REV_TYPES is None: 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 cls._REV_TYPES = rev
return cls._REV_TYPES[targ_cls] return cls._REV_TYPES[targ_cls]

View File

@ -96,7 +96,7 @@ class _TypeDisp(object):
@classmethod @classmethod
def _rev_lookup_type(cls, targ_cls): def _rev_lookup_type(cls, targ_cls):
if cls._REV_TYPES is None: 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 cls._REV_TYPES = rev
return cls._REV_TYPES[targ_cls] return cls._REV_TYPES[targ_cls]

View File

@ -119,7 +119,7 @@ class _TypeDisp(object):
@classmethod @classmethod
def _rev_lookup_type(cls, targ_cls): def _rev_lookup_type(cls, targ_cls):
if cls._REV_TYPES is None: 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 cls._REV_TYPES = rev
return cls._REV_TYPES[targ_cls] return cls._REV_TYPES[targ_cls]

View File

@ -61,7 +61,7 @@ class QuantumIfaces(app_manager.RyuApp, dict):
return self[iface_id] return self[iface_id]
def list_keys(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): def get_key(self, iface_id, key):
return self[iface_id][key] return self[iface_id][key]

View File

@ -387,7 +387,7 @@ class Bridge(object):
values = self._DEFAULT_VALUE values = self._DEFAULT_VALUE
for key, value in bridge_conf.items(): for key, value in bridge_conf.items():
values[key] = value 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'], self.bridge_id = BridgeId(values['priority'],
values['sys_ext_id'], values['sys_ext_id'],

View File

@ -153,7 +153,7 @@ class StringifyMixin(object):
assert isinstance(dict_, dict) assert isinstance(dict_, dict)
if len(dict_) != 1: if len(dict_) != 1:
return False return False
k = dict_.keys()[0] k = list(dict_.keys())[0]
if not isinstance(k, (bytes, unicode)): if not isinstance(k, (bytes, unicode)):
return False return False
for p in cls._class_prefixes: for p in cls._class_prefixes:
@ -167,7 +167,7 @@ class StringifyMixin(object):
@classmethod @classmethod
def _get_type(cls, k): def _get_type(cls, k):
if hasattr(cls, '_TYPE'): if hasattr(cls, '_TYPE'):
for t, attrs in cls._TYPE.iteritems(): for t, attrs in cls._TYPE.items():
if k in attrs: if k in attrs:
return _types[t] return _types[t]
return None return None
@ -249,7 +249,7 @@ class StringifyMixin(object):
@classmethod @classmethod
def obj_from_jsondict(cls, jsondict, **additional_args): def obj_from_jsondict(cls, jsondict, **additional_args):
assert len(jsondict) == 1 assert len(jsondict) == 1
for k, v in jsondict.iteritems(): for k, v in jsondict.items():
obj_cls = cls.cls_from_jsondict_key(k) obj_cls = cls.cls_from_jsondict_key(k)
return obj_cls.from_jsondict(v, **additional_args) return obj_cls.from_jsondict(v, **additional_args)

View File

@ -104,7 +104,7 @@ def ofp_msg_from_jsondict(dp, jsondict):
""" """
parser = dp.ofproto_parser parser = dp.ofproto_parser
assert len(jsondict) == 1 assert len(jsondict) == 1
for k, v in jsondict.iteritems(): for k, v in jsondict.items():
cls = getattr(parser, k) cls = getattr(parser, k)
assert issubclass(cls, MsgBase) assert issubclass(cls, MsgBase)
return cls.from_jsondict(v, datapath=dp) return cls.from_jsondict(v, datapath=dp)

View File

@ -1479,7 +1479,7 @@ class OFPActionSetField(OFPAction):
else: else:
# new api # new api
assert len(kwargs) == 1 assert len(kwargs) == 1
key = kwargs.keys()[0] key = list(kwargs.keys())[0]
value = kwargs[key] value = kwargs[key]
assert isinstance(key, (str, unicode)) assert isinstance(key, (str, unicode))
assert not isinstance(value, tuple) # no mask 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, # OFPMatch(eth_src=('ff:ff:ff:00:00:00'), eth_type=0x800,
# ipv4_src='10.0.0.1') # ipv4_src='10.0.0.1')
kwargs = dict(ofproto.oxm_normalize_user(k, v) for 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) fields = [ofproto.oxm_from_user(k, v) for (k, v)
in kwargs.iteritems()] in kwargs.items()]
# assumption: sorting by OXM type values makes fields # assumption: sorting by OXM type values makes fields
# meet ordering requirements (eg. eth_type before ipv4_src) # meet ordering requirements (eg. eth_type before ipv4_src)
fields.sort() fields.sort()
@ -3412,7 +3412,7 @@ class OFPMatch(StringifyMixin):
return key in dict(self._fields2) return key in dict(self._fields2)
def iteritems(self): def iteritems(self):
return dict(self._fields2).iteritems() return iter(dict(self._fields2).items())
def get(self, key, default=None): def get(self, key, default=None):
return dict(self._fields2).get(key, default) return dict(self._fields2).get(key, default)
@ -4037,7 +4037,7 @@ class OFPMatchField(StringifyMixin):
@classmethod @classmethod
def cls_to_header(cls, cls_, hasmask): def cls_to_header(cls, cls_, hasmask):
# XXX efficiency # 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) if (((k >> 8) & 1) != 0) == hasmask)
return inv[cls_] return inv[cls_]

View File

@ -845,7 +845,7 @@ class OFPMatch(StringifyMixin):
return key in dict(self._fields2) return key in dict(self._fields2)
def iteritems(self): def iteritems(self):
return dict(self._fields2).iteritems() return iter(dict(self._fields2).items())
def get(self, key, default=None): def get(self, key, default=None):
return dict(self._fields2).get(key, default) return dict(self._fields2).get(key, default)
@ -1533,7 +1533,7 @@ class OFPMatchField(StringifyMixin):
@classmethod @classmethod
def cls_to_header(cls, cls_, hasmask): def cls_to_header(cls, cls_, hasmask):
# XXX efficiency # 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) if (((k >> 8) & 1) != 0) == hasmask)
return inv[cls_] return inv[cls_]
@ -3061,7 +3061,7 @@ class OFPActionSetField(OFPAction):
else: else:
# new api # new api
assert len(kwargs) == 1 assert len(kwargs) == 1
key = kwargs.keys()[0] key = list(kwargs.keys())[0]
value = kwargs[key] value = kwargs[key]
assert isinstance(key, (str, unicode)) assert isinstance(key, (str, unicode))
assert not isinstance(value, tuple) # no mask assert not isinstance(value, tuple) # no mask

View File

@ -714,9 +714,9 @@ class OFPMatch(StringifyMixin):
self._fields2 = _ordered_fields self._fields2 = _ordered_fields
else: else:
kwargs = dict(ofproto.oxm_normalize_user(k, v) for 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) fields = [ofproto.oxm_from_user(k, v) for (k, v)
in kwargs.iteritems()] in kwargs.items()]
# assumption: sorting by OXM type values makes fields # assumption: sorting by OXM type values makes fields
# meet ordering requirements (eg. eth_type before ipv4_src) # meet ordering requirements (eg. eth_type before ipv4_src)
fields.sort() fields.sort()
@ -780,7 +780,7 @@ class OFPMatch(StringifyMixin):
return key in dict(self._fields2) return key in dict(self._fields2)
def iteritems(self): def iteritems(self):
return dict(self._fields2).iteritems() return iter(dict(self._fields2).items())
def get(self, key, default=None): def get(self, key, default=None):
return dict(self._fields2).get(key, default) return dict(self._fields2).get(key, default)
@ -1086,7 +1086,7 @@ class OFPMatchField(StringifyMixin):
@classmethod @classmethod
def cls_to_header(cls, cls_, hasmask): def cls_to_header(cls, cls_, hasmask):
# XXX efficiency # 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) if (((k >> 8) & 1) != 0) == hasmask)
return inv[cls_] return inv[cls_]
@ -5355,7 +5355,7 @@ class OFPActionSetField(OFPAction):
def __init__(self, field=None, **kwargs): def __init__(self, field=None, **kwargs):
super(OFPActionSetField, self).__init__() super(OFPActionSetField, self).__init__()
assert len(kwargs) == 1 assert len(kwargs) == 1
key = kwargs.keys()[0] key = list(kwargs.keys())[0]
value = kwargs[key] value = kwargs[key]
assert isinstance(key, (str, unicode)) assert isinstance(key, (str, unicode))
assert not isinstance(value, tuple) # no mask assert not isinstance(value, tuple) # no mask

View File

@ -715,9 +715,9 @@ class OFPMatch(StringifyMixin):
self._fields2 = _ordered_fields self._fields2 = _ordered_fields
else: else:
kwargs = dict(ofproto.oxm_normalize_user(k, v) for 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) fields = [ofproto.oxm_from_user(k, v) for (k, v)
in kwargs.iteritems()] in kwargs.items()]
# assumption: sorting by OXM type values makes fields # assumption: sorting by OXM type values makes fields
# meet ordering requirements (eg. eth_type before ipv4_src) # meet ordering requirements (eg. eth_type before ipv4_src)
fields.sort() fields.sort()
@ -781,7 +781,7 @@ class OFPMatch(StringifyMixin):
return key in dict(self._fields2) return key in dict(self._fields2)
def iteritems(self): def iteritems(self):
return dict(self._fields2).iteritems() return iter(dict(self._fields2).items())
def get(self, key, default=None): def get(self, key, default=None):
return dict(self._fields2).get(key, default) return dict(self._fields2).get(key, default)
@ -1227,7 +1227,7 @@ class OFPMatchField(StringifyMixin):
@classmethod @classmethod
def cls_to_header(cls, cls_, hasmask): def cls_to_header(cls, cls_, hasmask):
# XXX efficiency # 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) if (((k >> 8) & 1) != 0) == hasmask)
return inv[cls_] return inv[cls_]
@ -5465,7 +5465,7 @@ class OFPActionSetField(OFPAction):
def __init__(self, field=None, **kwargs): def __init__(self, field=None, **kwargs):
super(OFPActionSetField, self).__init__() super(OFPActionSetField, self).__init__()
assert len(kwargs) == 1 assert len(kwargs) == 1
key = kwargs.keys()[0] key = list(kwargs.keys())[0]
value = kwargs[key] value = kwargs[key]
assert isinstance(key, (str, unicode)) assert isinstance(key, (str, unicode))
assert not isinstance(value, tuple) # no mask assert not isinstance(value, tuple) # no mask

View File

@ -181,7 +181,7 @@ class RegisterWithArgChecks(object):
# Collect optional arguments. # Collect optional arguments.
opt_items = {} 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: if opt_arg in self._opt_args:
opt_items[opt_arg] = opt_value opt_items[opt_arg] = opt_value

View File

@ -72,7 +72,7 @@ def update_neighbor_enabled(neigh_ip_address, enabled):
req_args=[neighbors.IP_ADDRESS, neighbors.CHANGES]) req_args=[neighbors.IP_ADDRESS, neighbors.CHANGES])
def update_neighbor(neigh_ip_address, changes): def update_neighbor(neigh_ip_address, changes):
rets = [] rets = []
for k, v in changes.iteritems(): for k, v in changes.items():
if k == neighbors.MULTI_EXIT_DISC: if k == neighbors.MULTI_EXIT_DISC:
rets.append(_update_med(neigh_ip_address, v)) rets.append(_update_med(neigh_ip_address, v))

View File

@ -207,7 +207,7 @@ class RyuBGPSpeaker(RyuApp):
All valid VRFs are loaded. All valid VRFs are loaded.
""" """
vpns_conf = routing_settings.setdefault('vpns', {}) vpns_conf = routing_settings.setdefault('vpns', {})
for vrfname, vrf in vpns_conf.iteritems(): for vrfname, vrf in vpns_conf.items():
try: try:
vrf[vrfs.VRF_NAME] = vrfname vrf[vrfs.VRF_NAME] = vrfname
call('vrf.create', **vrf) call('vrf.create', **vrf)

View File

@ -160,7 +160,7 @@ class BMPClient(Activity):
def _construct_update(self, path): def _construct_update(self, path):
# Get copy of path's path attributes. # 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 path.is_withdraw:
if isinstance(path, Ipv4Path): if isinstance(path, Ipv4Path):
@ -220,7 +220,7 @@ class BMPClient(Activity):
msg = self._construct_peer_up_notification(peer) msg = self._construct_peer_up_notification(peer)
self._send(msg) 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) msg = self._construct_route_monitoring(peer, path)
self._send(msg) self._send(msg)

View File

@ -282,7 +282,7 @@ class CoreService(Factory, Activity):
- `new_rts`: (set) of new RTs that peer is interested in. - `new_rts`: (set) of new RTs that peer is interested in.
- `old_rts`: (set) of RTs that peers is no longer 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: if table.route_family == RF_RTC_UC:
continue continue
self._spawn('rt_filter_chg_%s' % peer, 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 # Check if we have to use all paths or just best path
if self._common_config.max_path_ext_rtfilter_all: if self._common_config.max_path_ext_rtfilter_all:
# We have to look at all paths for a RtDest # 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 known_path_list = rtcdest.known_path_list
for path in known_path_list: for path in known_path_list:
neigh = path.source neigh = path.source
@ -328,7 +328,7 @@ class CoreService(Factory, Activity):
# We iterate over all destination of the RTC table and for iBGP # 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 use all known paths' RTs for RT filter and for eBGP
# peers we only consider best-paths' RTs for RT filter # 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 path = rtcdest.best_path
# If this destination does not have any path, we continue # If this destination does not have any path, we continue
if not path: if not path:

View File

@ -36,7 +36,7 @@ class PeerManager(object):
@property @property
def iterpeers(self): def iterpeers(self):
return self._peers.itervalues() return iter(self._peers.values())
def set_peer_to_rtfilter_map(self, new_map): def set_peer_to_rtfilter_map(self, new_map):
self._peer_to_rtfilter_map = new_map self._peer_to_rtfilter_map = new_map
@ -69,7 +69,7 @@ class PeerManager(object):
def _get_non_rtc_peers(self): def _get_non_rtc_peers(self):
non_rtc_peer_list = set() non_rtc_peer_list = set()
for peer in self._peers.itervalues(): for peer in self._peers.values():
if (peer.in_established() and if (peer.in_established() and
not peer.is_mpbgp_cap_valid(RF_RTC_UC)): not peer.is_mpbgp_cap_valid(RF_RTC_UC)):
non_rtc_peer_list.add(peer) non_rtc_peer_list.add(peer)
@ -81,7 +81,7 @@ class PeerManager(object):
def get_peers_in_established(self): def get_peers_in_established(self):
"""Returns list of peers in established state.""" """Returns list of peers in established state."""
est_peers = [] est_peers = []
for peer in self._peers.itervalues(): for peer in self._peers.values():
if peer.in_established: if peer.in_established:
est_peers.append(peer) est_peers.append(peer)
return est_peers return est_peers
@ -107,7 +107,7 @@ class PeerManager(object):
route_family route_family
) )
for destination in table.itervalues(): for destination in table.values():
# Check if this destination's sent - routes include this peer. # Check if this destination's sent - routes include this peer.
# i.e. check if this destinations was advertised and enqueue # i.e. check if this destinations was advertised and enqueue
# the path only if it was. If the current best-path has not been # 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. Skips making request to peer that have valid RTC capability.
""" """
assert route_family != RF_RTC_UC 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 # First check if peer is in established state
if (peer.in_established and if (peer.in_established and
# Check if peer has valid capability for given address # Check if peer has valid capability for given address
@ -199,7 +199,7 @@ class PeerManager(object):
peer_rtc_as = neigh_conf.rtc_as peer_rtc_as = neigh_conf.rtc_as
# Iterate over all RT_NLRI destination communicate qualifying RT_NLRIs # Iterate over all RT_NLRI destination communicate qualifying RT_NLRIs
rtc_table = self._table_manager.get_rtc_table() 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 best_path = dest.best_path
# Ignore a destination that currently does not have best path # Ignore a destination that currently does not have best path
if not best_path: if not best_path:
@ -231,7 +231,7 @@ class PeerManager(object):
if route_family == RF_RTC_UC: if route_family == RF_RTC_UC:
continue continue
if peer.is_mbgp_cap_valid(route_family): if peer.is_mbgp_cap_valid(route_family):
for dest in table.itervalues(): for dest in table.values():
if dest.best_path: if dest.best_path:
peer.communicate_path(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 # Peers that have RTC capability and have common RT with the path
# also qualify # also qualify
peer_to_rtfilter_map = self._peer_to_rtfilter_map 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) # Ignore Network Controller (its not a BGP peer)
if peer is None: if peer is None:
continue continue

View File

@ -85,7 +85,7 @@ class TableCoreManager(object):
# Withdraw the best-path whose source was NC since it may have been # Withdraw the best-path whose source was NC since it may have been
# exported to VPN table. # exported to VPN table.
for destination in vrf_table.itervalues(): for destination in vrf_table.values():
best_path = destination.best_path best_path = destination.best_path
if best_path and best_path.source is None: if best_path and best_path.source is None:
vpn_clone = best_path.clone_to_vpn(vrf_conf.route_dist, 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. adds new path with path attributes as per current VRF configuration.
""" """
assert vrf_table assert vrf_table
for dest in vrf_table.itervalues(): for dest in vrf_table.values():
for path in dest.known_path_list: for path in dest.known_path_list:
if path.source is None: if path.source is None:
vrf_table.insert_vrf_path( vrf_table.insert_vrf_path(

View File

@ -81,7 +81,7 @@ class Table(object):
raise NotImplementedError() raise NotImplementedError()
def itervalues(self): def itervalues(self):
return self._destinations.itervalues() return iter(self._destinations.values())
def insert(self, path): def insert(self, path):
self._validate_path(path) self._validate_path(path)
@ -124,7 +124,7 @@ class Table(object):
version number. Also removes sent paths to this peer. version number. Also removes sent paths to this peer.
""" """
LOG.debug('Cleaning paths from table %s for peer %s', self, 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 # Remove paths learned from this source
paths_deleted = dest.remove_old_paths_from_source(peer) paths_deleted = dest.remove_old_paths_from_source(peer)
# Remove sent paths to this peer # Remove sent paths to this peer
@ -146,7 +146,7 @@ class Table(object):
LOG.debug('Cleaning table %s for given interested RTs %s', LOG.debug('Cleaning table %s for given interested RTs %s',
self, interested_rts) self, interested_rts)
uninteresting_dest_count = 0 uninteresting_dest_count = 0
for dest in self.itervalues(): for dest in self.values():
added_withdraw = \ added_withdraw = \
dest.withdraw_unintresting_paths(interested_rts) dest.withdraw_unintresting_paths(interested_rts)
if added_withdraw: if added_withdraw:
@ -343,7 +343,7 @@ class Destination(object):
@property @property
def sent_routes(self): def sent_routes(self):
return self._sent_routes.values() return list(self._sent_routes.values())
def add_new_path(self, new_path): def add_new_path(self, new_path):
self._validate_path(new_path) self._validate_path(new_path)

View File

@ -102,7 +102,7 @@ class VrfTable(Table):
remote_route_count = 0 remote_route_count = 0
local_route_count = 0 local_route_count = 0
for dest in self.itervalues(): for dest in self.values():
for path in dest.known_path_list: for path in dest.known_path_list:
if (hasattr(path.source, 'version_num') if (hasattr(path.source, 'version_num')
or path.source == VPN_TABLE): or path.source == VPN_TABLE):
@ -115,7 +115,7 @@ class VrfTable(Table):
LOCAL_ROUTES: local_route_count} LOCAL_ROUTES: local_route_count}
def import_vpn_paths_from_table(self, vpn_table, import_rts=None): 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 vpn_path = vpn_dest.best_path
if not vpn_path: if not vpn_path:
continue continue
@ -187,7 +187,7 @@ class VrfTable(Table):
def apply_import_maps(self): def apply_import_maps(self):
changed_dests = [] changed_dests = []
for dest in self.itervalues(): for dest in self.values():
assert isinstance(dest, VrfDest) assert isinstance(dest, VrfDest)
for import_map in self._import_maps: for import_map in self._import_maps:
for path in dest.known_path_list: for path in dest.known_path_list:

View File

@ -117,7 +117,7 @@ class Command(object):
if not isinstance(val, list): if not isinstance(val, list):
val = [val] val = [val]
for line in val: for line in val:
for k, v in line.iteritems(): for k, v in line.items():
if isinstance(v, dict): if isinstance(v, dict):
ret += cls.cli_resp_line_template.format( ret += cls.cli_resp_line_template.format(
k, '\n' + pprint.pformat(v) k, '\n' + pprint.pformat(v)
@ -194,7 +194,7 @@ class Command(object):
ret.append(self._quick_help()) ret.append(self._quick_help())
if len(self.subcommands) > 0: 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 = \ command_path, param_help, cmd_help = \
self._instantiate_subcommand(k)._quick_help(nested=True) self._instantiate_subcommand(k)._quick_help(nested=True)
if command_path or param_help or cmd_help: if command_path or param_help or cmd_help:
@ -245,7 +245,7 @@ class TextFilter(object):
iterator = enumerate(action_resp_value) iterator = enumerate(action_resp_value)
else: else:
resp = dict(action_resp_value) resp = dict(action_resp_value)
iterator = action_resp_value.iteritems() iterator = iter(action_resp_value.items())
remove = [] remove = []
@ -258,7 +258,7 @@ class TextFilter(object):
if key not in remove] if key not in remove]
else: else:
resp = dict([(key, value) resp = dict([(key, value)
for key, value in resp.iteritems() for key, value in resp.items()
if key not in remove]) if key not in remove])
return resp return resp

View File

@ -166,7 +166,7 @@ class Neighbor(Command):
[{'ip_addr': k, [{'ip_addr': k,
'as_num': str(v['remote_as']), 'as_num': str(v['remote_as']),
'bgp_state': v['stats']['bgp_state']} 'bgp_state': v['stats']['bgp_state']}
for k, v in ret.iteritems()]) for k, v in ret.items()])
@classmethod @classmethod
def cli_resp_formatter(cls, resp): def cli_resp_formatter(cls, resp):

View File

@ -63,7 +63,7 @@ class Rib(RibBase):
if resp.status == STATUS_ERROR: if resp.status == STATUS_ERROR:
return RibBase.cli_resp_formatter(resp) return RibBase.cli_resp_formatter(resp)
ret = cls._format_family_header() 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 += 'Family: {0}\n'.format(family)
ret += cls._format_family(data) ret += cls._format_family(data)
return ret return ret

View File

@ -70,7 +70,7 @@ class Routes(Command, RouteFormatterMixin):
if resp.status == STATUS_ERROR: if resp.status == STATUS_ERROR:
return Command.cli_resp_formatter(resp) return Command.cli_resp_formatter(resp)
ret = cls._format_family_header() 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 += 'VPN: {0}\n'.format(family)
ret += cls._format_family(data) ret += cls._format_family(data)
return ret return ret
@ -130,7 +130,7 @@ class Summary(Command, CountRoutesMixin):
vrf_confs = self.api.get_vrfs_conf() vrf_confs = self.api.get_vrfs_conf()
view = ConfDictView(vrf_confs) view = ConfDictView(vrf_confs)
encoded = view.encode() encoded = view.encode()
for vrf_key, conf in encoded.iteritems(): for vrf_key, conf in encoded.items():
vrf_name, vrf_rf = vrf_key vrf_name, vrf_rf = vrf_key
conf['routes_count'] = self._count_routes( conf['routes_count'] = self._count_routes(
vrf_name, vrf_name,
@ -138,7 +138,7 @@ class Summary(Command, CountRoutesMixin):
) )
encoded = dict([(str(k), v) encoded = dict([(str(k), v)
for k, v in encoded.iteritems()]) for k, v in encoded.items()])
return CommandsResponse( return CommandsResponse(
STATUS_OK, STATUS_OK,
encoded encoded

View File

@ -47,7 +47,7 @@ class InternalApi(object):
vrf_name = vrf_name.encode('ascii', 'ignore') vrf_name = vrf_name.encode('ascii', 'ignore')
route_count = \ 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} return {str((vrf_name, vrf_rf)): route_count}
def get_vrfs_conf(self): def get_vrfs_conf(self):
@ -56,7 +56,7 @@ class InternalApi(object):
def get_all_vrf_routes(self): def get_all_vrf_routes(self):
vrfs = self._get_vrf_tables() vrfs = self._get_vrf_tables()
ret = {} 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) ret[str((vrf_id, vrf_rf))] = self._get_single_vrf_routes(table)
return ret return ret
@ -64,10 +64,10 @@ class InternalApi(object):
vrf = self._get_vrf_table(vrf_id, vrf_rf) vrf = self._get_vrf_table(vrf_id, vrf_rf)
if not vrf: if not vrf:
raise WrongParamError('wrong vpn name %s' % str((vrf_id, vrf_rf))) 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): 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): def _get_vrf_table(self, vrf_name, vrf_rf):
return CORE_MANAGER.get_core_service()\ return CORE_MANAGER.get_core_service()\
@ -92,7 +92,7 @@ class InternalApi(object):
gtable = table_manager.get_global_table_by_route_family(rf) gtable = table_manager.get_global_table_by_route_family(rf)
if gtable is not None: if gtable is not None:
return [self._dst_to_dict(dst) return [self._dst_to_dict(dst)
for dst in sorted(gtable.itervalues())] for dst in sorted(gtable.values())]
else: else:
return [] return []

View File

@ -122,7 +122,7 @@ class OperatorDetailView(OperatorAbstractView):
def encode(self): def encode(self):
return {field_name: field.get(self._obj) 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)} if isinstance(field, fields.DataField)}
def rel(self, field_name): def rel(self, field_name):
@ -153,7 +153,7 @@ class OperatorListView(OperatorAbstractView):
def encode(self): def encode(self):
return RdyToFlattenList( return RdyToFlattenList(
[{field_name: field.get(obj) [{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)} if isinstance(field, fields.DataField)}
for obj in self.model] for obj in self.model]
) )
@ -175,28 +175,28 @@ class OperatorDictView(OperatorAbstractView):
def combine_related(self, field_name): def combine_related(self, field_name):
f = self._fields[field_name] f = self._fields[field_name]
return CombinedViewsWrapper(RdyToFlattenList( 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): def get_field(self, field_name):
f = self._fields[field_name] f = self._fields[field_name]
return RdyToFlattenDict( 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): def encode(self):
return RdyToFlattenDict( return RdyToFlattenDict(
{key: {field_name: field.get(obj) {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)} if isinstance(field, fields.DataField)}
for key, obj in self.model.iteritems()} for key, obj in self.model.items()}
) )
@property @property
def model(self): def model(self):
if self._filter_func is not None: if self._filter_func is not None:
new_model = RdyToFlattenDict() new_model = RdyToFlattenDict()
for k, v in self._obj.iteritems(): for k, v in self._obj.items():
if self._filter_func(k, v): if self._filter_func(k, v):
new_model[k] = v new_model[k] = v
return new_model return new_model
@ -282,7 +282,7 @@ def create_dict_view_class(detail_view_class, name):
if 'encode' in dir(detail_view_class): if 'encode' in dir(detail_view_class):
def encode(self): def encode(self):
return RdyToFlattenDict({key: detail_view_class(obj).encode() 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( return _create_collection_view(
detail_view_class, name, encode, OperatorDictView detail_view_class, name, encode, OperatorDictView

View File

@ -175,7 +175,7 @@ class PeerState(object):
def _remember_last_bgp_error(self, identifier, data): def _remember_last_bgp_error(self, identifier, data):
self._last_bgp_error = dict([(k, v) self._last_bgp_error = dict([(k, v)
for k, v in data.iteritems() for k, v in data.items()
if k != 'peer']) if k != 'peer'])
@property @property
@ -584,7 +584,7 @@ class Peer(Source, Sink, NeighborConfListener, Activity):
def on_update_in_filter(self): def on_update_in_filter(self):
LOG.debug('on_update_in_filter fired') 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) LOG.debug('received_path: %s', received_path)
path = received_path.path path = received_path.path
nlri_str = path.nlri.formatted_nlri_str nlri_str = path.nlri.formatted_nlri_str
@ -606,7 +606,7 @@ class Peer(Source, Sink, NeighborConfListener, Activity):
def on_update_out_filter(self): def on_update_out_filter(self):
LOG.debug('on_update_out_filter fired') 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) LOG.debug('sent_path: %s', sent_path)
path = sent_path.path path = sent_path.path
nlri_str = path.nlri.formatted_nlri_str nlri_str = path.nlri.formatted_nlri_str
@ -631,7 +631,7 @@ class Peer(Source, Sink, NeighborConfListener, Activity):
def on_update_attribute_maps(self): def on_update_attribute_maps(self):
# resend sent_route in case of filter matching # resend sent_route in case of filter matching
LOG.debug('on_update_attribute_maps fired') 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) LOG.debug('resend path: %s', sent_path)
path = sent_path.path path = sent_path.path
self.enque_outgoing_msg(OutgoingRoute(path)) self.enque_outgoing_msg(OutgoingRoute(path))
@ -837,7 +837,7 @@ class Peer(Source, Sink, NeighborConfListener, Activity):
new_pathattr.append(mpunreach_attr) new_pathattr.append(mpunreach_attr)
elif self.is_route_server_client: elif self.is_route_server_client:
nlri_list = [path.nlri] nlri_list = [path.nlri]
for pathattr in path.pathattr_map.itervalues(): for pathattr in path.pathattr_map.values():
new_pathattr.append(pathattr) new_pathattr.append(pathattr)
else: else:
# Supported and un-supported/unknown attributes. # Supported and un-supported/unknown attributes.
@ -1204,7 +1204,7 @@ class Peer(Source, Sink, NeighborConfListener, Activity):
else: else:
yield L yield L
opts = list(flatten( opts = list(flatten(
self._neigh_conf.get_configured_capabilites().values())) list(self._neigh_conf.get_configured_capabilites().values())))
open_msg = BGPOpen( open_msg = BGPOpen(
my_as=asnum, my_as=asnum,
bgp_identifier=bgpid, bgp_identifier=bgpid,
@ -1844,11 +1844,11 @@ class Peer(Source, Sink, NeighborConfListener, Activity):
LOG.debug('Communicating current best path for all afi/safi except' LOG.debug('Communicating current best path for all afi/safi except'
' 1/132') ' 1/132')
# We will enqueue best path from all global destination. # 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: if route_family == RF_RTC_UC:
continue continue
if self.is_mbgp_cap_valid(route_family): if self.is_mbgp_cap_valid(route_family):
for dest in table.itervalues(): for dest in table.values():
if dest.best_path: if dest.best_path:
self.communicate_path(dest.best_path) self.communicate_path(dest.best_path)

View File

@ -121,7 +121,7 @@ def validate_enabled(enabled):
@validate(name=CHANGES) @validate(name=CHANGES)
def validate_changes(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): if k not in (MULTI_EXIT_DISC, ENABLED, CONNECT_MODE):
raise ConfigValueError(desc="Unknown field to change: %s" % k) 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' raise ConfigTypeError(desc='Invalid filter type: %s, supported filter'
' types are %s' ' types are %s'
% (filter_['type'], % (filter_['type'],
SUPPORTED_FILTER_VALIDATORS.keys())) list(SUPPORTED_FILTER_VALIDATORS.keys())))
return SUPPORTED_FILTER_VALIDATORS[filter_['type']](filter_) return SUPPORTED_FILTER_VALIDATORS[filter_['type']](filter_)
@ -627,7 +627,7 @@ class NeighborsConf(BaseConf):
"""Returns current RTC AS configured for current neighbors. """Returns current RTC AS configured for current neighbors.
""" """
rtc_as_set = set() rtc_as_set = set()
for neigh in self._neighbors.itervalues(): for neigh in self._neighbors.values():
rtc_as_set.add(neigh.rtc_as) rtc_as_set.add(neigh.rtc_as)
return rtc_as_set return rtc_as_set
@ -670,7 +670,7 @@ class NeighborsConf(BaseConf):
@property @property
def settings(self): def settings(self):
return [neighbor.settings for _, neighbor in return [neighbor.settings for _, neighbor in
self._neighbors.iteritems()] self._neighbors.items()]
class NeighborConfListener(ConfWithIdListener, ConfWithStatsListener): class NeighborConfListener(ConfWithIdListener, ConfWithStatsListener):

View File

@ -404,7 +404,7 @@ class VrfsConf(BaseConf):
def vrf_confs(self): def vrf_confs(self):
"""Returns a list of configured `VrfConf`s """Returns a list of configured `VrfConf`s
""" """
return self._vrfs_by_rd_rf.values() return list(self._vrfs_by_rd_rf.values())
@property @property
def vrf_interested_rts(self): def vrf_interested_rts(self):

View File

@ -110,7 +110,7 @@ def get_unknow_opttrans_attr(path):
""" """
path_attrs = path.pathattr_map path_attrs = path.pathattr_map
unknown_opt_tran_attrs = {} unknown_opt_tran_attrs = {}
for _, attr in path_attrs.iteritems(): for _, attr in path_attrs.items():
if (isinstance(attr, BGPPathAttributeUnknown) and if (isinstance(attr, BGPPathAttributeUnknown) and
attr.is_optional_transitive()): attr.is_optional_transitive()):
unknown_opt_tran_attrs[attr.type_code] = attr unknown_opt_tran_attrs[attr.type_code] = attr

View File

@ -257,7 +257,7 @@ class BaseConfigurator(object):
kwargs = dict([(k, config[k]) for k in config if valid_ident(k)]) kwargs = dict([(k, config[k]) for k in config if valid_ident(k)])
result = c(**kwargs) result = c(**kwargs)
if props: if props:
for name, value in props.items(): for name, value in list(props.items()):
setattr(result, name, value) setattr(result, name, value)
return result return result
@ -366,7 +366,7 @@ class DictConfigurator(BaseConfigurator):
# which were in the previous configuration but # which were in the previous configuration but
# which are not in the new configuration. # which are not in the new configuration.
root = logging.root root = logging.root
existing = root.manager.loggerDict.keys() existing = list(root.manager.loggerDict.keys())
# The list needs to be sorted so that we can # The list needs to be sorted so that we can
# avoid disabling child loggers of explicitly # avoid disabling child loggers of explicitly
# named loggers. With a sorted list it is easier # named loggers. With a sorted list it is easier

View File

@ -140,7 +140,7 @@ class RouteTargetManager(object):
def on_rt_filter_chg_sync_peer(self, peer, new_rts, old_rts, table): 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 ', LOG.debug('RT Filter changed for peer %s, new_rts %s, old_rts %s ',
peer, new_rts, old_rts) 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 this destination does not have best path, we ignore it
if not dest.best_path: if not dest.best_path:
continue continue

View File

@ -30,7 +30,7 @@ from ryu import cfg
# import all packet libraries. # import all packet libraries.
PKT_LIB_PATH = 'ryu.lib.packet' 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: if not modname.startswith(PKT_LIB_PATH) or not moddef:
continue continue
for (clsname, clsdef, ) in inspect.getmembers(moddef): for (clsname, clsdef, ) in inspect.getmembers(moddef):
@ -882,7 +882,7 @@ class OfTester(app_manager.RyuApp):
'ipv6_flabel': 20, 'ipv6_flabel': 20,
'ipv6_exthdr': 9} 'ipv6_exthdr': 9}
match_fields = list() match_fields = list()
for key, united_value in match.iteritems(): for key, united_value in match.items():
if isinstance(united_value, tuple): if isinstance(united_value, tuple):
(value, mask) = united_value (value, mask) = united_value
# look up oxm_fields.TypeDescr to get mask length. # look up oxm_fields.TypeDescr to get mask length.
@ -1308,7 +1308,7 @@ class TestFile(stringify.StringifyMixin):
if v[k] == port_name: if v[k] == port_name:
v[k] = CONF['test-switch'][port_name] v[k] = CONF['test-switch'][port_name]
if isinstance(val, dict): if isinstance(val, dict):
for k, v in val.iteritems(): for k, v in val.items():
if k == "OFPActionOutput": if k == "OFPActionOutput":
if 'port' in v: if 'port' in v:
__replace_port_name("port", v) __replace_port_name("port", v)

View File

@ -35,7 +35,7 @@ from ryu import cfg
# import all packet libraries. # import all packet libraries.
PKT_LIB_PATH = 'ryu.lib.packet' 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: if not modname.startswith(PKT_LIB_PATH) or not moddef:
continue continue
for (clsname, clsdef, ) in inspect.getmembers(moddef): for (clsname, clsdef, ) in inspect.getmembers(moddef):

View File

@ -206,7 +206,7 @@ class Test_Parser(unittest.TestCase):
return map(f, d) return map(f, d)
if isinstance(d, dict): if isinstance(d, dict):
d2 = {} d2 = {}
for k, v in d.iteritems(): for k, v in d.items():
if k in names: if k in names:
continue continue
d2[k] = f(v) d2[k] = f(v)

View File

@ -131,7 +131,7 @@ class Test_Parser_Compat(unittest.TestCase):
# a parsed object can be inspected by old and new api # a parsed object can be inspected by old and new api
check(ofpp.OFPMatch.parser(buffer(new_buf), 0)) 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(): def _add_tests():

View File

@ -51,12 +51,12 @@ class Test_Parser_OFPMatch(unittest.TestCase):
if domask: if domask:
d = dict(self._ofp[ofpp].oxm_normalize_user(k, uv) d = dict(self._ofp[ofpp].oxm_normalize_user(k, uv)
for (k, uv) for (k, uv)
in d.iteritems()) in d.items())
match = ofpp.OFPMatch(**d) match = ofpp.OFPMatch(**d)
b = bytearray() b = bytearray()
match.serialize(b, 0) match.serialize(b, 0)
match2 = match.parser(buffer(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 match)
ok_(k in match2) ok_(k in match2)
eq_(match[k], v) eq_(match[k], v)

View File

@ -288,7 +288,7 @@ class PortDataState(dict):
curr = curr[self._NEXT] curr = curr[self._NEXT]
def clear(self): def clear(self):
for node in self._map.itervalues(): for node in self._map.values():
del node[:] del node[:]
root = self._root root = self._root
root[:] = [root, root, None] root[:] = [root, root, None]
@ -486,7 +486,7 @@ class Switches(app_manager.RyuApp):
def _get_switch(self, dpid): def _get_switch(self, dpid):
if dpid in self.dps: if dpid in self.dps:
switch = Switch(self.dps[dpid]) 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) switch.add_port(ofpport)
return switch return switch
@ -843,7 +843,7 @@ class Switches(app_manager.RyuApp):
switches = [] switches = []
if dpid is None: if dpid is None:
# reply all list # reply all list
for dp in self.dps.itervalues(): for dp in self.dps.values():
switches.append(self._get_switch(dp.id)) switches.append(self._get_switch(dp.id))
elif dpid in self.dps: elif dpid in self.dps:
switches.append(self._get_switch(dpid)) switches.append(self._get_switch(dpid))

View File

@ -65,7 +65,7 @@ def _likely_same(a, b):
def _find_loaded_module(modpath): def _find_loaded_module(modpath):
# copy() to avoid RuntimeError: dictionary changed size during iteration # 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__': if k == '__main__':
continue continue
if not hasattr(m, '__file__'): if not hasattr(m, '__file__'):