summaryrefslogtreecommitdiff
path: root/vtep
diff options
context:
space:
mode:
authorRussell Bryant <russell@ovn.org>2015-12-14 15:13:20 -0500
committerRussell Bryant <russell@ovn.org>2016-01-21 23:00:11 -0500
commitcb96c1b27e502c591eeeb831f04d92b400d757f4 (patch)
treedc653f9c3c3ce324404734a7a75565340744df34 /vtep
parentf7683a72770373d724852feca032a88b6416686e (diff)
downloadopenvswitch-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 'vtep')
-rwxr-xr-xvtep/ovs-vtep21
1 files changed, 11 insertions, 10 deletions
diff --git a/vtep/ovs-vtep b/vtep/ovs-vtep
index 1db4e0546..97397b0ca 100755
--- a/vtep/ovs-vtep
+++ b/vtep/ovs-vtep
@@ -30,6 +30,7 @@ import ovs.daemon
import ovs.unixctl.server
import ovs.vlog
from six.moves import range
+import six
VERSION = "0.99"
@@ -127,11 +128,11 @@ class Logical_Switch(object):
ovs_ofctl("add-flow %s priority=0,action=drop" % self.short_name)
def cleanup_ls(self):
- for port_no, tun_name, remote_ip in self.tunnels.itervalues():
+ for port_no, tun_name, remote_ip in six.itervalues(self.tunnels):
del_bfd(remote_ip)
def update_flood(self):
- flood_ports = self.ports.values()
+ flood_ports = list(self.ports.values())
# Traffic flowing from one 'unknown-dst' should not be flooded to
# port belonging to another 'unknown-dst'.
@@ -282,11 +283,11 @@ class Logical_Switch(object):
for tunnel in old_tunnels.difference(tunnels):
self.del_tunnel(tunnel)
- for mac in remote_macs.keys():
+ for mac in six.iterkeys(remote_macs):
if (self.remote_macs.get(mac) != remote_macs[mac]):
self.add_remote_mac(mac, remote_macs[mac])
- for mac in self.remote_macs.keys():
+ for mac in six.iterkeys(self.remote_macs):
if mac not in remote_macs:
self.del_remote_mac(mac)
@@ -308,7 +309,7 @@ class Logical_Switch(object):
# Go through all the logical switch's interfaces that end with "-l"
# and copy the statistics to logical_binding_stats.
- for interface in self.ports.iterkeys():
+ for interface in six.iterkeys(self.ports):
if not interface.endswith("-l"):
continue
# Physical ports can have a '-' as part of its name.
@@ -319,7 +320,7 @@ class Logical_Switch(object):
if not uuid:
continue
- for (mapfrom, mapto) in stats_map.iteritems():
+ for mapfrom, mapto in six.iteritems(stats_map):
value = ovs_vsctl("get interface %s statistics:%s"
% (interface, mapfrom)).strip('"')
vtep_ctl("set logical_binding_stats %s %s=%s"
@@ -435,7 +436,7 @@ def run_bfd():
'bfd_params:check_tnl_key': 'false'}
bfd_params_values = {}
- for key, default in bfd_params_default.iteritems():
+ for key, default in six.iteritems(bfd_params_default):
column = vtep_ctl("--if-exists get tunnel %s %s"
% (tunnel, key))
if not column:
@@ -443,7 +444,7 @@ def run_bfd():
else:
bfd_params_values[key] = column
- for key, value in bfd_params_values.iteritems():
+ for key, value in six.iteritems(bfd_params_values):
new_key = key.replace('_params', '')
ovs_vsctl("set interface %s %s=%s" % (port, new_key, value))
@@ -465,7 +466,7 @@ def run_bfd():
bfd_lconf_default = {'bfd_config_local:bfd_dst_ip': '169.254.1.0',
'bfd_config_local:bfd_dst_mac':
'00:23:20:00:00:01'}
- for key, value in bfd_lconf_default.iteritems():
+ for key, value in six.iteritems(bfd_lconf_default):
vtep_ctl("set tunnel %s %s=%s" % (tunnel, key, value))
# bfd_config_remote options from VTEP DB should be populated to
@@ -713,7 +714,7 @@ def main():
handle_physical()
- for ls_name, ls in Lswitches.items():
+ for ls_name, ls in six.iteritems(Lswitches):
ls.run()
run_bfd()