From 23b836102a856f64d8c105d128169845b0a63c95 Mon Sep 17 00:00:00 2001 From: daniceexi Date: Wed, 8 Jan 2014 04:59:33 -0500 Subject: [PATCH] defect 3135: changed the mount process for the statelite directory (for persistent entries) that make a directory after the node name and remount to the nodename directory instead of nfs root dir for persistent --- xCAT-server/lib/xcat/plugins/anaconda.pm | 3 +- .../netboot/add-on/statelite/rc.statelite | 15 +---- .../add-on/statelite/rc.statelite.ppc.redhat | 15 +---- .../xcat/netboot/rh/dracut/xcat-prepivot.sh | 35 +++++++++++ .../share/xcat/netboot/rh/dracut/xcatroot | 36 +++++++++++ xCAT-server/share/xcat/netboot/rh/genimage | 59 +++++++++++++++---- xCAT-server/share/xcat/netboot/sles/genimage | 37 ++++++++++++ 7 files changed, 160 insertions(+), 40 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/anaconda.pm b/xCAT-server/lib/xcat/plugins/anaconda.pm index 0e6db2e7f..951ec10ab 100644 --- a/xCAT-server/lib/xcat/plugins/anaconda.pm +++ b/xCAT-server/lib/xcat/plugins/anaconda.pm @@ -718,7 +718,8 @@ sub mknetboot } # END service node } - } + $kcmdline .= "NODE=$node "; + } else { $kcmdline = "imgurl=$httpmethod://$imgsrv:$httpport/$rootimgdir/rootimg.$suffix "; diff --git a/xCAT-server/share/xcat/netboot/add-on/statelite/rc.statelite b/xCAT-server/share/xcat/netboot/add-on/statelite/rc.statelite index e403514ad..6989fb57d 100755 --- a/xCAT-server/share/xcat/netboot/add-on/statelite/rc.statelite +++ b/xCAT-server/share/xcat/netboot/add-on/statelite/rc.statelite @@ -21,20 +21,7 @@ ELIST=[] # entry list, each entry will contain the type and the path declare -a CLIST declare -a PLIST -ME=`hostname -s` -MAX=30 -TRIES=1 -while [ x$ME = x ];do - TRIES=$[ $TRIES+1 ] - if [ $TRIES -eq $MAX ]; then - echo "Can NOT get the hostname of the node. System will fail to enable the persistent files.">/dev/console - break - fi - sleep 1 - ME=`hostname -s` -done - -PERSISTENT="${MNTDIR}/$SL/persistent/$ME" +PERSISTENT="${MNTDIR}/$SL/persistent" if [ ! -d $MNTDIR ]; then echo "statelite is only to be run in initrdfs" diff --git a/xCAT-server/share/xcat/netboot/add-on/statelite/rc.statelite.ppc.redhat b/xCAT-server/share/xcat/netboot/add-on/statelite/rc.statelite.ppc.redhat index 461dc0867..0e1ef8027 100755 --- a/xCAT-server/share/xcat/netboot/add-on/statelite/rc.statelite.ppc.redhat +++ b/xCAT-server/share/xcat/netboot/add-on/statelite/rc.statelite.ppc.redhat @@ -21,20 +21,7 @@ ELIST=[] # entry list, each entry will contain the type and the path declare -a CLIST declare -a PLIST -ME=`hostname` -MAX=30 -TRIES=1 -while [ x$ME = x ];do - TRIES=$[ $TRIES+1 ] - if [ $TRIES -eq $MAX ]; then - echo "Can NOT get the hostname of the node. System will fail to enable the persistent files.">/dev/console - break - fi - sleep 1 - ME=`hostname -s` -done - -PERSISTENT="${MNTDIR}/$SL/persistent/$ME" +PERSISTENT="${MNTDIR}/$SL/persistent" if [ ! -d $MNTDIR ]; then echo "statelite is only to be run in initrdfs" diff --git a/xCAT-server/share/xcat/netboot/rh/dracut/xcat-prepivot.sh b/xCAT-server/share/xcat/netboot/rh/dracut/xcat-prepivot.sh index 40ee23008..73498a91e 100755 --- a/xCAT-server/share/xcat/netboot/rh/dracut/xcat-prepivot.sh +++ b/xCAT-server/share/xcat/netboot/rh/dracut/xcat-prepivot.sh @@ -40,6 +40,9 @@ fi mount -t tmpfs rw $NEWROOT/$RWDIR mkdir -p $NEWROOT/$RWDIR/tmpfs ME=`hostname` +if [ ! -z $NODE ]; then + ME=$NODE +fi # mount the SNAPSHOT directory here for persistent use. if [ ! -z $SNAPSHOTSERVER ]; then @@ -65,6 +68,38 @@ if [ ! -z $SNAPSHOTSERVER ]; then echo "Trying again in $RS seconds..." sleep $RS done + + # create directory which is named after my node name + mkdir -p $NEWROOT/$RWDIR/persistent/$ME + ITER=0 + # umount current persistent mount + while ! umount -l $NEWROOT/$RWDIR/persistent; do + ITER=$(( ITER + 1 )) + if [ "$ITER" == "$MAXTRIES" ]; then + echo "Your are dead, rpower $ME boot to play again." + echo "Cannot umount $NEWROOT/$RWDIR/persistent." + /bin/sh + exit + fi + RS= $(( $RANDOM % 20 )) + echo "Trying again in $RS seconds..." + sleep $RS + done + + # mount persistent to server:/rootpath/nodename + ITER=0 + while ! mount $SNAPSHOTSERVER:/$SNAPSHOTROOT/$ME $NEWROOT/$RWDIR/persistent -o $MNT_OPTIONS; do + ITER=$(( ITER + 1 )) + if [ "$ITER" == "$MAXTRIES" ]; then + echo "Your are dead, rpower $ME boot to play again." + echo "Possible problems: cannot mount to $SNAPSHOTSERVER:/$SNAPSHOTROOT/$ME." + /bin/sh + exit + fi + RS= $(( $RANDOM % 20 )) + echo "Trying again in $RS seconds..." + sleep $RS + done fi # TODO: handle the dhclient/resolv.conf/ntp, etc diff --git a/xCAT-server/share/xcat/netboot/rh/dracut/xcatroot b/xCAT-server/share/xcat/netboot/rh/dracut/xcatroot index 477a7c549..638785f97 100755 --- a/xCAT-server/share/xcat/netboot/rh/dracut/xcatroot +++ b/xCAT-server/share/xcat/netboot/rh/dracut/xcatroot @@ -113,6 +113,10 @@ elif [ -r /rootimg-statelite.gz ]; then mount -t tmpfs rw $NEWROOT/$RWDIR mkdir -p $NEWROOT/$RWDIR/tmpfs ME=`hostname` + if [ ! -z $NODE ]; then + ME=$NODE + fi + # mount the SNAPSHOT directory here for persistent use. if [ ! -z $STATEMNT ]; then @@ -147,6 +151,38 @@ elif [ -r /rootimg-statelite.gz ]; then echo "Trying again in $RS seconds ..." sleep $RS done + + # create directory which is named after my node name + mkdir -p $NEWROOT/$RWDIR/persistent/$ME + ITER=0 + # umount current persistent mount + while ! umount -l $NEWROOT/$RWDIR/persistent; do + ITER=$(( ITER + 1 )) + if [ "$ITER" == "$MAXTRIES" ]; then + echo "Your are dead, rpower $ME boot to play again." + echo "Cannot umount $NEWROOT/$RWDIR/persistent." + /bin/sh + exit + fi + RS= $(( $RANDOM % 20 )) + echo "Trying again in $RS seconds..." + sleep $RS + done + + # mount persistent to server:/rootpath/nodename + ITER=0 + while ! mount $SNAPSHOTSERVER:/$SNAPSHOTROOT/$ME $NEWROOT/$RWDIR/persistent -o $MNT_OPTIONS; do + ITER=$(( ITER + 1 )) + if [ "$ITER" == "$MAXTRIES" ]; then + echo "Your are dead, rpower $ME boot to play again." + echo "Possible problems: cannot mount to $SNAPSHOTSERVER:/$SNAPSHOTROOT/$ME." + /bin/sh + exit + fi + RS= $(( $RANDOM % 20 )) + echo "Trying again in $RS seconds..." + sleep $RS + done fi $NEWROOT/etc/init.d/localdisk diff --git a/xCAT-server/share/xcat/netboot/rh/genimage b/xCAT-server/share/xcat/netboot/rh/genimage index 4f9284dae..2d4736e7a 100755 --- a/xCAT-server/share/xcat/netboot/rh/genimage +++ b/xCAT-server/share/xcat/netboot/rh/genimage @@ -1224,17 +1224,19 @@ for i in `cat /proc/cmdline`; do elif [ "\$KEY" == 'STATEMNT' ]; then STATELITE=1 VALUE=`echo \$i |awk -F= '{print \$2}'` - # the VALUE may be null - if [ ! -z \$VALUE ]; then - SNAPSHOTSERVER=`echo \$VALUE|awk -F: '{print \$1}'` - SNAPSHOTROOT=`echo \$VALUE|awk -F/ '{for(i=2;i<=NF;i++) printf "/%s",\$i}'` - # may be that there is not server and just a directory. - if [ -z \$SNAPSHOTROOT ] - then - SNAPSHOTROOT=\$SNAPSHOTSERVER - SNAPSHOTSERVER= - fi - fi + # the VALUE may be null + if [ ! -z \$VALUE ]; then + SNAPSHOTSERVER=`echo \$VALUE|awk -F: '{print \$1}'` + SNAPSHOTROOT=`echo \$VALUE|awk -F/ '{for(i=2;i<=NF;i++) printf "/%s",\$i}'` + # may be that there is not server and just a directory. + if [ -z \$SNAPSHOTROOT ] + then + SNAPSHOTROOT=\$SNAPSHOTSERVER + SNAPSHOTSERVER= + fi + fi + elif [ "\$KEY" == 'NODE' ]; then + NODENAME=`echo \$i |awk -F= '{print \$2}'` fi done @@ -1257,6 +1259,9 @@ if [ "\$STATELITE" = "1" ]; then MAXTRIES=5 ITER=0 ME=`hostname` + if [ ! -z "\$NODENAME" ]; then + ME=\$NODENAME + fi if [ "\$NFSROOT" = "1" ]; then while ! mount.nfs \${SERVER}:\${ROOTDIR}/rootimg \$NEWROOT -r -n -o nolock,rsize=32768,tcp,nfsvers=3,timeo=14; do ITER=\$(expr \$ITER + 1) @@ -1345,6 +1350,38 @@ EOMS echo -e "Trying again in \$RS seconds" sleep \$RS done + + # create directory which is named after my node name + mkdir -p \$NEWROOT/\$RWDIR/persistent/\$ME + ITER=0 + # umount current persistent mount + while ! umount -l \$NEWROOT/\$RWDIR/persistent; do + ITER=\$(( ITER + 1 )) + if [ "\$ITER" == "\$MAXTRIES" ]; then + echo "Your are dead, rpower \$ME boot to play again." + echo "Cannot umount \$NEWROOT/\$RWDIR/persistent." + /bin/sh + exit + fi + RS= \$(( \$RANDOM % 20 )) + echo "Trying again in \$RS seconds..." + sleep \$RS + done + + # mount persistent to server:/rootpath/nodename + ITER=0 + while ! mount \$SNAPSHOTSERVER:/\$SNAPSHOTROOT/\$ME \$NEWROOT/\$RWDIR/persistent -o nolock,rsize=32768; do + ITER=\$(( ITER + 1 )) + if [ "\$ITER" == "\$MAXTRIES" ]; then + echo "Your are dead, rpower \$ME boot to play again." + echo "Possible problems: cannot mount to \$SNAPSHOTSERVER:/\$SNAPSHOTROOT/\$ME." + /bin/sh + exit + fi + RS= \$(( \$RANDOM % 20 )) + echo "Trying again in \$RS seconds..." + sleep \$RS + done fi # have to preserve the initial DHCP request. diff --git a/xCAT-server/share/xcat/netboot/sles/genimage b/xCAT-server/share/xcat/netboot/sles/genimage index f04aecaef..6746625ee 100755 --- a/xCAT-server/share/xcat/netboot/sles/genimage +++ b/xCAT-server/share/xcat/netboot/sles/genimage @@ -1172,6 +1172,8 @@ for i in `cat /proc/cmdline`; do SNAPSHOTSERVER= fi fi + elif [ "\$KEY" == 'NODE' ]; then + NODENAME=`echo \$i |awk -F= '{print \$2}'` fi done @@ -1186,6 +1188,9 @@ if [ "\$STATELITE" = "1" ]; then MAXTRIES=15 ITER=0 ME=`hostname` + if [ ! -z "$NODENAME" ]; then + ME=$NODENAME + fi if [ "\$NFSROOT" = "1" ]; then while ! mount.nfs \${SERVER}:\${ROOTDIR}/rootimg \$NEWROOT -r -n -o nolock,rsize=32768,tcp,nfsvers=3,timeo=14; do ITER=\$(expr \$ITER + 1) @@ -1281,6 +1286,38 @@ fi echo -e "Trying again in \$RS seconds" sleep \$RS done + + # create directory which is named after my node name + mkdir -p \$NEWROOT/\$RWDIR/persistent/\$ME + ITER=0 + # umount current persistent mount + while ! umount -l \$NEWROOT/\$RWDIR/persistent; do + ITER=\$(( ITER + 1 )) + if [ "\$ITER" == "\$MAXTRIES" ]; then + echo "Your are dead, rpower \$ME boot to play again." + echo "Cannot umount \$NEWROOT/\$RWDIR/persistent." + /bin/sh + exit + fi + RS= \$(( \$RANDOM % 20 )) + echo "Trying again in \$RS seconds..." + sleep \$RS + done + + # mount persistent to server:/rootpath/nodename + ITER=0 + while ! mount \$SNAPSHOTSERVER:/\$SNAPSHOTROOT/\$ME \$NEWROOT/\$RWDIR/persistent -o nolock,\$XCATMNTOPTS; do + ITER=\$(( ITER + 1 )) + if [ "\$ITER" == "\$MAXTRIES" ]; then + echo "Your are dead, rpower \$ME boot to play again." + echo "Possible problems: cannot mount to \$SNAPSHOTSERVER:/\$SNAPSHOTROOT/\$ME." + /bin/sh + exit + fi + RS= \$(( \$RANDOM % 20 )) + echo "Trying again in \$RS seconds..." + sleep \$RS + done fi grep '\\(shell\\)' /proc/cmdline >/dev/null && shell