Alon Bar-Lev has uploaded a new change for review.
Change subject: bootstrap: sync utils.getHostUUID() with deployUtil.getHostID()
......................................................................
bootstrap: sync utils.getHostUUID() with deployUtil.getHostID()
Apparently, the host id is gotten in three different places:
1. Engine VdsInstaller::ConfigValues.BootstrapNodeIDCommand
2. deployUtil.getHostID()
3. utils.getHostUUID()
Change-Id Iae0713f95 did not handle (3).
Change-Id: I0c99fb4e99ca951e1daf4e856fc473ba82088d1c
Signed-off-by: Alon Bar-Lev <alonbl(a)redhat.com>
---
M vdsm/utils.py
1 file changed, 26 insertions(+), 2 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/59/7659/1
diff --git a/vdsm/utils.py b/vdsm/utils.py
index 5e2d4e5..02db29f 100644
--- a/vdsm/utils.py
+++ b/vdsm/utils.py
@@ -36,6 +36,7 @@
import fcntl
import functools
import stat
+import glob
import ethtool
@@ -663,6 +664,30 @@
except:
return False
+def _getAllMacs():
+
+ # (
+ # 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'):
+ mac = file(os.path.join(os.path.dirname(b), "address")). \
+ readline().replace("\n", "")
+ macs.append(mac)
+
+ for b in glob.glob('/proc/net/bonding/*'):
+ for line in file(b):
+ if line.startswith("Permanent HW addr: "):
+ macs.append(line.split(": ")[1].replace("\n",
""))
+
+ return set(macs) - set(["", "00:00:00:00:00:00"])
__hostUUID = ''
def getHostUUID():
@@ -687,9 +712,8 @@
else:
logging.warning('Could not find host UUID.')
- nics = netinfo.get()['nics']
try:
- mac = sorted([v['hwaddr'] for v in nics.itervalues()])[0]
+ mac = sorted(_getAllMacs())[0]
except:
mac = ""
logging.warning('Could not find host MAC.', exc_info=True)
--
To view, visit
http://gerrit.ovirt.org/7659
To unsubscribe, visit
http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0c99fb4e99ca951e1daf4e856fc473ba82088d1c
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Alon Bar-Lev <alonbl(a)redhat.com>