]> xenbits.xensource.com Git - xcp/xen-api.git/commitdiff
[PATCH] xenserver: Hoist identical bridge and vswitch functions into common code.
authorBen Pfaff <blp@nicira.com>
Thu, 8 Jul 2010 13:25:51 +0000 (14:25 +0100)
committerBen Pfaff <blp@nicira.com>
Thu, 8 Jul 2010 13:25:51 +0000 (14:25 +0100)
From 96c7918c4043326bfa0e05b3fc9cbb9547279d40 Mon Sep 17 00:00:00 2001
Date: Tue, 23 Feb 2010 09:47:31 -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>
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
---
 .../opt_xensource_libexec_InterfaceReconfigure.py  |   28 ++++++++++++++++++++
 ...xensource_libexec_InterfaceReconfigureBridge.py |   28 --------------------
 ...ensource_libexec_InterfaceReconfigureVswitch.py |   16 -----------
 3 files changed, 28 insertions(+), 44 deletions(-)

scripts/InterfaceReconfigure.py
scripts/InterfaceReconfigureBridge.py
scripts/InterfaceReconfigureVswitch.py

index 8f04bb8d70f5df5d9d52f009f18841d9902b5a78..78b7ab9349d49f70350020bb40272b5c277bc7bd 100644 (file)
@@ -658,6 +658,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 99e78c152904550b7d34f9b4228b63a053fd8946..dba3c7050af4142d6dc8204091574980b2f0ba1e 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 13bee08363a1d809aecf6193e319faa6c861488c..f63cf7d3c157da8910cf144799bdadce89f3d578 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
 #