WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-api

[Xen-API] [PATCH 28 of 33] interface-reconfigure: do not sort the result

To: xen-api@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-API] [PATCH 28 of 33] interface-reconfigure: do not sort the result in pif_get_bond_slaves
From: Ian Campbell <ian.campbell@xxxxxxxxxx>
Date: Fri, 18 Dec 2009 14:17:23 +0000
Cc: Ian Campbell <ian.campbell@xxxxxxxxxx>
Delivery-date: Fri, 18 Dec 2009 06:22:37 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <patchbomb.1261145815@xxxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-api-request@lists.xensource.com?subject=help>
List-id: Discussion of API issues surrounding Xen <xen-api.lists.xensource.com>
List-post: <mailto:xen-api@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-api-bounces@xxxxxxxxxxxxxxxxxxx
it is only required in one caller so perform the sort there.

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>

diff -r 7fbd1addf5d8 -r 7eba221bc261 scripts/InterfaceReconfigure.py
--- a/scripts/InterfaceReconfigure.py   Fri Dec 18 14:16:32 2009 +0000
+++ b/scripts/InterfaceReconfigure.py   Fri Dec 18 14:16:32 2009 +0000
@@ -449,23 +449,7 @@
     if not bondrec:
         raise Error("No bond record for bond master PIF")
 
-    # build a list of slave's pifs
-    slave_pifs = bondrec['slaves']
-
-    # Ensure any currently attached slaves are listed in the opposite order to 
the order in
-    # which they were attached.  The first slave attached must be the last 
detached since
-    # the bond is using its MAC address.
-    try:
-        attached_slaves = open("/sys/class/net/%s/bonding/slaves" % 
pifrec['device']).readline().split()
-        for slave in attached_slaves:
-            pifs = [p for p in db().get_pifs_by_device(slave) if not 
pif_is_vlan(p)]
-            slave_pif = pifs[0]
-            slave_pifs.remove(slave_pif)
-            slave_pifs.insert(0, slave_pif)
-    except IOError:
-        pass
-
-    return slave_pifs
+    return bondrec['slaves']
 
 #
 # VLAN PIFs
diff -r 7fbd1addf5d8 -r 7eba221bc261 scripts/interface-reconfigure
--- a/scripts/interface-reconfigure     Fri Dec 18 14:16:32 2009 +0000
+++ b/scripts/interface-reconfigure     Fri Dec 18 14:16:32 2009 +0000
@@ -570,6 +570,27 @@
             log("Invalid value for mtu = %s" % oc['mtu'])
     return None
 
+def pif_get_bond_slaves_sorted(pif):
+    pifrec = db().get_pif_record(pif)
+
+    # build a list of slave's pifs
+    slave_pifs = pif_get_bond_slaves(pif)
+
+    # Ensure any currently attached slaves are listed in the opposite order to 
the order in
+    # which they were attached.  The first slave attached must be the last 
detached since
+    # the bond is using its MAC address.
+    try:
+        attached_slaves = open("/sys/class/net/%s/bonding/slaves" % 
pifrec['device']).readline().split()
+        for slave in attached_slaves:
+            pifs = [p for p in db().get_pifs_by_device(slave) if not 
pif_is_vlan(p)]
+            slave_pif = pifs[0]
+            slave_pifs.remove(slave_pif)
+            slave_pifs.insert(0, slave_pif)
+    except IOError:
+        pass
+
+    return slave_pifs
+
 def configure_bond_interface(pif):
     """Write the configuration for a bond interface.
 
@@ -755,7 +776,7 @@
 
     # Need to bring down bond slaves first since the bond device
     # must be up to enslave/unenslave.
-    bond_slaves = pif_get_bond_slaves(pif)
+    bond_slaves = pif_get_bond_slaves_sorted(pif)
     log("bond slaves of %s - %s" % (db().get_pif_record(pif)['device'], 
[pif_netdev_name(s) for s in bond_slaves]))
     for slave in bond_slaves:
         slave_interface = pif_netdev_name(slave)

_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/mailman/listinfo/xen-api

<Prev in Thread] Current Thread [Next in Thread>