diff options
author | Russell Bryant <russell@ovn.org> | 2015-12-14 15:13:20 -0500 |
---|---|---|
committer | Russell Bryant <russell@ovn.org> | 2016-01-21 23:00:11 -0500 |
commit | cb96c1b27e502c591eeeb831f04d92b400d757f4 (patch) | |
tree | dc653f9c3c3ce324404734a7a75565340744df34 /xenserver | |
parent | f7683a72770373d724852feca032a88b6416686e (diff) | |
download | openvswitch-cb96c1b27e502c591eeeb831f04d92b400d757f4.tar.gz |
python: Convert dict iterators.
In Python 2, dict.items(), dict.keys(), and dict.values() returned a
list. dict.iteritems(), dict.iterkeys(), and dict.itervalues() returned
an iterator.
As of Python 3, dict.iteritems(), dict.itervalues(), and dict.iterkeys()
are gone. items(), keys(), and values() now return an iterator.
In the case where we want an iterator, we now use the six.iter*()
helpers. If we want a list, we explicitly create a list from the
iterator.
Signed-off-by: Russell Bryant <russell@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'xenserver')
-rwxr-xr-x | xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync b/xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync index bed80843c..a776c0084 100755 --- a/xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync +++ b/xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync @@ -34,6 +34,7 @@ import ovs.daemon import ovs.db.idl import ovs.unixctl import ovs.unixctl.server +import six vlog = ovs.vlog.Vlog("ovs-xapi-sync") session = None @@ -84,7 +85,7 @@ def get_network_by_bridge(br_name): recs = session.xenapi.network.get_all_records_where( 'field "bridge"="%s"' % br_name) if len(recs) > 0: - return recs.values()[0] + return next(six.itervalues(recs)) return None @@ -294,7 +295,7 @@ def main(): txn = ovs.db.idl.Transaction(idl) new_bridges = {} - for row in idl.tables["Bridge"].rows.itervalues(): + for row in six.itervalues(idl.tables["Bridge"].rows): bridge_id = bridges.get(row.name) if bridge_id is None: # Configure the new bridge. @@ -319,12 +320,12 @@ def main(): bridges = new_bridges iface_by_name = {} - for row in idl.tables["Interface"].rows.itervalues(): + for row in six.itervalues(idl.tables["Interface"].rows): iface_by_name[row.name] = row new_iface_ids = {} new_vm_ids = {} - for row in idl.tables["Interface"].rows.itervalues(): + for row in six.itervalues(idl.tables["Interface"].rows): # Match up paired vif and tap devices. if row.name.startswith("vif"): vif = row |