[Ovirt-devel] [PATCH node] Changes how macs are collected by ovirt-early.

Darryl L. Pierce dpierce at redhat.com
Tue Mar 31 16:11:27 UTC 2009


NOTE: this patch incorporates feedback from apevec to filter out both
      the admin NIC and the loopback NIC, along with any NIC that returns
      an invalid mac address of "00:00:00:00:00:00".

Instead of checking for those devices that are currently active, it
instead uses the list of network devices reported by sysfs. It then
iterates over that list and gets the mac address.

Signed-off-by: Darryl L. Pierce <dpierce at redhat.com>
---
 scripts/ovirt-early |   18 +++++++++++++++---
 1 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/scripts/ovirt-early b/scripts/ovirt-early
index 9ab2981..6421192 100755
--- a/scripts/ovirt-early
+++ b/scripts/ovirt-early
@@ -14,8 +14,20 @@ BONDING_MODCONF_FILE=/etc/modprobe.d/bonding
 AUGTOOL_CONFIG=/var/tmp/augtool-config
 
 get_mac_addresses() {
-    macs=$(ifconfig | awk '/HWaddr/ { print $5"="$1 }' \
-                    | tr '\n' ' ' | sed 's/ /%2C/g;s/:/%3A/g')
+    local DEVICE=$1
+
+    macs=""
+    devices=$(ls -b /sys/class/net/)
+    for device in $devices; do
+	if [ "$device" != "$DEVICE" ]; then
+	    mac=$(cat /sys/class/net/$device/address)
+	    if [ -n "$mac" -a "$mac" != "00:00:00:00:00:00" ]; then
+		iface=$device
+		macs="${macs}${mac}=${iface} "
+	    fi
+	fi
+    done
+    macs=$(echo $macs | sed 's/ /%2C/g;s/:/%3A/g;s/=/%3D/g')
 }
 
 configure_from_network() {
@@ -37,7 +49,7 @@ configure_from_network() {
                 if [ -n "$SRV_HOST" -a -n "$SRV_PORT" ]; then
                     log "oVirt Server found at: $SRV_HOST:$SRV_PORT"
                     cfgdb=$(mktemp)
-                    get_mac_addresses
+                    get_mac_addresses $DEVICE
                     log "MACs to use: $macs"
                     wget -O $cfgdb --no-check-certificate \
                       "http://$SRV_HOST:$SRV_PORT/ovirt/managed_node/config?host=$(hostname)&macs=$macs"
-- 
1.6.0.6




More information about the ovirt-devel mailing list