From patchwork Wed Sep 18 15:47:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Pfaff X-Patchwork-Id: 1164171 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ovn.org Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46YSYh2Chhz9sNw for ; Thu, 19 Sep 2019 04:04:56 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id BDA65DD9; Wed, 18 Sep 2019 18:02:58 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id B5715DB3 for ; Wed, 18 Sep 2019 18:02:56 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id CA4D282F for ; Wed, 18 Sep 2019 18:02:55 +0000 (UTC) X-Originating-IP: 66.170.99.95 Received: from localhost.localdomain (unknown [66.170.99.95]) (Authenticated sender: blp@ovn.org) by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id 8C8EB2000C; Wed, 18 Sep 2019 18:02:53 +0000 (UTC) From: Ben Pfaff To: dev@openvswitch.org Date: Wed, 18 Sep 2019 08:47:54 -0700 Message-Id: <20190918154755.16387-4-blp@ovn.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190918154755.16387-1-blp@ovn.org> References: <20190918154755.16387-1-blp@ovn.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Ben Pfaff Subject: [ovs-dev] [PATCH python3 3/4] xenserver: Make Python files parse in Python 3 also. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org I don't actually have any idea whether XenServer has moved forward to Python 3 these days, but these files are still OK in Python 2.x as well. The rest of the Python files in OVS seem to already be OK in Python 3. Signed-off-by: Ben Pfaff --- ...xensource_libexec_InterfaceReconfigureBridge.py | 10 +++++----- ..._lib_xsconsole_plugins-base_XSFeatureVSwitch.py | 14 +++++++------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/xenserver/opt_xensource_libexec_InterfaceReconfigureBridge.py b/xenserver/opt_xensource_libexec_InterfaceReconfigureBridge.py index a93e438667de..5cc22319a9eb 100644 --- a/xenserver/opt_xensource_libexec_InterfaceReconfigureBridge.py +++ b/xenserver/opt_xensource_libexec_InterfaceReconfigureBridge.py @@ -65,7 +65,7 @@ def load_bonding_driver(): f = open(sysfs_bonding_masters, "w") f.write("-bond0") f.close() - except IOError, e: + except IOError as e: log("Failed to load bonding driver: %s" % e) def bonding_driver_loaded(): @@ -92,7 +92,7 @@ def __create_bond_device(name): f = open(sysfs_bonding_masters, "w") f.write("+" + name) f.close() - except IOError, e: + except IOError as e: log("Failed to create %s: %s" % (name, e)) def create_bond_device(pif): @@ -114,7 +114,7 @@ def __destroy_bond_device(name): f.write("-" + name) f.close() retries = 0 - except IOError, e: + except IOError as e: time.sleep(0.5) else: log("bond master %s does not exist, not destroying" % name) @@ -355,8 +355,8 @@ def _configure_bond_interface(pif): # override defaults with values from other-config whose keys being with "bond-" oc = pifrec['other_config'] - overrides = filter(lambda (key,val): key.startswith("bond-"), oc.items()) - overrides = map(lambda (key,val): (key[5:], val), overrides) + overrides = filter(lambda key,val: key.startswith("bond-"), oc.items()) + overrides = map(lambda key,val: (key[5:], val), overrides) bond_options.update(overrides) # write the bond options to ifcfg-bondX diff --git a/xenserver/usr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py b/xenserver/usr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py index fdbbc0ed4c89..8946917d526e 100644 --- a/xenserver/usr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py +++ b/xenserver/usr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py @@ -39,7 +39,7 @@ class VSwitchService: def version(self): try: output = ShellPipe(["service", self.name, "version"]).Stdout() - except StandardError, e: + except StandardError as e: XSLogError("vswitch version retrieval error: " + str(e)) return "" for line in output: @@ -50,7 +50,7 @@ class VSwitchService: def status(self): try: output = ShellPipe(["service", self.name, "status"]).Stdout() - except StandardError, e: + except StandardError as e: XSLogError("vswitch status retrieval error: " + str(e)) return "" if len(output) == 0: @@ -69,7 +69,7 @@ class VSwitchService: def restart(self): try: ShellPipe(["service", self.name, "restart"]).Call() - except StandardError, e: + except StandardError as e: XSLogError("vswitch restart error: " + str(e)) @classmethod @@ -88,7 +88,7 @@ class VSwitchConfig: try: arg = [vsctl, "-vconsole:off"] + action.split() output = ShellPipe(arg).Stdout() - except StandardError, e: + except StandardError as e: XSLogError("config retrieval error: " + str(e)) return "" @@ -189,7 +189,7 @@ class VSwitchControllerDialogue(Dialogue): try: self.SetController(self.controller) Layout.Inst().PushDialogue(InfoDialogue(Lang("Setting controller successful"))) - except Exception, e: + except Exception as e: Layout.Inst().PushDialogue(InfoDialogue(Lang("Setting controller failed"))) self.ChangeState("INITIAL") @@ -213,7 +213,7 @@ class VSwitchControllerDialogue(Dialogue): try: self.SetController(None) Layout.Inst().PushDialogue(InfoDialogue(Lang("Controller deletion successful"))) - except Exception, e: + except Exception as e: Layout.Inst().PushDialogue(InfoDialogue(Lang("Controller deletion failed"))) def syncController(self): @@ -222,7 +222,7 @@ class VSwitchControllerDialogue(Dialogue): try: Task.Sync(lambda s: self._updateThisServer(s)) Layout.Inst().PushDialogue(InfoDialogue(Lang("Resyncing controller config successful"))) - except Exception, e: + except Exception as e: Layout.Inst().PushDialogue(InfoDialogue(Lang("Resyncing controller config failed"))) def SetController(self, ip):