summaryrefslogtreecommitdiff
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
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>
-rw-r--r--tests/interface-reconfigure.at16
-rw-r--r--xenserver/opt_xensource_libexec_InterfaceReconfigure.py11
-rw-r--r--xenserver/opt_xensource_libexec_InterfaceReconfigureVswitch.py2
3 files changed, 18 insertions, 11 deletions
diff --git a/tests/interface-reconfigure.at b/tests/interface-reconfigure.at
index bb3756be2..b4e455d94 100644
--- a/tests/interface-reconfigure.at
+++ b/tests/interface-reconfigure.at
@@ -708,7 +708,7 @@ action_up: xenbr2
Writing network configuration for xenbr2
Configuring xenbr2 using DHCP configuration
configure_datapath: bridge - xenbr2
-configure_datapath: physical - [u'eth2']
+configure_datapath: physical - ['eth2']
configure_datapath: extra ports - []
configure_datapath: extra bonds - []
/usr/bin/ovs-vsctl -vconsole:off get-fail-mode xenbr2
@@ -762,7 +762,7 @@ action_down: xenbr2
/sbin/ifdown xenbr2
deconfigure ipdev xenbr2 on xenbr2
deconfigure_bridge: bridge - xenbr2
-action_down: bring down physical devices - [u'eth2']
+action_down: bring down physical devices - ['eth2']
/sbin/ifconfig eth2 down
/usr/bin/ovs-vsctl --timeout=20
--with-iface --if-exists del-port xenbr2
@@ -785,7 +785,7 @@ action_up: xapi3
Writing network configuration for xapi3
Configuring xapi3 using None configuration
configure_datapath: bridge - xenbr3
-configure_datapath: physical - [u'eth3']
+configure_datapath: physical - ['eth3']
configure_datapath: extra ports - []
configure_datapath: extra bonds - []
Applying changes to /etc/sysconfig/network-scripts/route-xapi3 configuration
@@ -836,7 +836,7 @@ deconfigure ipdev xapi3 on xenbr3
deconfigure_bridge: bridge - xapi3
action_down: no more masters, bring down slave xenbr3
deconfigure_bridge: bridge - xenbr3
-action_down: bring down physical devices - [u'eth3']
+action_down: bring down physical devices - ['eth3']
/sbin/ifconfig eth3 down
/usr/bin/ovs-vsctl --timeout=20
--with-iface --if-exists del-port xapi3
@@ -869,7 +869,7 @@ Configuring xapi1 using None configuration
configure_datapath: leaving bond bond0 up
configure_datapath: leaving bond bond0 up
configure_datapath: bridge - xapi1
-configure_datapath: physical - [u'eth0', u'eth1']
+configure_datapath: physical - ['eth0', 'eth1']
configure_datapath: extra ports - []
configure_datapath: extra bonds - []
netdev: down: device xenbr0 does not exist, ignoring
@@ -926,7 +926,7 @@ action_down: xapi1
/sbin/ifdown xapi1
deconfigure ipdev xapi1 on xapi1
deconfigure_bridge: bridge - xapi1
-action_down: bring down physical devices - [u'eth0', u'eth1']
+action_down: bring down physical devices - ['eth0', 'eth1']
/sbin/ifconfig eth0 down
/sbin/ifconfig eth1 down
/usr/bin/ovs-vsctl --timeout=20
@@ -959,7 +959,7 @@ Configuring xapi2 using None configuration
configure_datapath: leaving bond bond0 up
configure_datapath: leaving bond bond0 up
configure_datapath: bridge - xapi1
-configure_datapath: physical - [u'eth0', u'eth1']
+configure_datapath: physical - ['eth0', 'eth1']
configure_datapath: extra ports - []
configure_datapath: extra bonds - []
netdev: down: device xenbr0 does not exist, ignoring
@@ -1022,7 +1022,7 @@ deconfigure ipdev xapi2 on xapi1
deconfigure_bridge: bridge - xapi2
action_down: no more masters, bring down slave xapi1
deconfigure_bridge: bridge - xapi1
-action_down: bring down physical devices - [u'eth0', u'eth1']
+action_down: bring down physical devices - ['eth0', 'eth1']
/sbin/ifconfig eth0 down
/sbin/ifconfig eth1 down
/usr/bin/ovs-vsctl --timeout=20
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])