xenserver: dbcache should always exist so don't bother checking.
[sliver-openvswitch.git] / xenserver / opt_xensource_libexec_InterfaceReconfigureVswitch.py
index 6a1d4ed..6c9e3fa 100644 (file)
@@ -351,6 +351,7 @@ def configure_datapath(pif):
 
     pool = db().get_pool_record()
     network = db().get_network_by_bridge(bridge)
+    network_rec = None
     fail_mode = None
     valid_fail_modes = ['standalone', 'secure']
 
@@ -366,6 +367,15 @@ def configure_datapath(pif):
 
     vsctl_argv += ['--', 'set', 'Bridge', bridge, 'fail_mode=%s' % fail_mode]
 
+    if network_rec:
+        dib = network_rec['other_config'].get('vswitch-disable-in-band')
+        if not dib:
+            vsctl_argv += ['--', 'remove', 'Bridge', bridge, 'other_config', 'disable-in-band']
+        elif dib in ['true', 'false']:
+            vsctl_argv += ['--', 'set', 'Bridge', bridge, 'other_config:disable-in-band=' + dib]
+        else:
+            log('"' + dib + '"' "isn't a valid setting for other_config:disable-in-band on " + bridge)
+
     vsctl_argv += set_br_external_ids(pif)
     vsctl_argv += ['## done configuring datapath %s' % bridge]
 
@@ -465,6 +475,10 @@ class DatapathVswitch(Datapath):
         dpname = pif_bridge_name(self._dp)
         
         if pif_is_vlan(self._pif):
+            # In some cases XAPI may misguidedly leave an instance of
+            # 'bridge' which should be deleted.
+            vsctl_argv += ['--', '--if-exists', 'del-br', bridge]
+
             # configure_datapath() set up the underlying datapath bridge.
             # Stack a VLAN bridge on top of it.
             vsctl_argv += ['--', '--may-exist', 'add-br',