summaryrefslogtreecommitdiff
path: root/xenserver/opt_xensource_libexec_InterfaceReconfigure.py
diff options
context:
space:
mode:
authorJoe Stringer <joe@ovn.org>2016-05-23 18:20:27 -0700
committerJoe Stringer <joe@ovn.org>2016-06-07 16:18:44 -0700
commit1ea636ec836719630cef9465bc248870a66a3b24 (patch)
tree43bf659235760821172e4ae7a1d852776225b723 /xenserver/opt_xensource_libexec_InterfaceReconfigure.py
parent8b35f045e18a1d1c9cf10eb214adf6d6f290592d (diff)
downloadopenvswitch-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/opt_xensource_libexec_InterfaceReconfigure.py')
-rw-r--r--xenserver/opt_xensource_libexec_InterfaceReconfigure.py11
1 files changed, 9 insertions, 2 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