warewulf / warewulf3

Warewulf is a scalable systems management suite originally developed to manage large high-performance Linux clusters.
107 stars 45 forks source link

Support Fallback to Matching Bond Devices Against HWADDR #304

Open bensallen opened 2 years ago

bensallen commented 2 years ago

Similar to what is currently done for normal interfaces at https://github.com/warewulf/warewulf3/blob/development/provision/initramfs/init#L428, fallback to matching against HWADDR for bonding devices. Currently only interface names are matched against in bondup().

bensallen commented 2 years ago

Will generalize https://github.com/warewulf/warewulf3/blob/development/provision/initramfs/init#L428 into a function so it can be called there and within bondup. Something like:

find_interface() {
    local HWADDR=$1
    local DEV 
    for DEV in $(echo /sys/class/net/* | xargs -n1 /usr/bin/basename | grep -v lo); do
        local DEVHWADDR=$(cat /sys/class/net/$DEV/address)
        # Use GUID if IB
        if [ ${#DEVHWADDR} -eq 59 ]; then
            DEVHWADDR=$(expr substr $DEVHWADDR 37 23)
        fi
        if [ $DEVHWADDR == $HWADDR ]; then
            echo $DEV
            return 0
        fi
    done
    return 1
}