From patchwork Tue May 24 01:20:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Stringer X-Patchwork-Id: 625457 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (archives.nicira.com [96.126.127.54]) by ozlabs.org (Postfix) with ESMTP id 3rDHfp40tCz9sdQ for ; Tue, 24 May 2016 11:21:06 +1000 (AEST) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 7A03A10900; Mon, 23 May 2016 18:20:57 -0700 (PDT) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx1e3.cudamail.com (mx1.cudamail.com [69.90.118.67]) by archives.nicira.com (Postfix) with ESMTPS id 59C89108FC for ; Mon, 23 May 2016 18:20:55 -0700 (PDT) Received: from bar5.cudamail.com (localhost [127.0.0.1]) by mx1e3.cudamail.com (Postfix) with ESMTPS id D976B4204D6 for ; Mon, 23 May 2016 19:20:54 -0600 (MDT) X-ASG-Debug-ID: 1464052854-09eadd02f2582590001-byXFYA Received: from mx1-pf1.cudamail.com ([192.168.24.1]) by bar5.cudamail.com with ESMTP id mVYaejGVmfx3YXnQ (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Mon, 23 May 2016 19:20:54 -0600 (MDT) X-Barracuda-Envelope-From: joe@ovn.org X-Barracuda-RBL-Trusted-Forwarder: 192.168.24.1 Received: from unknown (HELO relay6-d.mail.gandi.net) (217.70.183.198) by mx1-pf1.cudamail.com with ESMTPS (DHE-RSA-AES256-SHA encrypted); 24 May 2016 01:20:54 -0000 Received-SPF: pass (mx1-pf1.cudamail.com: SPF record at ovn.org designates 217.70.183.198 as permitted sender) X-Barracuda-Apparent-Source-IP: 217.70.183.198 X-Barracuda-RBL-IP: 217.70.183.198 Received: from mfilter27-d.gandi.net (mfilter27-d.gandi.net [217.70.178.155]) by relay6-d.mail.gandi.net (Postfix) with ESMTP id C93E1FB8A0 for ; Tue, 24 May 2016 03:20:52 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mfilter27-d.gandi.net Received: from relay6-d.mail.gandi.net ([IPv6:::ffff:217.70.183.198]) by mfilter27-d.gandi.net (mfilter27-d.gandi.net [::ffff:10.0.15.180]) (amavisd-new, port 10024) with ESMTP id M7pU8cCFrkZw for ; Tue, 24 May 2016 03:20:51 +0200 (CEST) X-Originating-IP: 208.91.1.34 Received: from archer.eng.vmware.com (unknown [208.91.1.34]) (Authenticated sender: joe@ovn.org) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id B0621FB881 for ; Tue, 24 May 2016 03:20:50 +0200 (CEST) X-CudaMail-Envelope-Sender: joe@ovn.org From: Joe Stringer To: dev@openvswitch.org X-CudaMail-Whitelist-To: dev@openvswitch.org X-CudaMail-MID: CM-E1-522070286 X-CudaMail-DTE: 052316 X-CudaMail-Originating-IP: 217.70.183.198 Date: Mon, 23 May 2016 18:20:27 -0700 X-ASG-Orig-Subj: [##CM-E1-522070286##][PATCH 2/6] xenserver: Fix string compatibility in python3. Message-Id: <1464052831-17278-3-git-send-email-joe@ovn.org> X-Mailer: git-send-email 2.8.2 In-Reply-To: <1464052831-17278-1-git-send-email-joe@ovn.org> References: <1464052831-17278-1-git-send-email-joe@ovn.org> X-Barracuda-Connect: UNKNOWN[192.168.24.1] X-Barracuda-Start-Time: 1464052854 X-Barracuda-Encrypted: ECDHE-RSA-AES256-GCM-SHA384 X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-ASG-Whitelist: Header =?UTF-8?B?eFwtY3VkYW1haWxcLXdoaXRlbGlzdFwtdG8=?= X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 Subject: [ovs-dev] [PATCH 2/6] xenserver: Fix string compatibility in python3. X-BeenThere: dev@openvswitch.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dev-bounces@openvswitch.org Sender: "dev" 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 --- tests/interface-reconfigure.at | 16 ++++++++-------- xenserver/opt_xensource_libexec_InterfaceReconfigure.py | 11 +++++++++-- .../opt_xensource_libexec_InterfaceReconfigureVswitch.py | 2 +- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/tests/interface-reconfigure.at b/tests/interface-reconfigure.at index bb3756be2f82..b4e455d94228 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 f37e038635de..9cdb3bc27fa6 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 30fc176694a9..d70c249146fb 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])