Change in vdsm[master]: bootstrap: node id: consider bonding MAC addresses as well

Alon Bar-Lev alonbl at redhat.com
Wed Aug 29 20:52:53 UTC 2012


Alon Bar-Lev has uploaded a new change for review.

Change subject: bootstrap: node id: consider bonding MAC addresses as well
......................................................................

bootstrap: node id: consider bonding MAC addresses as well

The node id is constructed using the lowest MAC address.

If bonding is applied after initial node id was taken, it may shade the
minimal address.

This change adds to the MAC addresses of bonding interfaces to the MAC
address addresses to consider.

Sync with engine command used for same purpose.

Change-Id: Iae0713f95c25e3e05b24bf8254499e4cd8e64d10
Signed-off-by: Alon Bar-Lev <alonbl at redhat.com>
---
M vdsm_reg/deployUtil.py.in
1 file changed, 26 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/96/7596/1

diff --git a/vdsm_reg/deployUtil.py.in b/vdsm_reg/deployUtil.py.in
index e22bfb5..fc7df29 100644
--- a/vdsm_reg/deployUtil.py.in
+++ b/vdsm_reg/deployUtil.py.in
@@ -290,13 +290,36 @@
     return strReturn
 
 def getMacs():
+
+    # (
+    #     find /sys/class/net/*/device | while read f; do \
+    #         cat "$(dirname "$f")/address"; \
+    #     done; \
+    #     [ -d /proc/net/bonding ] && \
+    #         find /proc/net/bonding -type f -exec cat '{}' \; | \
+    #         grep 'Permanent HW addr:' | \
+    #         sed 's/.* //'
+    # ) | sed -e '/00:00:00:00/d' -e '/^$/d'
+
     macs = []
     for b in glob.glob('/sys/class/net/*/device'):
-        nic = b.split('/')[-2]
-        addr = '/sys/class/net/' + nic + '/address'
-        mac = file(addr).readlines()[0].split()[0]
+        mac = file(os.path.join(os.path.dirname(b), "address")). \
+            readline().replace("\n", "")
         macs.append(mac)
 
+    for b in glob.glob('/proc/net/bonding/*'):
+        lines = file(b).readlines()
+        try:
+            line = (string for i, string in enumerate(lines) \
+                if "Permanent HW addr: " in string).next()
+            macs.append(line.split(": ")[1].replace("\n", ""))
+        except StopIteration:
+            pass
+
+    for r in ("", "00:00:00:00:00:00"):
+        while macs.count(r):
+            macs.remove(r)
+
     return macs
 
 def getHostID():


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iae0713f95c25e3e05b24bf8254499e4cd8e64d10
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Alon Bar-Lev <alonbl at redhat.com>


More information about the vdsm-patches mailing list