diff --git a/xCAT-server/lib/xcat/plugins/anaconda.pm b/xCAT-server/lib/xcat/plugins/anaconda.pm index cbcfcf3b9..82f9c402b 100644 --- a/xCAT-server/lib/xcat/plugins/anaconda.pm +++ b/xCAT-server/lib/xcat/plugins/anaconda.pm @@ -537,11 +537,9 @@ sub mknetboot # which is used for dracut # the redhat5.x os will ignore it my $useifname=0; - if ($reshash->{$node}->[0] and $reshash->{$node}->[0]->{installnic}) { - if ($reshash->{$node}->[0]->{installnic} ne "mac") { - $useifname=1; - $kcmdline .= "ifname=".$reshash->{$node}->[0]->{installnic} . ":"; - } + if ($reshash->{$node}->[0] and $reshash->{$node}->[0]->{installnic} and $reshash->{$node}->[0]->{installnic} ne "mac") { + $useifname=1; + $kcmdline .= "ifname=".$reshash->{$node}->[0]->{installnic} . ":"; } elsif ($nodebootif) { $useifname=1; $kcmdline .= "ifname=$nodebootif:"; @@ -555,7 +553,7 @@ sub mknetboot #} # append the mac address my $mac; - if($useifname && $machash->{$node}->[0] && $machash->{$node}->[0]->{'mac'}) { + if($machash->{$node}->[0] && $machash->{$node}->[0]->{'mac'}) { # TODO: currently, only "mac" attribute with classic style is used, the "|" delimited string of "macaddress!hostname" format is not used $mac = $machash->{$node}->[0]->{'mac'}; if ( (index($mac, "|") eq -1) and (index($mac, "!") eq -1) ) { @@ -563,20 +561,21 @@ sub mknetboot if ($mac !~ /:/) { $mac =~s/(..)(..)(..)(..)(..)(..)/$1:$2:$3:$4:$5:$6/; } - $kcmdline .= "$mac "; } else { - die qq{In the "mac" table, the "|" delimited string of "macaddress!hostname" format is not supported by "nodeset netboot|statelite if installnic/primarynic is set".}; + $callback->({ error=>[ qq{In the "mac" table, the "|" delimited string of "macaddress!hostname" format is not supported by "nodeset netboot|statelite if installnic/primarynic is set".}], errorcode=>[1]}); + return; } - #} else { # it should never happen, but we don't always do it this way - # $callback->({error=>["cannot find the mac address for $node in mac table"], errorcode=>[1]}); } - # add "netdev=" or "BOOTIF=" + if ($useifname && $mac) { + $kcmdline .= "$mac "; + } + + # add "netdev=" or "BOOTIF=" + # which are used for other scenarios my $netdev = ""; - if ($reshash->{$node}->[0] and $reshash->{$node}->[0]->{installnic}) { - if ($reshash->{$node}->[0]->{installnic} ne "mac") { - $kcmdline .= "netdev=" . $reshash->{$node}->[0]->{installnic} . " "; - } + if ($reshash->{$node}->[0] and $reshash->{$node}->[0]->{installnic} and $reshash->{$node}->[0]->{installnic} ne "mac") { + $kcmdline .= "netdev=" . $reshash->{$node}->[0]->{installnic} . " "; } elsif ($nodebootif) { $kcmdline .= "netdev=" . $nodebootif . " "; } elsif ( $reshash->{$node}->[0] and $reshash->{$node}->[0]->{primarynic}) { diff --git a/xCAT-server/share/xcat/netboot/rh/dracut/install.netboot b/xCAT-server/share/xcat/netboot/rh/dracut/install.netboot index 294be8e87..2206e0b4e 100755 --- a/xCAT-server/share/xcat/netboot/rh/dracut/install.netboot +++ b/xCAT-server/share/xcat/netboot/rh/dracut/install.netboot @@ -1,6 +1,6 @@ #!/bin/sh echo $drivers -dracut_install wget cpio gzip dash modprobe +dracut_install wget cpio gzip dash modprobe touch dracut_install grep ifconfig hostname awk egrep grep dirname inst "$moddir/xcatroot" "/sbin/xcatroot" inst_hook cmdline 10 "$moddir/xcat-cmdline.sh" diff --git a/xCAT-server/share/xcat/netboot/rh/dracut/install.statelite b/xCAT-server/share/xcat/netboot/rh/dracut/install.statelite index c9c25c6b2..3115fb447 100755 --- a/xCAT-server/share/xcat/netboot/rh/dracut/install.statelite +++ b/xCAT-server/share/xcat/netboot/rh/dracut/install.statelite @@ -1,5 +1,5 @@ #!/bin/sh echo $drivers -dracut_install wget cpio gzip dash modprobe wc +dracut_install wget cpio gzip dash modprobe wc touch dracut_install grep ifconfig hostname awk egrep grep dirname expr inst_hook pre-pivot 5 "$moddir/xcat-prepivot.sh" diff --git a/xCAT-server/share/xcat/netboot/rh/dracut/xcatroot b/xCAT-server/share/xcat/netboot/rh/dracut/xcatroot index accffddd6..945b31bf3 100755 --- a/xCAT-server/share/xcat/netboot/rh/dracut/xcatroot +++ b/xCAT-server/share/xcat/netboot/rh/dracut/xcatroot @@ -76,6 +76,28 @@ for lf in /tmp/dhclient.*.lease; do netif=${netif%.*} cp $lf "$NEWROOT/var/lib/dhclient/dhclient-$netif.leases" done + +if [ ! -z "$ifname" ]; then + MACX=${ifname#*:} + ETHX=${ifname%:$MACX*} +elif [ ! -z "$netdev" ]; then + ETHX=$netdev + MACX=`ip link show $netdev | grep ether | awk '{print $2}'` +elif [ ! -z "$BOOTIF" ]; then + MACX=$BOOTIF + ETHX=`ifconfig |grep -i $BOOTIF | awk '{print $1}'` +fi + +if [ ! -z "$MACX" ] && [ ! -z "$ETHX" ]; then + if [ ! -e $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX ]; then + touch $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX + fi + echo "DEVICE=$ETHX" > $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX + echo "BOOTPROTO=dhcp" >> $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX + echo "HWADDR=$MACX" >> $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX + echo "ONBOOT=yes" >> $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX +fi + cp /etc/resolv.conf "$NEWROOT/etc/" if [ -d "$NEWROOT/etc/sysconfig" -a ! -e "$NEWROOT/etc/sysconfig/selinux" ]; then diff --git a/xCAT-server/share/xcat/netboot/rh/genimage b/xCAT-server/share/xcat/netboot/rh/genimage index 42cf5a03d..02034cde8 100755 --- a/xCAT-server/share/xcat/netboot/rh/genimage +++ b/xCAT-server/share/xcat/netboot/rh/genimage @@ -1392,6 +1392,7 @@ sub generic_post { #This function is meant to leave the image in a state approxi open($cfgfile,">","$rootimg_dir/etc/resolv.conf"); print $cfgfile "#Dummy resolv.conf to make boot cleaner"; close($cfgfile); +# TODO # open($cfgfile,">","$rootimg_dir/etc/sysconfig/network-scripts/ifcfg-$prinic"); # print $cfgfile "ONBOOT=yes\nBOOTPROTO=dhcp\nDEVICE=$prinic\n"; # close($cfgfile);