[ovs-dev] [PATCH python3 3/4] xenserver: Make Python files parse in Python 3 also.

Ben Pfaff blp at ovn.org
Wed Sep 18 15:47:54 UTC 2019


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 <blp at ovn.org>
---
 ...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 "<unknown>"
         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 "<unknown>"
         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 "<unknown>"
 
@@ -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):
-- 
2.21.0



More information about the dev mailing list