xenserver: Hoist identical bridge and vswitch functions into common code.
authorBen Pfaff <blp@nicira.com>
Tue, 23 Feb 2010 17:47:31 +0000 (09:47 -0800)
committerBen Pfaff <blp@nicira.com>
Tue, 23 Feb 2010 17:52:13 +0000 (09:52 -0800)
The previous commit made pif_bridge_name() in the bridge and vswitch
versions of interface-reconfigure functionally identical, so this commit
hoists them into a single common implementation in InterfaceReconfigure.py.

pif_is_bridged() also comes along for the ride because it is also generic
and because it is logically related.  Only the bridge code uses it at the
moment.

Suggested-by: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
xenserver/opt_xensource_libexec_InterfaceReconfigure.py
xenserver/opt_xensource_libexec_InterfaceReconfigureBridge.py
xenserver/opt_xensource_libexec_InterfaceReconfigureVswitch.py

index 33f541a103b4c2ee3f9db3d750f4c60910b19589..3847cb65b40bbfdc853717a41bf88855f26f4f2d 100644 (file)
@@ -637,6 +637,34 @@ def pif_netdev_name(pif):
     else:
         return pifrec['device']
 
+#
+# Bridges
+#
+
+def pif_is_bridged(pif):
+    pifrec = db().get_pif_record(pif)
+    nwrec = db().get_network_record(pifrec['network'])
+
+    if nwrec['bridge']:
+        # TODO: sanity check that nwrec['bridgeless'] != 'true'
+        return True
+    else:
+        # TODO: sanity check that nwrec['bridgeless'] == 'true'
+        return False
+
+def pif_bridge_name(pif):
+    """Return the bridge name of a pif.
+
+    PIF must be a bridged PIF."""
+    pifrec = db().get_pif_record(pif)
+
+    nwrec = db().get_network_record(pifrec['network'])
+
+    if nwrec['bridge']:
+        return nwrec['bridge']
+    else:
+        raise Error("PIF %(uuid)s does not have a bridge name" % pifrec)
+
 #
 # Bonded PIFs
 #
index 0fa9322d49f770a64a532e0b905f065af0770992..783fad301a9c76a85b8387029cf60b1294915612 100644 (file)
@@ -135,34 +135,6 @@ def destroy_bond_device(pif):
 
     __destroy_bond_device(name)
 
-#
-# Bridges
-#
-
-def pif_is_bridged(pif):
-    pifrec = db().get_pif_record(pif)
-    nwrec = db().get_network_record(pifrec['network'])
-
-    if nwrec['bridge']:
-        # TODO: sanity check that nwrec['bridgeless'] != 'true'
-        return True
-    else:
-        # TODO: sanity check that nwrec['bridgeless'] == 'true'
-        return False
-
-def pif_bridge_name(pif):
-    """Return the bridge name of a pif.
-
-    PIF must be a bridged PIF."""
-    pifrec = db().get_pif_record(pif)
-
-    nwrec = db().get_network_record(pifrec['network'])
-
-    if nwrec['bridge']:
-        return nwrec['bridge']
-    else:
-        raise Error("PIF %(uuid)s does not have a bridge name" % pifrec)
-
 #
 # Bring Interface up/down.
 #
index f777b178712179124741aca5df8131ba72e5909a..41acf58b087b1636a40c7fc139263cc21eca5c27 100644 (file)
@@ -36,22 +36,6 @@ def netdev_up(netdev, mtu=None):
 
     run_command(["/sbin/ifconfig", netdev, 'up'] + mtu)
 
-#
-# Bridges
-#
-
-def pif_bridge_name(pif):
-    """Return the bridge name of a pif.
-
-    PIF must be a bridged PIF."""
-
-    pifrec = db().get_pif_record(pif)
-    nwrec = db().get_network_record(pifrec['network'])
-    if nwrec['bridge']:
-        return nwrec['bridge']
-    else:
-        raise Error("PIF %(uuid)s does not have a bridge name" % pifrec)
-
 #
 # PIF miscellanea
 #