Dan Kenigsberg has uploaded a new change for review.

Change subject: net: drop nicSort
......................................................................

net: drop nicSort

nicSort was introduced so that vdsm calls ifup on bonded nics in the
same order that initscripts does it, in order to obtain the same master
mac address.

A simpler and safer solution is to delegate ifup of bonded nics to
initscripts, which does that when we ifup the bond device.

In this commit we drop nicSort together with its remaining usage.

Change-Id: If8fdbb281030ab7f0eec38481045dbd6c2603ce1
Signed-off-by: Dan Kenigsberg <[email protected]>
---
M tests/configNetworkTests.py
M vdsm/configNetwork.py
2 files changed, 4 insertions(+), 43 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/85/10585/1

diff --git a/tests/configNetworkTests.py b/tests/configNetworkTests.py
index bf836ac..f8221d5 100644
--- a/tests/configNetworkTests.py
+++ b/tests/configNetworkTests.py
@@ -65,15 +65,6 @@
         if inspect.getargspec(self.assertRaises)[3] is None:
             self.assertRaises = self._assertRaises
 
-    def testNicSort(self):
-        nics = {'nics_init': ('p33p1', 'eth1', 'lan0', 'em0', 'p331',
-                              'Lan1', 'eth0', 'em1', 'p33p2', 'p33p10'),
-                'nics_expected': ('Lan1', 'em0', 'em1', 'eth0', 'eth1',
-                                  'lan0', 'p33p1', 'p33p10', 'p33p2', 'p331')}
-
-        nics_res = configNetwork.nicSort(nics['nics_init'])
-        self.assertEqual(nics['nics_expected'], tuple(nics_res))
-
     def testIsBridgeNameValid(self):
         invalidBrName = ('-abc', 'abcdefghijklmnop', 'a:b', 'a.b')
         for i in invalidBrName:
diff --git a/vdsm/configNetwork.py b/vdsm/configNetwork.py
index 7a076f9..57dcddc 100755
--- a/vdsm/configNetwork.py
+++ b/vdsm/configNetwork.py
@@ -133,39 +133,6 @@
     users.discard(owner)
     return users
 
-# This function must respect the order used in:
-#
-#   /etc/rc.d/init.d/network
-#
-#   echo -e "ifcfg-eth0\nifcfg-eth1" \
-#       | sed -e '/ifcfg-[A-Za-z0-9#\._-]\+$/ { s/^ifcfg-//g;s/[0-9]/ &/}' \
-#       | sort -k 1,1 -k 2n
-#
-# Relevant cases:
-#   nicSort(["p33p2", "p33p10"]) => ["p33p10", "p33p2"]
-#   nicSort(["p331", "p33p1"]) => ["p33p1", "p331"]
-#
-
-
-def nicSort(nics):
-    "Return a list of nics/interfaces ordered by name"
-
-    nics_list = []
-    nics_rexp = re.compile("^(\D*)(\d*)(.*)$")
-
-    for nic_name in nics:
-        nic_sre = nics_rexp.match(nic_name)
-        prefix, stridx, postfix = nic_sre.groups((nic_name, "0", ""))
-
-        try:
-            intidx = int(stridx)
-        except ValueError:
-            intidx = 0
-
-        nics_list.append((prefix, intidx, stridx + postfix))
-
-    return [x + z for x, y, z in sorted(nics_list)]
-
 
 class ConfigWriter(object):
     CONFFILE_HEADER = '# automatically generated by vdsm'
@@ -331,12 +298,15 @@
             return "Bridge"
         elif re.search('^VLAN=yes$', content, re.MULTILINE):
             return "Vlan"
+        elif re.search('^SLAVE=yes$', content, re.MULTILINE):
+            return "Slave"
         else:
             return "Other"
 
     def _sortModifiedIfcfgs(self):
         devdict = {'Bridge': [],
                    'Vlan': [],
+                   'Slave': [],
                    'Other': []}
         for confFile, _ in self._backups.iteritems():
             try:
@@ -350,7 +320,7 @@
 
             devdict[self._devType(content)].append(dev)
 
-        return nicSort(devdict['Other']) + devdict['Vlan'] + devdict['Bridge']
+        return devdict['Other'] + devdict['Vlan'] + devdict['Bridge']
 
     def _stopAtomicDevices(self):
         for dev in reversed(self._sortModifiedIfcfgs()):


--
To view, visit http://gerrit.ovirt.org/10585
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If8fdbb281030ab7f0eec38481045dbd6c2603ce1
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Dan Kenigsberg <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to