Blame SOURCES/cobbler-rhel7-snippets.patch

1330ca
--- a/snippets/post_install_network_config	
1330ca
+++ a/snippets/post_install_network_config	
1330ca
@@ -147,7 +147,7 @@ fi
1330ca
         #if $configbymac and $is_vlan == "false" and $bonding.lower() != "master"
1330ca
             ## This is the code path physical interfaces will follow.
1330ca
             ## Get the current interface name
1330ca
-IFNAME=\$(ifconfig -a | grep -i '$mac' | cut -d ' ' -f 1)
1330ca
+IFNAME=\$(ip -o link | grep -i '$mac' | sed -e 's/^[0-9]*: //' -e 's/:.*//')
1330ca
             ## Rename this interface in modprobe.conf
1330ca
             ## FIXME: if both interfaces startwith eth this is wrong
1330ca
 if [ -f "/etc/modprobe.conf" ] && [ \$IFNAME ]; then
1330ca
--- a/snippets/pre_install_network_config	
1330ca
+++ a/snippets/pre_install_network_config	
1330ca
@@ -1,5 +1,27 @@ 
1330ca
 #if $getVar("system_name","") != ""
1330ca
 # Start pre_install_network_config generated code
1330ca
+#raw
1330ca
+# generic functions to be used later for discovering NICs
1330ca
+mac_exists() {
1330ca
+  if which ip &> /dev/null; then
1330ca
+    ip -o link | grep -i "$1" &> /dev/null
1330ca
+    return $?
1330ca
+  else
1330ca
+    ifconfig -a | grep -i "$1" &> /dev/null
1330ca
+    return $?
1330ca
+  fi
1330ca
+}
1330ca
+get_ifname() {
1330ca
+  if which ip &> /dev/null; then
1330ca
+    IFNAME=$(ip -o link | grep -i "$1" | sed -e 's/^[0-9]*: //' -e 's/:.*//')
1330ca
+  else
1330ca
+    IFNAME=$(ifconfig -a | grep -i "$1" | cut -d " " -f 1)
1330ca
+    if [ -z $IFNAME ]; then
1330ca
+      IFNAME=$(ifconfig -a | grep -i -B 2 "$1" | sed -n '/flags/s/:.*$//p')
1330ca
+    fi
1330ca
+  fi
1330ca
+}
1330ca
+#end raw
1330ca
     #set ikeys = $interfaces.keys()
1330ca
     #import re
1330ca
     #set $vlanpattern = $re.compile("[a-zA-Z0-9]+[\.:][0-9]+")
1330ca
@@ -75,9 +97,9 @@ 
1330ca
                 #set $netinfo = "%s --hostname=%s" % ($netinfo, $hostname)
1330ca
             #end if
1330ca
 # Configuring $iname ($mac)
1330ca
-if ifconfig -a | grep -i $mac
1330ca
+if mac_exists $mac
1330ca
 then
1330ca
-  IFNAME=\$(ifconfig -a | grep -i '$mac' | cut -d " " -f 1)
1330ca
+  get_ifname $mac
1330ca
   echo "network --device=\$IFNAME $netinfo" >> /tmp/pre_install_network_config
1330ca
 fi
1330ca
         #else
1330ca