diff options
author | Joe Stringer <joe@ovn.org> | 2016-05-23 18:20:27 -0700 |
---|---|---|
committer | Joe Stringer <joe@ovn.org> | 2016-06-07 16:18:44 -0700 |
commit | 1ea636ec836719630cef9465bc248870a66a3b24 (patch) | |
tree | 43bf659235760821172e4ae7a1d852776225b723 /xenserver | |
parent | 8b35f045e18a1d1c9cf10eb214adf6d6f290592d (diff) | |
download | openvswitch-1ea636ec836719630cef9465bc248870a66a3b24.tar.gz |
xenserver: Fix string compatibility in python3.
PEP 3120 made UTF-8 the default source encoding for python3 strings;
ensure that the output for strings are consistent between python2.7 and
python3.
Signed-off-by: Joe Stringer <joe@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'xenserver')
-rw-r--r-- | xenserver/opt_xensource_libexec_InterfaceReconfigure.py | 11 | ||||
-rw-r--r-- | xenserver/opt_xensource_libexec_InterfaceReconfigureVswitch.py | 2 |
2 files changed, 10 insertions, 3 deletions
diff --git a/xenserver/opt_xensource_libexec_InterfaceReconfigure.py b/xenserver/opt_xensource_libexec_InterfaceReconfigure.py index f37e03863..9cdb3bc27 100644 --- a/xenserver/opt_xensource_libexec_InterfaceReconfigure.py +++ b/xenserver/opt_xensource_libexec_InterfaceReconfigure.py @@ -758,15 +758,22 @@ def pif_ipdev_name(pif): def netdev_exists(netdev): return os.path.exists(root_prefix() + "/sys/class/net/" + netdev) + +def unicode_2to3(string): + if sys.version_info < (3,): + return string.encode() + return string + + def pif_netdev_name(pif): """Get the netdev name for a PIF.""" pifrec = db().get_pif_record(pif) if pif_is_vlan(pif): - return "%(device)s.%(VLAN)s" % pifrec + return unicode_2to3("%(device)s.%(VLAN)s" % pifrec) else: - return pifrec['device'] + return unicode_2to3(pifrec['device']) # # Bridges diff --git a/xenserver/opt_xensource_libexec_InterfaceReconfigureVswitch.py b/xenserver/opt_xensource_libexec_InterfaceReconfigureVswitch.py index 30fc17669..d70c24914 100644 --- a/xenserver/opt_xensource_libexec_InterfaceReconfigureVswitch.py +++ b/xenserver/opt_xensource_libexec_InterfaceReconfigureVswitch.py @@ -655,7 +655,7 @@ class DatapathVswitch(Datapath): for flow in self._bridge_flows: if flow.find('in_port=%s') != -1 or flow.find('actions=%s') != -1: for port in ofports: - f = flow % (port) + f = flow % (port.decode()) run_command(['/usr/bin/ovs-ofctl', 'add-flow', dpname, f]) else: run_command(['/usr/bin/ovs-ofctl', 'add-flow', dpname, flow]) |