diff --git a/xCAT-server/lib/xcat/plugins/anaconda.pm b/xCAT-server/lib/xcat/plugins/anaconda.pm index b615099f3..27479fba1 100644 --- a/xCAT-server/lib/xcat/plugins/anaconda.pm +++ b/xCAT-server/lib/xcat/plugins/anaconda.pm @@ -180,6 +180,8 @@ sub mknetboot my $installroot; $installroot = "/install"; my $xcatdport = "3001"; + my $xcatiport = "3002"; + my $nodestatus = "y"; #if ($sitetab) #{ @@ -190,6 +192,12 @@ sub mknetboot { $installroot = $site_ent; } + @ents = xCAT::TableUtils->get_site_attribute("nodestatus"); + $site_ent = $ents[0]; + if ( defined($site_ent) ) + { + $nodestatus = $site_ent; + } # ($ref) = $sitetab->getAttribs({key => 'xcatdport'}, 'value'); @ents = xCAT::TableUtils->get_site_attribute("xcatdport"); $site_ent = $ents[0]; @@ -197,6 +205,12 @@ sub mknetboot { $xcatdport = $site_ent; } + @ents = xCAT::TableUtils->get_site_attribute("xcatiport"); + $site_ent = $ents[0]; + if ( defined($site_ent) ) + { + $xcatiport = $site_ent; + } # ($ref) = $sitetab->getAttribs({key => 'tftpdir'}, 'value'); @ents = xCAT::TableUtils->get_site_attribute("tftpdir"); $site_ent = $ents[0]; @@ -679,8 +693,10 @@ sub mknetboot } else { $xcatmasterip = $xcatmaster; } - $kcmdline .= - "XCAT=$xcatmasterip:$xcatdport "; + + $kcmdline .= "XCAT=$xcatmaster:$xcatdport "; + + if ($rootfstype ne "ramdisk") { # BEGIN service node my $isSV = xCAT::Utils->isServiceNode(); @@ -701,9 +717,14 @@ sub mknetboot else { $kcmdline = "imgurl=$httpmethod://$imgsrv:$httpport/$rootimgdir/rootimg.$suffix "; - $kcmdline .= "XCAT=$xcatmaster:$xcatdport "; + $kcmdline .= "XCAT=$xcatmaster:$xcatdport "; $kcmdline .= "NODE=$node "; } + #inform statelite/stateless node not to update the nodestatus during provision + if(($nodestatus eq "n") or ($nodestatus eq "N") or ($nodestatus eq "0")){ + $kcmdline .= " nonodestatus "; + } + # add one parameter: ifname=: # which is used for dracut diff --git a/xCAT-server/lib/xcat/plugins/sles.pm b/xCAT-server/lib/xcat/plugins/sles.pm index a23b20259..0d6a0f2e4 100644 --- a/xCAT-server/lib/xcat/plugins/sles.pm +++ b/xCAT-server/lib/xcat/plugins/sles.pm @@ -64,7 +64,8 @@ sub mknetboot $installroot = "/install"; my $xcatdport = "3001"; - + my $xcatiport = "3002"; + my $nodestatus = "y"; #if ($sitetab) #{ #(my $ref) = $sitetab->getAttribs({key => 'installdir'}, 'value'); @@ -79,6 +80,17 @@ sub mknetboot if ( defined($t_entry) ) { $xcatdport = $t_entry; } + @entries = xCAT::TableUtils->get_site_attribute("xcatiport"); + $t_entry = $entries[0]; + if ( defined($t_entry) ) { + $xcatiport = $t_entry; + } + @entries = xCAT::TableUtils->get_site_attribute("nodestatus"); + $t_entry = $entries[0]; + if ( defined($t_entry) ) { + $nodestatus = $t_entry; + } + #} my $ntents = $ostab->getNodesAttribs($req->{node}, ['os', 'arch', 'profile', 'provmethod']); @@ -553,6 +565,13 @@ sub mknetboot "imgurl=$httpmethod://$imgsrv/$rootimgdir/rootimg.$suffix "; } $kcmdline .= "XCAT=$xcatmaster:$xcatdport quiet "; + + #if site.nodestatus="n", append "nonodestatus" to kcmdline + #to inform the statelite/stateless node not to update the nodestatus during provision + if(($nodestatus eq "n") or ($nodestatus eq "N") or ($nodestatus eq "0")){ + $kcmdline .= " nonodestatus "; + } + $kcmdline .= "NODE=$node "; # add the kernel-booting parameter: netdev=, or BOOTIF= diff --git a/xCAT-server/share/xcat/install/scripts/pre.rh b/xCAT-server/share/xcat/install/scripts/pre.rh index a0d8675c6..8fc78775f 100644 --- a/xCAT-server/share/xcat/install/scripts/pre.rh +++ b/xCAT-server/share/xcat/install/scripts/pre.rh @@ -13,6 +13,24 @@ if [ -r /tmp/updates/etc/pki/tls/certs/ca-bundle.crt ]; then cp -f /tmp/updates/etc/pki/tls/certs/ca-bundle.crt /etc/pki/tls/certs/ fi +cat >/tmp/baz.py </tmp/foo.py </foo.log 2>&1 & #time to ascertain fstype and PReP/UEFI/legacy diff --git a/xCAT-server/share/xcat/install/scripts/pre.sles b/xCAT-server/share/xcat/install/scripts/pre.sles index 055fcd393..b1c587cd1 100644 --- a/xCAT-server/share/xcat/install/scripts/pre.sles +++ b/xCAT-server/share/xcat/install/scripts/pre.sles @@ -14,28 +14,30 @@ cat >/tmp/bar.awk </tmp/foo.log 2>&1 & + shopt -s nullglob for disk in /dev/vd*[^0-9];do if [ -z "$firstdirectdisk" ]; then firstdirectdisk=$disk; fi #remember first disk as a guess of medium resort diff --git a/xCAT-server/share/xcat/netboot/rh/dracut/install.netboot b/xCAT-server/share/xcat/netboot/rh/dracut/install.netboot index e9beb2376..d9cd35d83 100755 --- a/xCAT-server/share/xcat/netboot/rh/dracut/install.netboot +++ b/xCAT-server/share/xcat/netboot/rh/dracut/install.netboot @@ -4,5 +4,6 @@ dracut_install wget cpio gzip dash modprobe touch echo cut wc dracut_install grep ifconfig hostname awk egrep grep dirname expr dracut_install mount.nfs dracut_install parted mke2fs bc mkswap swapon chmod +inst "$moddir/xcat-updateflag" "/tmp/updateflag" 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 456fe5799..727f2b864 100755 --- a/xCAT-server/share/xcat/netboot/rh/dracut/install.statelite +++ b/xCAT-server/share/xcat/netboot/rh/dracut/install.statelite @@ -3,4 +3,6 @@ echo $drivers dracut_install wget cpio gzip dash modprobe wc touch echo cut dracut_install grep ifconfig hostname awk egrep grep dirname expr dracut_install parted mke2fs bc mkswap swapon chmod +inst "$moddir/xcat-updateflag" "/tmp/updateflag" +inst_hook pre-mount 5 "$moddir/xcat-premount.sh" 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 45c663ee7..477a7c549 100755 --- a/xCAT-server/share/xcat/netboot/rh/dracut/xcatroot +++ b/xCAT-server/share/xcat/netboot/rh/dracut/xcatroot @@ -5,6 +5,22 @@ XCATMASTER=$XCAT . /lib/dracut-lib.sh rootlimit="$(getarg rootlimit=)" + + +getarg nonodestatus +NODESTATUS=$? + +MASTER=`echo $XCATMASTER |awk -F: '{print $1}'` +XCATIPORT="$(getarg XCATIPORT=)" +if [ $? -ne 0 ]; then +XCATIPORT="3002" +fi + + +if [ $NODESTATUS -ne 0 ];then +/tmp/updateflag $MASTER $XCATIPORT "installstatus netbooting" +fi + if [ ! -z "$imgurl" ]; then if [ xhttp = x${imgurl%%:*} ]; then NFS=0 diff --git a/xCAT-server/share/xcat/netboot/rh/genimage b/xCAT-server/share/xcat/netboot/rh/genimage index 28537feb0..47b8cc962 100755 --- a/xCAT-server/share/xcat/netboot/rh/genimage +++ b/xCAT-server/share/xcat/netboot/rh/genimage @@ -771,11 +771,19 @@ sub mkinitrd_dracut { $perm = (stat("$fullpath/$dracutdir/install.statelite"))[2]; chmod($perm&07777, "$dracutmpath/install"); + cp("$fullpath/$dracutdir/xcat-updateflag",$dracutmpath); + $perm = (stat("$fullpath/$dracutdir/xcat-updateflag"))[2]; + chmod($perm&07777, "$dracutmpath/xcat-updateflag"); + cp("$fullpath/$dracutdir/xcat-prepivot.sh",$dracutmpath); $perm = (stat("$fullpath/$dracutdir/xcat-prepivot.sh"))[2]; chmod($perm&07777, "$dracutmpath/xcat-prepivot.sh"); - # update etc/dracut.conf + cp("$fullpath/$dracutdir/xcat-premount.sh",$dracutmpath); + $perm = (stat("$fullpath/$dracutdir/xcat-premount.sh"))[2]; + chmod($perm&07777, "$dracutmpath/xcat-premount.sh"); + + #update etc/dracut.conf open($DRACUTCONF, '>', "$rootimg_dir/etc/dracut.conf"); if (-d glob("$rootimg_dir/usr/share/dracut/modules.d/[0-9]*fadump")){ print $DRACUTCONF qq{dracutmodules+="xcat nfs base network kernel-modules fadump"\n}; @@ -795,6 +803,10 @@ sub mkinitrd_dracut { $perm = (stat("$fullpath/$dracutdir/xcat-cmdline.sh"))[2]; chmod($perm&07777, "$dracutmpath/xcat-cmdline.sh"); + cp("$fullpath/$dracutdir/xcat-updateflag",$dracutmpath); + $perm = (stat("$fullpath/$dracutdir/xcat-updateflag"))[2]; + chmod($perm&07777, "$dracutmpath/xcat-updateflag"); + if ($prinic) { my $optspec; open($optspec,'>>',"$dracutmpath/xcat-cmdline.sh"); @@ -1051,6 +1063,7 @@ grep '\(debug\)' /proc/cmdline > /dev/null && export DEBUG=1 # TODO: does "anaconda.busybox sh" support "set " ? PRINIC=$prinic +NODESTATUS='y' for i in `cat /proc/cmdline`; do KEY=`echo \$i |awk -F= '{print \$1}'` @@ -1063,6 +1076,14 @@ for i in `cat /proc/cmdline`; do VALUE=`echo \$i |awk -F= '{print \$2}'` # format: XCAT=xcatmaster:3001 XCATSERVER=\$VALUE + elif [ "\$KEY" == 'XCATIPORT' ]; then + VALUE=`echo \$i |awk -F= '{print \$2}'` + # format: XCAT=xcatmaster:3001 + XCATIPORT=\$VALUE + fi + #if "nonodestatus" specified,do not update the nodestatus + if [ \$i == 'nonodestatus' ]; then + NODESTATUS='n' fi done @@ -1091,6 +1112,18 @@ while ! ifconfig | grep inet; do done ifconfig lo 127.0.0.1 ifconfig lo up + +XCATMASTER=`echo \$XCATSERVER|awk -F: '{print \$1}'` + +if [ -z \$XCATIPORT ]; then + XCATIPORT="3002" +fi + +#update nodelist.nodestatus to "netbooting" +if [ \$NODESTATUS != 'n' ]; then + /tmp/updateflag \$XCATMASTER \$XCATIPORT "installstatus netbooting" +fi + cd / for i in `cat /proc/cmdline`; do KEY=`echo \$i |awk -F= '{print \$1}'` @@ -1137,6 +1170,10 @@ for i in `cat /proc/cmdline`; do fi done + + + + # show xCAT logo fancydisplay @@ -1346,8 +1383,38 @@ EOMS open($inifile,">"."/tmp/xcatinitrd.$$/bin/netstart"); print $inifile "#!/sbin/nash\n"; close($inifile); + + #/tmp/updateflag: a script to feedback node provision status to xcatd + system("mkdir -p /tmp/xcatinitrd.$$/tmp/"); + open($inifile, ">","/tmp/xcatinitrd.$$/tmp/updateflag"); + + print $inifile < /tmp/ncarg + nc \$1 \$2 -w 60 -e /tmp/updateflag +else + retrytimes=0 + cmd="" + while [ "\$cmd" != "done" ]; do + retrytimes=`expr \$retrytimes + 1` + if [ \$retrytimes -eq 60 ]; then + break; + fi + read -t 60 cmd + if [ "\$cmd" == "ready" ]; then + head -n 1 /tmp/ncarg + rm -rf /tmp/ncarg + fi + done + +fi +EOMS + close($inifile); + chmod(0755,"/tmp/xcatinitrd.$$/init"); chmod(0755,"/tmp/xcatinitrd.$$/bin/netstart"); + chmod(0755,"/tmp/xcatinitrd.$$/tmp/updateflag"); @filestoadd=(); foreach (@ndrivers) { if (-f "$customdir/$_") { diff --git a/xCAT-server/share/xcat/netboot/sles/genimage b/xCAT-server/share/xcat/netboot/sles/genimage index 0e41dc7be..f38226de5 100755 --- a/xCAT-server/share/xcat/netboot/sles/genimage +++ b/xCAT-server/share/xcat/netboot/sles/genimage @@ -1032,6 +1032,7 @@ EOMS # check the kernel parameters firstly # if one parameter for the booting device is here, it will be used PRINIC=$prinic +NODESTATUS='y' XCATMNTOPTS='nolock,tcp' for i in `cat /proc/cmdline`; do KEY=`echo \$i |awk -F= '{print \$1}'` @@ -1050,6 +1051,11 @@ for i in `cat /proc/cmdline`; do XCATMNTOPTS=\$VALUE fi + + + if [ \$i == 'nonodestatus' ]; then + NODESTATUS='n' + fi done if [ -z "\$IFACE" ]; then @@ -1083,6 +1089,18 @@ echo "STARTMODE=nfsroot" > /tmp/ifcfg-\$IFACE ip addr add dev lo 127.0.0.1/8 ip link set lo up + + +XCATMASTER=`echo \$XCATSERVER|awk -F: '{print \$1}'` + +if [ -z \$XCATIPORT ]; then + XCATIPORT="3002" +fi + +if [ \$NODESTATUS != 'n' ]; then + /tmp/updateflag \$XCATMASTER \$XCATIPORT "installstatus netbooting" +fi + cd / for i in `cat /proc/cmdline`; do KEY=`echo \$i |awk -F= '{print \$1}'` @@ -1373,8 +1391,43 @@ cat /var/lib/dhcpcd/*info | grep HOSTNAME | uniq | awk -F= '{print \$2}'| sed \" END close($inifile); + + #if "nonodestatus" specified,do not update the nodestatus + system("mkdir -p /tmp/xcatinitrd.$$/tmp/"); + open($inifile, ">","/tmp/xcatinitrd.$$/tmp/updateflag"); + + print $inifile <