datapath: Put return type on same line as arguments for functions.
[openvswitch] / xenserver / opt_xensource_libexec_InterfaceReconfigureVswitch.py
index c31fa2dbf98eeffbb04bcbd6ef361298f14a3dba..1e45759adf15ffcb006c13bf13c46598a6049872 100644 (file)
@@ -12,6 +12,7 @@
 # GNU Lesser General Public License for more details.
 #
 from InterfaceReconfigure import *
+import os
 import re
 
 #
@@ -367,6 +368,13 @@ class DatapathVswitch(Datapath):
 
     @classmethod
     def rewrite(cls):
+        if not os.path.exists("/var/run/openvswitch/db.sock"):
+            # ovsdb-server is not running, so we can't update the database.
+            # Probably we are being called as part of system shutdown.  Just
+            # skip the update, since the external-ids will be updated on the
+            # next boot anyhow.
+            return
+
         vsctl_argv = []
         for pif in db().get_all_pifs():
             pifrec = db().get_pif_record(pif)
@@ -421,7 +429,18 @@ class DatapathVswitch(Datapath):
         self._extra_ports = extra_ports
 
     def bring_down_existing(self):
-        pass
+        # interface-reconfigure is never explicitly called to down a
+        # bond master.  However, when we are called to up a slave it
+        # is implicit that we are destroying the master.
+        #
+        # This is (only) important in the case where the bond master
+        # uses DHCP.  We need to kill the dhclient process, otherwise
+        # bringing the bond master back up later will fail because
+        # ifup will refuse to start a duplicate dhclient.
+        bond_masters = pif_get_bond_masters(self._pif)
+        for master in bond_masters:
+            log("action_up: bring down bond master %s" % (pif_netdev_name(master)))
+            run_command(["/sbin/ifdown", pif_bridge_name(master)])
 
     def configure(self):
         # Bring up physical devices. ovs-vswitchd initially enables or