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 /debian | |
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 'debian')
-rwxr-xr-x | debian/ovs-monitor-ipsec | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/debian/ovs-monitor-ipsec b/debian/ovs-monitor-ipsec index 0f39191a8..15022947c 100755 --- a/debian/ovs-monitor-ipsec +++ b/debian/ovs-monitor-ipsec @@ -40,6 +40,7 @@ import ovs.unixctl import ovs.unixctl.server import ovs.vlog from six.moves import range +import six vlog = ovs.vlog.Vlog("ovs-monitor-ipsec") root_prefix = '' # Prefix for absolute file names, for testing. @@ -152,7 +153,7 @@ path certificate "%s"; conf_file = open(root_prefix + self.conf_file, 'w') conf_file.write(Racoon.conf_header % (self.psk_file, self.cert_dir)) - for host, vals in self.cert_hosts.iteritems(): + for host, vals in six.iteritems(self.cert_hosts): conf_file.write(Racoon.cert_entry % (host, vals["certificate"], vals["private_key"], vals["peer_cert_file"])) @@ -169,7 +170,7 @@ path certificate "%s"; psk_file.write("# Generated by Open vSwitch...do not modify by hand!") psk_file.write("\n\n") - for host, vals in self.psk_hosts.iteritems(): + for host, vals in six.iteritems(self.psk_hosts): psk_file.write("%s %s\n" % (host, vals["psk"])) psk_file.close() @@ -354,11 +355,11 @@ class IPsec: def update_ipsec(ipsec, interfaces, new_interfaces): - for name, vals in interfaces.iteritems(): + for name, vals in six.iteritems(interfaces): if name not in new_interfaces: ipsec.del_entry(vals["local_ip"], vals["remote_ip"]) - for name, vals in new_interfaces.iteritems(): + for name, vals in six.iteritems(new_interfaces): orig_vals = interfaces.get(name) if orig_vals: # Configuration for this host already exists. Check if it's @@ -377,7 +378,7 @@ def update_ipsec(ipsec, interfaces, new_interfaces): def get_ssl_cert(data): - for ovs_rec in data["Open_vSwitch"].rows.itervalues(): + for ovs_rec in data["Open_vSwitch"].rows.values(): if ovs_rec.ssl: ssl = ovs_rec.ssl[0] if ssl.certificate and ssl.private_key: @@ -440,7 +441,7 @@ def main(): ssl_cert = get_ssl_cert(idl.tables) new_interfaces = {} - for rec in idl.tables["Interface"].rows.itervalues(): + for rec in six.itervalues(idl.tables["Interface"].rows): if rec.type == "ipsec_gre": name = rec.name options = rec.options |