ofctl: Improve manpage.
[openvswitch] / xenserver / opt_xensource_libexec_InterfaceReconfigureVswitch.py
index c336041145e096fd46ebe2b92ae6f3f49de06e97..0d14251bff2b7f615cd9986d4d479de09b42154e 100644 (file)
@@ -171,10 +171,13 @@ def configure_datapath(pif):
     vsctl_argv = []
     extra_up_ports = []
 
+    assert not pif_is_vlan(pif)
     bridge = pif_bridge_name(pif)
 
     physical_devices = datapath_get_physical_pifs(pif)
 
+    vsctl_argv += ['## configuring datapath %s' % bridge]
+
     # Determine additional devices to deconfigure.
     #
     # Given all physical devices which are part of this PIF we need to
@@ -257,31 +260,41 @@ def configure_datapath(pif):
         vsctl_argv += ['# add physical device %s' % iface]
         vsctl_argv += ['--', '--may-exist', 'add-port', bridge, iface]
 
+    vsctl_argv += set_br_external_ids(pif)
+    vsctl_argv += ['## done configuring datapath %s' % bridge]
+
     return vsctl_argv,extra_up_ports
 
-def deconfigure_datapath(pif):
+def deconfigure_bridge(pif):
     vsctl_argv = []
 
     bridge = pif_bridge_name(pif)
 
-    physical_devices = datapath_get_physical_pifs(pif)
+    log("deconfigure_bridge: bridge           - %s" % bridge)
 
-    log("deconfigure_datapath: bridge           - %s" % bridge)
-    log("deconfigure_datapath: physical devices - %s" % [pif_netdev_name(p) for p in physical_devices])
+    vsctl_argv += ['# deconfigure bridge %s' % bridge]
+    vsctl_argv += ['--', '--if-exists', 'del-br', bridge]
 
-    for p in physical_devices:
-        dev = pif_netdev_name(p)
-        vsctl_argv += ['# deconfigure physical port %s' % dev]
-        vsctl_argv += datapath_deconfigure_physical(dev)
-        netdev_down(dev)
+    return vsctl_argv
 
-    if len(physical_devices) > 1:
-        vsctl_argv += ['# deconfigure bond %s' % pif_netdev_name(pif)]
-        vsctl_argv += datapath_deconfigure_bond(pif_netdev_name(pif))
+def set_br_external_ids(pif):
+    xs_network_uuids = []
+    for nwpif in db().get_pifs_by_device(db().get_pif_record(pif)['device']):
+        rec = db().get_pif_record(nwpif)
 
-    vsctl_argv += ['# deconfigure bridge %s' % bridge]
-    vsctl_argv += ['--', '--if-exists', 'del-br', bridge]
+        # When state is read from dbcache PIF.currently_attached
+        # is always assumed to be false... Err on the side of
+        # listing even detached networks for the time being.
+        #if nwpif != pif and not rec['currently_attached']:
+        #    log("Network PIF %s not currently attached (%s)" % (rec['uuid'],pifrec['uuid']))
+        #    continue
+        nwrec = db().get_network_record(rec['network'])
+        xs_network_uuids += [nwrec['uuid']]
 
+    vsctl_argv = []
+    vsctl_argv += ['# configure xs-network-uuids']
+    vsctl_argv += ['--', 'br-set-external-id', pif_bridge_name(pif),
+            'xs-network-uuids', ';'.join(xs_network_uuids)]
     return vsctl_argv
 
 #
@@ -324,22 +337,8 @@ class DatapathVswitch(Datapath):
             # Stack a VLAN bridge on top of it.
             vsctl_argv += ['--', '--may-exist', 'add-br',
                            bridge, pif_bridge_name(self._dp), pifrec['VLAN']]
-        xs_network_uuids = []
-        for nwpif in db().get_pifs_by_device(db().get_pif_record(self._pif)['device']):
-            rec = db().get_pif_record(nwpif)
-
-            # When state is read from dbcache PIF.currently_attached
-            # is always assumed to be false... Err on the side of
-            # listing even detached networks for the time being.
-            #if nwpif != pif and not rec['currently_attached']:
-            #    log("Network PIF %s not currently attached (%s)" % (rec['uuid'],pifrec['uuid']))
-            #    continue
-            nwrec = db().get_network_record(rec['network'])
-            xs_network_uuids += [nwrec['uuid']]
-
-        vsctl_argv += ['# configure xs-network-uuids']
-        vsctl_argv += ['--', 'br-set-external-id', bridge,
-                'xs-network-uuids', ';'.join(xs_network_uuids)]
+
+            vsctl_argv += set_br_external_ids(self._pif)
 
         if ipdev != bridge:
             vsctl_argv += ["# deconfigure ipdev %s" % ipdev]
@@ -367,11 +366,12 @@ class DatapathVswitch(Datapath):
         physical_devices = datapath_get_physical_pifs(self._dp)
         
         for p in physical_devices:
-            oc = db().get_pif_record(p)['other_config']
+            prec = db().get_pif_record(p)
+            oc = prec['other_config']
 
             dev = pif_netdev_name(p)
 
-            mtu = mtu_setting(oc)
+            mtu = mtu_setting(prec['network'], "PIF", oc)
 
             netdev_up(dev, mtu)
 
@@ -406,6 +406,9 @@ class DatapathVswitch(Datapath):
         vsctl_argv += datapath_deconfigure_ipdev(ipdev)
 
         if pif_is_vlan(self._pif):
+            # Delete the VLAN bridge.
+            vsctl_argv += deconfigure_bridge(self._pif)
+
             # If the VLAN's slave is attached, leave datapath setup.
             slave = pif_get_vlan_slave(self._pif)
             if db().get_pif_record(slave)['currently_attached']:
@@ -429,6 +432,6 @@ class DatapathVswitch(Datapath):
                 dp = None
 
         if dp:
-            vsctl_argv += deconfigure_datapath(dp)
+            vsctl_argv += deconfigure_bridge(dp)
 
         datapath_modify_config(vsctl_argv)