From 9394d1bb667864673043421a3fea1b6010fe0ed6 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 22 May 2014 23:52:26 -0700 Subject: [PATCH 01/99] Add the Version file --- Version | 1 + 1 file changed, 1 insertion(+) create mode 100644 Version diff --git a/Version b/Version new file mode 100644 index 000000000..2701a226a --- /dev/null +++ b/Version @@ -0,0 +1 @@ +2.8.4 From f2f22c029d9a83c82db10112810ab4df3f776201 Mon Sep 17 00:00:00 2001 From: litingt Date: Fri, 23 May 2014 01:16:49 -0700 Subject: [PATCH 02/99] xCAT 2.8.5 version file --- Version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Version b/Version index 2701a226a..766d70806 100644 --- a/Version +++ b/Version @@ -1 +1 @@ -2.8.4 +2.8.5 From 5fa4bdb407165b63b37d13d057015d2a1afb9b43 Mon Sep 17 00:00:00 2001 From: daniceexi Date: Thu, 8 May 2014 10:11:37 -0400 Subject: [PATCH 03/99] code change for rh7 stateless support --- xCAT-server/share/xcat/netboot/rh/genimage | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/xCAT-server/share/xcat/netboot/rh/genimage b/xCAT-server/share/xcat/netboot/rh/genimage index 37eadfd8f..0acc19ed4 100755 --- a/xCAT-server/share/xcat/netboot/rh/genimage +++ b/xCAT-server/share/xcat/netboot/rh/genimage @@ -583,8 +583,8 @@ if ( (-d "$rootimg_dir/usr/share/dracut") or (-d "$rootimg_dir/usr/lib/dracut") my $dracutver = `rpm --root $rootimg_dir -qi dracut | grep Version | awk -F' ' '{print \$3}'`; chomp($dracutver); if ($dracutver =~ /^\d\d\d$/) { - if (($dracutver >= "009") and ($dracutver < "033")) { - $dracutdir = "dracut_009"; + if ($dracutver >= "033") { + $dracutdir = "dracut_033"; } else { $dracutdir = "dracut"; # The default directory } @@ -924,7 +924,11 @@ sub mkinitrd_dracut { $additional_options= qq{--include /tmp/cmdline /etc/cmdline}; } - system("chroot $rootimg_dir dracut $additional_options -f /tmp/initrd.$$.gz $kernelver"); + # force the dracut run in non-hostonly mode for dracut higher than version 033 + if ($dracutver > "033") { + $additional_options .= " -N"; + } + system("chroot $rootimg_dir dracut -N $additional_options -f /tmp/initrd.$$.gz $kernelver"); print "the initial ramdisk for $mode is generated successfully.\n"; move("$rootimg_dir/tmp/initrd.$$.gz", "$destdir/initrd-$mode.gz"); } @@ -1665,7 +1669,11 @@ sub using_systemd { my $os = shift; if ($os =~ /fedora(\d+)/) { if ($1 >= 15) { - return 1; + return 1; + } + }elsif ($os =~ /rhels(\d+)/) { + if ($1 >= 7) { + return 1; } } From 137e201aba105e6b1cee580b045122f3446298ce Mon Sep 17 00:00:00 2001 From: daniceexi Date: Thu, 8 May 2014 10:14:04 -0400 Subject: [PATCH 04/99] add dracut support scripts for dracut-033. Most of them are copied from dracut --- .../share/xcat/netboot/rh/dracut_033/check | 3 + .../netboot/rh/dracut_033/install.netboot | 9 + .../netboot/rh/dracut_033/install.statelite | 8 + .../xcat/netboot/rh/dracut_033/installkernel | 2 + .../netboot/rh/dracut_033/xcat-cmdline.sh | 4 + .../netboot/rh/dracut_033/xcat-premount.sh | 18 ++ .../netboot/rh/dracut_033/xcat-prepivot.sh | 126 +++++++++ .../netboot/rh/dracut_033/xcat-updateflag | 24 ++ .../share/xcat/netboot/rh/dracut_033/xcatroot | 259 ++++++++++++++++++ 9 files changed, 453 insertions(+) create mode 100755 xCAT-server/share/xcat/netboot/rh/dracut_033/check create mode 100755 xCAT-server/share/xcat/netboot/rh/dracut_033/install.netboot create mode 100755 xCAT-server/share/xcat/netboot/rh/dracut_033/install.statelite create mode 100755 xCAT-server/share/xcat/netboot/rh/dracut_033/installkernel create mode 100644 xCAT-server/share/xcat/netboot/rh/dracut_033/xcat-cmdline.sh create mode 100644 xCAT-server/share/xcat/netboot/rh/dracut_033/xcat-premount.sh create mode 100755 xCAT-server/share/xcat/netboot/rh/dracut_033/xcat-prepivot.sh create mode 100755 xCAT-server/share/xcat/netboot/rh/dracut_033/xcat-updateflag create mode 100755 xCAT-server/share/xcat/netboot/rh/dracut_033/xcatroot diff --git a/xCAT-server/share/xcat/netboot/rh/dracut_033/check b/xCAT-server/share/xcat/netboot/rh/dracut_033/check new file mode 100755 index 000000000..d7cc89ce0 --- /dev/null +++ b/xCAT-server/share/xcat/netboot/rh/dracut_033/check @@ -0,0 +1,3 @@ +#!/bin/sh +[ "$1" = "-d" ] && echo network +exit 0 diff --git a/xCAT-server/share/xcat/netboot/rh/dracut_033/install.netboot b/xCAT-server/share/xcat/netboot/rh/dracut_033/install.netboot new file mode 100755 index 000000000..b52b6690f --- /dev/null +++ b/xCAT-server/share/xcat/netboot/rh/dracut_033/install.netboot @@ -0,0 +1,9 @@ +#!/bin/sh +echo $drivers +dracut_install wget cpio gzip 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_033/install.statelite b/xCAT-server/share/xcat/netboot/rh/dracut_033/install.statelite new file mode 100755 index 000000000..7c7646652 --- /dev/null +++ b/xCAT-server/share/xcat/netboot/rh/dracut_033/install.statelite @@ -0,0 +1,8 @@ +#!/bin/sh +echo $drivers +dracut_install wget cpio gzip 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_033/installkernel b/xCAT-server/share/xcat/netboot/rh/dracut_033/installkernel new file mode 100755 index 000000000..7902ce5f7 --- /dev/null +++ b/xCAT-server/share/xcat/netboot/rh/dracut_033/installkernel @@ -0,0 +1,2 @@ +#!/bin/bash +instmods nfs sunrpc diff --git a/xCAT-server/share/xcat/netboot/rh/dracut_033/xcat-cmdline.sh b/xCAT-server/share/xcat/netboot/rh/dracut_033/xcat-cmdline.sh new file mode 100644 index 000000000..80d088557 --- /dev/null +++ b/xCAT-server/share/xcat/netboot/rh/dracut_033/xcat-cmdline.sh @@ -0,0 +1,4 @@ +root=1 +rootok=1 +netroot=xcat +echo '[ -e $NEWROOT/proc ]' > $hookdir/initqueue/finished/xcatroot.sh diff --git a/xCAT-server/share/xcat/netboot/rh/dracut_033/xcat-premount.sh b/xCAT-server/share/xcat/netboot/rh/dracut_033/xcat-premount.sh new file mode 100644 index 000000000..40c1dbbe5 --- /dev/null +++ b/xCAT-server/share/xcat/netboot/rh/dracut_033/xcat-premount.sh @@ -0,0 +1,18 @@ +#!/bin/sh +#script to update nodelist.nodestatus during provision + +MASTER=`echo $XCAT |awk -F: '{print $1}'` + +getarg nonodestatus +NODESTATUS=$? + +XCATIPORT="$(getarg XCATIPORT=)" +if [ $? -ne 0 ]; then +XCATIPORT="3002" +fi + + + +if [ $NODESTATUS -ne 0 ];then +/tmp/updateflag $MASTER $XCATIPORT "installstatus netbooting" +fi diff --git a/xCAT-server/share/xcat/netboot/rh/dracut_033/xcat-prepivot.sh b/xCAT-server/share/xcat/netboot/rh/dracut_033/xcat-prepivot.sh new file mode 100755 index 000000000..d6eac21f9 --- /dev/null +++ b/xCAT-server/share/xcat/netboot/rh/dracut_033/xcat-prepivot.sh @@ -0,0 +1,126 @@ +#!/bin/sh +NEWROOT=/sysroot +SERVER=${SERVER%%/*} +SERVER=${SERVER%:} +RWDIR=.statelite +if [ ! -z $STATEMNT ]; then #btw, uri style might have left future options other than nfs open, will u se // to detect uri in the future I guess + SNAPSHOTSERVER=${STATEMNT%:*} + SNAPSHOTROOT=${STATEMNT#*/} + #echo $SNAPSHOTROOT + #echo $SNAPSHOTSERVER + # may be that there is not server and just a directory. + if [ -z $SNAPSHOTROOT ]; then + SNAPSHOTROOT=$SNAPSHOTSERVER + SNAPSHOTSERVER= + fi +fi + +echo Setting up Statelite +mkdir -p $NEWROOT + +# now we need to mount the rest of the system. This is the read/write portions +# echo Mounting snapshot directories + +MAXTRIES=7 +ITER=0 +if [ ! -e "$NEWROOT/$RWDIR" ]; then + echo "" + echo "This NFS root directory doesn't have a /$RWDIR directory for me to mount a rw filesystem. You'd better create it... " + echo "" + /bin/sh +fi + +if [ ! -e "$NEWROOT/etc/init.d/statelite" ]; then + echo "" + echo "$NEWROOT/etc/init.d/statelite doesn't exist. Perhaps you didn't create this image with th e -m statelite mode" + echo "" + /bin/sh +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 + mkdir -p $NEWROOT/$RWDIR/persistent + MAXTRIES=5 + ITER=0 + if [ -z $MNTOPTS ]; then + MNT_OPTIONS="nolock,rsize=32768,tcp,nfsvers=3,timeo=14" + else + MNT_OPTIONS=$MNTOPTS + fi + while ! mount $SNAPSHOTSERVER:/$SNAPSHOTROOT $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: +1. $SNAPSHOTSERVER is not exporting $SNAPSHOTROOT ? +2. Is DNS set up? Maybe that's why I can't mount $SNAPSHOTSERVER." + /bin/sh + exit + fi + RS= $(( $RANDOM % 20 )) + 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 +echo "Get to enable localdisk" +$NEWROOT/etc/init.d/localdisk +$NEWROOT/etc/init.d/statelite +READONLY=yes +export READONLY +fastboot=yes +export fastboot +keep_old_ip=yes +export keep_old_ip +mount -n --bind /dev $NEWROOT/dev +mount -n --bind /proc $NEWROOT/proc +mount -n --bind /sys $NEWROOT/sys + +if [ -d "$NEWROOT/etc/sysconfig" -a ! -e "$NEWROOT/etc/sysconfig/selinux" ]; then + echo "SELINUX=disabled" >> "$NEWROOT/etc/sysconfig/selinux" +fi + +# inject new exit_if_exists +echo 'settle_exit_if_exists="--exit-if-exists=/dev/root"; rm "$job"' > $hookdir/initqueue/xcat.sh +# force udevsettle to break +> $hookdir/initqueue/work diff --git a/xCAT-server/share/xcat/netboot/rh/dracut_033/xcat-updateflag b/xCAT-server/share/xcat/netboot/rh/dracut_033/xcat-updateflag new file mode 100755 index 000000000..2f9ac3165 --- /dev/null +++ b/xCAT-server/share/xcat/netboot/rh/dracut_033/xcat-updateflag @@ -0,0 +1,24 @@ +#!/bin/awk -f +#script to feedback the node provision status to xcatd +BEGIN { + + xcatdhost = ARGV[1] + xcatiport = ARGV[2] + + + ns = "/inet/tcp/0/" xcatdhost "/" xcatiport + print "xCAT_xcatd" |& ns + + while(1) { + ns |& getline + + if($0 == "ready") + print ARGV[3] |& ns + if($0 == "done") + break + } + + close(ns) + + exit 0 +} diff --git a/xCAT-server/share/xcat/netboot/rh/dracut_033/xcatroot b/xCAT-server/share/xcat/netboot/rh/dracut_033/xcatroot new file mode 100755 index 000000000..4cde3f1ca --- /dev/null +++ b/xCAT-server/share/xcat/netboot/rh/dracut_033/xcatroot @@ -0,0 +1,259 @@ +#!/bin/sh +NEWROOT=$3 +RWDIR=.statelite +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 + FILENAME=${imgurl##*/} + while [ ! -r "$FILENAME" ]; do + echo Getting $imgurl... + if ! wget $imgurl; then + rm -f $FILENAME + sleep 27 + fi + done + elif [ xnfs = x${imgurl%%:*} ]; then + NFS=1 + SERVER=${imgurl#nfs:} + SERVER=${SERVER#/} + SERVER=${SERVER#/} + ROOTDIR=$SERVER + SERVER=${SERVER%%/*} + SERVER=${SERVER%:} + ROOTDIR=/${ROOTDIR#*/} + fi +fi +#echo 0 > /proc/sys/vm/zone_reclaim_mode #Avoid kernel bug + +if [ -r /rootimg.sfs ]; then + echo Setting up squashfs with ram overlay. + mknod /dev/loop0 b 7 0 + mkdir -p /ro + mkdir -p /rw + mount -t squashfs /rootimg.sfs /ro + mount -t tmpfs rw /rw + mount -t aufs -o dirs=/rw:/ro mergedroot $NEWROOT + mkdir -p $NEWROOT/ro + mkdir -p $NEWROOT/rw + mount --move /ro $NEWROOT/ro + mount --move /rw $NEWROOT/rw +elif [ -r /rootimg.gz ]; then + echo Setting up RAM-root tmpfs. + if [ -z $rootlimit ];then + mount -t tmpfs -o mode=755 rootfs $NEWROOT + else + mount -t tmpfs -o mode=755,size=$rootlimit rootfs $NEWROOT + fi + + cd $NEWROOT + echo -n "Extracting root filesystem:" + if [ -x /bin/cpio ]; then + gzip -cd /rootimg.gz |/bin/cpio -idum + else + gzip -cd /rootimg.gz |cpio -idum + fi + $NEWROOT/etc/init.d/localdisk + echo Done +elif [ -r /rootimg-statelite.gz ]; then + echo Setting up RAM-root tmpfs for statelite mode. + + if [ -z $rootlimit];then + mount -t tmpfs -o mode=755 rootfs $NEWROOT + else + mount -t tmpfs -o mode=755,size=$rootlimit rootfs $NEWROOT + fi + + cd $NEWROOT + echo -n "Extracting root filesystem:" + if [ -x /bin/cpio ]; then + gzip -cd /rootimg-statelite.gz |/bin/cpio -idum + else + gzip -cd /rootimg-statelite.gz |cpio -idum + fi + echo Done + # then, the statelite staffs will be processed + echo Setting up Statelite + modprobe nfs + MAXTRIES=7 + ITER=0 + if [ ! -e "$NEWROOT/$RWDIR" ]; then + echo "" + echo "The /$RWDIR directory doesn't exist in the rootimg... " + echo "" + /bin/sh + fi + + if [ ! -e "$NEWROOT/etc/init.d/statelite" ]; then + echo "" + echo "$NEWROOT/etc/init.d/statelite doesn't exist... " + echo "" + /bin/sh + 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 $STATEMNT ]; then + SNAPSHOTSERVER=${STATEMNT%:*} + SNAPSHOTROOT=${STATEMNT#*/} + if [ -z $SNAPSHOTROOT ]; then + SNAPSHOTROOT=$SNAPSHOTSERVER + SNAPSHOTSERVER= + fi + fi + + if [ ! -z $SNAPSHOTSERVER ]; then + mkdir -p $NEWROOT/$RWDIR/persistent + MAXTRIES=5 + ITER=0 + if [ -z $MNTOPTS ]; then + MNT_OPTIONS="nolock,rsize=32768,tcp,nfsvers=3,timeo=14" + else + MNT_OPTIONS=$MNTOPTS + fi + while ! mount $SNAPSHOTSERVER:/$SNAPSHOTROOT $NEWROOT/$RWDIR/persistent -o $MNT_OPTIONS; do + ITER=$(( ITER + 1 )) + if [ "$ITER" == "$MAXTRIES" ]; then + echo "You are dead, rpower $ME boot to play again." + echo "Possible problems: +1. $SNAPSHOTSERVER is not exporting $SNAPSHOTROOT ? +2. Is DNS set up? Maybe that's why I can't mount $SNAPSHOTSERVER." + /bin/sh + exit + fi + RS=$(( $RANDOM % 20 )) + 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 + $NEWROOT/etc/init.d/statelite + fastboot=yes + export fastboot + keep_old_ip=yes + export keep_old_ip + + mount -n --bind /dev $NEWROOT/dev + mount -n --bind /proc $NEWROOT/proc + mount -n --bind /sys $NEWROOT/sys + +else + echo -n Failed to download image, panicing in 5... + for i in 4 3 2 1 0; do + /bin/sleep 1 + echo -n $i... + done + echo + echo "You're dead. rpower nodename reset to play again. + +* Did you packimage with -m cpio, -m squashfs, or -m nfs? +* If using -m squashfs did you include aufs.ko with geninitrd? + e.g.: -n tg3,squashfs,aufs,loop +* If using -m nfs did you export NFS and sync rootimg? And + did you include the aufs and nfs modules in the proper order: + e.g.: -n tg3,aufs,loop,sunrpc,lockd,nfs_acl,nfs + +" + /bin/dash + exit +fi +cd / + +if [ -z $STATEMNT ]; then + for lf in /tmp/dhclient.*.lease; do + netif=${lf#*.} + 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 +fi + +cp /etc/resolv.conf "$NEWROOT/etc/" + +if [ -d "$NEWROOT/etc/sysconfig" -a ! -e "$NEWROOT/etc/sysconfig/selinux" ]; then + echo "SELINUX=disabled" >> "$NEWROOT/etc/sysconfig/selinux" +fi + +# inject new exit_if_exists +echo 'settle_exit_if_exists="--exit-if-exists=/dev/root"; rm "$job"' > $hookdir/initqueue/xcat.sh +# force udevsettle to break +> $hookdir/initqueue/work From 6a50b11ffca5790972e177d16f693e3e0e7b935d Mon Sep 17 00:00:00 2001 From: daniceexi Date: Wed, 14 May 2014 08:03:35 -0400 Subject: [PATCH 05/99] use ip command to replace ifconfig in xcatroot for diskless on rh3 --- .../share/xcat/netboot/rh/dracut_033/xcatroot | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/xCAT-server/share/xcat/netboot/rh/dracut_033/xcatroot b/xCAT-server/share/xcat/netboot/rh/dracut_033/xcatroot index 4cde3f1ca..feed0dcd3 100755 --- a/xCAT-server/share/xcat/netboot/rh/dracut_033/xcatroot +++ b/xCAT-server/share/xcat/netboot/rh/dracut_033/xcatroot @@ -218,6 +218,25 @@ else fi cd / +function getdevfrommac() { + boothwaddr=$1 + ip link show | while read line + do + dev=`echo $line | egrep "^[0-9]+: [0-9A-Za-z]+" | cut -d ' ' -f 2 | cut -d ':' -f 1` + if [ "X$dev" != "X" ]; then + devname=$dev + fi + + if [ "X$devname" != "X" ]; then + hwaddr=`echo $line | egrep "^[ ]*link" | awk '{print $2}'` + if [ "X$hwaddr" = "X$boothwaddr" ]; then + echo $devname + fi + fi + done +} + + if [ -z $STATEMNT ]; then for lf in /tmp/dhclient.*.lease; do netif=${lf#*.} @@ -233,7 +252,7 @@ if [ -z $STATEMNT ]; then MACX=`ip link show $netdev | grep ether | awk '{print $2}'` elif [ ! -z "$BOOTIF" ]; then MACX=$BOOTIF - ETHX=`ifconfig |grep -i $BOOTIF | awk '{print $1}'` + ETHX=$(getdevfrommac $BOOTIF) fi if [ ! -z "$MACX" ] && [ ! -z "$ETHX" ]; then From 2000a8c562f6bfc048d377532a82c523ac900a3c Mon Sep 17 00:00:00 2001 From: daniceexi Date: Thu, 15 May 2014 03:54:58 -0400 Subject: [PATCH 06/99] for rh7, the initrd for stateless has to been built first to make the installkernel cfg file added first --- xCAT-server/share/xcat/netboot/rh/genimage | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-server/share/xcat/netboot/rh/genimage b/xCAT-server/share/xcat/netboot/rh/genimage index 0acc19ed4..7fc298298 100755 --- a/xCAT-server/share/xcat/netboot/rh/genimage +++ b/xCAT-server/share/xcat/netboot/rh/genimage @@ -779,8 +779,8 @@ system("chroot $rootimg_dir depmod $kernelver"); # the other one is for statelite if ($dracutmode) { - mkinitrd_dracut("statelite"); mkinitrd_dracut("stateless"); + mkinitrd_dracut("statelite"); } else { mkinitrd("statelite"); mkinitrd("stateless"); From 641b6c7aa9b0da04a267fdfa7d32e54129ca3293 Mon Sep 17 00:00:00 2001 From: daniceexi Date: Thu, 15 May 2014 06:56:19 -0400 Subject: [PATCH 07/99] rh7 diskless support that don't cfg tmp in fstab --- .../share/xcat/netboot/rh/compute.rhels7.ppc64.postinstall | 2 -- 1 file changed, 2 deletions(-) diff --git a/xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64.postinstall b/xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64.postinstall index ad071c87c..246dbdd63 100755 --- a/xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64.postinstall +++ b/xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64.postinstall @@ -26,8 +26,6 @@ proc /proc proc rw 0 0 sysfs /sys sysfs rw 0 0 devpts /dev/pts devpts rw,gid=5,mode=620 0 0 ${profile}_${arch} / tmpfs rw 0 1 -none /tmp tmpfs defaults,size=10m 0 2 -none /var/tmp tmpfs defaults,size=10m 0 2 END From b8cacc08b59dbd0923a6ce614bdfdd50d7826f27 Mon Sep 17 00:00:00 2001 From: daniceexi Date: Mon, 19 May 2014 10:17:51 -0400 Subject: [PATCH 08/99] rh7 statelite support. create /etc/sysconfig/network-scripts/ifcfg-ethx for statelite node --- .../netboot/rh/dracut_033/xcat-prepivot.sh | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/xCAT-server/share/xcat/netboot/rh/dracut_033/xcat-prepivot.sh b/xCAT-server/share/xcat/netboot/rh/dracut_033/xcat-prepivot.sh index d6eac21f9..d0e4c97ba 100755 --- a/xCAT-server/share/xcat/netboot/rh/dracut_033/xcat-prepivot.sh +++ b/xCAT-server/share/xcat/netboot/rh/dracut_033/xcat-prepivot.sh @@ -116,6 +116,54 @@ mount -n --bind /dev $NEWROOT/dev mount -n --bind /proc $NEWROOT/proc mount -n --bind /sys $NEWROOT/sys +function getdevfrommac() { + boothwaddr=$1 + ip link show | while read line + do + dev=`echo $line | egrep "^[0-9]+: [0-9A-Za-z]+" | cut -d ' ' -f 2 | cut -d ':' -f 1` + if [ "X$dev" != "X" ]; then + devname=$dev + fi + + if [ "X$devname" != "X" ]; then + hwaddr=`echo $line | egrep "^[ ]*link" | awk '{print $2}'` + if [ "X$hwaddr" = "X$boothwaddr" ]; then + echo $devname + fi + fi + done +} + + +for lf in /tmp/dhclient.*.lease; do + netif=${lf#*.} + 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=$(getdevfrommac $BOOTIF) +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 echo "SELINUX=disabled" >> "$NEWROOT/etc/sysconfig/selinux" fi From 990b282fc7615f51e58b2fe38789dffd04190560 Mon Sep 17 00:00:00 2001 From: daniceexi Date: Mon, 19 May 2014 10:20:00 -0400 Subject: [PATCH 09/99] rh7 statelite support. remove the root dir from fstab to avoiding the remount which overwrite the root dir to rw --- .../share/xcat/netboot/rh/compute.rhels7.ppc64.postinstall | 1 - 1 file changed, 1 deletion(-) diff --git a/xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64.postinstall b/xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64.postinstall index 246dbdd63..dc423d20d 100755 --- a/xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64.postinstall +++ b/xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64.postinstall @@ -25,7 +25,6 @@ cat <$installroot/etc/fstab proc /proc proc rw 0 0 sysfs /sys sysfs rw 0 0 devpts /dev/pts devpts rw,gid=5,mode=620 0 0 -${profile}_${arch} / tmpfs rw 0 1 END From 50322fae7d7911f810f5a1271013e93ceae59c76 Mon Sep 17 00:00:00 2001 From: daniceexi Date: Mon, 19 May 2014 10:22:48 -0400 Subject: [PATCH 10/99] rh stateless support. remove the tmp and root dir mount requirement in fstab. They can be handled correctly by dracut and dracut cfg file --- .../share/xcat/netboot/rh/compute.rhels7.x86_64.postinstall | 3 --- 1 file changed, 3 deletions(-) diff --git a/xCAT-server/share/xcat/netboot/rh/compute.rhels7.x86_64.postinstall b/xCAT-server/share/xcat/netboot/rh/compute.rhels7.x86_64.postinstall index f157e7421..01bc23cb4 100755 --- a/xCAT-server/share/xcat/netboot/rh/compute.rhels7.x86_64.postinstall +++ b/xCAT-server/share/xcat/netboot/rh/compute.rhels7.x86_64.postinstall @@ -25,9 +25,6 @@ cat <$installroot/etc/fstab proc /proc proc rw 0 0 sysfs /sys sysfs rw 0 0 devpts /dev/pts devpts rw,gid=5,mode=620 0 0 -${profile}_${arch} / tmpfs rw 0 1 -none /tmp tmpfs defaults,size=10m 0 2 -none /var/tmp tmpfs defaults,size=10m 0 2 END #-- Uncomment the line contains "cons" in /etc/inittab From c6165321945b46be6a6917b1ec56df7c78ab174f Mon Sep 17 00:00:00 2001 From: daniceexi Date: Tue, 20 May 2014 07:59:01 -0400 Subject: [PATCH 11/99] defect 4133: transfer the xml specific character which starts with & to general format --- xCAT-server/share/xcat/install/scripts/post.debian | 4 ++-- xCAT-server/share/xcat/install/scripts/post.ubuntu | 4 ++-- xCAT-server/share/xcat/install/scripts/post.xcat | 4 ++-- xCAT/postscripts/xcatdsklspost | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/xCAT-server/share/xcat/install/scripts/post.debian b/xCAT-server/share/xcat/install/scripts/post.debian index 08dea2719..9e9038d31 100644 --- a/xCAT-server/share/xcat/install/scripts/post.debian +++ b/xCAT-server/share/xcat/install/scripts/post.debian @@ -59,7 +59,7 @@ do mv $i/postscripts /xcatpost rm -rf $i chmod +x /xcatpost/* - /xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /xcatpost/mypostscript + /xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' | sed -e 's/<//' -e 's/&/&/' -e 's/"/"/' -e "s/'/'/" > /xcatpost/mypostscript MYCONT=`grep MASTER /xcatpost/mypostscript` MAX_RETRIES=10 RETRY=0 @@ -72,7 +72,7 @@ do let SLI=$RANDOM%10+10 sleep $SLI - /xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /xcatpost/mypostscript + /xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' | sed -e 's/<//' -e 's/&/&/' -e 's/"/"/' -e "s/'/'/" > /xcatpost/mypostscript MYCONT=`grep MASTER /xcatpost/mypostscript` done diff --git a/xCAT-server/share/xcat/install/scripts/post.ubuntu b/xCAT-server/share/xcat/install/scripts/post.ubuntu index eb64b7e4b..34f1f4a5f 100644 --- a/xCAT-server/share/xcat/install/scripts/post.ubuntu +++ b/xCAT-server/share/xcat/install/scripts/post.ubuntu @@ -61,7 +61,7 @@ do mv $i/postscripts /xcatpost rm -rf $i chmod +x /xcatpost/* - /xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /xcatpost/mypostscript + /xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' | sed -e 's/<//' -e 's/&/&/' -e 's/"/"/' -e "s/'/'/" > /xcatpost/mypostscript MYCONT=`grep MASTER /xcatpost/mypostscript` MAX_RETRIES=10 RETRY=0 @@ -74,7 +74,7 @@ do let SLI=$RANDOM%10+10 sleep $SLI - /xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /xcatpost/mypostscript + /xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' | sed -e 's/<//' -e 's/&/&/' -e 's/"/"/' -e "s/'/'/" > /xcatpost/mypostscript MYCONT=`grep MASTER /xcatpost/mypostscript` done diff --git a/xCAT-server/share/xcat/install/scripts/post.xcat b/xCAT-server/share/xcat/install/scripts/post.xcat index 61dbd8379..054d74daa 100755 --- a/xCAT-server/share/xcat/install/scripts/post.xcat +++ b/xCAT-server/share/xcat/install/scripts/post.xcat @@ -44,7 +44,7 @@ do if [ ! -x /xcatpost/mypostscript ]; then chmod +x /xcatpost/* - /xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /xcatpost/mypostscript + /xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' | sed -e 's/<//' -e 's/&/&/' -e 's/"/"/' -e "s/'/'/" > /xcatpost/mypostscript MYCONT=`grep MASTER /xcatpost/mypostscript` @@ -59,7 +59,7 @@ do let SLI=$RANDOM%10+10 sleep $SLI - /xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /xcatpost/mypostscript + /xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' | sed -e 's/<//' -e 's/&/&/' -e 's/"/"/' -e "s/'/'/" > /xcatpost/mypostscript MYCONT=`grep MASTER /xcatpost/mypostscript` done diff --git a/xCAT/postscripts/xcatdsklspost b/xCAT/postscripts/xcatdsklspost index 4bed671bf..38b33b28c 100755 --- a/xCAT/postscripts/xcatdsklspost +++ b/xCAT/postscripts/xcatdsklspost @@ -508,7 +508,7 @@ if [ ! -x /$xcatpost/mypostscript ]; then useflowcontrol=0 fi fi - /$xcatpost/getpostscript.awk | egrep '' | sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /$xcatpost/mypostscript; + /$xcatpost/getpostscript.awk | egrep '' | sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' | sed -e 's/<//' -e 's/&/&/' -e 's/"/"/' -e "s/'/'/" > /$xcatpost/mypostscript; MYCONT=`grep MASTER /$xcatpost/mypostscript` @@ -539,7 +539,7 @@ if [ ! -x /$xcatpost/mypostscript ]; then useflowcontrol=0 fi fi - /$xcatpost/getpostscript.awk | sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /$xcatpost/mypostscript; + /$xcatpost/getpostscript.awk | sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' | sed -e 's/<//' -e 's/&/&/' -e 's/"/"/' -e "s/'/'/" > /$xcatpost/mypostscript; MYCONT=`grep MASTER /$xcatpost/mypostscript` if [ ! -z "$MYCONT" ]; then break; From 2bd823ec590f88f46f704200c221764c67bfaa92 Mon Sep 17 00:00:00 2001 From: daniceexi Date: Tue, 20 May 2014 10:14:22 -0400 Subject: [PATCH 12/99] defect 4134: missing the use of xCAT::SvrUtils in conserver.pm so that when makeconservercf walks into error path to call SverUtils->sendmsg, an code error is displayed --- xCAT-server/lib/xcat/plugins/conserver.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/xCAT-server/lib/xcat/plugins/conserver.pm b/xCAT-server/lib/xcat/plugins/conserver.pm index da4aeb285..adb2a0d60 100644 --- a/xCAT-server/lib/xcat/plugins/conserver.pm +++ b/xCAT-server/lib/xcat/plugins/conserver.pm @@ -7,6 +7,7 @@ use xCAT::Utils; use xCAT::TableUtils; use Getopt::Long; use Sys::Hostname; +use xCAT::SvrUtils; use strict; use Data::Dumper; From c3129c1701257b7ee99c0915c3c28a4a6cabcc56 Mon Sep 17 00:00:00 2001 From: daniceexi Date: Wed, 21 May 2014 04:37:35 -0400 Subject: [PATCH 13/99] defect 4125:support to have parameters in niccustomscripts attribute --- xCAT/postscripts/confignics | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/xCAT/postscripts/confignics b/xCAT/postscripts/confignics index bcfbe3cbd..5e2803f5b 100755 --- a/xCAT/postscripts/confignics +++ b/xCAT/postscripts/confignics @@ -19,16 +19,19 @@ function splitconfig(){ IFS=$',' array_conf_temp=($1) IFS=$old_ifs - for i in ${array_conf_temp[@]} + + i=0 + while [ $i -lt ${#array_conf_temp[@]} ] do + token="${array_conf_temp[$i]}" D= - if [ `echo $i | grep "!"` ];then + if echo "$token" | grep "!"; then D="!" else D=":" fi - key=`echo $i | cut -d"$D" -f 1` - str_temp_value=`echo $i | cut -d"$D" -f 2` + key=`echo "$token" | cut -d"$D" -f 1` + str_temp_value=`echo "$token" | cut -d"$D" -f 2` str_temp=$(hashget hash_defined_nics $key) if [ -n "$str_temp" ];then @@ -37,7 +40,8 @@ function splitconfig(){ str_temp="$str_temp_value" str_all_nics=$str_all_nics"$key " fi - hashset hash_defined_nics $key $str_temp + hashset hash_defined_nics $key "$str_temp" + i=$((i+1)) done } @@ -198,8 +202,8 @@ if [ -z "$NICIPS" ];then exit 0 fi -splitconfig $NICIPS -splitconfig $NICCUSTOMSCRIPTS +splitconfig "$NICIPS" +splitconfig "$NICCUSTOMSCRIPTS" if [ $boot_myscript -eq 1 ];then . $str_dir_name/$myscript From f56d9b0c1223d1239a99d05854491dcbce84411b Mon Sep 17 00:00:00 2001 From: daniceexi Date: Fri, 23 May 2014 03:03:30 -0400 Subject: [PATCH 14/99] defect: 4133: fix the code to transfer escape character for the output of getpostscript.awk --- xCAT/postscripts/xcatdsklspost | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xCAT/postscripts/xcatdsklspost b/xCAT/postscripts/xcatdsklspost index 38b33b28c..c9ac442bc 100755 --- a/xCAT/postscripts/xcatdsklspost +++ b/xCAT/postscripts/xcatdsklspost @@ -508,7 +508,7 @@ if [ ! -x /$xcatpost/mypostscript ]; then useflowcontrol=0 fi fi - /$xcatpost/getpostscript.awk | egrep '' | sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' | sed -e 's/<//' -e 's/&/&/' -e 's/"/"/' -e "s/'/'/" > /$xcatpost/mypostscript; + /$xcatpost/getpostscript.awk | egrep '' | sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' | sed -e 's/<//g' -e 's/&/\&/g' -e 's/"/"/g' -e "s/'/'/g" > /$xcatpost/mypostscript; MYCONT=`grep MASTER /$xcatpost/mypostscript` @@ -539,7 +539,7 @@ if [ ! -x /$xcatpost/mypostscript ]; then useflowcontrol=0 fi fi - /$xcatpost/getpostscript.awk | sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' | sed -e 's/<//' -e 's/&/&/' -e 's/"/"/' -e "s/'/'/" > /$xcatpost/mypostscript; + /$xcatpost/getpostscript.awk | sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' | sed -e 's/<//g' -e 's/&/\&/g' -e 's/"/"/g' -e "s/'/'/g" > /$xcatpost/mypostscript; MYCONT=`grep MASTER /$xcatpost/mypostscript` if [ ! -z "$MYCONT" ]; then break; From 70e64d8b68b1749c6882fd05f5244082848d69f2 Mon Sep 17 00:00:00 2001 From: daniceexi Date: Mon, 26 May 2014 01:18:28 -0400 Subject: [PATCH 15/99] defect 4133: continue the fix for the xml escape char conversion when getting mypostscript --- xCAT-server/share/xcat/install/scripts/post.debian | 4 ++-- xCAT-server/share/xcat/install/scripts/post.ubuntu | 4 ++-- xCAT-server/share/xcat/install/scripts/post.xcat | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/xCAT-server/share/xcat/install/scripts/post.debian b/xCAT-server/share/xcat/install/scripts/post.debian index 9e9038d31..5d54bc7d6 100644 --- a/xCAT-server/share/xcat/install/scripts/post.debian +++ b/xCAT-server/share/xcat/install/scripts/post.debian @@ -59,7 +59,7 @@ do mv $i/postscripts /xcatpost rm -rf $i chmod +x /xcatpost/* - /xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' | sed -e 's/<//' -e 's/&/&/' -e 's/"/"/' -e "s/'/'/" > /xcatpost/mypostscript + /xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' | sed -e 's/<//g' -e 's/&/\&/g' -e 's/"/"/g' -e "s/'/'/g" > /xcatpost/mypostscript MYCONT=`grep MASTER /xcatpost/mypostscript` MAX_RETRIES=10 RETRY=0 @@ -72,7 +72,7 @@ do let SLI=$RANDOM%10+10 sleep $SLI - /xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' | sed -e 's/<//' -e 's/&/&/' -e 's/"/"/' -e "s/'/'/" > /xcatpost/mypostscript + /xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' | sed -e 's/<//g' -e 's/&/\&/g' -e 's/"/"/g' -e "s/'/'/g" > /xcatpost/mypostscript MYCONT=`grep MASTER /xcatpost/mypostscript` done diff --git a/xCAT-server/share/xcat/install/scripts/post.ubuntu b/xCAT-server/share/xcat/install/scripts/post.ubuntu index 34f1f4a5f..618ae1aad 100644 --- a/xCAT-server/share/xcat/install/scripts/post.ubuntu +++ b/xCAT-server/share/xcat/install/scripts/post.ubuntu @@ -61,7 +61,7 @@ do mv $i/postscripts /xcatpost rm -rf $i chmod +x /xcatpost/* - /xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' | sed -e 's/<//' -e 's/&/&/' -e 's/"/"/' -e "s/'/'/" > /xcatpost/mypostscript + /xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' | sed -e 's/<//g' -e 's/&/\&/g' -e 's/"/"/g' -e "s/'/'/g" > /xcatpost/mypostscript MYCONT=`grep MASTER /xcatpost/mypostscript` MAX_RETRIES=10 RETRY=0 @@ -74,7 +74,7 @@ do let SLI=$RANDOM%10+10 sleep $SLI - /xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' | sed -e 's/<//' -e 's/&/&/' -e 's/"/"/' -e "s/'/'/" > /xcatpost/mypostscript + /xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' | sed -e 's/<//g' -e 's/&/\&/g' -e 's/"/"/g' -e "s/'/'/g" > /xcatpost/mypostscript MYCONT=`grep MASTER /xcatpost/mypostscript` done diff --git a/xCAT-server/share/xcat/install/scripts/post.xcat b/xCAT-server/share/xcat/install/scripts/post.xcat index 054d74daa..10d406998 100755 --- a/xCAT-server/share/xcat/install/scripts/post.xcat +++ b/xCAT-server/share/xcat/install/scripts/post.xcat @@ -44,7 +44,7 @@ do if [ ! -x /xcatpost/mypostscript ]; then chmod +x /xcatpost/* - /xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' | sed -e 's/<//' -e 's/&/&/' -e 's/"/"/' -e "s/'/'/" > /xcatpost/mypostscript + /xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' | sed -e 's/<//g' -e 's/&/\&/g' -e 's/"/"/g' -e "s/'/'/g" > /xcatpost/mypostscript MYCONT=`grep MASTER /xcatpost/mypostscript` @@ -59,7 +59,7 @@ do let SLI=$RANDOM%10+10 sleep $SLI - /xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' | sed -e 's/<//' -e 's/&/&/' -e 's/"/"/' -e "s/'/'/" > /xcatpost/mypostscript + /xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' | sed -e 's/<//g' -e 's/&/\&/g' -e 's/"/"/g' -e "s/'/'/g" > /xcatpost/mypostscript MYCONT=`grep MASTER /xcatpost/mypostscript` done From 43998b11e2b1c06dc29179276f5df66aafbcaae8 Mon Sep 17 00:00:00 2001 From: immarvin Date: Fri, 23 May 2014 02:56:39 -0700 Subject: [PATCH 16/99] correct the getNodeNetworkCfg to get the network gateway --- perl-xCAT/xCAT/NetworkUtils.pm | 96 +++++++++++++++++----------------- 1 file changed, 49 insertions(+), 47 deletions(-) diff --git a/perl-xCAT/xCAT/NetworkUtils.pm b/perl-xCAT/xCAT/NetworkUtils.pm index 1bd6397e0..4926e0be5 100755 --- a/perl-xCAT/xCAT/NetworkUtils.pm +++ b/perl-xCAT/xCAT/NetworkUtils.pm @@ -1992,50 +1992,6 @@ sub isIpaddr } -#------------------------------------------------------------------------------- -=head3 getSubnetGateway - Description: - Get gateway from the networks table of the specified net. - - Arguments: - net: the net, ie. the "net" field of the networks table - Returns: - Return a string, of the gateway - undef - Failed to get the gateway - Globals: - none - Error: - none - Example: - my $gateway = xCAT::NetworkUtils::getSubnetGateway('192.168.1.0'); - Comments: - none - -=cut -#------------------------------------------------------------------------------- -sub getSubnetGateway -{ - my $netname=shift; - if( $netname =~ /xCAT::NetworkUtils/) - { - $netname=shift; - } - - my $gateway=undef; - my $nettab = xCAT::Table->new("networks"); - unless($nettab) { die "No entry defined in networks"; } - my @nets = $nettab->getAllAttribs('net','gateway'); - foreach(@nets) - { - if("$_->{net}" eq "$netname") - { - $gateway = $_->{gateway}; - last; - } - } - - return $gateway; -} #------------------------------------------------------------------------------- @@ -2093,6 +2049,50 @@ sub getNodeNameservers{ return \%nodenameservers; } +#------------------------------------------------------------------------------- +=head3 getNodeGateway + Description: + Get gateway from the networks table of the node. + + Arguments: + ip: the ip address of the node + Returns: + Return a string, of the gateway + undef - Failed to get the gateway + Globals: + none + Error: + none + Example: + my $gateway = xCAT::NetworkUtils::getNodeGateway('192.168.1.0'); + Comments: + none + +=cut +#------------------------------------------------------------------------------- +sub getNodeGateway +{ + my $ip=shift; + if( $ip =~ /xCAT::NetworkUtils/) + { + $ip=shift; + } + my $gateway=undef; + + my $nettab = xCAT::Table->new("networks"); + if ($nettab) { + my @nets = $nettab->getAllAttribs('net','mask','gateway'); + foreach my $net (@nets) { + if (xCAT::NetworkUtils::isInSameSubnet( $net->{'net'}, $ip, $net->{'mask'}, 0)) { + $gateway=$net->{'gateway'}; + } + } + } + + + return $gateway; +} + #------------------------------------------------------------------------------- =head3 getNodeNetworkCfg @@ -2122,8 +2122,8 @@ sub getNodeNetworkCfg if( $node =~ /xCAT::NetworkUtils/) { $node =shift; - } - + } + my $nets = xCAT::NetworkUtils::my_nets(); my $ip = xCAT::NetworkUtils->getipaddr($node); my $mask = undef; @@ -2132,12 +2132,14 @@ sub getNodeNetworkCfg { my $netname; ($netname,$mask) = split /\//, $net; - $gateway=xCAT::NetworkUtils::getSubnetGateway($netname); last if ( xCAT::NetworkUtils::isInSameSubnet( $netname, $ip, $mask, 1)); } + $gateway=xCAT::NetworkUtils::getNodeGateway($ip); return ($ip, $node, $gateway, xCAT::NetworkUtils::formatNetmask($mask,1,0)); } + + #------------------------------------------------------------------------------- =head3 get_hdwr_ip From 0b999b2888d81853a40674d8a4d2b150ae82ab7c Mon Sep 17 00:00:00 2001 From: immarvin Date: Mon, 26 May 2014 21:13:54 -0700 Subject: [PATCH 17/99] add grub2-xcat as the dependency of xCAT-server --- xCAT-server/xCAT-server.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-server/xCAT-server.spec b/xCAT-server/xCAT-server.spec index 2b6ee0988..3c8a18b62 100644 --- a/xCAT-server/xCAT-server.spec +++ b/xCAT-server/xCAT-server.spec @@ -34,7 +34,7 @@ Obsoletes: atftp-xcat %ifos linux %ifnarch s390x # PCM does not use or ship grub2-xcat -#Requires: grub2-xcat +Requires: grub2-xcat %endif %endif %endif From 1039462c4476a5734baa2a3c699386c0f481850d Mon Sep 17 00:00:00 2001 From: daniceexi Date: Tue, 27 May 2014 07:46:47 -0400 Subject: [PATCH 18/99] xcatws.cgi: fix the output when slpnodes resource has no output; fix the output message for nodestat resource --- xCAT-server/xCAT-wsapi/xcatws.cgi | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/xCAT-server/xCAT-wsapi/xcatws.cgi b/xCAT-server/xCAT-wsapi/xcatws.cgi index c63a2b164..bc29399a4 100755 --- a/xCAT-server/xCAT-wsapi/xcatws.cgi +++ b/xCAT-server/xCAT-wsapi/xcatws.cgi @@ -124,7 +124,7 @@ my %URIdef = ( GET => { desc => "Get the running status for the node {noderange}.", usage => "||$usagemsg{objreturn}|", - example => "|Get the running status for node node1|GET|/nodes/node1/nodestat|x|", + example => "|Get the running status for node node1|GET|/nodes/node1/nodestat|{\n \"node1\":{\n \"nodestat\":\"noping\"\n }\n}|", cmd => "nodestat", fhandler => \&actionhdl, outhdler => \&actionout, @@ -1401,6 +1401,9 @@ sub defout { $lines = \@alldata; } foreach my $l (@$lines) { + if ($l =~ /No responses/) { # handle the case that no output from lsslp command + return; + } if ($l =~ /^Object name: / || $l =~ /^\S+:$/) { # start new node if ($l =~ /^Object name:\s+(\S+)/) { # handle the output of lsdef -t $nodename = $1; From ceb63707714848fba5238f809340e4ea34342dd9 Mon Sep 17 00:00:00 2001 From: daniceexi Date: Tue, 27 May 2014 08:33:55 -0400 Subject: [PATCH 19/99] fix a minor typo in destiny.pm --- xCAT-server/lib/xcat/plugins/destiny.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/destiny.pm b/xCAT-server/lib/xcat/plugins/destiny.pm index fed153414..a0b5ecd6f 100755 --- a/xCAT-server/lib/xcat/plugins/destiny.pm +++ b/xCAT-server/lib/xcat/plugins/destiny.pm @@ -609,8 +609,8 @@ sub nextdestiny { } if ($callnodeset) { - $args; - if($noupdate_flag) + my $args; + if($noupdate_flag) { $args = ['enact', '--noupdateinitrd']; } From 16ecce4057bc51f64a7e785c1cda4f7f86667ac0 Mon Sep 17 00:00:00 2001 From: daniceexi Date: Tue, 27 May 2014 09:44:35 -0400 Subject: [PATCH 20/99] defect 4083: the dash and busybox rpm packages have been removed from rh7 iso and xcat stateless and satelite do not need them any more for rh7, so remove them from the stateless and statelite pkglist --- xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64.pkglist | 2 -- xCAT-server/share/xcat/netboot/rh/compute.rhels7.x86_64.pkglist | 2 -- 2 files changed, 4 deletions(-) diff --git a/xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64.pkglist b/xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64.pkglist index 452804038..aee31ff58 100644 --- a/xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64.pkglist +++ b/xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64.pkglist @@ -5,10 +5,8 @@ dhclient kernel openssh-server openssh-clients -busybox wget rsyslog -dash vim-minimal ntp rsyslog diff --git a/xCAT-server/share/xcat/netboot/rh/compute.rhels7.x86_64.pkglist b/xCAT-server/share/xcat/netboot/rh/compute.rhels7.x86_64.pkglist index 18ceb3e33..410cd004c 100644 --- a/xCAT-server/share/xcat/netboot/rh/compute.rhels7.x86_64.pkglist +++ b/xCAT-server/share/xcat/netboot/rh/compute.rhels7.x86_64.pkglist @@ -6,8 +6,6 @@ dhclient kernel openssh-server openssh-clients -busybox -dash iputils bc irqbalance From 76a8941cbc90859a8b0ce5def3b8d3e1830519e8 Mon Sep 17 00:00:00 2001 From: ligc Date: Tue, 27 May 2014 16:58:08 -0500 Subject: [PATCH 21/99] fix for bug 4142: add vios as a new device type --- perl-xCAT/xCAT/RemoteShellExp.pm | 4 ++++ xCAT-server/share/xcat/devicetype/vios/config | 5 +++++ 2 files changed, 9 insertions(+) create mode 100644 xCAT-server/share/xcat/devicetype/vios/config diff --git a/perl-xCAT/xCAT/RemoteShellExp.pm b/perl-xCAT/xCAT/RemoteShellExp.pm index 90b15ed43..df62c73fa 100755 --- a/perl-xCAT/xCAT/RemoteShellExp.pm +++ b/perl-xCAT/xCAT/RemoteShellExp.pm @@ -810,6 +810,10 @@ sub senddeviceskeys # add to the command $setupcmd .=$key; $setupcmd .="\""; + # Special case for vios + if ($ENV{DEVICETYPE} eq 'vios') { + $setupcmd = "\"echo $key | tee -a ~/.ssh/authorized_keys2\""; + } # For each input device my @nodelist=split(/,/,$nodes); foreach my $node (@nodelist) { diff --git a/xCAT-server/share/xcat/devicetype/vios/config b/xCAT-server/share/xcat/devicetype/vios/config new file mode 100644 index 000000000..da9165090 --- /dev/null +++ b/xCAT-server/share/xcat/devicetype/vios/config @@ -0,0 +1,5 @@ +[main] +ssh-setup-command=echo +[xdsh] +pre-command=NULL +post-command=NULL From ccccc1e74368a3e3ab519d33d649b68a7ccd2246 Mon Sep 17 00:00:00 2001 From: lissav Date: Tue, 27 May 2014 09:31:50 -0400 Subject: [PATCH 22/99] defect 4138 --- xCAT-server/lib/xcat/plugins/updatenode.pm | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/xCAT-server/lib/xcat/plugins/updatenode.pm b/xCAT-server/lib/xcat/plugins/updatenode.pm index 2861206e3..c39693c92 100644 --- a/xCAT-server/lib/xcat/plugins/updatenode.pm +++ b/xCAT-server/lib/xcat/plugins/updatenode.pm @@ -1385,6 +1385,13 @@ sub updatenoderunps foreach my $snkey (keys %servernodes) { + if ((!defined($snkey)) or ($snkey eq "")) { # if we could not find the xcatmaster + + my $rsp = {}; + $rsp->{error}->[0] = "Could not find xcatmaster for @{$servernodes{$snkey}}. Will skip this node. "; + $callback->($rsp); + next; + } my $nodestring = join(',', @{$servernodes{$snkey}}); my $args; my $mode; From 15b679b90797ab18d6387757b213847eb7298425 Mon Sep 17 00:00:00 2001 From: lissav Date: Tue, 27 May 2014 09:50:30 -0400 Subject: [PATCH 23/99] defect 4076 --- xCAT-server/lib/xcat/plugins/imgport.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-server/lib/xcat/plugins/imgport.pm b/xCAT-server/lib/xcat/plugins/imgport.pm index 198fee11c..8156b0a4c 100644 --- a/xCAT-server/lib/xcat/plugins/imgport.pm +++ b/xCAT-server/lib/xcat/plugins/imgport.pm @@ -1802,7 +1802,7 @@ sub make_files { } if ( $hasplugin ) { # Issue xcatd reload to load the new plugins - system("/etc/init.d/xcatd reload"); + system("/etc/init.d/xcatd restart"); $hasplugin=0; } From 4bcc4e2dbcd9ca954809d6fbef934c16e6f30484 Mon Sep 17 00:00:00 2001 From: lissav Date: Tue, 27 May 2014 09:52:06 -0400 Subject: [PATCH 24/99] defect 4076 --- xCAT-rmc/xCAT-rmc.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-rmc/xCAT-rmc.spec b/xCAT-rmc/xCAT-rmc.spec index 6262886df..d7c6f6e73 100644 --- a/xCAT-rmc/xCAT-rmc.spec +++ b/xCAT-rmc/xCAT-rmc.spec @@ -106,7 +106,7 @@ fi %ifos linux if [ -f "/proc/cmdline" ]; then # prevent running it during install into chroot image if [ -f $RPM_INSTALL_PREFIX0/sbin/xcatd ]; then - /etc/init.d/xcatd reload + /etc/init.d/xcatd restart fi fi %else From bd774c768f32d3bdda3eafd4e6e6959dd7a446df Mon Sep 17 00:00:00 2001 From: lissav Date: Tue, 27 May 2014 10:01:22 -0400 Subject: [PATCH 25/99] defect 4076 + DB2 updates --- xCAT-server/lib/xcat/plugins/kit.pm | 69 +++++++++++++++++++++++------ 1 file changed, 55 insertions(+), 14 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/kit.pm b/xCAT-server/lib/xcat/plugins/kit.pm index 0d6912c54..aec853777 100644 --- a/xCAT-server/lib/xcat/plugins/kit.pm +++ b/xCAT-server/lib/xcat/plugins/kit.pm @@ -1411,7 +1411,7 @@ sub addkit if ( $hasplugin ) { # Issue xcatd reload to load the new plugins - system("/etc/init.d/xcatd reload"); + system("/etc/init.d/xcatd restart"); } } } @@ -1494,6 +1494,7 @@ sub rmkit my %kitnames; my $des = shift @ARGV; my @kits = split ',', $des; + my $DBname = xCAT::Utils->get_DBName; # support for DB2 foreach my $kit (@kits) { # Check if it is a kitname or basename @@ -1508,7 +1509,12 @@ sub rmkit } $kitnames{$kit} = 1; } else { - my @entries = $tabs{kit}->getAllAttribsWhere( "basename = '$kit'", 'kitname', 'isinternal'); + my @entries; + if ($DBname =~ /^DB2/) { + @entries = $tabs{kit}->getAllAttribsWhere( "\"basename\" = '$kit'", 'kitname', 'isinternal'); + } else { + @entries = $tabs{kit}->getAllAttribsWhere( "basename = '$kit'", 'kitname', 'isinternal'); + } unless (@entries) { my %rsp; push@{ $rsp{data} }, "Kit $kit could not be found in DB $t"; @@ -1545,8 +1551,12 @@ sub rmkit # Find all the components in this kit. my $kitcompnames; - my @kitcomphash = $tabs{kitcomponent}->getAllAttribsWhere( "kitname = '$kitname'", 'kitcompname', 'postbootscripts', 'genimage_postinstall'); - + my @kitcomphash; + if ($DBname =~ /^DB2/) { + @kitcomphash = $tabs{kitcomponent}->getAllAttribsWhere( "\"kitname\" = '$kitname'", 'kitcompname', 'postbootscripts', 'genimage_postinstall'); + } else { + @kitcomphash = $tabs{kitcomponent}->getAllAttribsWhere( "kitname = '$kitname'", 'kitcompname', 'postbootscripts', 'genimage_postinstall'); + } if (@entries && (@entries > 0)) { if($::VERBOSE and !$test){ @@ -1682,7 +1692,12 @@ sub rmkit } # Remove kitrepo - my @kitrepohash = $tabs{kitrepo}->getAllAttribsWhere( "kitname = '$kitname'", 'kitreponame'); + my @kitrepohash; + if ($DBname =~ /^DB2/) { + @kitrepohash = $tabs{kitrepo}->getAllAttribsWhere( "\"kitname\" = '$kitname'", 'kitreponame'); + } else { + @kitrepohash = $tabs{kitrepo}->getAllAttribsWhere( "kitname = '$kitname'", 'kitreponame'); + } foreach my $kitrepo ( @kitrepohash ) { my $kitreponame = $kitrepo->{kitreponame}; $tabs{kitrepo}->delEntries({kitreponame => $kitreponame}); @@ -1716,7 +1731,7 @@ sub rmkit if ( $hasplugin ) { # Issue xcatd reload to load the new plugins - system("/etc/init.d/xcatd reload"); + system("/etc/init.d/xcatd restart"); } } @@ -1878,7 +1893,7 @@ sub addkitcomp return 1; } - + my $DBname = xCAT::Utils->get_DBName; # support for DB2 my %tabs = (); my @tables = qw(kit kitrepo kitcomponent osimage osdistro linuximage); foreach my $t ( @tables ) { @@ -1911,7 +1926,12 @@ sub addkitcomp $kitcomps{$kitcomponent}{name} = $kitcomponent; $kitcomps{$kitcomponent}{basename} = $kitcomptable->{'basename'}; } else { - my @entries = $tabs{kitcomponent}->getAllAttribsWhere( "basename = '$kitcomponent'", 'kitcompname' , 'version', 'release'); + my @entries; + if ($DBname =~ /^DB2/) { + @entries = $tabs{kitcomponent}->getAllAttribsWhere( "\"basename\" = '$kitcomponent'", 'kitcompname' , 'version', 'release'); + } else { + @entries = $tabs{kitcomponent}->getAllAttribsWhere( "basename = '$kitcomponent'", 'kitcompname' , 'version', 'release'); + } unless (@entries) { my %rsp; push@{ $rsp{data} }, "$kitcomponent kitcomponent does not exist"; @@ -2101,7 +2121,12 @@ sub addkitcomp my @kitcompdeps = split ',', $kitcomptable->{'kitcompdeps'}; foreach my $kitcompdependency ( @kitcompdeps ) { my ($kitcompdep, $vers) = split /<=|>=|=|<|>/, $kitcompdependency; - my @entries = $tabs{kitcomponent}->getAllAttribsWhere( "basename = '$kitcompdep'", 'kitreponame', 'kitname', 'kitcompname' , 'serverroles', 'kitcompdeps', 'version', 'prerequisite', 'release'); + my @entries; + if ($DBname =~ /^DB2/) { + @entries = $tabs{kitcomponent}->getAllAttribsWhere( "\"basename\" = '$kitcompdep'", 'kitreponame', 'kitname', 'kitcompname' , 'serverroles', 'kitcompdeps', 'version', 'prerequisite', 'release'); + } else { + @entries = $tabs{kitcomponent}->getAllAttribsWhere( "basename = '$kitcompdep'", 'kitreponame', 'kitname', 'kitcompname' , 'serverroles', 'kitcompdeps', 'version', 'prerequisite', 'release'); + } unless (@entries) { my %rsp; push@{ $rsp{data} }, "Cannot find any matched kit component for kit component $kitcomp dependency $kitcompdep"; @@ -2413,7 +2438,7 @@ sub rmkitcomp return 1; } - + my $DBname = xCAT::Utils->get_DBName; # support for DB2 my %tabs = (); my @tables = qw(kit kitrepo kitcomponent osimage osdistro linuximage); foreach my $t ( @tables ) { @@ -2456,7 +2481,12 @@ sub rmkitcomp $kitcomps{$kitcomponent}{driverpacks} = $kitcomptable->{driverpacks}; $kitcomps{$kitcomponent}{genimage_postinstall} = $kitcomptable->{genimage_postinstall}; } else { - my @entries = $tabs{kitcomponent}->getAllAttribsWhere( "basename = '$kitcomponent'", 'kitcompname' , 'version', 'release'); + my @entries; + if ($DBname =~ /^DB2/) { + @entries = $tabs{kitcomponent}->getAllAttribsWhere( "\"basename\" = '$kitcomponent'", 'kitcompname' , 'version', 'release'); + } else { + @entries = $tabs{kitcomponent}->getAllAttribsWhere( "basename = '$kitcomponent'", 'kitcompname' , 'version', 'release'); + } unless (@entries) { my %rsp; push@{ $rsp{data} }, "$kitcomponent kitcomponent does not exist"; @@ -2530,7 +2560,12 @@ sub rmkitcomp my ($kitcompdep, $vers) = split /<=|>=|=|<|>/, $kitcompdependency; # Get the kit component full name from basename. - my @entries = $tabs{kitcomponent}->getAllAttribsWhere( "basename = '$kitcompdep'", 'kitcompname' , 'version', 'release'); + my @entries; + if ($DBname =~ /^DB2/) { + @entries = $tabs{kitcomponent}->getAllAttribsWhere( "\"basename\" = '$kitcompdep'", 'kitcompname' , 'version', 'release'); + } else { + @entries = $tabs{kitcomponent}->getAllAttribsWhere( "basename = '$kitcompdep'", 'kitcompname' , 'version', 'release'); + } unless (@entries) { my %rsp; push@{ $rsp{data} }, "kitcomponent $kitcompdep basename does not exist"; @@ -3214,7 +3249,7 @@ sub chkkitcomp create_version_response('chkkitcomp'); return 1; # no usage - just exit } - + my $DBname = xCAT::Utils->get_DBName; # support for DB2 my %tabs = (); my @tables = qw(kit kitrepo kitcomponent osimage osdistro linuximage); foreach my $t ( @tables ) { @@ -3248,7 +3283,12 @@ sub chkkitcomp $kitcomps{$kitcomponent}{serverroles} = $kitcomptable->{serverroles}; $kitcompbasename{$kitcomptable->{basename}} = 1; } else { - my @entries = $tabs{kitcomponent}->getAllAttribsWhere( "basename = '$kitcomponent'", 'kitcompname' , 'version', 'release'); + my @entries; + if ($DBname =~ /^DB2/) { + @entries = $tabs{kitcomponent}->getAllAttribsWhere( "\"basename\" = '$kitcomponent'", 'kitcompname' , 'version', 'release'); + } else { + @entries = $tabs{kitcomponent}->getAllAttribsWhere( "basename = '$kitcomponent'", 'kitcompname' , 'version', 'release'); + } unless (@entries) { my %rsp; push@{ $rsp{data} }, "$kitcomponent kitcomponent does not exist"; @@ -4660,6 +4700,7 @@ sub db_get_table_rows { my $table = xCAT::Table->new($tablename); my @table_rows = (); + # todo fix for DB2 support if (defined($filter_stmt)) { if (length($filter_stmt) > 0) { @table_rows = $table->getAllAttribsWhere($filter_stmt, @{$attrs}); From e3517ad90416f5bc364fa932fb6354037d39b36a Mon Sep 17 00:00:00 2001 From: lissav Date: Tue, 27 May 2014 10:03:50 -0400 Subject: [PATCH 26/99] defect 4076 + DB2 updates --- xCAT-OpenStack/xCAT-OpenStack.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-OpenStack/xCAT-OpenStack.spec b/xCAT-OpenStack/xCAT-OpenStack.spec index 68d3da8f3..1426238c1 100644 --- a/xCAT-OpenStack/xCAT-OpenStack.spec +++ b/xCAT-OpenStack/xCAT-OpenStack.spec @@ -92,7 +92,7 @@ rm -rf $RPM_BUILD_ROOT %ifos linux if [ -f "/proc/cmdline" ]; then # prevent running it during install into chroot image if [ -f $RPM_INSTALL_PREFIX0/sbin/xcatd ]; then - /etc/init.d/xcatd reload + /etc/init.d/xcatd restart fi fi %endif From befcde6768e97f7ac62931699f9c3404474a6908 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 27 May 2014 11:28:02 -0400 Subject: [PATCH 27/99] Add 8.1/2012r2 KMS keys --- xCAT-server/lib/perl/xCAT/WinUtils.pm | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/xCAT-server/lib/perl/xCAT/WinUtils.pm b/xCAT-server/lib/perl/xCAT/WinUtils.pm index 6c3d1ca23..23a2fd166 100644 --- a/xCAT-server/lib/perl/xCAT/WinUtils.pm +++ b/xCAT-server/lib/perl/xCAT/WinUtils.pm @@ -13,6 +13,13 @@ our %kmskeymap = ( "win8.professional_n" => "XCVCF-2NXM9-723PB-MHCB7-2RYQQ", "win8.enterprise" => "32JNW-9KQ84-P47T8-D8GGY-CWCK7", "win8.enterprise_n" => "JMNMF-RHW7P-DMY6X-RF3DR-X2BQT", + "win81.professional" => "GCRJD-8NW9H-F2CDX-CCM8D-9D6T9", + "win81.professional_n" => "HMCNV-VVBFX-7HMBH-CTY9B-B4FXY", + "win81.enterprise" => "MHF9N-XY6XB-WVXMC-BTDCT-MKKG7", + "win81.enterprise_n" => "TT4HM-HN7YT-62K67-RGRQJ-JFFXW", + "win2012r2.standard" => "D2N9P-3P6X9-2R39C-7RTCD-MDVJX", + "win2012r2.datacenter" => "W3GGN-FT8W3-Y4M27-J84CP-Q3VJ9", + "win2012r2.essentials" => "KNC87-3J2TX-XB4WP-VCPJV-M4FWM", "win2012.standard" => "XC9B7-NBPP2-83J2H-RHMBY-92BT4", #note that core and non-core share KMS key "win2012.datacenter" => "48HP8-DN98B-MYWDG-T2DCC-8W83P", "win7.professional" => "FJ82H-XT6CR-J8D7P-XQJJ2-GPDD4", From 39c9881cc1181c12084b0f33a7fedd25e7d9c43f Mon Sep 17 00:00:00 2001 From: lissav Date: Tue, 27 May 2014 12:06:15 -0400 Subject: [PATCH 28/99] defect 4097 Support MariaDB --- xCAT-client/bin/mysqlsetup | 87 +++++++++++++++++--------- xCAT-client/pods/man1/mysqlsetup.1.pod | 9 +-- 2 files changed, 64 insertions(+), 32 deletions(-) diff --git a/xCAT-client/bin/mysqlsetup b/xCAT-client/bin/mysqlsetup index fb782c4d7..4b00497d8 100755 --- a/xCAT-client/bin/mysqlsetup +++ b/xCAT-client/bin/mysqlsetup @@ -8,10 +8,9 @@ - This is script is called after the installation or upgrade of MySQL - on xCAT. It will automate the setup of the MySQL and xCAT to run - xCAT on the MySQL DB. - Note: if will setup an xcatdb,a xcatadmin, and a MySQL root password. + This script automates the setup of the MySQL/MariaDB server and creates the xCAT database to run + xCAT on MySQL/MariaDB. + Note: it will setup an xcat database (xcatdb),a xcatadmin id , and a MySQL root password. It will interact for the password to assign, unless the XCATMYSQLADMIN_PW and the XCATMYSQLROOT_PW env variables are set to the admin and mysql root password, resp. @@ -150,8 +149,8 @@ $::linuxos = xCAT::Utils->osver(); # # check to see if mysql is installed -# -my $cmd = "rpm -qa | grep mysql"; + # +my $cmd = "rpm -qa | grep -i perl-DBD-mysql"; if ( $::debianflag ){ $cmd = "dpkg -l | grep mysql-server"; } @@ -159,10 +158,17 @@ xCAT::Utils->runcmd($cmd, 0); if ($::RUNCMD_RC != 0) { my $message = - "\nMySQL is not installed. If on AIX, it should be first obtained from the xcat dependency tarballs and installed before running this command.\n If on Linux, install from the OS CDs."; + "\nMySQL perl DBD is not installed. If on AIX, it should be first obtained from the xcat dependency tarballs and installed before running this command.\n If on Linux, install from the OS CDs."; xCAT::MsgUtils->message("E", " $cmd failed. $message"); exit(1); } +# is this MariaDB or MySQL +$::MariaDB=0; +$cmd = "rpm -qa | grep -i mariadb"; # check this is MariaDB not MySQL +xCAT::Utils->runcmd($cmd, 0); +if ($::RUNCMD_RC == 0) { + $::MariaDB=1; +} # check to see if MySQL is running $::mysqlrunning = 0; @@ -328,7 +334,6 @@ if (($::INIT) && ($::xcatrunningmysql == 0)) # MySQL not running, then initialize the database if ($::mysqlrunning == 0) { - # Add mysql user and group for AIX # Correct directory permissions # @@ -436,7 +441,7 @@ sub usage { xCAT::MsgUtils->message( 'I', - "Usage:\nmysqlsetup - Performs the setup of MySQL for xCAT to use as its database. See man mysqlsetup for more information." + "Usage:\nmysqlsetup - Performs the setup of MySQL or MariaDB for xCAT to use as its database. See man mysqlsetup for more information." ); my $msg = "mysqlsetup <-h|--help>\n <-v|--version>\n <-i|--init> [-f|hostfile] [-o|--odbc] [-L|--LL] [-V|--verbose]\n <-u|--update> <-f|hostfile> [-o|--odbc] [-L|--LL] [-V|--verbose]\n <-o|--odbc> [-V|--verbose]\n <-L|--LL> [-V|--verbose]"; @@ -870,14 +875,20 @@ sub mysqlstart } else { - if ($::linuxos =~ /rh.*/) - { + if ($::MariaDB==1) { # running MariaDB + $cmd = "service mariadb start"; + + } else { # it is mysql + + if ($::linuxos =~ /rh.*/) + { $cmd = "service mysqld start"; - } - else - { # sles + } + else + { # sles $cmd = "service mysql start"; - } + } + } } xCAT::Utils->runcmd($cmd, 0); if ($::RUNCMD_RC != 0) @@ -973,16 +984,21 @@ sub mysqlreboot } else # linux { - if ($::linuxos =~ /rh.*/) - { - $cmd = "chkconfig mysqld on"; - } - else - { # sles - $cmd = "chkconfig mysql on"; - if ( $::debianflag ){ - $cmd = "update-rc.d mysql defaults"; - } + if ($::MariaDB==1 ) { # MariaDB not MySQL + + $cmd = "chkconfig mariadb on"; + } else { # mysql + if ($::linuxos =~ /rh.*/) + { + $cmd = "chkconfig mysqld on"; + } + else + { # sles + $cmd = "chkconfig mysql on"; + if ( $::debianflag ){ + $cmd = "update-rc.d mysql defaults"; + } + } } xCAT::Utils->runcmd($cmd, 0); if ($::RUNCMD_RC != 0) @@ -1058,7 +1074,12 @@ sub setupxcatdb my $timeout = 10; # sets Expect default timeout, 0 accepts immediately my $pwd_sent = 0; my $pwd_prompt = 'Enter password: '; - my $mysql_prompt = 'mysql> '; + my $mysql_prompt; + if ($::MariaDB == 1) { # setup MariaDB + $mysql_prompt = 'MariaDB \[\(none\)\]> '; + } else { + $mysql_prompt = 'mysql> '; + } my $expect_log = undef; my $debug = 0; #if ($::VERBOSE) @@ -1178,7 +1199,12 @@ sub setupLL my $timeout = 10; # sets Expect default timeout, 0 accepts immediately my $pwd_sent = 0; my $pwd_prompt = 'Enter password: '; - my $mysql_prompt = 'mysql> '; + my $mysql_prompt; + if ($::MariaDB == 1) { # setup MariaDB + $mysql_prompt = 'MariaDB \[\(none\)\]> '; + } else { + $mysql_prompt = 'mysql> '; + } my $expect_log = undef; my $debug = 0; #if ($::VERBOSE) @@ -1308,7 +1334,12 @@ sub addhosts my $timeout = 10; # sets Expect default timeout, 0 accepts immediately my $pwd_sent = 0; my $pwd_prompt = 'Enter password: '; - my $mysql_prompt = 'mysql> '; + my $mysql_prompt; + if ($::MariaDB == 1) { # setup MariaDB + $mysql_prompt = 'MariaDB \[\(none\)\]> '; + } else { + $mysql_prompt = 'mysql> '; + } my $expect_log = undef; foreach my $host (@hosts) diff --git a/xCAT-client/pods/man1/mysqlsetup.1.pod b/xCAT-client/pods/man1/mysqlsetup.1.pod index 2ac3be44a..fc6addb57 100644 --- a/xCAT-client/pods/man1/mysqlsetup.1.pod +++ b/xCAT-client/pods/man1/mysqlsetup.1.pod @@ -1,6 +1,6 @@ =head1 NAME -B - Sets up the MySQL database for xCAT to use. +B - Sets up the MySQL or MariaDB database for xCAT to use. =head1 SYNOPSIS @@ -19,9 +19,10 @@ B {B<-L>|B<--LL>} [-V|--verbose] =head1 DESCRIPTION -B - Sets up the MySQL database for xCAT to use. The mysqlsetup script is run on the Management Node as root after the MySQL code has been installed. Before running the init option, the MySQL server should be stopped. The xCAT daemon, xcatd, must be running, do not stop it. No xCAT commands should be run during the init process, because we will be migrating the xCAT database to MySQL and restarting the xcatd daemon as well as the MySQL daemon. For full information on all the steps that will be done, read the "Configure MySQL and Migrate xCAT Data to MySQL" sections in +B - Sets up the MySQL or MariaDB database (linux only for MariaDB) for xCAT to use. The mysqlsetup script is run on the Management Node as root after the MySQL code or MariaDB code has been installed. Before running the init option, the MySQL server should be stopped, if it is running. The xCAT daemon, xcatd, must be running, do not stop it. No xCAT commands should be run during the init process, because we will be migrating the xCAT database to MySQL or MariaDB and restarting the xcatd daemon as well as the MySQL daemon. For full information on all the steps that will be done, read the "Configure MySQL and Migrate xCAT Data to MySQL" sections in https://sourceforge.net/apps/mediawiki/xcat/index.php?title=Setting_Up_MySQL_as_the_xCAT_DB Two passwords must be supplied for the setup, a password for the xcatadmin id and a password for the root id in the MySQL database. These will be prompted for interactively, unless the environment variables XCATMYSQLADMIN_PW and XCATMYSQLROOT_PW are set to the passwords for the xcatadmin id and root id in the database,resp. +Note below we refer to MySQL but it works the same for MariaDB. =head1 OPTIONS @@ -41,8 +42,8 @@ Displays verbose messages. =item B<-i|--init> -The init option is used to setup an installed MySQL database so that xCAT can use the database. This involves creating the xcatdb database, the xcatadmin id, allowing access to the xcatdb database by the Management Node. It customizes the my.cnf configuration file for xcat and starts the MySQL server. It also backs up the current xCAT database and restores it into the newly setup xcatdb MySQL database. It creates the /etc/xcat/cfgloc file to point the xcatd daemon to the MySQL database and restarts the xcatd daemon using the database. -On AIX, it additionally setup the mysql id and group and corrects the permissions in the MySQL install directories. For AIX, you should be using the MySQL rpms available from the xCAT website. For Linux, you should use the MySQL rpms shipped with the OS. You can chose the -f and/or the -o option, to run after the init. +The init option is used to setup a xCAT database on an installed MySQL or MariaDB server for xCAT to use. The mysqlsetup script will check for the installed MariaDB server rpm first and will use MariaDB if it is installed. This involves creating the xcatdb database, the xcatadmin id, allowing access to the xcatdb database by the Management Node. It customizes the my.cnf configuration file for xcat and starts the MySQL server. It also backs up the current xCAT database and restores it into the newly setup xcatdb MySQL database. It creates the /etc/xcat/cfgloc file to point the xcatd daemon to the MySQL database and restarts the xcatd daemon using the database. +On AIX, it additionally setup the mysql id and group and corrects the permissions in the MySQL install directories. For AIX, you should be using the MySQL rpms available from the xCAT website. For Linux, you should use the MySQL or MariaDB rpms shipped with the OS. You can chose the -f and/or the -o option, to run after the init. =item B<-u|--update> From 8ec332fbc4f523e6cda9f811f01e78018cce3aba Mon Sep 17 00:00:00 2001 From: lissav Date: Tue, 27 May 2014 12:31:27 -0400 Subject: [PATCH 29/99] defect 4091 --- xCAT/postscripts/confignics | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT/postscripts/confignics b/xCAT/postscripts/confignics index 5e2803f5b..0c6b7251e 100755 --- a/xCAT/postscripts/confignics +++ b/xCAT/postscripts/confignics @@ -184,7 +184,7 @@ if [ "$str_temp" = "mac" ];then fi done else - str_inst_nic=`ifconfig -a | grep -i "$MACADDRESS" | awk '{print $1;}'` + str_inst_nic=`ip -o link | grep -i "$MACADDRESS" | awk '{print $2;}' | sed s/://` fi elif [ `echo $str_temp | grep -E "e(n|th)[0-9]+"` ];then str_inst_nic=$str_temp From 8311ef3f4dd440b768eff3a85cd86c358a86c72a Mon Sep 17 00:00:00 2001 From: lissav Date: Tue, 27 May 2014 12:39:03 -0400 Subject: [PATCH 30/99] defect 4091 --- perl-xCAT/xCAT/InstUtils.pm | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/perl-xCAT/xCAT/InstUtils.pm b/perl-xCAT/xCAT/InstUtils.pm index 71c4a1785..e227950db 100644 --- a/perl-xCAT/xCAT/InstUtils.pm +++ b/perl-xCAT/xCAT/InstUtils.pm @@ -217,14 +217,13 @@ sub is_me #my ($b1, $b2, $b3, $b4) = split /\./, $nameIP; # get all the possible IPs for the node I'm running on - my $ifcmd = "ifconfig -a | grep 'inet'"; - my $result = xCAT::Utils->runcmd($ifcmd, -1, 1); + my $ipcmd = "ip addr | grep 'inet'"; + my $result = xCAT::Utils->runcmd($ipcmd, -1, 1); if ($::RUNCMD_RC != 0) { - my $rsp; - # push @{$rsp->{data}}, "Could not run $ifcmd.\n"; - # xCAT::MsgUtils->message("E", $rsp, $callback); - $::VERBOSE = $verb; + my $str="Error running ipcmd"; + xCAT::MsgUtils->message("S", $str); + $::VERBOSE = $verb; return 0; } @@ -232,7 +231,6 @@ sub is_me { my ($inet, $myIP, $str) = split(" ", $int); chomp $myIP; - $myIP =~ s/addr://; $myIP =~ s/\/.*//; # ipv6 address 4000::99/64 $myIP =~ s/\%.*//; # ipv6 address ::1%1/128 From 103f32d2a23df90b8e84ecc87acf5082f1f8fcda Mon Sep 17 00:00:00 2001 From: lissav Date: Tue, 27 May 2014 13:01:50 -0400 Subject: [PATCH 31/99] defect 4091 --- perl-xCAT/xCAT/NetworkUtils.pm | 184 ++++++++------------------------- 1 file changed, 43 insertions(+), 141 deletions(-) diff --git a/perl-xCAT/xCAT/NetworkUtils.pm b/perl-xCAT/xCAT/NetworkUtils.pm index 4926e0be5..3bcc6383f 100755 --- a/perl-xCAT/xCAT/NetworkUtils.pm +++ b/perl-xCAT/xCAT/NetworkUtils.pm @@ -643,16 +643,11 @@ sub get_nic_ip { my $nic; my %iphash; - my $cmd = "ifconfig -a"; - my $result = `$cmd`; my $mode = "MULTICAST"; + my $payingattention=0; + my $interface; + my $keepcurrentiface; - ############################################# - # Error running command - ############################################# - if ( !$result ) { - return undef; - } if (xCAT::Utils->isAIX()) { ############################################################## @@ -664,6 +659,14 @@ sub get_nic_ip # en1: ... # ############################################################## + my $cmd = "ifconfig -a"; + my $result = `$cmd`; + ############################################# + # Error running command + ############################################# + if ( !$result ) { + return undef; + } my @adapter = split /(\w+\d+):\s+flags=/, $result; foreach ( @adapter ) { if ($_ =~ /^(en\d)/) { @@ -683,44 +686,39 @@ sub get_nic_ip } } } - else { - ############################################################## - # Should look like this for Linux: - # eth0 Link encap:Ethernet HWaddr 00:02:55:7B:06:30 - # inet addr:9.114.154.193 Bcast:9.114.154.223 - # inet6 addr: fe80::202:55ff:fe7b:630/64 Scope:Link - # UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 - # RX packets:1280982 errors:0 dropped:0 overruns:0 frame:0 - # TX packets:3535776 errors:0 dropped:0 overruns:0 carrier:0 - # collisions:0 txqueuelen:1000 - # RX bytes:343489371 (327.5 MiB) TX bytes:870969610 (830.6 MiB) - # Base address:0x2600 Memory:fbfe0000-fc0000080 - # - # eth1 ... - # Redhat7 - #eth0: flags=4163 mtu 1500 - # inet 10.1.0.178 netmask 255.255.0.0 broadcast 10.1.255.255 - # - ############################################################## - my @adapter= split /\n{2,}/, $result; - foreach ( @adapter ) { - if ( !($_ =~ /LOOPBACK/ ) and - $_ =~ /UP( |,|>)/ and - $_ =~ /$mode/ ) { - my @ip = split /\n/; - for my $ent ( @ip ) { - if ($ent =~ /^(eth\d|ib\d|hf\d)\s+/) { - $nic = $1; - } - if ($ent =~ /^(eth\d:|ib\d:|hf\d:)\s+/) { - $nic = $1; - } - $ent=~ s/addr://; # works for Redhat7 also - if ( $ent =~ /^\s*inet \s*(\d+\.\d+\.\d+\.\d+)/ ) { - $iphash{$nic} = $1; - next; - } + else { # linux + my @ipoutput = `ip addr`; + ############################################# + # Error running command + ############################################# + if ( !@ipoutput ) { + return undef; + } + foreach my $line (@ipoutput) { + if ($line =~ /^\d/) { # new interface, new context.. + if ($interface and not $keepcurrentiface) { + #don't bother reporting unusable nics + delete $iphash{$interface}; } + $keepcurrentiface=0; + if ( !($line =~ /LOOPBACK/ ) and + $line =~ /UP( |,|>)/ and + $line =~ /$mode/ ) { + + $payingattention=1; + $line =~ /^([^:]*): ([^:]*):/; + $interface=$2; + } else { + $payingattention=0; + next; + } + } + unless ($payingattention) { next; } + if ($line =~ /inet/) { + $keepcurrentiface=1; + } + if ( $line =~ /^\s*inet \s*(\d+\.\d+\.\d+\.\d+)/ ) { + $iphash{$interface} = $1; } } } @@ -1843,102 +1841,6 @@ sub validate_ip } return([0]); } - -#------------------------------------------------------------------------------- - -=head3 getFacingIP - Gets the ip address of the adapter of the localhost that is facing the - the given node. - Assume it is the same as my_ip_facing... - Arguments: - The name of the node that is facing the localhost. - Returns: - The ip address of the adapter that faces the node. - -=cut - -#------------------------------------------------------------------------------- -sub getFacingIP -{ - my ($class, $node) = @_; - my $ip; - my $cmd; - my @ipaddress; - - my $nodeip = inet_ntoa(inet_aton($node)); - unless ($nodeip =~ /\d+\.\d+\.\d+\.\d+/) - { - return 0; #Not supporting IPv6 here IPV6TODO - } - - $cmd = "ifconfig" . " -a"; - $cmd = $cmd . "| grep \"inet \""; - my @result = xCAT::Utils->runcmd($cmd, 0); - if ($::RUNCMD_RC != 0) - { - xCAT::MsgUtils->message("S", "Error from $cmd\n"); - exit $::RUNCMD_RC; - } - - # split node address - my ($n1, $n2, $n3, $n4) = split('\.', $nodeip); - - foreach my $addr (@result) - { - my $ip; - my $mask; - if (xCAT::Utils->isLinux()) - { - my ($inet, $addr1, $Bcast, $Mask) = split(" ", $addr); - if ((!$addr1) || (!$Mask)) { next; } - my @ips = split(":", $addr1); - my @masks = split(":", $Mask); - $ip = $ips[1]; - $mask = $masks[1]; - } - else - { #AIX - my ($inet, $addr1, $netmask, $mask1, $Bcast, $bcastaddr) = - split(" ", $addr); - if ((!$addr1) && (!$mask1)) { next; } - $ip = $addr1; - $mask1 =~ s/0x//; - $mask = - `printf "%d.%d.%d.%d" \$(echo "$mask1" | sed 's/../0x& /g')`; - } - - if ($ip && $mask) - { - - # split interface IP - my ($h1, $h2, $h3, $h4) = split('\.', $ip); - - # split mask - my ($m1, $m2, $m3, $m4) = split('\.', $mask); - - # AND this interface IP with the netmask of the network - my $a1 = ((int $h1) & (int $m1)); - my $a2 = ((int $h2) & (int $m2)); - my $a3 = ((int $h3) & (int $m3)); - my $a4 = ((int $h4) & (int $m4)); - - # AND node IP with the netmask of the network - my $b1 = ((int $n1) & (int $m1)); - my $b2 = ((int $n2) & (int $m2)); - my $b3 = ((int $n3) & (int $m3)); - my $b4 = ((int $n4) & (int $m4)); - - if (($b1 == $a1) && ($b2 == $a2) && ($b3 == $a3) && ($b4 == $a4)) - { - return $ip; - } - } - } - - xCAT::MsgUtils->message("S", "Cannot find master for the node $node\n"); - return 0; -} - #------------------------------------------------------------------------------- =head3 isIpaddr From 76d749c2707b3756a67fdfca67babbd321d7920a Mon Sep 17 00:00:00 2001 From: lissav Date: Tue, 27 May 2014 13:04:44 -0400 Subject: [PATCH 32/99] defect 4091 --- xCAT/postscripts/hardeths | 29 +++++++++++++++++++++++------ xCAT/postscripts/updatenetwork | 3 ++- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/xCAT/postscripts/hardeths b/xCAT/postscripts/hardeths index 68e963c22..b29e2953c 100755 --- a/xCAT/postscripts/hardeths +++ b/xCAT/postscripts/hardeths @@ -1,4 +1,4 @@ -#!/bin/sh +PREFIXMASK#!/bin/sh # pmatch determines if 1st argument string is matched by 2nd argument pattern pmatch () @@ -9,6 +9,18 @@ pmatch () return 1 # non-zero return code means string not matched by pattern } +# converts netmask CIDR fromat to x.x.x.x mask value +maskfromprefix () +{ + prefixlen=$1 + maskval=$((0xffffffff>>(32-prefixlen)<<(32-prefixlen))) + mask1=$((maskval >> 24)) + mask2=$((maskval >> 16 & 0xff)) + mask3=$((maskval >> 8 & 0xff)) + mask4=$((maskval & 0xff)) + echo $mask1.$mask2.$mask3.$mask4 + NETMASK=$mask1.$mask2.$mask3.$mask4 +} network_ipv4calc () { @@ -56,9 +68,12 @@ else echo "GATEWAY=$defgw" >> /etc/sysconfig/network fi fi -for nic in `ifconfig -a|grep -B1 "inet addr"|awk '{print $1}'|grep -v inet|grep -v -- --|grep -v lo`; do - IPADDR=`ifconfig $nic |grep "inet addr"|awk '{print $2}' |awk -F: '{print $2}'` - NETMASK=`ifconfig $nic |grep "inet addr"|awk '{print $4}' |awk -F: '{print $2}'` +for nic in `ip link |grep "BROADCAST" |awk '{print $2}' | sed s/://`; do + IPADDRMASK=`ip addr show dev $nic | grep inet | grep -v inet6 | awk '{print $2}' | head -n 1` + IPADDR=`echo $IPADDRMASK | awk -F'/' '{print $1}'` + PREFIXMASK=`echo $IPADDRMASK | awk -F'/' '{print $2}'` + # converts to x.x.x.x mask value + maskfromprefix $PREFIXMASK if ( pmatch $OSVER "ubuntu*" ) then NETWORK=`network_ipv4calc $IPADDR $NETMASK` @@ -69,7 +84,7 @@ for nic in `ifconfig -a|grep -B1 "inet addr"|awk '{print $1}'|grep -v inet|grep else gateway_line="" fi - + # add info to interfaces file on ubuntu, TBD does unbuntu change to systemd, this will not exist cat >>/etc/network/interfaces < Date: Tue, 27 May 2014 13:25:00 -0400 Subject: [PATCH 33/99] defect 4077 --- xCAT-server/sbin/xcatconfig | 98 ++----------------------------------- 1 file changed, 5 insertions(+), 93 deletions(-) diff --git a/xCAT-server/sbin/xcatconfig b/xCAT-server/sbin/xcatconfig index cf004dd61..b55d916bb 100755 --- a/xCAT-server/sbin/xcatconfig +++ b/xCAT-server/sbin/xcatconfig @@ -1020,44 +1020,6 @@ sub genSSHNodeHostKey } -# is_lsb_ubuntu return value indicates whether system appears to be Ubuntu. -# Using required /etc/lsb-release file, instead of optional lsb_release command. - -sub is_lsb_ubuntu -{ - if (open(my $relfile, "<", "/etc/lsb-release")) { - my @text = <$relfile>; - close($relfile); - chomp(@text); - my $distrib_id = ''; - - foreach (@text) { - if ( $_ =~ /^\s*DISTRIB_ID=(.*)$/ ) { - $distrib_id = $1; # last DISTRIB_ID value in file used - } - } - - if ( $distrib_id =~ /^(Ubuntu|"Ubuntu")\s*$/ ) { - return 1; # return "true" - } - } - - return 0; # return "false" -} - -sub is_debian -{ - if ( -e "/etc/debian_version" && -e "/etc/issue"){ - open(my $relfile, "<", "/etc/issue"); - my $line = <$relfile>; - close($relfile); - if ( $line =~ /debian.*/i ){ - return 1; - } - } - return 0; -} - sub is_redhat6sp4 { if( -e "/etc/redhat-release" ){ @@ -1072,21 +1034,6 @@ sub is_redhat6sp4 } -# on Ubuntu need to painstakingly compare /etc/localtime with files under -# /usr/share/zoneinfo since /etc/localtime # isn't always a symbolic link -sub discover_timezone_ubuntu -{ - my $localtime = "/etc/localtime"; - my $zoneinfo = "/usr/share/zoneinfo"; - - my $zone_result = `find $zoneinfo -type f -exec cmp -s $localtime {} \\; -print | grep -v posix | grep -v SystemV`; - - my @zones = split /\n/, $zone_result; - - $zones[0] =~ s/$zoneinfo\///; - - return $zones[0]; -} #----------------------------------------------------------------------------- @@ -1158,6 +1105,7 @@ sub initDB # set value based on OS my ($domain, $timezone); + my $timezone = xCAT::Utils->gettimezone(); if ($::osname eq 'AIX') { my ($name, $rest) = split('\.', $hname); @@ -1170,35 +1118,10 @@ sub initDB $domain = ""; } - $timezone = $ENV{'TZ'}; } else # linux { $domain = `hostname -d`; - my $tz; - if (-f "/etc/redhat-release") - { - - # on Redhat look for "ZONE" - $tz = - `grep ^ZONE /etc/sysconfig/clock|cut -d= -f 2|sed -e 's/"//g'`; - } - elsif ( is_lsb_ubuntu() || is_debian() ) - { - $tz = discover_timezone_ubuntu; - if (!$tz){ - $tz = `cat /etc/timezone`; - chomp $tz; - } - } - else - { - - # on SuSE look for "TIMEZONE" - $tz = - `grep ^TIMEZONE /etc/sysconfig/clock|cut -d= -f 2|sed -e 's/"//g'`; - } - $timezone = $tz; } chomp $timezone; @@ -1973,6 +1896,7 @@ sub setuphttp { my $cmd; + my $distro = xCAT::Utils->osver(); # restart httpd if (-e "/etc/init.d/apache2") { #for sles/ubuntu @@ -2000,8 +1924,7 @@ sub setuphttp # enable httpd if (-e "/etc/init.d/apache2") { - if (is_lsb_ubuntu() || is_debian() ) - { # for ubuntu + if ( $distro =~ /ubuntu.*/ || $distro =~ /debian.*/i) { $cmd = "/usr/sbin/update-rc.d apache2 enable"; } else @@ -2009,18 +1932,6 @@ sub setuphttp $cmd = "/sbin/chkconfig apache2 on"; } } -# elsif (-e "/sbin/chkconfig") -# { -# $cmd = "/sbin/chkconfig httpd on"; -# } -# elsif (-e "/usr/sbin/chkconfig") -# { -# $cmd = "/usr/sbin/chkconfig httpd on"; -# } -# else -# { -# $cmd = "chkconfig httpd on"; -# } else { my $CHKCONFIG = xCAT::Utils->fullpathbin("chkconfig"); @@ -2253,6 +2164,7 @@ sub setupMNinDB sub startnamedonboot { # start named on boot + my $distro = xCAT::Utils->osver(); if (xCAT::Utils->isAIX()) { #/etc/inittab @@ -2272,7 +2184,7 @@ sub startnamedonboot #chkconfig my $serv = "named"; my $cmd = "/sbin/chkconfig $serv on"; - if ( is_lsb_ubuntu() || is_debian() ){ + if ( $distro =~ /ubuntu.*/ || $distro =~ /debian.*/i) { $serv = "bind9"; $cmd = "update-rc.d $serv enable"; } From 543b2d23afdda4b7caf21a8f69af8c0a6648154f Mon Sep 17 00:00:00 2001 From: immarvin Date: Wed, 28 May 2014 02:25:50 -0700 Subject: [PATCH 34/99] correct the build spec and script --- makerpm | 1 + xCAT/xCAT.spec | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/makerpm b/makerpm index 5fa58918a..e48de76d5 100755 --- a/makerpm +++ b/makerpm @@ -85,6 +85,7 @@ function makexcat { cd `dirname $0`/$RPMNAME tar --exclude .svn -czf $RPMROOT/SOURCES/license.tar.gz LICENSE.html cp xcat.conf $RPMROOT/SOURCES + cp xcat.conf.apach24 $RPMROOT/SOURCES cp xCATSN $RPMROOT/SOURCES cd - >/dev/null elif [ "$RPMNAME" = "xCAT-buildkit" ]; then diff --git a/xCAT/xCAT.spec b/xCAT/xCAT.spec index 11a2c55ae..3838d7268 100644 --- a/xCAT/xCAT.spec +++ b/xCAT/xCAT.spec @@ -171,7 +171,7 @@ then cp /etc/httpd/conf.d/xcat.conf.apach24 /etc/httpd/conf.d/xcat.conf elif [ -n "$(apachectl -v 2>&1 |grep -e '^Server version\s*:.*\/2.4')" ] then - rm -rf /etc/httpd/conf.d/xcat.conf + rm -rf /etc/apache2/conf.d/xcat.conf cp /etc/apache2/conf.d/xcat.conf.apach24 /etc/apache2/conf.d/xcat.conf else rm -rf /etc/httpd/conf.d/xcat.conf From fd2055c51c9c48475df9aac35e7882ff52344bb8 Mon Sep 17 00:00:00 2001 From: daniceexi Date: Wed, 28 May 2014 10:27:41 -0400 Subject: [PATCH 35/99] defect 4079: to support rh7 that hostname is cfged in /etc/hostname. Check the existence of /etc/hostname, use itif yes, otherwise use /etc/sysconfig/network --- .../xcat/openstack/postscripts/config_ops_bm_node | 4 ++-- .../xcat/openstack/postscripts/deconfig_ops_bm_node | 4 ++-- xCAT-server/share/xcat/hamn/deactivate-mn | 6 +++++- xCAT/postscripts/configeth | 12 ++++++++---- xCAT/postscripts/hardeths | 6 +++++- xCAT/postscripts/updatenetwork | 12 ++++++++---- 6 files changed, 30 insertions(+), 14 deletions(-) diff --git a/xCAT-OpenStack-baremetal/share/xcat/openstack/postscripts/config_ops_bm_node b/xCAT-OpenStack-baremetal/share/xcat/openstack/postscripts/config_ops_bm_node index e516a138a..e67f48393 100755 --- a/xCAT-OpenStack-baremetal/share/xcat/openstack/postscripts/config_ops_bm_node +++ b/xCAT-OpenStack-baremetal/share/xcat/openstack/postscripts/config_ops_bm_node @@ -100,8 +100,8 @@ change_host_name() if [ "$str_os_type" = "sles" ];then echo "Persistently changing the hostname not implemented yet." - #debian ubuntu - elif [ "$str_os_type" = "debian" ];then + #debian ubuntu and rh7 + elif [ -f "/etc/hostname" ];then conf_file="/etc/hostname" echo "$str_hostname" > $conf_file else diff --git a/xCAT-OpenStack-baremetal/share/xcat/openstack/postscripts/deconfig_ops_bm_node b/xCAT-OpenStack-baremetal/share/xcat/openstack/postscripts/deconfig_ops_bm_node index da148f47e..81ef22564 100755 --- a/xCAT-OpenStack-baremetal/share/xcat/openstack/postscripts/deconfig_ops_bm_node +++ b/xCAT-OpenStack-baremetal/share/xcat/openstack/postscripts/deconfig_ops_bm_node @@ -36,8 +36,8 @@ change_host_name() if [ "$str_os_type" = "sles" ];then echo "Persistently changing the hostname not implemented yet." - #debian ubuntu - elif [ "$str_os_type" = "debian" ];then + #debian ubuntu and rh7 + elif [ -f "/etc/hostname" ];then conf_file="/etc/hostname" echo "$str_hostname" > $conf_file else diff --git a/xCAT-server/share/xcat/hamn/deactivate-mn b/xCAT-server/share/xcat/hamn/deactivate-mn index da2f19dd2..9a4ab6ddf 100755 --- a/xCAT-server/share/xcat/hamn/deactivate-mn +++ b/xCAT-server/share/xcat/hamn/deactivate-mn @@ -251,7 +251,11 @@ then then BOOT_HOSTNAME=$(lsattr -El inet0 -a hostname | awk '{print $2}') else # Linux - BOOT_HOSTNAME=`grep HOSTNAME /etc/sysconfig/network | cut -f 2 -d "="` + if [ -f "/etc/hostname" ]; then + BOOT_HOSTNAME=`cat /etc/hostname` + else + BOOT_HOSTNAME=`grep HOSTNAME /etc/sysconfig/network | cut -f 2 -d "="` + fi fi hostname ${BOOT_HOSTNAME} fi diff --git a/xCAT/postscripts/configeth b/xCAT/postscripts/configeth index 85994e869..247257b84 100755 --- a/xCAT/postscripts/configeth +++ b/xCAT/postscripts/configeth @@ -392,11 +392,15 @@ elif [ "$1" = "-s" ];then fi fi hostname $NODE - grep -i "HOSTNAME" /etc/sysconfig/network - if [ $? -eq 0 ];then - sed -i "s/.*HOSTNAME.*/HOSTNAME=${NODE}/i" /etc/sysconfig/network + if [ -f "/etc/hostname" ]; then + echo $NODE > /etc/hostname else - echo "HOSTNAME=${NODE}" >> /etc/sysconfig/network + grep -i "HOSTNAME" /etc/sysconfig/network + if [ $? -eq 0 ];then + sed -i "s/.*HOSTNAME.*/HOSTNAME=${NODE}/i" /etc/sysconfig/network + else + echo "HOSTNAME=${NODE}" >> /etc/sysconfig/network + fi fi fi exit 0 diff --git a/xCAT/postscripts/hardeths b/xCAT/postscripts/hardeths index b29e2953c..f3f8b2236 100755 --- a/xCAT/postscripts/hardeths +++ b/xCAT/postscripts/hardeths @@ -63,7 +63,11 @@ then else #RedHat uses /etc/sysconfig/network-scripts/ifcfg-eth NICFILEPRE="/etc/sysconfig/network-scripts/ifcfg-" - sed -i "s/HOSTNAME.*/HOSTNAME=`hostname`/" /etc/sysconfig/network + if [ -f "/etc/hostname" ]; then # for rh7 + echo `hostname` >/etc/hostname + else + sed -i "s/HOSTNAME.*/HOSTNAME=`hostname`/" /etc/sysconfig/network + fi if [ ! -z "$defgw" ]; then echo "GATEWAY=$defgw" >> /etc/sysconfig/network fi diff --git a/xCAT/postscripts/updatenetwork b/xCAT/postscripts/updatenetwork index d1bcd6a4c..8da573914 100644 --- a/xCAT/postscripts/updatenetwork +++ b/xCAT/postscripts/updatenetwork @@ -16,11 +16,15 @@ device_names=`ip link |grep "BROADCAST" |awk '{print $2}' | sed s/://` str_cfg_file='' if [ -d "/etc/sysconfig/network-scripts/" ];then #redhat - grep -i HOSTNAME /etc/sysconfig/network - if [ $? -eq 0 ];then - sed -i "s/HOSTNAME=.*/HOSTNAME=$HOSTNAME/g" /etc/sysconfig/network + if [ -f "/etc/hostname" ]; then #RH7 + echo $HOSTNAME > /etc/hostname else - echo "HOSTNAME=$HOSTNAME" >> /etc/sysconfig/network + grep -i HOSTNAME /etc/sysconfig/network + if [ $? -eq 0 ];then + sed -i "s/HOSTNAME=.*/HOSTNAME=$HOSTNAME/g" /etc/sysconfig/network + else + echo "HOSTNAME=$HOSTNAME" >> /etc/sysconfig/network + fi fi for i in $device_names;do str_cfg_file="/etc/sysconfig/network-scripts/ifcfg-$i" From de8815cb0b60f7701ef744a07e0d6d4d9cf8c907 Mon Sep 17 00:00:00 2001 From: lissav Date: Wed, 28 May 2014 10:07:07 -0400 Subject: [PATCH 36/99] defect 4091 RHEL7 support --- xCAT-server/share/xcat/tools/detect_dhcpd | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/xCAT-server/share/xcat/tools/detect_dhcpd b/xCAT-server/share/xcat/tools/detect_dhcpd index d696a66eb..78d33e19f 100755 --- a/xCAT-server/share/xcat/tools/detect_dhcpd +++ b/xCAT-server/share/xcat/tools/detect_dhcpd @@ -39,12 +39,19 @@ my $start = Time::HiRes::gettimeofday(); $start =~ s/(\d.*)\.(\d.*)/$1/; if (!$nic) { print "specify a nic\n"; print $::USAGE; exit 1;} -my $IP = `ifconfig $nic | grep "inet addr" | awk '{print \$2}' | awk -F: '{print \$2}'`; +#my $IP = `ifconfig $nic | grep "inet addr" | awk '{print \$2}' | awk -F: '{print \$2}'`; +my $IPADDRMASK = `ip addr show dev $nic | grep inet | grep -v inet6 | awk '{print \$2}' | head -n 1`; +my ($IP,$MASK)= split (/\//,$IPADDRMASK); my $MAC; +my $tmpMAC; +my @ipoutput; if ($::MACADD) { $MAC = $::MACADD; } else { - $MAC = `ifconfig $nic | grep "HWaddr" | /usr/bin/awk '{print \$5}'`; +# $MAC = `ifconfig $nic | grep "HWaddr" | /usr/bin/awk '{print \$5}'`; + $tmpMAC = `ip link show $nic | grep ether`; + @ipoutput= split (' ',$tmpMAC); + $MAC=$ipoutput[1]; } chomp($IP); From 1f8574c8fcafb86e0e52d0583b7bb558f6e7f46c Mon Sep 17 00:00:00 2001 From: Jia Zhao Date: Thu, 29 May 2014 11:02:03 +0800 Subject: [PATCH 37/99] support fuzzy matching mode in cfmsync --- perl-xCAT/xCAT/CFMUtils.pm | 127 ++++++++++++++++++++++++++++++++++++- 1 file changed, 125 insertions(+), 2 deletions(-) diff --git a/perl-xCAT/xCAT/CFMUtils.pm b/perl-xCAT/xCAT/CFMUtils.pm index 987cb0d65..314d3c4b9 100644 --- a/perl-xCAT/xCAT/CFMUtils.pm +++ b/perl-xCAT/xCAT/CFMUtils.pm @@ -500,6 +500,7 @@ sub setCFMPkglistFile { Arguments: $imagename - the specified linuximage name @curospkgs - the currently selected OS packages list + $mode - using Fuzzy Matching or Exact Matching to check packages Returns: 0 - update successfully 1 - update failed @@ -509,13 +510,22 @@ sub setCFMPkglistFile { none Example: my $ret = CAT::CFMUtils->updateCFMPkglistFile($imagename, @cur_selected_pkgs); + my $ret = CAT::CFMUtils->updateCFMPkglistFile($imagename, @cur_selected_pkgs, 1); =cut #----------------------------------------------------------------------------- sub updateCFMPkglistFile { - my ($class, $img, $ospkgs) = @_; - + my ($class, $img, $ospkgs, $mode) = @_; + + if(defined($mode)){ + # Exact Matching + $mode = 1; + }else { + # Fuzzy Matching + $mode = 0; + } + my @cur_selected = @$ospkgs; my $cfmpkglist = "/install/osimages/$img/pkglist.cfm"; @@ -549,6 +559,14 @@ sub updateCFMPkglistFile { my @selected = @$selected_ref; @basepkgs = xCAT::CFMUtils->arrayops("U", \@basepkgs, \@selected); } + + # Fuzzy Matching + if (not $mode){ + my ($ref1, $ref2, $ref3) = xCAT::CFMUtils->updateSelectedPkgs(\@pre_selected, \@pre_removed, \@cur_selected); + @pre_selected = @$ref1; + @pre_removed = @$ref2; + @cur_selected = @$ref3; + } # get diff between previous and current selected OS packages lists my @diff = xCAT::CFMUtils->getPkgsDiff(\@pre_selected, \@cur_selected); @@ -661,6 +679,48 @@ sub getPreOSpkgsList { return (\@selected, \@removed); } +#----------------------------------------------------------------------------- + +=head3 getPreBaseOSpkgsList + Get previously selected and removed base OS packages lists from pkglist file. Packages named with "example.xxx" should be the base name "example" + + Arguments: + $ospkglist - the path for ospkglist file + Returns: + refs for selected and removed OS packages arrays + Globals: + none + Error: + none + Example: + my $pre_selected_ref = xCAT::CFMUtils->getPreOSpkgsList($ospkglist); + +=cut + +#----------------------------------------------------------------------------- +sub getPreBaseOSpkgsList { + my ($class, $pkglist) = @_; + + my ($pre_selected_ref, $pre_removed_ref) = xCAT::CFMUtils->getPreOSpkgsList($pkglist); + + my %pre_selected_hash = (); + foreach (@$pre_selected_ref) { + my @names = split(/\./, $_); + my $basename = $names[0]; + + if ($_ =~ /^$basename\.([^\.]+)$/) { + $pre_selected_hash{$basename} = 1; + }else { + $pre_selected_hash{$_} = 1; + } + } + + @pre_selected = keys %pre_selected_hash; + + return \@pre_selected; +} + + #----------------------------------------------------------------------------- =head3 getPkgsDiff @@ -819,3 +879,66 @@ sub arrayops { #return (\@union, \@intersection, \@difference); } + + +#----------------------------------------------------------------------------- + +=head3 updateSelectedPkgs + Update previous selected, previous removed and current selected packages based on fuzzy matching rules. Packages named with "example.i686" should be same with package "example" + + Arguments: + \@pre_selected - reference to previous selected packages + \@pre_removed - reference to previous removed packages + \@cur_selected - reference to current selected packages + Returns: + new previous selected, previous removed, current selected packages + Globals: + none + Error: + none + Example: + my ($ref1, $ref2, $ref3) = xCAT::CFMUtils->arrayops(\@pre_selected, \@pre_removed, \@cur_selected); + +=cut + +#----------------------------------------------------------------------------- +sub updateSelectedPkgs() { + my ($class, $pre_selected_ref, $pre_removed_ref, $cur_selected_ref) = @_; + + my %pre_selected_hash = map{$_ => 1} @$pre_selected_ref; + my %pre_removed_hash = map{$_ => 1} @$pre_removed_ref; + my %cur_selected_hash = map{$_ => 1} @$cur_selected_ref; + + my %new_pre_selected_hash = %pre_selected_hash; + my %new_pre_removed_hash = %pre_removed_hash; + my %new_cur_selected_hash = %cur_selected_hash; + + foreach (keys %cur_selected_hash) { + my $father = $_; + my $flag = 0; + foreach (keys %pre_selected_hash) { + my $child = $_; + if ($child =~ /^$father\.([^\.]+)$/) { + $new_cur_selected_hash{$child} = 1; + $flag = 1; + } + } + if ($flag and not exists $pre_selected_hash{$father}){ + delete $new_cur_selected_hash{$father} if exists $new_cur_selected_hash{$father}; + } + + foreach (keys %pre_removed_hash) { + my $child = $_; + if ($child =~ /^$father\.([^\.]+)$/) { + delete $new_pre_removed_hash{$child} if exists $new_pre_removed_hash{$child}; + } + } + } + + my @new_cur_selected = keys %new_cur_selected_hash; + my @new_pre_selected = keys %new_pre_selected_hash; + my @new_pre_removed = keys %new_pre_removed_hash; + + + return (\@new_pre_selected, \@new_pre_removed, \@new_cur_selected); +} From 37ceb9fc132b72692309d848496e42588efc84c8 Mon Sep 17 00:00:00 2001 From: Jia Zhao Date: Thu, 29 May 2014 14:02:45 +0800 Subject: [PATCH 38/99] not regenerate ips for BMC/FSP NIC in pcm --- xCAT-server/lib/xcat/plugins/profilednodes.pm | 29 +++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/profilednodes.pm b/xCAT-server/lib/xcat/plugins/profilednodes.pm index ae1a88826..4991a6fd7 100644 --- a/xCAT-server/lib/xcat/plugins/profilednodes.pm +++ b/xCAT-server/lib/xcat/plugins/profilednodes.pm @@ -771,10 +771,30 @@ Usage: } # If network profile specified. Need re-generate IPs for all nodess again. + # As new design, ignore BMC/FSP NIC while reinstall nodes if(exists $args_dict{'networkprofile'}){ + my $newNetProfileName = $args_dict{'networkprofile'}; + my $oldNetProfileName = $nodeoldprofiles{'networkprofile'}; + + my $newNicsRef = xCAT::ProfiledNodeUtils->get_nodes_nic_attrs([$newNetProfileName])->{$newNetProfileName}; + my $oldNicsRef = xCAT::ProfiledNodeUtils->get_nodes_nic_attrs([$oldNetProfileName])->{$oldNetProfileName}; + + my %updateNicsHash = (); + foreach my $newNic (keys %$newNicsRef) { + if ($newNicsRef->{$newNic}->{'type'} ne 'BMC' and $newNicsRef->{$newNic}->{'type'} ne 'FSP'){ + $updateNicsHash{$newNic} = 1; + } + } + foreach my $oldNic (keys %$oldNicsRef) { + if ($oldNicsRef->{$oldNic}->{'type'} ne 'BMC' and $oldNicsRef->{$oldNic}->{'type'} ne 'FSP'){ + $updateNicsHash{$oldNic} = 1; + } + } + + my $updateNics = join(",", keys %updateNicsHash); setrsp_progress("Regenerate IP addresses for nodes..."); $retref = ""; - $retref = xCAT::Utils->runxcmd({command=>["noderegenips"], node=>$nodes, sequential=>[1]}, $request_command, 0, 2); + $retref = xCAT::Utils->runxcmd({command=>["noderegenips"], node=>$nodes, arg=>["nics=$updateNics"], sequential=>[1]}, $request_command, 0, 2); $retstrref = parse_runxcmd_ret($retref); if ($::RUNCMD_RC != 0){ setrsp_progress("Warning: failed to generate IPs for nodes."); @@ -843,6 +863,7 @@ Usage: $netProfileNicsRef = xCAT::ProfiledNodeUtils->get_nodes_nic_attrs([$netProfileName]); my $nicsref = $netProfileNicsRef->{$netProfileName}; my @nicslist = keys %$nicsref; + #3. validate specified nics if(exists $args_dict{'nics'}){ @updateNics = split(",", $args_dict{'nics'}); @@ -910,7 +931,9 @@ Usage: unless (grep {$_ eq $nicname} @updateNics){ # if the nic not specified, just keep the old IP&NIC record in nics table. my $oldip = $nodesNicsRef->{$node}->{$nicname}->{"ip"}; - $nicipsAttr{$node}{nicips} .= $nicname."!".$oldip.","; + if ($oldip) { + $nicipsAttr{$node}{nicips} .= $nicname."!".$oldip.","; + } }else{ my $ipsref = $freeIPsHash{$nicname}; my $nextip = shift @$ipsref; @@ -932,7 +955,7 @@ Usage: } } } - + #8. Update database. setrsp_progress("Updating database records..."); my $nicstab = xCAT::Table->new('nics',-create=>1); From b6658bd232abcd354f0bd80db98809acbfa86c7b Mon Sep 17 00:00:00 2001 From: immarvin Date: Thu, 29 May 2014 01:30:42 -0700 Subject: [PATCH 39/99] fix defect #4145 [DEV] /etc/httpd/conf.d/xcat.conf is missing after xcat upgrade --- xCAT/xCAT.spec | 38 ++++++++++++++------------------------ 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/xCAT/xCAT.spec b/xCAT/xCAT.spec index 3838d7268..44d60be69 100644 --- a/xCAT/xCAT.spec +++ b/xCAT/xCAT.spec @@ -116,6 +116,7 @@ fi %install +mkdir -p $RPM_BUILD_ROOT/etc/xcat/conf.orig mkdir -p $RPM_BUILD_ROOT/etc/apache2/conf.d mkdir -p $RPM_BUILD_ROOT/etc/httpd/conf.d mkdir -p $RPM_BUILD_ROOT/install/postscripts @@ -152,10 +153,9 @@ chmod 755 $RPM_BUILD_ROOT/install/postscripts/* rm LICENSE.html mkdir -p postscripts/hostkeys cd - -cp %{SOURCE1} $RPM_BUILD_ROOT/etc/apache2/conf.d/xcat.conf.apach22 -cp %{SOURCE7} $RPM_BUILD_ROOT/etc/apache2/conf.d/xcat.conf.apach24 -cp %{SOURCE1} $RPM_BUILD_ROOT/etc/httpd/conf.d/xcat.conf.apach22 -cp %{SOURCE7} $RPM_BUILD_ROOT/etc/httpd/conf.d/xcat.conf.apach24 +cp %{SOURCE1} $RPM_BUILD_ROOT/etc/httpd/conf.d/xcat.conf +cp %{SOURCE1} $RPM_BUILD_ROOT/etc/apache2/conf.d/xcat.conf +cp %{SOURCE7} $RPM_BUILD_ROOT/etc/xcat/conf.orig/xcat.conf.apach24 cp %{SOURCE5} $RPM_BUILD_ROOT/etc/xCATMN mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/doc/packages/xCAT @@ -168,23 +168,15 @@ cp LICENSE.html $RPM_BUILD_ROOT/%{prefix}/share/doc/packages/xCAT if [ -n "$(httpd -v 2>&1 |grep -e '^Server version\s*:.*\/2.4')" ] then rm -rf /etc/httpd/conf.d/xcat.conf - cp /etc/httpd/conf.d/xcat.conf.apach24 /etc/httpd/conf.d/xcat.conf -elif [ -n "$(apachectl -v 2>&1 |grep -e '^Server version\s*:.*\/2.4')" ] -then - rm -rf /etc/apache2/conf.d/xcat.conf - cp /etc/apache2/conf.d/xcat.conf.apach24 /etc/apache2/conf.d/xcat.conf -else - rm -rf /etc/httpd/conf.d/xcat.conf - cp /etc/httpd/conf.d/xcat.conf.apach22 /etc/httpd/conf.d/xcat.conf - - rm -rf /etc/apache2/conf.d/xcat.conf - cp /etc/apache2/conf.d/xcat.conf.apach22 /etc/apache2/conf.d/xcat.conf + cp /etc/xcat/conf.orig/xcat.conf.apach24 /etc/httpd/conf.d/xcat.conf +fi + +if [ -n "$(apachectl -v 2>&1 |grep -e '^Server version\s*:.*\/2.4')" ] +then + rm -rf /etc/apache2/conf.d/xcat.conf + cp /etc/xcat/conf.orig/xcat.conf.apach24 /etc/apache2/conf.d/xcat.conf fi -rm -rf /etc/apache2/conf.d/xcat.conf.apach22 -rm -rf /etc/apache2/conf.d/xcat.conf.apach24 -rm -rf /etc/httpd/conf.d/xcat.conf.apach22 -rm -rf /etc/httpd/conf.d/xcat.conf.apach24 %endif @@ -220,11 +212,9 @@ exit 0 %files %{prefix} # one for sles, one for rhel. yes, it's ugly... -/etc/apache2/conf.d/xcat.conf.apach22 -/etc/apache2/conf.d/xcat.conf.apach24 -/etc/httpd/conf.d/xcat.conf.apach22 -/etc/httpd/conf.d/xcat.conf.apach24 - +/etc/xcat/conf.orig/xcat.conf.apach24 +/etc/httpd/conf.d/xcat.conf +/etc/apache2/conf.d/xcat.conf /etc/xCATMN /install/postscripts /install/prescripts From 92aedad72732821bfba97b6da8407fb2605f3328 Mon Sep 17 00:00:00 2001 From: daniceexi Date: Thu, 29 May 2014 07:29:24 -0400 Subject: [PATCH 40/99] defect 4144: to allow the recursion call for local named that the dns resolve request from other network is also allowed --- xCAT-server/lib/xcat/plugins/ddns.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/xCAT-server/lib/xcat/plugins/ddns.pm b/xCAT-server/lib/xcat/plugins/ddns.pm index 5d7f90473..ddda1a6a8 100755 --- a/xCAT-server/lib/xcat/plugins/ddns.pm +++ b/xCAT-server/lib/xcat/plugins/ddns.pm @@ -1009,6 +1009,7 @@ sub update_namedconf { push @newnamed,"options {\n"; unless ($slave && xCAT::Utils->isLinux()) { push @newnamed,"\tdirectory \"".$ctx->{zonesdir}."\";\n"; + push @newnamed, "\tallow-recursion { any; };\n"; } push @newnamed,"\t\t//listen-on-v6 { any; };\n"; if ($ctx->{forwarders}) { From c976cb43a17b38e630bebfa21424738b9f186bdd Mon Sep 17 00:00:00 2001 From: immarvin Date: Thu, 29 May 2014 02:52:35 -0700 Subject: [PATCH 41/99] correct xCATsn.spec to support apache2/httpd 2.4.x --- xCATsn/xCATsn.spec | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/xCATsn/xCATsn.spec b/xCATsn/xCATsn.spec index 2e514c536..0fd02f9f0 100644 --- a/xCATsn/xCATsn.spec +++ b/xCATsn/xCATsn.spec @@ -15,6 +15,7 @@ Source1: xcat.conf Source2: license.tar.gz Source3: xCATSN Source5: templates.tar.gz +Source6: xcat.conf.apach24 Provides: xCATsn = %{version} Requires: xCAT-server xCAT-client perl-DBD-SQLite @@ -80,6 +81,7 @@ tar -xf license.tar %install %ifos linux +mkdir -p $RPM_BUILD_ROOT/etc/xcat/conf.orig mkdir -p $RPM_BUILD_ROOT/etc/apache2/conf.d mkdir -p $RPM_BUILD_ROOT/etc/httpd/conf.d/ mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/xcat/ @@ -87,6 +89,8 @@ mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/xcat/ cp %{SOURCE1} $RPM_BUILD_ROOT/etc/apache2/conf.d/xcat.conf cp %{SOURCE1} $RPM_BUILD_ROOT/etc/httpd/conf.d/xcat.conf cp %{SOURCE3} $RPM_BUILD_ROOT/etc/xCATSN +cp %{SOURCE1} $RPM_BUILD_ROOT/etc/xcat/conf.orig/xcat.conf.apach22 +cp %{SOURCE6} $RPM_BUILD_ROOT/etc/xcat/conf.orig/xcat.conf.apach24 mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/doc/packages/xCAT cp LICENSE.html $RPM_BUILD_ROOT/%{prefix}/share/doc/packages/xCAT @@ -122,6 +126,23 @@ fi %endif %post +%ifos linux +#Apply the correct httpd/apache configuration file according to the httpd/apache version +if [ -n "$(httpd -v 2>&1 |grep -e '^Server version\s*:.*\/2.4')" ] +then + rm -rf /etc/httpd/conf.d/xcat.conf + cp /etc/xcat/conf.orig/xcat.conf.apach24 /etc/httpd/conf.d/xcat.conf +fi + +if [ -n "$(apachectl -v 2>&1 |grep -e '^Server version\s*:.*\/2.4')" ] +then + rm -rf /etc/apache2/conf.d/xcat.conf + cp /etc/xcat/conf.orig/xcat.conf.apach24 /etc/apache2/conf.d/xcat.conf +fi + + +%endif + # create dir for the current pid and move the original ones from /tmp/xcat to /var/run/xcat mkdir -p /var/run/xcat if [ -r "/tmp/xcat/installservice.pid" ]; then @@ -161,7 +182,6 @@ if [ -e "/etc/redhat-release" ]; then else # SuSE apachedaemon='apache2' fi - # start xcatd on linux chkconfig $apachedaemon on if [ -f "/proc/cmdline" ]; then # prevent running it during install into chroot image @@ -199,6 +219,8 @@ fi %{prefix} # one for sles, one for rhel. yes, it's ugly... %ifos linux +/etc/xcat/conf.orig/xcat.conf.apach24 +/etc/xcat/conf.orig/xcat.conf.apach22 /etc/httpd/conf.d/xcat.conf /etc/apache2/conf.d/xcat.conf %endif From a292d019d6f87cbdb016193030188c57fc45260a Mon Sep 17 00:00:00 2001 From: immarvin Date: Thu, 29 May 2014 03:41:04 -0700 Subject: [PATCH 42/99] backup xcat.conf.apach22 in /etc/xcat/conf.orig/ --- xCAT/xCAT.spec | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xCAT/xCAT.spec b/xCAT/xCAT.spec index 44d60be69..893f04996 100644 --- a/xCAT/xCAT.spec +++ b/xCAT/xCAT.spec @@ -156,6 +156,7 @@ cd - cp %{SOURCE1} $RPM_BUILD_ROOT/etc/httpd/conf.d/xcat.conf cp %{SOURCE1} $RPM_BUILD_ROOT/etc/apache2/conf.d/xcat.conf cp %{SOURCE7} $RPM_BUILD_ROOT/etc/xcat/conf.orig/xcat.conf.apach24 +cp %{SOURCE1} $RPM_BUILD_ROOT/etc/xcat/conf.orig/xcat.conf.apach22 cp %{SOURCE5} $RPM_BUILD_ROOT/etc/xCATMN mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/doc/packages/xCAT @@ -213,6 +214,7 @@ exit 0 %{prefix} # one for sles, one for rhel. yes, it's ugly... /etc/xcat/conf.orig/xcat.conf.apach24 +/etc/xcat/conf.orig/xcat.conf.apach22 /etc/httpd/conf.d/xcat.conf /etc/apache2/conf.d/xcat.conf /etc/xCATMN From db70dcfaa37067a87fade809e2fdbd30786cd1be Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Thu, 29 May 2014 10:32:02 -0400 Subject: [PATCH 43/99] Fix output that occurs on require xCAT::Client when ip is not in path --- perl-xCAT/xCAT/Client.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/perl-xCAT/xCAT/Client.pm b/perl-xCAT/xCAT/Client.pm index 66b4374c7..e604c45a0 100644 --- a/perl-xCAT/xCAT/Client.pm +++ b/perl-xCAT/xCAT/Client.pm @@ -27,7 +27,7 @@ if ($inet6support) { if ($^O =~ /^linux/i) { # Is IPv6 enabled on the MN or xcat client node at all? - my $ipv6enabled = `ip addr | grep inet6`; + my $ipv6enabled = `ip addr 2> /dev/null | grep inet6`; if (!$ipv6enabled) { $inet6support = 0; } From 6ef42b3ae82bc50310be3f864cdc75743eddf2d2 Mon Sep 17 00:00:00 2001 From: Bruce Potter Date: Thu, 29 May 2014 16:08:54 -0400 Subject: [PATCH 44/99] fixed bug in xcatws.cgi handling attr values with = in it --- xCAT-server/xCAT-wsapi/xcatws.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-server/xCAT-wsapi/xcatws.cgi b/xCAT-server/xCAT-wsapi/xcatws.cgi index bc29399a4..72c8e6a89 100755 --- a/xCAT-server/xCAT-wsapi/xcatws.cgi +++ b/xCAT-server/xCAT-wsapi/xcatws.cgi @@ -1414,7 +1414,7 @@ sub defout { } else { # just an attribute of the current node if (! $nodename) { error('improperly formatted lsdef output from xcatd', $STATUS_TEAPOT); } - my ($attr, $val) = $l =~ /^\s*(\S+)=(.*)$/; + my ($attr, $val) = $l =~ /^\s*(\S+?)=(.*)$/; if (!defined($attr)) { error('improperly formatted lsdef output from xcatd', $STATUS_TEAPOT); } $json->{$nodename}->{$attr} = $val; } From f1472b029da953aea8c2f400475e18182668b1e4 Mon Sep 17 00:00:00 2001 From: immarvin Date: Fri, 30 May 2014 03:12:08 -0700 Subject: [PATCH 45/99] fix defect #4146 post.rh.common scipt has ifconfig that does work even on Redhat6 --- .../share/xcat/install/scripts/post.rh.common | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/xCAT-server/share/xcat/install/scripts/post.rh.common b/xCAT-server/share/xcat/install/scripts/post.rh.common index 79bc733a7..9ad02fd7a 100644 --- a/xCAT-server/share/xcat/install/scripts/post.rh.common +++ b/xCAT-server/share/xcat/install/scripts/post.rh.common @@ -13,7 +13,8 @@ if [ -z "$PRINIC" ] then for karg in $(cat /proc/cmdline |sed -e 's/-/:/g' -e 's/ /\n/g'); do if [ "${karg%%=*}" = "BOOTIF" ]; then - export PRINIC=`ifconfig -a|grep -i "hwaddr ${karg#*=01:}"|awk '{print $1}'` + #export PRINIC=`ifconfig -a|grep -i "hwaddr ${karg#*=01:}"|awk '{print $1}'` + export PRINIC=`ip -o link|grep -i "${karg#*=}"|awk '{print $2}'|sed s/://` fi done if [ -z "$PRINIC" ]; then @@ -24,13 +25,16 @@ if [ -z "$PRINIC" ] then export PRINIC=eth0 elif [[ `echo "$PRINIC" | grep -sqE ^[A-Fa-f0-9]+:[A-Fa-f0-9]+:[A-Fa-f0-9]+:[A-Fa-f0-9]+:[A-Fa-f0-9]+:[A-Fa-f0-9]+$ ;echo $?` == "0" ]]; then - export PRINIC=`ifconfig -a | grep -i "HWaddr $PRINIC" | awk '{print $1}'` + #export PRINIC=`ifconfig -a | grep -i "HWaddr $PRINIC" | awk '{print $1}'` + export PRINIC=`ip -o link|grep -i "$PRINIC"|awk '{print $2}'|sed s/://` fi -IP=$(ifconfig $PRINIC | grep inet | awk '{print $2}' | awk -F: '{print $2}') +#IP=$(ifconfig $PRINIC | grep inet | awk '{print $2}' | awk -F: '{print $2}') +IP=$(ip addr show dev $PRINIC | grep inet | grep -v inet6 | awk '{print $2}' | head -n 1 | awk -F '/' '{print $1}') if [ -z $IP ] then dhclient eth0 - IP=$(ifconfig $PRINIC | grep inet | awk '{print $2}' | awk -F: '{print $2}') + #IP=$(ifconfig $PRINIC | grep inet | awk '{print $2}' | awk -F: '{print $2}') + IP=$(ip addr show dev $PRINIC | grep inet | grep -v inet6 | awk '{print $2}' | head -n 1 | awk -F '/' '{print $1}') fi export HOSTNAME=$(host $IP 2>/dev/null | awk '{print $5}' | awk -F. '{print $1}') From 321e6696f89b7ac8852c44d316c38bcbe8350d47 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 30 May 2014 10:23:31 -0400 Subject: [PATCH 46/99] Fix rpower wake turning off an on system --- xCAT-server/lib/xcat/plugins/ipmi.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/xCAT-server/lib/xcat/plugins/ipmi.pm b/xCAT-server/lib/xcat/plugins/ipmi.pm index b2aaeb0f3..848185f95 100644 --- a/xCAT-server/lib/xcat/plugins/ipmi.pm +++ b/xCAT-server/lib/xcat/plugins/ipmi.pm @@ -1541,6 +1541,7 @@ sub power_with_context { return; } elsif ($subcommand eq "wake") { $sessdata->{ipmisession}->subcmd(netfn=>0x3a,command=>0x1d,data=>[0,0],callback=>\&power_response,callback_args=>$sessdata); + return; } elsif (not $argmap{$subcommand}) { xCAT::SvrUtils::sendmsg([1,"unsupported command power $subcommand"],$callback); return; From 54af542d3508f609e5ff0d9176170b9e9a2d36e4 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 30 May 2014 11:05:05 -0400 Subject: [PATCH 47/99] Fix BMCPORT specification working with spaces --- xCAT-genesis-scripts/bin/bmcsetup | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/xCAT-genesis-scripts/bin/bmcsetup b/xCAT-genesis-scripts/bin/bmcsetup index 79c46ee51..4a6b1a87a 100755 --- a/xCAT-genesis-scripts/bin/bmcsetup +++ b/xCAT-genesis-scripts/bin/bmcsetup @@ -51,11 +51,13 @@ if [ "$IPMIMFG" == 2 ]; then #IBM BMCPORT=`grep bmcport /tmp/ipmicfg.xml |awk -F\> '{print $2}'|awk -F\< '{print $1}'` if [ ! -z "$BMCPORT" ]; then let idev=0 + IFS=',' for p in $BMCPORT; do ipmitool -d $idev raw 0xc 1 1 0xc0 $p > /dev/null ipmitool -d $idev raw 0x04 0x12 0x09 0x01 0x18 0x${p}1 0x00 > /dev/null let idev=idev+1 done + unset IFS fi elif [ "$XPROD" == "291" ]; then LOCKEDUSERS=1 @@ -65,10 +67,12 @@ if [ "$IPMIMFG" == 2 ]; then #IBM BMCPORT=`grep bmcport /tmp/ipmicfg.xml |awk -F\> '{print $2}'|awk -F\< '{print $1}'` if [ ! -z "$BMCPORT" ]; then let idev=0 + IFS=',' for p in $BMCPORT; do ipmitool -d $idev raw 0xc 1 1 0xc0 $p > /dev/null let idev=idev+1 done + unset IFS fi fi fi @@ -82,6 +86,7 @@ elif [ "$IPMIMFG" == 20301 ] ; then BMCPORT=`grep bmcport /tmp/ipmicfg.xml |awk -F\> '{print $2}'|awk -F\< '{print $1}'` if [ ! -z "$BMCPORT" ]; then let idev=0 + IFS=',' for p in $BMCPORT; do ipmitool -d $idev raw 0xc 1 1 0xc0 $p > /dev/null NEWPORT=`ipmitool -d $idev raw 0xc 2 1 0xc0 0 0|awk '{print $2}'` @@ -89,6 +94,7 @@ elif [ "$IPMIMFG" == 20301 ] ; then let idev=idev+1 done + unset IFS fi elif [ "$IPMIMFG" == "47488" ]; then LOCKEDUSERS=1 From dbbed4ef1f83add0373e3f2112cd387ec06a930d Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 30 May 2014 11:24:13 -0400 Subject: [PATCH 48/99] Mark pending firmware to be clear that firmware is not yet active --- xCAT-server/lib/xcat/plugins/ipmi.pm | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/ipmi.pm b/xCAT-server/lib/xcat/plugins/ipmi.pm index 848185f95..e6e67cd25 100644 --- a/xCAT-server/lib/xcat/plugins/ipmi.pm +++ b/xCAT-server/lib/xcat/plugins/ipmi.pm @@ -1957,11 +1957,20 @@ sub got_bios_buildid { my $sessdata = $res{sessdata}; if ($res{data}) { $sessdata->{biosbuildid} = $res{data}; - get_imm_property(property=>"/v2/bios/build_version",callback=>\&got_bios_version,sessdata=>$sessdata); + get_imm_property(property=>"/v2/bios/pending_build_version",callback=>\&got_bios_pending_buildid,sessdata=>$sessdata); } else { initfru_with_mprom($sessdata); } } +sub got_bios_pending_buildid { + my %res = @_; + my $sessdata = $res{sessdata}; + $sessdata->{biosbuildpending} = 0; + if ($res{data}) { + $sessdata->{biosbuildpending} = 1; + } + get_imm_property(property=>"/v2/bios/build_version",callback=>\&got_bios_version,sessdata=>$sessdata); +} sub got_bios_version { my %res = @_; my $sessdata = $res{sessdata}; @@ -1980,7 +1989,12 @@ sub got_bios_date { my $fru = FRU->new(); $fru->rec_type("bios,uefi,firmware"); $fru->desc("UEFI Version"); - $fru->value($sessdata->{biosbuildversion}." (".$sessdata->{biosbuildid}." ".$sessdata->{biosbuilddate}.")"); + my $pending = ""; + if ($sessdata->{biosbuildpending}) { + $pending = " [PENDING]"; + } + my $value = $sessdata->{biosbuildversion}." (".$sessdata->{biosbuildid}." ".$sessdata->{biosbuilddate}.")$pending"; + $fru->value($value); $sessdata->{fru_hash}->{uefi} = $fru; get_imm_property(property=>"/v2/fpga/build_id",callback=>\&got_fpga_buildid,sessdata=>$sessdata); } else { From 0c29a9c630eaebec20b7d6139115d354899cf41c Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 30 May 2014 11:27:17 -0400 Subject: [PATCH 49/99] Fix problem where firmware was erroneously marked pending --- xCAT-server/lib/xcat/plugins/ipmi.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-server/lib/xcat/plugins/ipmi.pm b/xCAT-server/lib/xcat/plugins/ipmi.pm index e6e67cd25..c5eaa002b 100644 --- a/xCAT-server/lib/xcat/plugins/ipmi.pm +++ b/xCAT-server/lib/xcat/plugins/ipmi.pm @@ -1966,7 +1966,7 @@ sub got_bios_pending_buildid { my %res = @_; my $sessdata = $res{sessdata}; $sessdata->{biosbuildpending} = 0; - if ($res{data}) { + if ($res{data} and $res{data} ne ' ') { $sessdata->{biosbuildpending} = 1; } get_imm_property(property=>"/v2/bios/build_version",callback=>\&got_bios_version,sessdata=>$sessdata); From f48da3fc64ab75a59845401e8e1cd3b375601f2d Mon Sep 17 00:00:00 2001 From: lissav Date: Mon, 2 Jun 2014 09:07:54 -0400 Subject: [PATCH 50/99] defect 4091 --- xCAT-client/bin/rcons | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/xCAT-client/bin/rcons b/xCAT-client/bin/rcons index 979759c49..86497d9f1 100755 --- a/xCAT-client/bin/rcons +++ b/xCAT-client/bin/rcons @@ -115,7 +115,11 @@ else length=`expr $index2 - $index1` length=`expr $length - 1` cons_ip=`expr substr "$result" $pos $length` - ifconfig |grep "$cons_ip" + if [ "$os" == "AIX" ]; then + ifconfig |grep "$cons_ip" + else + ip addr |grep "$cons_ip" + fi if [ $? -eq 0 ]; then CONSERVER="" fi From 5e85167b7bc1488a4f6dba75793c5cc1e555a63d Mon Sep 17 00:00:00 2001 From: lissav Date: Mon, 2 Jun 2014 09:13:41 -0400 Subject: [PATCH 51/99] defect 4091 --- xCAT/postscripts/configeth | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/xCAT/postscripts/configeth b/xCAT/postscripts/configeth index 247257b84..195fab5a6 100755 --- a/xCAT/postscripts/configeth +++ b/xCAT/postscripts/configeth @@ -335,7 +335,8 @@ elif [ "$1" = "-s" ];then if [ -n "$MACADDRESS" ];then str_inst_mac=$MACADDRESS else - str_inst_mac=`ifconfig $str_inst_nic | grep HWaddr | awk -F'HWaddr' '{print $2}' | sed 's/\s*//'` + #str_inst_mac=`ifconfig $str_inst_nic | grep HWaddr | awk -F'HWaddr' '{print $2}' | sed 's/\s*//'` + str_inst_mac=`ip link show $netdev | grep ether | awk '{print $2}'` fi if [ -z "$str_inst_ip" -o -z "$str_inst_mask" ];then From db3c98cffec2640287e19c697f94afaabf0e1b68 Mon Sep 17 00:00:00 2001 From: Bruce Potter Date: Mon, 2 Jun 2014 11:59:47 -0400 Subject: [PATCH 52/99] backported SI files to 2.8 branch --- xCAT-SoftLayer/bin/getslnodes | 17 +- xCAT-SoftLayer/bin/khrem | 88 +++++++ xCAT-SoftLayer/bin/modifygrub | 119 +++++++-- xCAT-SoftLayer/bin/pushinitrd | 175 ++++++++++-- xCAT-SoftLayer/postscripts/configbond | 248 ++++++++++++++++++ xCAT-SoftLayer/postscripts/setdefaultroute | 26 +- .../sles/compute.sles11.softlayer.tmpl | 44 +++- .../si-post-install/15all.configefi | 82 ++++++ .../si-post-install/16all.updatenetwork | 209 +++++++++++++++ .../si-post-install/20all.makeinitrd | 18 ++ .../si-post-install/99all.killsyslog | 25 ++ xCAT-SoftLayer/xCAT-SoftLayer.spec | 21 +- xCAT-genesis-scripts/bin/doxcat | 106 ++++++-- 13 files changed, 1108 insertions(+), 70 deletions(-) create mode 100755 xCAT-SoftLayer/bin/khrem create mode 100755 xCAT-SoftLayer/postscripts/configbond create mode 100755 xCAT-SoftLayer/si-post-install/15all.configefi create mode 100755 xCAT-SoftLayer/si-post-install/16all.updatenetwork create mode 100755 xCAT-SoftLayer/si-post-install/20all.makeinitrd create mode 100755 xCAT-SoftLayer/si-post-install/99all.killsyslog diff --git a/xCAT-SoftLayer/bin/getslnodes b/xCAT-SoftLayer/bin/getslnodes index ae02b6642..d5549ad1c 100755 --- a/xCAT-SoftLayer/bin/getslnodes +++ b/xCAT-SoftLayer/bin/getslnodes @@ -38,8 +38,6 @@ if (scalar(@ARGV)>1) { $usage->(1); } my $hnmatch = $ARGV[0]; # if they specified a hostname match, only show svrs that start with that readconf("$ENV{HOME}/.slconfig"); # get the userid and api key from the config file -#my $api_username = 'SL276540'; -#my $api_key = '799d5d9267a927a330ec016f00bfe17e6fc532d203cf68b3b0d997b2d27a3ce1'; my $slinstalled = eval { push @INC, $CONFIG{apidir}; require SoftLayer::API::SOAP; }; if (!$slinstalled) { die "Error: the SoftLayer::API::SOAP perl module is not installed. Download it using 'git clone https://github.com/softlayer/softlayer-api-perl-client' and put the directory in ~/.slconfig ."; } @@ -64,12 +62,23 @@ foreach my $server (@$servers) { print "\tbmc=".$server->{remoteManagementComponent}->{ipmiIpAddress}."\n"; print "\tbmcusername=".$server->{remoteManagementAccounts}->[0]->{username}."\n"; print "\tbmcpassword=".$server->{remoteManagementAccounts}->[0]->{password}."\n"; - print "\tmac=".$server->{backendNetworkComponents}->[0]->{macAddress}."\n"; - print "\tip=".$server->{privateIpAddress}."\n"; + + # find the 1st active private nic that is not the bmc + foreach my $nic (@{$server->{backendNetworkComponents}}) { + #print "nic:\n"; foreach my $key (keys(%$nic)) { print " $key = ", $nic->{$key}, "\n"; } + if ($nic->{status} eq 'ACTIVE' && $nic->{name} eq 'eth' && $nic->{macAddress} && $nic->{primaryIpAddress}) { + # found it + print "\tmac=".$nic->{macAddress}."\n"; + print "\tip=".$nic->{primaryIpAddress}."\n"; + } + } + #print "\tip=".$server->{privateIpAddress}."\n"; # getting this from the backendNetworkComponents instead + print "\tserial=".$server->{manufacturerSerialNumber}."\n"; print "\tnetboot=xnba\n"; print "\tarch=x86_64\n"; print "\tusercomment=hostname:".$server->{fullyQualifiedDomainName}.", user:".$server->{operatingSystem}->{passwords}->[0]->{username}.", pw:".$server->{operatingSystem}->{passwords}->[0]->{password}."\n"; + verbose('SoftLayer API bare metal server entry: ' . Dumper($server)); #print Dumper($server->{remoteManagementAccounts}); #print "#Softlayer_account_info_for ".$server->{fullyQualifiedDomainName} . " Username: "; #print $server->{operatingSystem}->{passwords}->[0]->{username} . " Password: "; diff --git a/xCAT-SoftLayer/bin/khrem b/xCAT-SoftLayer/bin/khrem new file mode 100755 index 000000000..ac212c484 --- /dev/null +++ b/xCAT-SoftLayer/bin/khrem @@ -0,0 +1,88 @@ +#!/usr/bin/perl + +# remove entries from the .ssh/known_hosts file for a node + +use strict; +use Getopt::Long; +use Data::Dumper; +#$Data::Dumper::Maxdepth=2; + +# Globals - these are set once and then only read. +my $HELP; +my $VERBOSE; +my $file = '~/.ssh/known_hosts'; + +my $usage = sub { + my $exitcode = shift @_; + print "Usage: khrem \n"; + print " Removes the entries in the .ssh/known_hosts file associated with this node.\n"; + exit $exitcode; +}; + +# Process the cmd line args +Getopt::Long::Configure("bundling"); +#Getopt::Long::Configure("pass_through"); +Getopt::Long::Configure("no_pass_through"); +if (!GetOptions('h|?|help' => \$HELP, 'v|verbose' => \$VERBOSE)) { $usage->(1); } + +if ($HELP) { $usage->(0); } +if (scalar(@ARGV)!=1) { $usage->(1); } +my $node = $ARGV[0]; # if they specified a hostname match, only show svrs that start with that + +my @output = runcmd("host $node"); +my $hostname; +my $line = shift @output; +#print "line=$line\n"; +if ($line =~ m/is an alias for /) { + ($hostname) = $line =~ m/is an alias for ([^\.]+)/; + #print "hostname=$hostname\n"; + $line = shift @output; + } +#print "line=$line\n"; +my ($ip) = $line =~ m/has address (.+)$/; +if (defined($hostname)) { + print "Removing entries from $file for: $node, $hostname, $ip\n"; + runcmd("sed -i '/^$node/d;/^$hostname/d;/^$ip/d' $file"); + } +else { + print "Removing entries from $file for: $node, $ip\n"; + runcmd("sed -i '/^$node/d;/^$ip/d' $file"); +} + +exit(0); + + +# Pring msg only if -v was specified +sub verbose { if ($VERBOSE) { print shift, "\n"; } } + + + + +# Run a command. If called in the context of return an array, it will capture the output +# of the cmd and return it. Otherwise, it will display the output to stdout. +# If the cmd has a non-zero rc, this function will die with a msg. +sub runcmd +{ + my ($cmd) = @_; + my $rc; + + $cmd .= ' 2>&1' ; + verbose($cmd); + + my @output; + if (wantarray) { + @output = `$cmd`; + $rc = $?; + } + else { + system($cmd); + $rc = $?; + } + + if ($rc) { + $rc = $rc >> 8; + if ($rc > 0) { die "Error: rc $rc return from cmd: $cmd\n"; } + else { die "Error: system error returned from cmd: $cmd\n"; } + } + elsif (wantarray) { return @output; } +} diff --git a/xCAT-SoftLayer/bin/modifygrub b/xCAT-SoftLayer/bin/modifygrub index a6d28407f..a1769e8e9 100755 --- a/xCAT-SoftLayer/bin/modifygrub +++ b/xCAT-SoftLayer/bin/modifygrub @@ -12,12 +12,14 @@ use Socket; # Globals - these are set once and then only read. my $HELP; my $VERBOSE; +my $DRYRUN; my $WAITTIME; +my $PROVMETHOD; my $XCATNETBOOTTITLE = 'xCAT network boot kernel and initrd'; my $usage = sub { my $exitcode = shift @_; - print "Usage: modifygrub [-?|-h|--help] [-v|--verbose] [-w ] \n\n"; + print "Usage: modifygrub [-?|-h|--help] [-v|--verbose] [--dryrun] [-w ] [-p \n\n"; if (!$exitcode) { print "Modify the grub config file on the node to boot the specified kernel and initrd.\n"; } @@ -30,7 +32,7 @@ if (-f '/etc/os-release') { die "This script doesn't support ubuntu yet.\n"; } Getopt::Long::Configure("bundling"); #Getopt::Long::Configure("pass_through"); Getopt::Long::Configure("no_pass_through"); -if (!GetOptions('h|?|help' => \$HELP, 'v|verbose' => \$VERBOSE, 'w|waittime=s' => \$WAITTIME)) { $usage->(1); } +if (!GetOptions('h|?|help' => \$HELP, 'v|verbose' => \$VERBOSE, 'dryrun' => \$DRYRUN, 'w|waittime=s' => \$WAITTIME, 'p|provmethod=s' => \$PROVMETHOD)) { $usage->(1); } if ($HELP) { $usage->(0); } if (scalar(@ARGV) != 4) { $usage->(1); } @@ -60,35 +62,89 @@ sub addKernelParms { $args->{kernelparms} =~ s//$nodename/g; # get node ip and add it to the kernel parms - my ($nic, $ip, $netmask, $gateway) = getNodeIpInfo($args); + my ($nic, $ip, $netmask, $network, $broadcast, $gateway, $mac) = getNodeIpInfo($args); if (!$ip) { die "Error: could not find the NIC that would connect to the xCAT mgmt node's IP (".$args->{mnip}.").\n"; } - $args->{kernelparms} .= " hostip=$ip netmask=$netmask gateway=$gateway dns=$mnip hostname=$nodename netdevice=$nic netwait=$WAITTIME textmode=1"; + # if we are booting genesis, need to add the BOOTIF parm + my $bootif; + if ($args->{kernelpath} =~ m/genesis\.kernel\.x86_64/) { + $bootif = $mac; + $bootif =~ s/:/-/g; + $bootif = "BOOTIF=01-$bootif"; + } + + #todo: if you are running genesis shell (nodeset shell), this if-else will depend on the nodeset done before that. + # really should check for currstate=shell, or something like that + if (defined($PROVMETHOD) && $PROVMETHOD eq 'sysclone') { + # add additional parms for sysclone + # DEVICE=eth0 IPADDR=10.0.0.99 NETMASK=255.255.255.0 NETWORK=10.0.0.0 BROADCAST=10.0.0.255 GATEWAY=10.0.0.1 GATEWAYDEV=eth0 + #todo: should we also add ETHER_SLEEP=$WAITTIME textmode=1 dns=$mnip ? + $args->{kernelparms} .= " $bootif IPADDR=$ip NETMASK=$netmask NETWORK=$network BROADCAST=$broadcast GATEWAY=$gateway HOSTNAME=$nodename DEVICE=$nic GATEWAYDEV=$nic"; + } + else { # scripted install + #todo: the parameters for kickstart are likely different + $args->{kernelparms} .= " $bootif hostip=$ip netmask=$netmask gateway=$gateway dns=$mnip hostname=$nodename netdevice=$nic netwait=$WAITTIME textmode=1"; + } } -# get this nodes nic, ip, netmask, and gateway. Returns them in a 4 element array. +# get this nodes nic, ip, netmask, gateway, and mac. Returns them in a 5 element array. sub getNodeIpInfo { my $args = shift @_; - my ($ipprefix) = $args->{mnip}=~m/^(\d+\.\d+)\./; #todo: this is a hack, just using the 1st 2 octets of the mn ip addr + my ($ipprefix) = $args->{mnip}=~m/^(\d+)\./; #todo: this is a hack, just using the 1st octet of the mn ip addr verbose("using IP prefix $ipprefix"); - # parse ip addr show output, looking for ipprefix, to determine nic and ip + # parse ip addr show output, looking for ipprefix, to determine nic, ip, mac my @output = runcmd("ip addr show"); - my ($nic, $ipandmask); + my ($nic, $mac, $ipandmask); foreach my $line (@output) { - my ($nictmp, $iptmp); + my ($nictmp, $mactmp, $iptmp); if (($nictmp) = $line=~m/^\d+:\s+(\S+): /) { $nic = $nictmp; } # new stanza, remember it + if (($mactmp) = $line=~m|^\s+link/ether\s+(\S+) |) { $mac = $mactmp; } # got mac, remember it if (($iptmp) = $line=~m/^\s+inet\s+($ipprefix\S+) /) { $ipandmask = $iptmp; last; } # got ip, we are done } - my ($ip, $netmask) = convertIpAndMask($ipandmask); + if (!defined($ipandmask)) { die "Error: can't find a NIC with a prefix $ipprefix that communicates with".$args->{mnip}.".\n"; } + my ($ip, $netmask, $network, $broadcast) = convertIpAndMask($ipandmask); - # if the nic is a bonded nic (common on sl), then find the 1st real nic that is part of it - my $realnic = $nic; + # if the nic is a bonded nic (common on sl), then find the 1st real nic that is up that is part of it. + # also find that real nics real mac + my $realnic; if ($nic =~ /^bond/) { my @nics = grep(m/\s+master\s+$nic\s+/, @output); if (!scalar(@nics)) { die "Error: can't find the NICs that are part of $nic.\n"; } - ($realnic) = $nics[0]=~m/^\d+:\s+(\S+): /; + foreach my $line (@nics) { + my ($nictmp, $state) = $line=~m/^\d+:\s+(\S+): .* state\s+(\S+)/; + if (defined($nictmp) && defined($state) && $state eq 'UP') { $realnic = $nictmp; last; } # got ip, we are done + } + if (!defined($realnic)) { die "Error: can't find a physical NIC that is up and part of $nic.\n"; } + + # now get the real mac of this real nic (when 2 nics are bonded, ip addr show displays one of the nics + # macs for both nics and the bond). So we have to depend on /proc/net/bonding/$bond instead. + my @bondout = runcmd("cat /proc/net/bonding/$nic"); + my $foundnic; + foreach my $line (@bondout) { + my $mactmp; + if ($line=~m/^Slave Interface:\s+$realnic/) { $foundnic = 1; } # found the stanza for this nic, remember it + if ($foundnic && (($mactmp) = $line=~m/^Permanent HW addr:\s+(\S+)/)) { $mac = $mactmp; last; } + } } + else { $realnic = $nic; } + + # centos/redhat seems to name the nic in a different order than sles on some svrs. + # sles seems to name them in the same order as 'ip addr show' displays them, centos does not. + # so if we are on centos right now, we need to count down to determine the number that sles + # will give the nic that we have selected, because it is the sles naming that we care about, + # because that is the initrd that will be running in the scripted install case. + # For the sysclone case, genesis doxcat should be changed to use the mac to find the nic. + if (isRedhat()) { + my @nics = grep(m/^\d+:\s+eth/, @output); + my $i = 0; + foreach my $line (@nics) { + my ($nictmp) = $line=~m/^\d+:\s+(\S+):/; + if (defined($nictmp) && $nictmp eq $realnic) { $realnic = "eth$i"; last; } # got ip, we are done + $i++; + } + } + print "Determined that SLES will call the install NIC $realnic (it has mac $mac)\n"; # finally, find the gateway my $gateway; @@ -102,19 +158,37 @@ sub getNodeIpInfo { verbose("using xCAT mgmt node IP as the fall back gateway."); } - verbose("IP info: realnic=$realnic, ip=$ip, netmask=$netmask, gateway=$gateway"); - return ($realnic, $ip, $netmask, $gateway); + verbose("IP info: realnic=$realnic, ip=$ip, netmask=$netmask, gateway=$gateway, mac=$mac"); + return ($realnic, $ip, $netmask, $network, $broadcast, $gateway, $mac); } -# Convert an ip/mask in slash notation (like 10.0.0.1/26) to separate ip and netmask like 10.0.0.1 and 255.255.255.192 +# Convert an ip/mask in slash notation (like 10.1.1.1/26) to separate ip, netmask, network, and broadcast values, +# like: 10.1.1.1, 255.255.255.192, 10.1.1.0, 10.1.1.63 sub convertIpAndMask { my $ipandmask = shift @_; my ($ip, $masknum) = split('/', $ipandmask); - my $netbin = oct("0b" . '1' x $masknum . '0' x (32-$masknum)); # create a str like '1111100', then convert to binary - my @netarr=unpack('C4',pack('N',$netbin)); # separate into the 4 octets - my $netmask=join('.',@netarr); # put them together into the normal looking netmask - return ($ip, $netmask); + + # build the netmask + my $nmbin = oct("0b" . '1' x $masknum . '0' x (32-$masknum)); # create a str like '1111100', then convert to binary + my @nmarr=unpack('C4',pack('N',$nmbin)); # separate into the 4 octets + my $netmask=join('.',@nmarr); # put them together into the normal looking netmask + + # create binary form of ip + my @iparr=split(/\./,$ip); + my ( $ipbin ) = unpack('N', pack('C4',@iparr ) ); + + # Calculate network address by logical AND operation of ip & netmask and convert network address to IP address format + my $netbin = ( $ipbin & $nmbin ); + my @netarr=unpack('C4', pack('N',$netbin ) ); + my $network=join(".",@netarr); + + # Calculate broadcast address by inverting the netmask and adding it to the network address + my $bcbin = ( $ipbin & $nmbin ) + ( ~ $nmbin ); + my @bcarr=unpack('C4', pack('N',$bcbin ) ) ; + my $broadcast=join(".",@bcarr); + + return ($ip, $netmask, $network, $broadcast); } @@ -155,6 +229,11 @@ sub updateGrub { "\tkernel " . $fileprefix . $args->{kernelpath} . ' ' . $args->{kernelparms} . "\n", "\tinitrd " . $fileprefix . $args->{initrdpath} . "\n", ); + if ($DRYRUN) { + print "Dry run: would add this stanza to $grubfile:\n"; + foreach my $l (@entry) { print $l; } + return; + } my $needtowritefile = 1; if (grep(/^title\s+$XCATNETBOOTTITLE/, @lines)) { $needtowritefile = updateGrubEntry(\@lines, \@entry); } # there is already an entry in there diff --git a/xCAT-SoftLayer/bin/pushinitrd b/xCAT-SoftLayer/bin/pushinitrd index 7e3cd5a7e..62c19d8ba 100755 --- a/xCAT-SoftLayer/bin/pushinitrd +++ b/xCAT-SoftLayer/bin/pushinitrd @@ -13,12 +13,13 @@ use Data::Dumper; # Globals - these are set once and then only read. my $HELP; my $VERBOSE; +my $DRYRUN; my $WAITTIME; my $NOAUTOINST; my $usage = sub { my $exitcode = shift @_; - print "Usage: pushinitrd [-?|-h|--help] [-v|--verbose] [-w ] \n\n"; + print "Usage: pushinitrd [-?|-h|--help] [-v|--verbose] [--dryrun] [-w ] \n\n"; if (!$exitcode) { print "Copy the initrd, kernel, params, and static IP info to nodes, so they can net install\n"; print "even across vlans (w/o setting up pxe/dhcp broadcast relay). This assumes a working\n"; @@ -32,7 +33,7 @@ my $usage = sub { Getopt::Long::Configure("bundling"); #Getopt::Long::Configure("pass_through"); Getopt::Long::Configure("no_pass_through"); -if (!GetOptions('h|?|help' => \$HELP, 'v|verbose' => \$VERBOSE, 'w|waittime=s' => \$WAITTIME, 'a|noautoinst' => \$NOAUTOINST)) { $usage->(1); } +if (!GetOptions('h|?|help' => \$HELP, 'v|verbose' => \$VERBOSE, 'dryrun' => \$DRYRUN, 'w|waittime=s' => \$WAITTIME, 'a|noautoinst' => \$NOAUTOINST)) { $usage->(1); } if ($HELP) { $usage->(0); } if (scalar(@ARGV) != 1) { $usage->(1); } @@ -45,7 +46,11 @@ copyFilesToNodes($noderange, \%bootparms); updateGrubOnNodes($noderange, \%bootparms); -if (!$NOAUTOINST) { modifyAutoinstFiles($noderange, \%bootparms); } +if ($DRYRUN) { exit(0); } + +if ($bootparms{osimageprovmethod} eq 'install' && !$NOAUTOINST) { modifyAutoinstFiles($noderange, \%bootparms); } + +if ($bootparms{osimageprovmethod} eq 'sysclone') { copySyscloneFiles(); } exit(0); @@ -54,23 +59,31 @@ exit(0); sub getBootParms { my $nr = shift @_; my %bootparms; - my @output = runcmd("nodels $nr bootparams.kernel bootparams.initrd bootparams.kcmdline"); + my @output = runcmd("nodels $nr bootparams.kernel bootparams.initrd bootparams.kcmdline nodetype.provmethod"); # the attributes can be displayed in a different order than requested, so need to grep for them - my @gresults; - foreach my $a (qw(kernel initrd kcmdline)) { - my $attr = "bootparams.$a"; - @gresults = grep(/^\S+:\s+$attr:/, @output); + foreach my $attr (qw(bootparams.kernel bootparams.initrd bootparams.kcmdline nodetype.provmethod)) { + my ($a) = $attr =~ m/\.(.*)$/; + my @gresults = grep(/^\S+:\s+$attr:/, @output); if (!scalar(@gresults)) { die "Error: attribute $attr not defined for the noderange. Did you run 'nodeset osimage=' ?\n"; } # for now just pick the 1st one. They should all be the same, except for the node name in kcmdline chomp($gresults[0]); $gresults[0] =~ s/^\S+:\s+$attr:\s*//; + #print "gresults='$gresults[0]'\n"; + if ($gresults[0] !~ m/\S/) { die "Error: attribute $attr not defined for the noderange. Did you run 'nodeset osimage=' ?\n"; } $bootparms{$a} = $gresults[0]; - if ($a eq 'kcmdline') { $bootparms{$a} =~ s|/install/autoinst/\S+|/install/autoinst/|; } } + $bootparms{kcmdline} =~ s|/install/autoinst/\S+|/install/autoinst/|; + + # from the nodes provmethod, get the osimage provmethod, so we know the type of install + @output = runcmd("lsdef -t osimage $bootparms{provmethod} -ci provmethod"); + chomp($output[0]); + if ($output[0] =~ m/^Could not find/) { die "Error: provmethod $bootparms{provmethod} is set for the node, but there is no osimage definition by that name."; } + my ($junk, $provmethod) = split(/=/, $output[0]); + $bootparms{osimageprovmethod} = $provmethod; # get the mgmt node cluster-facing ip addr - @output = runcmd('lsdef -t site -i master -c'); + @output = runcmd('lsdef -t site -ci master'); chomp($output[0]); my ($junk, $ip) = split(/=/, $output[0]); $bootparms{mnip} = $ip; @@ -90,8 +103,13 @@ sub copyFilesToNodes { my $localfile = "/tftpboot/$file"; # for the my $remotefile = '/boot/' . remoteFilename($file); - print "Copying $localfile to $nr:$remotefile\n"; - runcmd("xdcp $nr -p $localfile $remotefile"); + if ($DRYRUN) { + print "Dry run: would copy $localfile to $nr:$remotefile\n"; + } + else { + print "Copying $localfile to $nr:$remotefile\n"; + runcmd("xdcp $nr -p $localfile $remotefile"); + } } } @@ -99,7 +117,7 @@ sub copyFilesToNodes { # Form the remote file name, using the last 2 parts of the path, separated by "-" sub remoteFilename { my $f = shift @_; - $f =~ s|^.*/([^/]+)/([^/]+)$|$1-$2|; + $f =~ s|^.*?([^/]+)/([^/]+)$|$1-$2|; return $f; } @@ -110,10 +128,11 @@ sub updateGrubOnNodes { my $nr = shift @_; my $bootparms = shift @_; my $vtxt = ($VERBOSE ? '-v' : ''); + my $dtxt = ($DRYRUN ? '--dryrun' : ''); my @output = runcmd('which modifygrub'); my $modifygrub = $output[0]; chomp($modifygrub); - my $cmd = "xdsh $nr -e $modifygrub $vtxt -w $WAITTIME " . remoteFilename($bootparms->{kernel}) . ' ' . remoteFilename($bootparms->{initrd}) . ' '; + my $cmd = "xdsh $nr -e $modifygrub $vtxt $dtxt -w $WAITTIME -p " . $bootparms->{osimageprovmethod} . ' ' . remoteFilename($bootparms->{kernel}) . ' ' . remoteFilename($bootparms->{initrd}) . ' '; # we need to quote the kernel parms, both here when passing it to xdsh, and on the node # when xdsh is passing it to modifygrub. The way to get single quotes inside single quotes # is to quote each of the outer single quotes with double quotes. @@ -124,8 +143,7 @@ sub updateGrubOnNodes { } -# Hack the autoinst files to wait in a key spot to make them work even tho it takes -# the NICs almost a min before they can transmit after a state change. +# Hack the autoinst files to overcome the nic coming up delay. #todo: this has only been tested with SLES nodes sub modifyAutoinstFiles { my $nr = shift @_; @@ -135,30 +153,145 @@ sub modifyAutoinstFiles { my @nodes = runcmd("nodels $nr"); chomp(@nodes); + # Modify chroot.sles to insert a wait in the /etc/init.d/network of each node. This is + # necessary because even tho compute.sles11.softlayer.tmpl configures bonding, when autoyast + # reboots the node after installing the rpms, it does not bring up the network in the normal way + # at first and seems to skip any bonding and the if-up.d scripts. So we are left doing this. + # (After autoyast is done with all of its post-configuration, it brings up the network in the + # normal way, so bonding gets done then, which is good at least.) + # Edit each file to have chroot.sles insert a wait at the end of /etc/init.d/network # this finds the end of boot.sh script (which is chroot.sles) my $search = '\n\]\]>\s*\s*\s*'; + # hack the /etc/init.d/network script to put a wait in it my $file = '/mnt/etc/init.d/network'; # at this point in the installation, the permanent file system is just mounted - #my $waitstring = 'echo Sleeping for 55s;sleep 55'; - # this is the string to insert in the nodes /etc/init.d/network script. It is a while loop pinging the mn, but some of the chars need to be escape for sed - my $waitstring = 'echo Waiting to reach xCAT mgmt node...;while \[ \$\(\(xcati+=1\)\) -le 60 \] \&\& ! ping -c2 -w3 ' . $bootparms->{mnip} .'; do echo i=\$xcati ; done; sleep 10'; + # this is the string to insert in the nodes /etc/init.d/network script. It is a while loop pinging the mn, but some of the chars need to be escaped for sed + my $waitstring = 'echo -n Waiting to reach xCAT mgmt node ' . $bootparms->{mnip} . '.;xcatretries=60;while \[ \$\(\(xcati+=1\)\) -le \$xcatretries \] \&\& ! ping -c2 -w3 ' . $bootparms->{mnip} .' \>\/dev\/null 2\>\&1; do echo -n .; done; if \[ \$xcati -le \$xcatretries \]; then echo success; else echo failed; fi'; # this crazy sed string is from google. It gathers up the whole file into the hold buffer, and then the substitution is done on the whole file my $sedstring = q|sed -n '1h;1!H;${;g;s/\(\t\treload_firewall\n\)\n/\1\t\t| . $waitstring . q(\n\n/g;p;}') . " $file > $file.new"; # finally create the perl replace string that will be used to modify the autoinst file my $replace = "$sedstring\nchmod 755 $file.new; mv -f $file.new $file"; - # now actually update the file + # Add a script that gets invoked by the OS after the nic is brought up + # Note: this does not work, because midway thru the autoyast process, the if-up.d scripts do not seem to get invoked + # so autoyast fails to get the media + # these are specific to SLES + #my $netdir = '/etc/sysconfig/network'; + #my $filename = '/etc/sysconfig/network/if-up.d/xcat-sl-wait'; + #my $mnip = $bootparms->{mnip}; + #todo: to support rhel, use these values instead + #my $netdir='/etc/sysconfig/network-scripts'; + #my $filename='/sbin/ifup-local'; + #my $replace = qq( +#FILENAME=$filename +#NETDIR=$netdir +#MNIP=$mnip +#); +# $replace .= q( +#cat >$FILENAME << EOF1 +#MNIP=$MNIP +#NETDIR=$NETDIR +#EOF1 +# +# this part of the file we do NOT want to expand the variables in the content +#cat >>$FILENAME << 'EOF2' +#NIC="$1" +# look in this ifcfg script to get the nics ip to see if this is the one we should be waiting on +#NICIP=`awk -F= '/^IPADDR/ {print $2}' $NETDIR/ifcfg-$NIC | tr -d \' ` +#if [ "${NICIP%.*.*}" != "${MNIP%.*.*}" ]; then exit; fi # hack: compare the 1st 2 octets +#echo -n Waiting to reach xCAT mgmt node $MNIP. +#xcatretries=60 +#while [ $((xcati+=1)) -le $xcatretries ] && ! ping -c2 -w3 $MNIP >/dev/null 2>&1; do echo -n .; done +#if [ $xcati -le $xcatretries ]; then echo " success"; else echo " failed"; fi +#sleep 3 +#EOF2 +# +#chmod +x $FILENAME +#); + + # The compute.sles11.softlayer.tmpl file contains 2 variables (node ip and netmask) that are + # not replaced by Template.pm. Substitute those in the autoinst files now. + # Also use our own multiline sed to put the network script hack in. print "Updating /install/autoinst files.\n"; foreach my $n (@nodes) { my $f = "/install/autoinst/$n"; + my ($ip, $netmask, $gateway) = getNodeIpInfo($n); + runcmd("sed -i 's/#NODEIPADDR#/$ip/;s/#NODENETMASK#/$netmask/;s/#NODEGATEWAY#/$gateway/' $f"); + my $matches = sed($f, $search, $replace, mode=>'insertbefore'); if (!$matches) { die "Error: could not find the right place in $f to insert the sed of the network wait.\n"; } } } +# Copy softlayer specific systemimager post-install scripts to the systemimager location. +# These cause si to use static ip and insert a wait into the bring up of the network. +sub copySyscloneFiles { + my $cmd = "cp -f /opt/xcat/share/xcat/sysclone/post-install/* /install/sysclone/scripts/post-install"; + print "Copying SoftLayer-specific post scripts to the SystemImager post-install directory.\n"; + runcmd($cmd); +} + + +# Get IP and network of a node +sub getNodeIpInfo { + my $node = shift; + + # get ip for the node + my @output = runcmd("nodels $node hosts.ip"); + chomp($output[0]); + my ($junk, $ip) = split(/\s+/, $output[0]); + #todo: also support getting the ip from name resolution + if (!$ip) { die "Error: the ip attribute must be set for $node.\n"; } + + # find relevant network in the networks table + # first get the networks in a hash + my %networks; + @output = runcmd("lsdef -t network -ci net,mask,gateway"); + foreach my $line (@output) { + chomp($line); + my ($netname, $attr, $val) = $line =~ m/^(.+):\s+(.+?)=(.+)$/; + $networks{$netname}->{$attr} = $val; + } + # now go thru the networks looking for the correct one + my ($netmask, $gateway); + foreach my $key (keys %networks) { + if (isIPinNet($ip, $networks{$key}->{net}, $networks{$key}->{mask})) { # found it + $netmask = $networks{$key}->{mask}; + $gateway = $networks{$key}->{gateway}; + last; + } + } + if (!$netmask) { die "Error: could not find a network in the networks table that $node $ip is part of.\n"; } + if (!$gateway) { die "Error: gateway not specified in the networks table for the network that $node $ip is part of.\n"; } + + verbose("IP info for $node: ip=$ip, netmask=$netmask, gateway=$gateway"); + return ($ip, $netmask, $gateway); +} + + +# Is the IP in the network/netmask combo +sub isIPinNet { + my ($ip, $net, $mask) = @_; + my $ipbin = convert2bin($ip); + my $netbin = convert2bin($net); + my $maskbin = convert2bin($mask); + $ipbin &= $maskbin; + if ($ipbin && $netbin && ($ipbin == $netbin)) { return 1; } + else { return 0; } +} + + +# Convert dotted decimal format (1.2.3.4) to a binary number +sub convert2bin { + my @arr=split(/\./, shift); + my ($bin) = unpack('N', pack('C4',@arr ) ); + return $bin; +} + + # this is like multi-line sed replace function -# Args: filename, search-string, replace-string +# Args: filename, search-string, replace-string, options (mode=>{insertbefore,insertafter,replace}) sub sed { my ($file, $search, $replace, %options) = @_; #my $opts = 's'; diff --git a/xCAT-SoftLayer/postscripts/configbond b/xCAT-SoftLayer/postscripts/configbond new file mode 100755 index 000000000..537ed5df4 --- /dev/null +++ b/xCAT-SoftLayer/postscripts/configbond @@ -0,0 +1,248 @@ +#!/usr/bin/perl + +# xCAT postscript for configuring bonding of nics. +# Usage: configbond bond1 eth1 [eth3] +# +# Note: this postscript currently has some assumptions that are specific to the softlayer environment. +# We only use this to configure bond1, because bond0 gets configured by the node provisioning process. +# (altho this script would work for bond0) + +use strict; +# Check number of args + +my $nargs = $#ARGV + 1; +if (scalar(@ARGV) < 2 || scalar(@ARGV) > 3) { + system("logger -t xcat -p local4.err 'Usage: configbond []'"); + exit 1; +} + +my $bond = shift(@ARGV); +my $nic = $ARGV[0]; +my @devs; +push(@devs,@ARGV); +my $nicips = $ENV{NICIPS}; +my $nicnetworks = $ENV{NICNETWORKS}; +my $net_cnt = $ENV{NETWORKS_LINES}; + +#todo: change this script so they dont need to specify nicnetworks +if (!$nicips || !$nicnetworks) { system("logger -t xcat -p local4.err 'configbond: must specify attributes nicips and nicnetworks in the xcat db for this node.'"); exit 1; } + +#todo: these are specific to softlayer. They should be another attribute or argument +my $bondingopts = 'mode=4 miimon=100 downdelay=0 updelay=0 lacp_rate=fast xmit_hash_policy=1'; + +my $netmask =''; +my $ipaddr = ''; +my $nic_num = ''; +my $subnet = ''; +my $nic_net = ''; +my $net_name = ''; +my @nic_nets = (); # array of networks for this nic +my @nic_ips =(); # array of ipaddresses for this nic +my @networks = (); # array of all networks from networks table. + # { network_name, subnet, netmask } + +system("logger -t xcat -p local4.err 'configbond: Master: $bond'"); +system("logger -t xcat -p local4.err 'configbond: Slaves: @devs'"); +#system("logger -t xcat -p local4.err 'configbond: NIC: $nic'"); +system("logger -t xcat -p local4.err 'configbond: NICNETWORKS: $nicnetworks'"); +system("logger -t xcat -p local4.err 'configbond: NICIPS: $nicips'"); + +# Update modprobe +my $file = "/etc/modprobe.d/$bond.conf"; +if (!open(FILE, ">$file")) { system("logger -t xcat -p local4.err 'configbond: cannot open $file.'"); exit 1; } + +print FILE "alias $bond bonding\n"; +# the bonding options are put in the ifcfg file instead +#print FILE "options $bond mode=balance-rr miimon=100\n"; +close FILE; + +# create array of network info. Needed in case where there are +# more than one ip address per nic and shouldn't be many networks. +my $net_info; +my $cnt = 1; + +while ( $cnt <= $net_cnt ) { + $net_info = $ENV{"NETWORKS_LINE$cnt"}; + $net_info =~ /^netname=([^\|]*)\|\|/; + $net_name = $1; + $net_info =~ /net=([^\|]*)\|\|/; + $subnet = $1; + $net_info =~ /mask=([^\|]*)\|\|/; + $netmask = $1; + push @{ $networks[$cnt-1] }, ($net_name, $subnet, $netmask); + $cnt +=1; +} + +# get network or networks for this nic from NICNETWORKS: +# eth0:1_0_0_0-255_255_0_0|network2,eth1:1_1_0_0 +# create array of networks for this nic +foreach my $nic_networks (split(/,/,$nicnetworks)) { + my @net = (); + if ( $nic_networks =~ /!/ ) { + @net = split(/!/,$nic_networks); + } else { + @net = split(/:/,$nic_networks); + } + if ($net[0] eq $nic) { + @nic_nets = split(/\|/,$net[1]); + last; + } +} + +# get all nic ipaddress from $nicips: i.e. eth0:1.0.0.1|2.0.0.1,eth1:1.1.1.1 +# Then get all ips for this specific nic, i.e. eth0. +foreach my $ips (split(/,/,$nicips)) { + my @ip = (); + if ( $ips =~ /!/ ) { + @ip = split(/!/,$ips); + } else { + @ip = split(/:/,$ips); + } + if ($ip[0] eq $nic ) { + @nic_ips = split(/\|/,$ip[1]); + } +} + + +my $i; +for ($i=0; $i < (scalar @nic_ips) ; $i++ ) { + + # Time to create the interfaces. + # loop through the nic networks, find the matching networks to get the + # subnet and netmask and then create the appropriate ifcfg file for linux + my $specific_nic = $nic; + if ($i > 0) { + $specific_nic = $nic . ":" . ($i); + } + + #todo: support case in which nicnetworks is not specified, find the correct network by calculation + $cnt = 0; + $subnet = ""; + $netmask = ""; + $net_name = ""; + while ( $cnt < $net_cnt ) { + if ( $networks[$cnt][0] eq $nic_nets[$i] ) { + + $subnet = $networks[$cnt][1]; + $netmask = $networks[$cnt][2]; + $cnt = $net_cnt; # found match - get out. + } + else { + $cnt++; + } + } + + # check that there is a subnet and netmask set + if ( !(length($subnet) > 0) || !(length($netmask) > 0) ) { + system("logger -t xcat -p local4.err 'configbond: network subnet or netmask not set.'"); + exit 1; + } + system("logger -t xcat -p local4.err 'configbond: network subnet and netmask: $subnet, $netmask'"); + system("logger -t xcat -p local4.err 'configbond: $specific_nic, $nic_ips[$i]'"); + + # Write the master info to the ifcfg file + if (-d "/etc/sysconfig/network-scripts") { + # rhel/centos/fedora + my $dir = "/etc/sysconfig/network-scripts"; + if (!open(FILE, ">$dir/ifcfg-$bond")) { system("logger -t xcat -p local4.err 'configbond: cannot open $dir/ifcfg-$bond.'"); exit 1; } + + print FILE "DEVICE=$bond\n"; + print FILE "BOOTPROTO=none\n"; + print FILE "IPADDR=$nic_ips[$i]\n"; + print FILE "NETMASK=$netmask\n"; + print FILE "ONBOOT=yes\n"; + print FILE "USERCTL=no\n"; + print FILE qq(BONDING_OPTS="$bondingopts"\n); + close FILE; + + # Configure slaves + my @output = `ip addr show 2>&1`; # to check for existance of the device later + foreach my $dev (@devs) { + # as a convenience, make sure the device exists before adding it to the bond + if (!grep(m/^\d+:\s+$dev:/, @output)) { + system("logger -t xcat -p local4.err 'configbond: not configuring $dev because it does not exist.'"); + unlink("$dir/ifcfg-$dev"); # in case it was left over in the image we are cloning + next; + } + + system("logger -t xcat -p local4.err 'configbond: slave dev: $dev'"); + if (!open(FILE, ">$dir/ifcfg-$dev")) { system("logger -t xcat -p local4.err 'configbond: cannot open $dir/ifcfg-$dev'"); exit 1; } + print FILE "DEVICE=$dev\n"; + print FILE "BOOTPROTO=none\n"; + print FILE "MASTER=$bond\n"; + print FILE "ONBOOT=yes\n"; + print FILE "SLAVE=yes\n"; + print FILE "USERCTL=no\n"; + close FILE; + } + } + elsif (-d "/etc/sysconfig/network") { + # sles + my $dir = "/etc/sysconfig/network"; + if (!open(FILE, ">$dir/ifcfg-$bond")) { system("logger -t xcat -p local4.err 'configbond: cannot open $dir/ifcfg-$bond.'"); exit 1; } + + print FILE "BOOTPROTO=static\n"; + print FILE "BONDING_MASTER=yes\n"; + print FILE "BONDING_MODULE_OPTS='$bondingopts'\n"; + print FILE "NAME='Bonded Interface'\n"; + print FILE "IPADDR=$nic_ips[$i]\n"; + print FILE "NETMASK=$netmask\n"; + print FILE "STARTMODE=onboot\n"; + print FILE "USERCONTROL=no\n"; + my $devnum = 0; + my @output = `ip addr show 2>&1`; # to check for existance of the device later + foreach my $dev (@devs) { + if (!grep(m/^\d+:\s+$dev:/, @output)) { next; } + print FILE "BONDING_SLAVE_$devnum=$dev\n"; + $devnum++; + } + close FILE; + + # Configure slaves + foreach my $dev (@devs) { + # as a convenience, make sure the device exists before adding it to the bond + if (!grep(m/^\d+:\s+$dev:/, @output)) { + system("logger -t xcat -p local4.err 'configbond: not configuring $dev because it does not exist.'"); + unlink("$dir/ifcfg-$dev"); # in case it was left over in the image we are cloning + next; + } + + system("logger -t xcat -p local4.err 'configbond: slave dev: $dev'"); + if (!open(FILE, ">$dir/ifcfg-$dev")) { system("logger -t xcat -p local4.err 'configbond: cannot open $dir/ifcfg-$dev'"); exit 1; } + print FILE "BOOTPROTO=none\n"; + print FILE "STARTMODE=hotplug\n"; + close FILE; + } + } + else { + # do not recognize this distro + system("logger -t xcat -p local4.err 'configbond: network directory is not either the Red Hat or SuSE format.'"); + exit 1; + } + + # Apply the changes. Since we are only doing bond1 right now, lets not restart the whole network + # so we dont disrupt the installnic connection. Instead we just need to bring down the slave nics, + # and then bring up the bond nic. + #runcmd("service network restart"); + foreach my $dev (@devs) { + runcmd("ifdown $dev"); + } + runcmd("ifdown $bond"); # in case it was already up + runcmd("ifup $bond"); # note: this wont reload the bonding kernel module, so we are depending on the provisioning process to already have set the correct bonding options + system("logger -t xcat -p local4.info 'configbond: successfully configured $specific_nic.'"); + +} +exit 0; + +sub runcmd { + my $cmd = shift @_; + $cmd .= ' 2>&1'; + my @output = `$cmd`; + my $rc = $? >> 8; + if ($rc) { + system("logger -t xcat -p local4.err 'configeth: command $cmd failed with rc $rc: " . join('',@output) . "'"); + my $errout= "configeth: command $cmd failed with rc $rc."; + `echo $errout`; + exit $rc; + } +} diff --git a/xCAT-SoftLayer/postscripts/setdefaultroute b/xCAT-SoftLayer/postscripts/setdefaultroute index 6932b0d79..7e574ca4c 100755 --- a/xCAT-SoftLayer/postscripts/setdefaultroute +++ b/xCAT-SoftLayer/postscripts/setdefaultroute @@ -1,6 +1,28 @@ #!/bin/bash # set the default route of the node to the ip address and nic passed in +# this should be added to the postbootscripts, NOT postscripts -set -x -ip route replace to default via $1 dev $2 +gateway="$1" +nic="$2" + +# set it temporarily +echo "ip route replace to default via $gateway dev $nic" +ip route replace to default via $gateway dev $nic + +# set it permanently +#todo: this is only for sles right now +file=/etc/sysconfig/network/routes +if grep -q -E '^default ' $file; then + # replace the default route that is already in there + sed -i 's/^default .*$/default '$gateway' - -/' $file +else + # no default route yet, append to file + echo "default $gateway - -" >>$file +fi + +# While we are here, clean up the network wait hack, if it is still there. +# (It was added during scripted install, because autoyast will not use the bond +# configuration for 1 part of the process.) Do not know a better place to clean +# this up. +sed -i '/Waiting to reach xCAT mgmt node/d' /etc/init.d/network \ No newline at end of file diff --git a/xCAT-SoftLayer/share/xcat/install/sles/compute.sles11.softlayer.tmpl b/xCAT-SoftLayer/share/xcat/install/sles/compute.sles11.softlayer.tmpl index 96bf8ed28..c95392007 100644 --- a/xCAT-SoftLayer/share/xcat/install/sles/compute.sles11.softlayer.tmpl +++ b/xCAT-SoftLayer/share/xcat/install/sles/compute.sles11.softlayer.tmpl @@ -67,7 +67,6 @@ - true #TABLE:site:key=domain:value# #TABLE:nodelist:$NODE:node# @@ -78,10 +77,53 @@ #TABLE:site:key=domain:value# + + + yes + mode=4 miimon=100 downdelay=0 updelay=0 lacp_rate=fast xmit_hash_policy=1 + eth0 + eth2 + bond0 + static + auto + #NODEIPADDR# + #NODENETMASK# + no + + + none + eth0 + Ethernet Card 0 + off + + + none + eth2 + Ethernet Card 2 + off + + false + + + default + - + #NODEGATEWAY# + - + + + + + + root + /etc/modprobe.d/bond0.conf + 644 + + #INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/pre.sles# #INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/chroot.sles# diff --git a/xCAT-SoftLayer/si-post-install/15all.configefi b/xCAT-SoftLayer/si-post-install/15all.configefi new file mode 100755 index 000000000..34b112f0c --- /dev/null +++ b/xCAT-SoftLayer/si-post-install/15all.configefi @@ -0,0 +1,82 @@ +#!/bin/bash + +# SI post-install script to configure the efi boot mgr or grub after SI has installed the OS +# SI post-install scripts run in a chroot environment of the final OS image + +if [ -d /sys/firmware/efi ]; then + echo "Setting Boot Manager for the next boot." + echo "delete all sysclone boot list" + str_bootnums=`efibootmgr | grep 'syscloneLinux' | awk '{print $1}' | sed 's/boot//i' | sed 's/*//'` + for str_num in $str_bootnums + do + efibootmgr -b $str_num -B -q + done + + if [ -f "/boot/efi/EFI/redhat/grub.efi" ];then + efibootmgr -c -l \\EFI\\redhat\\grub.efi -L syscloneLinux + elif [ -f "/boot/efi/efi/SuSE/elilo.efi" ];then + efibootmgr -c -l \\efi\\SuSE\\elilo.efi -L syscloneLinux + else + echo "Can not find the boot loader." + exit 1 + fi +else + echo "run grub-install to configure the MBR." + if [ -e /etc/mtab ];then + mv /etc/mtab /etc/mtab.bak + fi + grep -v rootfs /proc/mounts > /etc/mtab + boot_device='' + if [ -f "/etc/systemconfig/systemconfig.conf" ];then + boot_device=`cat /etc/systemconfig/systemconfig.conf | grep BOOTDEV | awk '{print $3}'` + else + boot_root=`mount | grep -E ' on\s+/ type ' | awk '{print $1}'` + boot_device=`echo $boot_root | sed -e 's/[0-9]*$//'` + + #str_temp=`mount | awk '{print $1","$3}'` + #for line in $str_temp + #do + # mp=`echo $line | awk -F, '{print $2}'` + # if [ "$mp" = "/" ];then + # boot_device=`echo $line | awk -F, '{print $1}' | sed -e 's/[0-9]*$//'` + # break + # fi + #done + fi + + if [ -n "$boot_device" ];then + echo "The boot device is $boot_device" + echo "The boot root device is $boot_root" + else + echo "Can not find the boot device, return error" + exit 1 + fi + + # set grub to use this boot device + if grep -qe '^VERSION\s*=\s*11' /etc/SuSE-release; then + #sles11, run grub-install.unsupported directly + echo "grub-install.unsupported --no-floppy --recheck $boot_device" + grub-install.unsupported --no-floppy --recheck $boot_device + # note: the error about grub-set-default not existing is harmless, because we want the default to be 0 anyway + else + #for sles10, should run grub-install with parameters + echo "grub-install --no-floppy --recheck $boot_device" + grub-install --no-floppy --recheck $boot_device + fi + + # change the entries in the grub conf file to use the correct boot root device + # (not the one leftover from the golden image) + if [ -f "/boot/grub/grub.conf" ];then + conffile="/boot/grub/grub.conf" + else + conffile="/boot/grub/menu.lst" + fi + sed -i 's| root=\S*| root='$boot_root'|' $conffile + sed -i 's| resume=\S*| noresume|' $conffile + + if [ -e /etc/mtab.bak ];then + mv -f /etc/mtab.bak /etc/mtab + else + rm -f /etc/mtab + fi +fi diff --git a/xCAT-SoftLayer/si-post-install/16all.updatenetwork b/xCAT-SoftLayer/si-post-install/16all.updatenetwork new file mode 100755 index 000000000..a5b58d999 --- /dev/null +++ b/xCAT-SoftLayer/si-post-install/16all.updatenetwork @@ -0,0 +1,209 @@ +#!/bin/bash + +# SI post-install script to configure network settings after SI has installed the OS +# SI post-install scripts run in a chroot environment of the final OS image + +. /tmp/post-install/variables.txt + +bondingopts='mode=4 miimon=100 downdelay=0 updelay=0 lacp_rate=fast xmit_hash_policy=1' + +# determine if we should be using a static ip or dhcp +staticIP () { + # Eventually we should use the SI variable IP_ASSIGNMENT_METHOD below to determine this. + # But this requires a patch in both xcat/sysclone (to set si_getimage -ip-assignment method) + # and SI (to set IP_ASSIGNMENT_METHOD as a result of that). Until both of those patches + # are in the main releases, assume that if we have set the IPADDR kernel parm for the boot + # kernel to use static ip, that the final OS should use static ip too. + # Note: the IPADDR environment variable will be set by SI, even if it got it thru dhcp, so + # that is not a reliable way to decide. + str=`cat /proc/cmdline` + #str='netmask=255.255.255.192 IPADDR=10.54.51.11 GATEWAY=10.54.51.1 dns=10.54.51.2 hostname=sap64-4 DEVICE=eth0' + for parm in $str; do + key=`echo $parm|awk -F= '{print $1}'` + value=`echo $parm|awk -F= '{print $2}'` + if [[ $key == "IPADDR" || $key == "ipaddr" ]]; then + return 0 # yes, we should use static ip + fi + done + if [[ -n $IP_ASSIGNMENT_METHOD && ${IP_ASSIGNMENT_METHOD,,} == "static" ]]; then + return 0 # this means yes/true + fi + return 1 +} + +#delete the udev rule in the image +rule_file=`ls /etc/udev/rules.d/*net_persistent_names.rules 2>/dev/null` +if [ -n "$rule_file" ];then + rm -f $rule_file +fi + +hostname $HOSTNAME +bond=bond0 +# this is a softlayer assumption that the two devices on the private net will be eth0 and eth2 +if [[ $DEVICE == "eth0" ]]; then + DEVICE2=eth2 +elif [[ $DEVICE == "eth2" ]]; then + DEVICE2=eth0 +fi +ip addr show|grep -q -E "^[0-9]+:\s+$DEVICE2:" # make sure it exists on the system +if [[ $? == 0 ]]; then + DEVICE2EXISTS="yes" +fi + +device_names=`ifconfig -a | grep -i hwaddr | grep -i 'Ethernet' | grep -v usb| awk '{print $1}'` +str_cfg_file='' +if [ -d "/etc/sysconfig/network-scripts/" ];then + #redhat + dir="/etc/sysconfig/network-scripts" + grep -i HOSTNAME /etc/sysconfig/network + if [ $? -eq 0 ];then + sed -i "s/HOSTNAME=.*/HOSTNAME=$HOSTNAME/g" /etc/sysconfig/network + else + echo "HOSTNAME=$HOSTNAME" >> /etc/sysconfig/network + fi + if staticIP; then + # delete all nic cfg files left over from the golden node + for i in $device_names;do + rm -f "$dir/ifcfg-$i" + done + + # set static ip from variables in variables.txt + # write ifcfg-bond0. For now we assume the installnic should be part of bond0, + # because in SL i think that is always the case. + i="$bond" + str_cfg_file="$dir/ifcfg-$i" + echo "DEVICE=$i" > $str_cfg_file + echo "BOOTPROTO=none" >> $str_cfg_file + echo "ONBOOT=yes" >> $str_cfg_file + echo "USERCTL=no" >> $str_cfg_file + echo 'BONDING_OPTS="'$bondingopts'"' >> $str_cfg_file + echo "IPADDR=$IPADDR" >> $str_cfg_file + echo "NETMASK=$NETMASK" >> $str_cfg_file + echo "NETWORK=$NETWORK" >> $str_cfg_file + echo "BROADCAST=$BROADCAST" >> $str_cfg_file + #todo: add gateway config? Not sure, because the boot kernels gateway might not be the final OS gateway + + # write ifcfg-eth0 + i="$DEVICE" + str_cfg_file="$dir/ifcfg-$i" + echo "DEVICE=$i" > $str_cfg_file + echo "BOOTPROTO=none" >> $str_cfg_file + echo "MASTER=$bond" >> $str_cfg_file + echo "ONBOOT=yes" >> $str_cfg_file + echo "SLAVE=yes" >> $str_cfg_file + echo "USERCTL=no" >> $str_cfg_file + + i="$DEVICE2" + str_cfg_file="$dir/ifcfg-$i" + if [[ $DEVICE2EXISTS == "yes" ]]; then + # write ifcfg-eth2 + echo "DEVICE=$i" > $str_cfg_file + echo "BOOTPROTO=none" >> $str_cfg_file + echo "MASTER=$bond" >> $str_cfg_file + echo "ONBOOT=yes" >> $str_cfg_file + echo "SLAVE=yes" >> $str_cfg_file + echo "USERCTL=no" >> $str_cfg_file + else + rm -f $str_cfg_file # in case it was left over in the image that was captured + fi + + # write modprobe alias config + str_cfg_file="/etc/modprobe.d/$bond.conf" + echo "alias $bond bonding" > $str_cfg_file + + #todo: figure out how to set the default gateway in rhel + else + # use dhcp for all nics + for i in $device_names;do + str_cfg_file="$dir/ifcfg-$i" + echo "DEVICE=$i" > $str_cfg_file + echo "BOOTPROTO=dhcp" >> $str_cfg_file + echo "NM_CONTROLLED=yes" >> $str_cfg_file + echo "ONBOOT=yes" >> $str_cfg_file + done + fi +elif [ -d "/etc/sysconfig/network/" ];then + #suse + dir="/etc/sysconfig/network" + echo "$HOSTNAME" > /etc/HOSTNAME + if staticIP; then + # delete all nic cfg files left over from the golden node + for i in $device_names;do + rm -f "$dir/ifcfg-$i" + done + + # set static ip from variables in variables.txt + # write ifcfg-bond0. For now we assume the installnic should be part of bond0, + # because in SL i think that is always the case. + i="$bond" + str_cfg_file="$dir/ifcfg-$i" + echo "BOOTPROTO=static" > $str_cfg_file + echo "STARTMODE=onboot" >> $str_cfg_file + echo "BONDING_MASTER=yes" >> $str_cfg_file + echo "BONDING_MODULE_OPTS='$bondingopts'" >> $str_cfg_file + echo "NAME='Bonded Interface'" >> $str_cfg_file + echo "IPADDR=$IPADDR" >> $str_cfg_file + echo "NETMASK=$NETMASK" >> $str_cfg_file + echo "NETWORK=$NETWORK" >> $str_cfg_file + echo "BROADCAST=$BROADCAST" >> $str_cfg_file + echo "USERCONTROL=no" >> $str_cfg_file + echo "BONDING_SLAVE_0=$DEVICE" >> $str_cfg_file + if [[ $DEVICE2EXISTS == "yes" ]]; then + echo "BONDING_SLAVE_1=$DEVICE2" >> $str_cfg_file + fi + + # write ifcfg-eth0 + i="$DEVICE" + str_cfg_file="$dir/ifcfg-$i" + echo "BOOTPROTO=none" > $str_cfg_file + echo "STARTMODE=hotplug" >> $str_cfg_file + + i="$DEVICE2" + str_cfg_file="$dir/ifcfg-$i" + if [[ $DEVICE2EXISTS == "yes" ]]; then + # write ifcfg-eth2 + echo "BOOTPROTO=none" > $str_cfg_file + echo "STARTMODE=hotplug" >> $str_cfg_file + else + rm -f $str_cfg_file # in case it was left over in the image that was captured + fi + + # write modprobe alias config + str_cfg_file="/etc/modprobe.d/$bond.conf" + echo "alias $bond bonding" > $str_cfg_file + + # set the default gateway (at this point this is the private nic gateway, to handle provision across vlans) + file=/etc/sysconfig/network/routes + if grep -q -E '^default ' $file; then + # replace the default route that is already in there + sed -i 's/^default .*$/default '$GATEWAY' - -/' $file + else + # no default route yet, append to file + echo "default $GATEWAY - -" >>$file + fi + + # this was the original config of the eth0 nic (without bonding) + #echo "DEVICE=$i" > $str_cfg_file + #echo "BOOTPROTO=static" >> $str_cfg_file + #echo "STARTMODE=onboot" >> $str_cfg_file + #echo "IPADDR=$IPADDR" >> $str_cfg_file + #echo "NETMASK=$NETMASK" >> $str_cfg_file + #echo "NETWORK=$NETWORK" >> $str_cfg_file + #echo "BROADCAST=$BROADCAST" >> $str_cfg_file + #todo: add gateway config? Not sure, because the boot kernels gateway might not be the final OS gateway + else + # use dhcp for all nics + for i in $device_names;do + str_cfg_file="$dir/ifcfg-$i" + echo "DEVICE=$i" > $str_cfg_file + echo "BOOTPROTO=dhcp" >> $str_cfg_file + echo "STARTMODE=onboot" >> $str_cfg_file + echo "DHCLIENT_PRIMARY_DEVICE=yes" >> $str_cfg_file + done + fi +else + #ubuntu + echo "Does not support ubuntu." + exit 1 +fi + diff --git a/xCAT-SoftLayer/si-post-install/20all.makeinitrd b/xCAT-SoftLayer/si-post-install/20all.makeinitrd new file mode 100755 index 000000000..761890045 --- /dev/null +++ b/xCAT-SoftLayer/si-post-install/20all.makeinitrd @@ -0,0 +1,18 @@ +#!/bin/bash + +# This SI post-install script is needed because the initrd that autoyast/kickstart/ubuntu builds when installing +# sles/rh/ubuntu on the golden node may not have the drivers when that initrd runs on the node that is +# being deployed with this image (specifically, drivers to be able to mount the disk). +# So rebuild the initrd on the to-node after putting the image on the disk, but before rebooting. + +#todo: Make this script work on red hat by checking for dracut and using that if it exists. +# And do whatever is necessary on ubuntu. + +if [[ -f /sbin/dracut ]]; then + #todo: implement rh case using dracut + echo "Note: not regenerating the initrd, because dracut is not supported by this node yet." +else + # suse/sles + echo "Running mkinitrd to regenerate the initrd with the drivers needed by this node:" + mkinitrd +fi diff --git a/xCAT-SoftLayer/si-post-install/99all.killsyslog b/xCAT-SoftLayer/si-post-install/99all.killsyslog new file mode 100755 index 000000000..348910189 --- /dev/null +++ b/xCAT-SoftLayer/si-post-install/99all.killsyslog @@ -0,0 +1,25 @@ +#!/bin/bash + +# SI post-install script, run after SI has installed the OS, to kill processes SI does not kill +# (so /a can be umounted cleanly) +# SI post-install scripts run in a chroot environment of the final OS image + +if [ -f "/etc/SuSE-release" ];then + str_out=`ps -ef | grep -v grep | grep syslog-ng` + if [ $? -eq 0 ];then + str_id=`echo $str_out | awk '{print $2}'` + kill -9 $str_id + fi +fi + +# SI starts klogd in the chroot, but does not kill it. Remove this line when SI fixes their bug. +killall klogd + +# flush all write buffers, just in case SI can not umount /a +echo "Syncing file systems" +sync + +#todo: remove +#echo "Processes still using /:" +#fuser -v / +#sleep 30 \ No newline at end of file diff --git a/xCAT-SoftLayer/xCAT-SoftLayer.spec b/xCAT-SoftLayer/xCAT-SoftLayer.spec index df514ddfb..7ee7e06d1 100644 --- a/xCAT-SoftLayer/xCAT-SoftLayer.spec +++ b/xCAT-SoftLayer/xCAT-SoftLayer.spec @@ -17,6 +17,11 @@ BuildArch: noarch Requires: xCAT-server #Requires: xCAT-server >= %{epoch}:%(cat Version|cut -d. -f 1,2) +# perl-ExtUtils-MakeMaker, perl-CPAN, perl-Test-Harness are only available in rhel. +# When this rpm supports being installed in sles, need to add these to xcat-dep. +# perl-SOAP-Lite is already in xcat-dep +Requires: perl-ExtUtils-MakeMaker perl-CPAN perl-Test-Harness perl-SOAP-Lite + Provides: xCAT-SoftLayer = %{epoch}:%{version} %description @@ -43,18 +48,22 @@ xCAT-SoftLayer provides Utilities to make xCAT work in a SoftLayer environment. rm -rf $RPM_BUILD_ROOT mkdir -p $RPM_BUILD_ROOT/%{prefix}/bin mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/xcat/install -mkdir -p $RPM_BUILD_ROOT/install/postscripts +mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/xcat/sysclone/postscripts mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/doc/packages/xCAT-SoftLayer mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/man/man1 mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/doc/man1 +mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/xcat/sysclone/post-install cp -p -R share/xcat/install/* $RPM_BUILD_ROOT/%{prefix}/share/xcat/install/ cp -d bin/* $RPM_BUILD_ROOT/%{prefix}/bin chmod 755 $RPM_BUILD_ROOT/%{prefix}/bin/* -cp -d postscripts/* $RPM_BUILD_ROOT/install/postscripts -chmod 755 $RPM_BUILD_ROOT/install/postscripts/* +cp -d postscripts/* $RPM_BUILD_ROOT/%{prefix}/share/xcat/sysclone/postscripts +chmod 755 $RPM_BUILD_ROOT/%{prefix}/share/xcat/sysclone/postscripts/* + +cp -d si-post-install/* $RPM_BUILD_ROOT/%{prefix}/share/xcat/sysclone/post-install +chmod 755 $RPM_BUILD_ROOT/%{prefix}/share/xcat/sysclone/post-install/* cp LICENSE.html $RPM_BUILD_ROOT/%{prefix}/share/doc/packages/xCAT-SoftLayer chmod 644 $RPM_BUILD_ROOT/%{prefix}/share/doc/packages/xCAT-SoftLayer/* @@ -71,4 +80,8 @@ rm -rf $RPM_BUILD_ROOT %defattr(-,root,root) #%doc LICENSE.html %{prefix} -/install/postscripts + +%post +# We are shipping the postscripts in a sysclone dir and then copying them to /install/postscripts here, +# because we want to allow base xcat to eventually ship them and not conflict on the file name/path +cp -f /%{prefix}/share/xcat/sysclone/postscripts/* /install/postscripts diff --git a/xCAT-genesis-scripts/bin/doxcat b/xCAT-genesis-scripts/bin/doxcat index 4a383982f..7e84e097c 100755 --- a/xCAT-genesis-scripts/bin/doxcat +++ b/xCAT-genesis-scripts/bin/doxcat @@ -4,11 +4,13 @@ # Bug reported by Jeff Lang . Thanks, Jeff! # -modprobe acpi_cpufreq +modprobe acpi_cpufreq 2>/dev/null # on some machines this fails modprobe cpufreq_ondemand -for gov in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; do - echo -n ondemand > $gov -done +if ls /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor &>/dev/null; then + for gov in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; do + echo -n ondemand > $gov + done +fi if [ ! -z "$BOOTIF" ]; then BOOTIF=`echo $BOOTIF|sed -e s/01-// -e s/-/:/g` echo -n "Waiting for device with address $BOOTIF to appear.." @@ -74,21 +76,89 @@ echo '};' >> /var/lib/lldpad/lldpad.conf done echo '};' >> /var/lib/lldpad/lldpad.conf lldpad -d -dhclient -cf /etc/dhclient.conf -pf /var/run/dhclient.$bootnic.pid $bootnic & -#we'll kick of IPv6 and IPv4 on all nics, but not wait for them to come up unless doing discovery, to reduce -#chances that we'll perform a partial discovery -#in other scenarios where downed non-bootnics cause issues, will rely on retries to fix things up -dhclient -6 -pf /var/run/dhclient6.$bootnic.pid $bootnic -lf /var/lib/dhclient/dhclient6.leases & -NICSTOBRINGUP=`ip link|grep mtu|grep -v LOOPBACK|grep -v $bootnic|grep -v usb|grep -v ,UP|awk -F: '{print $2}'` -export NICSTOBRINGUP -for nic in $NICSTOBRINGUP; do - (while ! ethtool $nic | grep Link\ detected|grep yes > /dev/null; do sleep 5; done; dhclient -cf /etc/dhclient.conf -pf /var/run/dhclient.$nic.pid $nic ) & - (while ! ethtool $nic | grep Link\ detected|grep yes > /dev/null; do sleep 5; done; dhclient -cf /etc/dhclient.conf -6 -pf /var/run/dhclient6.$nic.pid -lf /var/lib/dhclient/dhclient6.leases $nic ) & -done -openssl genrsa -out /etc/xcat/certkey.pem 4096 > /dev/null 2>&1 & - - +# Caclulate the broadcast address of a given IP address and mask. +bcastcalc(){ + read oct1 oct2 oct3 oct4 << HERE + $(echo "$1" | sed -e 's/\./ /g') +HERE + read msk1 msk2 msk3 msk4 << HERE + $(echo "$2" | sed -e 's/\./ /g') +HERE + ipa=$(($oct1+(255-($oct1 | $msk1)))) + ipb=$(($oct2+(255-($oct2 | $msk2)))) + ipc=$(($oct3+(255-($oct3 | $msk3)))) + ipd=$(($oct4+(255-($oct4 | $msk4)))) + echo "$ipa.$ipb.$ipc.$ipd" +} + +# Calculates the number of bits in a netmask for converting something like 255.255.255.192 to 26 so +# you can use the notation 10.0.0.1/26 +mask2prefix() { + nbits=0 + old_ifs=$IFS + IFS=. + for dec in $1 ; do + case $dec in + 255) let nbits+=8;; + 254) let nbits+=7;; + 252) let nbits+=6;; + 248) let nbits+=5;; + 240) let nbits+=4;; + 224) let nbits+=3;; + 192) let nbits+=2;; + 128) let nbits+=1;; + 0);; + *) echo "Error: $dec is not recognised"; exit 1 + esac + done + IFS=$old_ifs + echo "$nbits" +} + +# see if they specified static ip info, otherwise use dhcp +for parm in `cat /proc/cmdline`; do + key=`echo $parm|awk -F= '{print $1}'` + value=`echo $parm|awk -F= '{print $2}'` + if [[ ${key,,} == "hostip" || ${key,,} == "ipaddr" ]]; then + hostip=$value + elif [[ ${key,,} == "netmask" ]]; then + netmask=$value + elif [[ ${key,,} == "gateway" ]]; then + gateway=$value + fi +done +if [[ -n $hostip && -n $netmask && -n $gateway && -n $bootnic ]]; then + # doing static ip + # the device was determined above from the bootif mac, and put in bootnic + numbits=$(mask2prefix $netmask) + broadcast=$(bcastcalc $hostip $netmask) + echo "Setting static IP=$hostip/$numbits broadcast=$broadcast gateway=$gateway device=$bootnic BOOTIF=$BOOTIF ..." + ip addr add $hostip/$numbits broadcast $broadcast dev $bootnic scope global label $bootnic + ip link set $bootnic up + ip route replace to default via $gateway dev $bootnic + # in softlayer it takes up to 60 seconds for the nic to actually be able to communicate + echo -n Waiting to reach xCAT mgmt node $gateway. + xcatretries=60 + while [ $((xcati+=1)) -le $xcatretries ] && ! ping -c2 -w3 $gateway >/dev/null 2>&1; do echo -n .; done + if [ $xcati -le $xcatretries ]; then echo " success"; else echo " failed"; fi + sleep 3 +else + echo "Setting IP via DHCP..." + dhclient -cf /etc/dhclient.conf -pf /var/run/dhclient.$bootnic.pid $bootnic & + #we'll kick of IPv6 and IPv4 on all nics, but not wait for them to come up unless doing discovery, to reduce + #chances that we'll perform a partial discovery + #in other scenarios where downed non-bootnics cause issues, will rely on retries to fix things up + dhclient -6 -pf /var/run/dhclient6.$bootnic.pid $bootnic -lf /var/lib/dhclient/dhclient6.leases & + NICSTOBRINGUP=`ip link|grep mtu|grep -v LOOPBACK|grep -v $bootnic|grep -v usb|grep -v ,UP|awk -F: '{print $2}'` + export NICSTOBRINGUP + for nic in $NICSTOBRINGUP; do + (while ! ethtool $nic | grep Link\ detected|grep yes > /dev/null; do sleep 5; done; dhclient -cf /etc/dhclient.conf -pf /var/run/dhclient.$nic.pid $nic ) & + (while ! ethtool $nic | grep Link\ detected|grep yes > /dev/null; do sleep 5; done; dhclient -cf /etc/dhclient.conf -6 -pf /var/run/dhclient6.$nic.pid -lf /var/lib/dhclient/dhclient6.leases $nic ) & + done +fi + +openssl genrsa -out /etc/xcat/certkey.pem 4096 > /dev/null 2>&1 & gripeiter=101 echo -n "Acquiring network addresses.." From 8a2f7bc6174f44b3c27cbbd5b7c7c3b558641228 Mon Sep 17 00:00:00 2001 From: lissav Date: Mon, 2 Jun 2014 12:57:32 -0400 Subject: [PATCH 53/99] force a build --- perl-xCAT/xCAT/Utils.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/perl-xCAT/xCAT/Utils.pm b/perl-xCAT/xCAT/Utils.pm index e660b1da4..f9f454b10 100644 --- a/perl-xCAT/xCAT/Utils.pm +++ b/perl-xCAT/xCAT/Utils.pm @@ -16,6 +16,7 @@ if ($^O =~ /^aix/i) { use lib "$::XCATROOT/lib/perl"; # do not put a use or require for xCAT::Table here. Add to each new routine # needing it to avoid reprocessing of user tables ( ExtTab.pm) for each command call +# use POSIX qw(ceil); use File::Path; use Socket; From 1f377385a05bc05adaa2485b6c4ec8d061ec495e Mon Sep 17 00:00:00 2001 From: lissav Date: Mon, 2 Jun 2014 13:19:02 -0400 Subject: [PATCH 54/99] fix syntax errors --- perl-xCAT/xCAT/CFMUtils.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/perl-xCAT/xCAT/CFMUtils.pm b/perl-xCAT/xCAT/CFMUtils.pm index 314d3c4b9..2c66e0004 100644 --- a/perl-xCAT/xCAT/CFMUtils.pm +++ b/perl-xCAT/xCAT/CFMUtils.pm @@ -715,7 +715,7 @@ sub getPreBaseOSpkgsList { } } - @pre_selected = keys %pre_selected_hash; + my @pre_selected = keys %pre_selected_hash; return \@pre_selected; } From 2dc79ab3976ee25eca532279a6c72941d36850b5 Mon Sep 17 00:00:00 2001 From: lissav Date: Mon, 2 Jun 2014 13:19:55 -0400 Subject: [PATCH 55/99] force build --- Version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Version b/Version index 766d70806..2701a226a 100644 --- a/Version +++ b/Version @@ -1 +1 @@ -2.8.5 +2.8.4 From 742f8b611b20a1f208457cde25fd14569a5ea721 Mon Sep 17 00:00:00 2001 From: lissav Date: Mon, 2 Jun 2014 13:20:20 -0400 Subject: [PATCH 56/99] force build --- Version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Version b/Version index 2701a226a..766d70806 100644 --- a/Version +++ b/Version @@ -1 +1 @@ -2.8.4 +2.8.5 From e574664a508b0d6cc6a423830ecfc81015aed387 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Mon, 2 Jun 2014 13:33:57 -0400 Subject: [PATCH 57/99] Update auto-partitioning for RHEL7 In RHEL7, the preferred filesystem is now xfs and the efi partition type is unambiguously present. --- xCAT-server/share/xcat/install/scripts/pre.rh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/xCAT-server/share/xcat/install/scripts/pre.rh b/xCAT-server/share/xcat/install/scripts/pre.rh index 346b6de73..c5be7d407 100644 --- a/xCAT-server/share/xcat/install/scripts/pre.rh +++ b/xCAT-server/share/xcat/install/scripts/pre.rh @@ -225,19 +225,26 @@ elif grep ext4 /proc/filesystems > /dev/null; then else FSTYPE=ext3 fi +BOOTFSTYPE=ext3 +EFIFSTYPE=vfat +if uname -r|grep ^3.*el7 > /dev/null; then + FSTYPE=xfs + BOOTFSTYPE=xfs + EFIFSTYPE=efi +fi if [ `uname -m` = "ppc64" ]; then echo 'part None --fstype "PPC PReP Boot" --ondisk '$instdisk' --size 8' >> /tmp/partitioning fi if [ -d /sys/firmware/efi ]; then echo 'bootloader --driveorder='$instdisk >> /tmp/partitioning - echo 'part /boot/efi --size 50 --ondisk '$instdisk' --fstype vfat' >> /tmp/partitioning + echo 'part /boot/efi --size 50 --ondisk '$instdisk' --fstype $EFIFSTYPE' >> /tmp/partitioning else echo 'bootloader' >> /tmp/partitioning fi #TODO: ondisk detection, /dev/disk/by-id/edd-int13_dev80 for legacy maybe, and no idea about efi. at least maybe blacklist SAN if mptsas/mpt2sas/megaraid_sas seen... -echo "part /boot --size 256 --fstype ext3 --ondisk $instdisk" >> /tmp/partitioning +echo "part /boot --size 256 --fstype $BOOTFSTYPE --ondisk $instdisk" >> /tmp/partitioning echo "part swap --recommended --ondisk $instdisk" >> /tmp/partitioning echo "part / --size 1 --grow --ondisk $instdisk --fstype $FSTYPE" >> /tmp/partitioning From ab2f4e9dfd4d62349422250073dc45245ccd0818 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Mon, 2 Jun 2014 13:38:18 -0400 Subject: [PATCH 58/99] Apply previous changes to the pre for rhel7 specifically --- xCAT-server/share/xcat/install/scripts/pre.rh.rhel7 | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/xCAT-server/share/xcat/install/scripts/pre.rh.rhel7 b/xCAT-server/share/xcat/install/scripts/pre.rh.rhel7 index 09203dfc6..6d94227d3 100644 --- a/xCAT-server/share/xcat/install/scripts/pre.rh.rhel7 +++ b/xCAT-server/share/xcat/install/scripts/pre.rh.rhel7 @@ -178,8 +178,14 @@ if [ -z "$instdisk" ]; then instdisk=$firstdisk fi fi - +BOOTFSTYPE=ext3 +EFIFSTYPE=vfat +if uname -r|grep ^3.*el7 > /dev/null; then + BOOTFSTYPE=xfs + FSTYPE=xfs + EFIFSTYPE=efi +fi modprobe ext4 >& /dev/null modprobe ext4dev >& /dev/null if grep ext4dev /proc/filesystems > /dev/null; then @@ -194,11 +200,11 @@ if [ `uname -m` = "ppc64" ]; then echo 'part None --fstype "PPC PReP Boot" --ondisk '$instdisk' --size 8' >> /tmp/partitioning fi if [ -d /sys/firmware/efi ]; then - echo 'part /boot/efi --size 50 --ondisk '$instdisk' --fstype vfat' >> /tmp/partitioning + echo 'part /boot/efi --size 50 --ondisk '$instdisk' --fstype efi' >> /tmp/partitioning fi #TODO: ondisk detection, /dev/disk/by-id/edd-int13_dev80 for legacy maybe, and no idea about efi. at least maybe blacklist SAN if mptsas/mpt2sas/megaraid_sas seen... -echo "part /boot --size 256 --fstype ext3 --ondisk $instdisk" >> /tmp/partitioning +echo "part /boot --size 256 --fstype $BOOTFSTYPE --ondisk $instdisk" >> /tmp/partitioning echo "part swap --recommended --ondisk $instdisk" >> /tmp/partitioning echo "part / --size 1 --grow --ondisk $instdisk --fstype $FSTYPE" >> /tmp/partitioning From 437c8a4863e22c33f6c0ae8c1ac33dc6da55468d Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Mon, 2 Jun 2014 13:48:49 -0400 Subject: [PATCH 59/99] Fix mistakes in the adjustment to rhel7 default FS cohice --- .../share/xcat/install/scripts/pre.rh.rhel7 | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/xCAT-server/share/xcat/install/scripts/pre.rh.rhel7 b/xCAT-server/share/xcat/install/scripts/pre.rh.rhel7 index 6d94227d3..57023d6e9 100644 --- a/xCAT-server/share/xcat/install/scripts/pre.rh.rhel7 +++ b/xCAT-server/share/xcat/install/scripts/pre.rh.rhel7 @@ -178,14 +178,6 @@ if [ -z "$instdisk" ]; then instdisk=$firstdisk fi fi -BOOTFSTYPE=ext3 -EFIFSTYPE=vfat - -if uname -r|grep ^3.*el7 > /dev/null; then - BOOTFSTYPE=xfs - FSTYPE=xfs - EFIFSTYPE=efi -fi modprobe ext4 >& /dev/null modprobe ext4dev >& /dev/null if grep ext4dev /proc/filesystems > /dev/null; then @@ -195,12 +187,20 @@ elif grep ext4 /proc/filesystems > /dev/null; then else FSTYPE=ext3 fi +BOOTFSTYPE=ext3 +EFIFSTYPE=vfat + +if uname -r|grep '^3.*el7' > /dev/null; then + BOOTFSTYPE=xfs + FSTYPE=xfs + EFIFSTYPE=efi +fi if [ `uname -m` = "ppc64" ]; then echo 'part None --fstype "PPC PReP Boot" --ondisk '$instdisk' --size 8' >> /tmp/partitioning fi if [ -d /sys/firmware/efi ]; then - echo 'part /boot/efi --size 50 --ondisk '$instdisk' --fstype efi' >> /tmp/partitioning + echo 'part /boot/efi --size 50 --ondisk '$instdisk' --fstype '$EFIFSTYPE >> /tmp/partitioning fi #TODO: ondisk detection, /dev/disk/by-id/edd-int13_dev80 for legacy maybe, and no idea about efi. at least maybe blacklist SAN if mptsas/mpt2sas/megaraid_sas seen... From 2a44f59f15406ce5b7028b03f3cd43aa4633ae80 Mon Sep 17 00:00:00 2001 From: mellor Date: Mon, 2 Jun 2014 15:14:55 -0400 Subject: [PATCH 60/99] clarify osimage partitionfile description --- perl-xCAT/xCAT/Schema.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/perl-xCAT/xCAT/Schema.pm b/perl-xCAT/xCAT/Schema.pm index f4c6779a7..0c638b901 100755 --- a/perl-xCAT/xCAT/Schema.pm +++ b/perl-xCAT/xCAT/Schema.pm @@ -708,7 +708,7 @@ linuximage => { table_desc => 'Information about a Linux operating system image that can be used to deploy cluster nodes.', descriptions => { imagename => 'The name of this xCAT OS image definition.', - template => 'The fully qualified name of the template file that is used to create the kick start file for diskful installation.', + template => 'The fully qualified name of the template file that will be used to create the OS installer configuration file for stateful installations (e.g. kickstart for RedHat, autoyast for SLES).', boottarget => 'The name of the boottarget definition. When this attribute is set, xCAT will use the kernel, initrd and kernel params defined in the boottarget definition instead of the default.', addkcmdline=> 'User specified arguments to be passed to the kernel. The user arguments are appended to xCAT.s default kernel arguments. This attribute is ignored if linuximage.boottarget is set.', pkglist => 'The fully qualified name of the file that stores the distro packages list that will be included in the image. Make sure that if the pkgs in the pkglist have dependency pkgs, the dependency pkgs should be found in one of the pkgdir', @@ -727,7 +727,7 @@ linuximage => { permission => 'The mount permission of /.statelite directory is used, its default value is 755', dump => qq{The NFS directory to hold the Linux kernel dump file (vmcore) when the node with this image crashes, its format is "nfs:///". If you want to use the node's "xcatmaster" (its SN or MN), can be left blank. For example, "nfs:///" means the NFS directory to hold the kernel dump file is on the node's SN, or MN if there's no SN.}, crashkernelsize => 'the size that assigned to the kdump kernel. If the kernel size is not set, 256M will be the default value.', - partitionfile => 'The path of the configuration file which is used to part the disk for the node. For stateful: two types of value can be set for this attribute. One is "", the content of the partition file must use the corresponding format with the OS type. The other one is "s:", the content of the partition file should be a shell script which must write the partition definition into /tmp/partitionfile on the node. For statelite: the valid value is , refer to the statelite doc for the xCAT defined format of the configuration file.', + partitionfile => 'The path of the configuration file which will be used to partition the disk for the node. For stateful osimages,two types of files are supported: "" which contains a partitioning definition that will be inserted directly into the generated autoinst configuration file and must be formatted for the corresponding OS installer (e.g. kickstart for RedHat, autoyast for SLES). "s:" which specifies a shell script that will be run from the OS installer configuration file %pre section; the script must write the correct partitioning definition into the file /tmp/partitionfile on the node which will be included into the configuration file during the install process. For statelite osimages, partitionfile should specify ""; see the xCAT Statelite documentation for the xCAT defined format of this configuration file.', driverupdatesrc => 'The source of the drivers which need to be loaded during the boot. Two types of driver update source are supported: Driver update disk and Driver rpm package. The value for this attribute should be comma separated sources. Each source should be the format tab:full_path_of_srouce_file. The tab keyword can be: dud (for Driver update disk) and rpm (for driver rpm). If missing the tab, the rpm format is the default. e.g. dud:/install/dud/dd.img,rpm:/install/rpm/d.rpm', comments => 'Any user-written notes.', disable => "Set to 'yes' or '1' to comment out this row.", @@ -742,7 +742,7 @@ winimage => { imagename => 'The name of this xCAT OS image definition.', template => 'The fully qualified name of the template file that is used to create the windows unattend.xml file for diskful installation.', installto => 'The disk and partition that the Windows will be deployed to. The valid format is :. If not set, default value is 0:1 for bios boot mode(legacy) and 0:3 for uefi boot mode; If setting to 1, it means 1:1 for bios boot and 1:3 for uefi boot', - partitionfile => 'The path of partition configuration file. Since the partition configuration for bios boot mode and uefi boot mode are different, this configuration file should include two parts if customer wants to support both bios and uefi mode. If customer just wants to support one of the modes, specify one of them anyway. Example of partition configuration file: [BIOS]xxxxxxx[UEFI]yyyyyyy. To simplify the setting, you also can set installto in partitionfile with section likes [INSTALLTO]0:1', + partitionfile => 'The path of partition configuration file. Since the partition configuration for bios boot mode and uefi boot mode are different, this configuration file can include both configurations if you need to support both bios and uefi mode. Either way, you must specify the boot mode in the configuration. Example of partition configuration file: [BIOS]xxxxxxx[UEFI]yyyyyyy. To simplify the setting, you also can set installto in partitionfile with section like [INSTALLTO]0:1', winpepath => 'The path of winpe which will be used to boot this image. If the real path is /tftpboot/winboot/winpe1/, the value for winpepath should be set to winboot/winpe1', comments => 'Any user-written notes.', disable => "Set to 'yes' or '1' to comment out this row.", From bafbe2361a8dddd2c0b1d6d5769d87611e3759e5 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Mon, 2 Jun 2014 15:11:53 -0400 Subject: [PATCH 61/99] Change RHEL7 to use lvm for / by default --- xCAT-server/share/xcat/install/scripts/pre.rh.rhel7 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xCAT-server/share/xcat/install/scripts/pre.rh.rhel7 b/xCAT-server/share/xcat/install/scripts/pre.rh.rhel7 index 57023d6e9..765c03510 100644 --- a/xCAT-server/share/xcat/install/scripts/pre.rh.rhel7 +++ b/xCAT-server/share/xcat/install/scripts/pre.rh.rhel7 @@ -206,7 +206,9 @@ fi #TODO: ondisk detection, /dev/disk/by-id/edd-int13_dev80 for legacy maybe, and no idea about efi. at least maybe blacklist SAN if mptsas/mpt2sas/megaraid_sas seen... echo "part /boot --size 256 --fstype $BOOTFSTYPE --ondisk $instdisk" >> /tmp/partitioning echo "part swap --recommended --ondisk $instdisk" >> /tmp/partitioning -echo "part / --size 1 --grow --ondisk $instdisk --fstype $FSTYPE" >> /tmp/partitioning +echo "part pv.01 --size 1 --grow --ondisk $instdisk" >> /tmp/partitioning +echo "volgroup system pv.01" >> /tmp/partitioning +echo "logvol / --vgname=system --name=root --size 1 --grow --fstype $FSTYPE" >> /tmp/partitioning #XCA_PARTITION_SCRIPT# From 9f39989eb4ec76e77fe93447cd8e1a1d296d96b1 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Mon, 2 Jun 2014 16:27:20 -0400 Subject: [PATCH 62/99] Support shortname directive for templates that may require it --- xCAT-server/lib/perl/xCAT/Template.pm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/xCAT-server/lib/perl/xCAT/Template.pm b/xCAT-server/lib/perl/xCAT/Template.pm index 3ba3117c4..a99a2e9f8 100644 --- a/xCAT-server/lib/perl/xCAT/Template.pm +++ b/xCAT-server/lib/perl/xCAT/Template.pm @@ -219,6 +219,8 @@ sub subvars { } #ok, now do everything else.. + my $shortname = $node; + $shortname =~ s/\..*//; $inc =~ s/#TABLE:([^:]+):([^:]+):([^#]+)#/tabdb($1,$2,$3)/eg; $inc =~ s/#TABLEBLANKOKAY:([^:]+):([^:]+):([^#]+)#/tabdb($1,$2,$3,'1')/eg; $inc =~ s/#INCLUDE_NOP:([^#^\n]+)#/includefile($1,1,0)/eg; @@ -243,6 +245,7 @@ sub subvars { $inc =~ s/#WINDISABLENULLADMIN#/windows_disable_null_admin()/eg; $inc =~ s/#MANAGEDADDRESSMODE#/managed_address_mode()/eg; $inc =~ s/#HOSTNAME#/$node/g; + $inc =~ s/#SHORTNAME#/$shortname/g; $inc =~ s/#GETNODEDOMAIN:([^#]+)#/get_node_domain($1)/eg; my $nrtab = xCAT::Table->new("noderes"); From d3a9856f9dd71101f8f1ef52ec4d2ef471718014 Mon Sep 17 00:00:00 2001 From: daniceexi Date: Tue, 3 Jun 2014 05:03:04 -0400 Subject: [PATCH 63/99] REST API: support keyword ALLRESOURCES for GET nodes,networks,osimage,policy --- xCAT-server/xCAT-wsapi/xcatws.cgi | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/xCAT-server/xCAT-wsapi/xcatws.cgi b/xCAT-server/xCAT-wsapi/xcatws.cgi index 72c8e6a89..b088bee6c 100755 --- a/xCAT-server/xCAT-wsapi/xcatws.cgi +++ b/xCAT-server/xCAT-wsapi/xcatws.cgi @@ -1414,7 +1414,7 @@ sub defout { } else { # just an attribute of the current node if (! $nodename) { error('improperly formatted lsdef output from xcatd', $STATUS_TEAPOT); } - my ($attr, $val) = $l =~ /^\s*(\S+?)=(.*)$/; + my ($attr, $val) = $l =~ /^\s*(\S+.*?)=(.*)$/; if (!defined($attr)) { error('improperly formatted lsdef output from xcatd', $STATUS_TEAPOT); } $json->{$nodename}->{$attr} = $val; } @@ -1645,7 +1645,14 @@ sub defhdl { # push the object name - node/noderange if (defined ($urilayers[1])) { - push @args, ('-o', $urilayers[1]); + if ($urilayers[1] eq "ALLRESOURCES") { + unless (isGET()) { + error("Keyword ALLRESOURCES is only supported for GET Action.",$STATUS_NOT_FOUND); + } + push @args, '-l'; + } else { + push @args, ('-o', $urilayers[1]); + } } # For the put/post which specifies attributes like mgt=ipmi groups=all From 44452f4cd8f69406fed0d97f4cbfa4dfd8ac1d65 Mon Sep 17 00:00:00 2001 From: daniceexi Date: Tue, 3 Jun 2014 07:29:47 -0400 Subject: [PATCH 64/99] defect 4151:restapi: add error message if using incorrect authorize keys/passwd --- xCAT-server/xCAT-wsapi/xcatws.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-server/xCAT-wsapi/xcatws.cgi b/xCAT-server/xCAT-wsapi/xcatws.cgi index b088bee6c..17cd8faa2 100755 --- a/xCAT-server/xCAT-wsapi/xcatws.cgi +++ b/xCAT-server/xCAT-wsapi/xcatws.cgi @@ -2339,7 +2339,7 @@ sub filterData { foreach my $msg (@{$_->{error}}) { if ($msg =~ /(Permission denied|Authentication failure)/) { # return 401 Unauthorized - sendResponseMsg($STATUS_UNAUTH); + error("Authentication failure", $STATUS_UNAUTH); } else { push @{$outputerror->{error}}, $msg; } From 5a52fb253d617cac79a2bf00c5e0d30631c08ad1 Mon Sep 17 00:00:00 2001 From: mellor Date: Tue, 3 Jun 2014 11:27:09 -0400 Subject: [PATCH 65/99] defect 4147 - fix prescripts preprocess_request to only process nodes that have prescripts defined --- xCAT-server/lib/xcat/plugins/prescripts.pm | 35 ++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/prescripts.pm b/xCAT-server/lib/xcat/plugins/prescripts.pm index 27bbf6931..ca9988ac3 100644 --- a/xCAT-server/lib/xcat/plugins/prescripts.pm +++ b/xCAT-server/lib/xcat/plugins/prescripts.pm @@ -46,8 +46,39 @@ sub preprocess_request #if already preprocessed, go straight to request if ($req->{_xcatpreprocessed}->[0] == 1) { return [$req]; } - my $nodes = $req->{node}; - if (!$nodes) { return;} + my $req_nodes = $req->{node}; + if (!$req_nodes) { return;} + + my @nodes; + my $command = $req->{command}->[0]; + my $column; + if ($command eq 'runbeginpre') { $column = 'begin'; } + elsif ($command eq 'runendpre') { $column = 'end'; } + else { $column = ''; } + + # See if anything in the prescripts table for the nodes. If not, skip. + # Nothing to do. + my $tab = xCAT::Table->new('prescripts'); + #first check if xcatdefaults entry + if ( $tab->getAttribs({node=>"xcatdefaults"},$column) ) { + # yes - process all nodes + @nodes = @$req_nodes; + } else { + # no xcatdefaults, check for node entries + my $tabdata=$tab->getNodesAttribs($req_nodes,['node', $column]); + if ($tabdata) { + foreach my $node (@$req_nodes) { + if (($tabdata->{$node}) && + ($tabdata->{$node}->[0]) && + ($tabdata->{$node}->[0]->{$column}) ) { + push (@nodes,$node); + } + } + } + } + + # if no nodes left to process, we are done + if (! @nodes) { return; } my $service = "xcat"; my @args=(); From 7a5fa1df0e7ff86df038a5dc81825a7c4b5b1cc2 Mon Sep 17 00:00:00 2001 From: mellor Date: Tue, 3 Jun 2014 11:32:07 -0400 Subject: [PATCH 66/99] defect 4147 again - fix prescripts preprocess_request to only process nodes that have prescripts defined --- xCAT-server/lib/xcat/plugins/prescripts.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-server/lib/xcat/plugins/prescripts.pm b/xCAT-server/lib/xcat/plugins/prescripts.pm index ca9988ac3..505e2659f 100644 --- a/xCAT-server/lib/xcat/plugins/prescripts.pm +++ b/xCAT-server/lib/xcat/plugins/prescripts.pm @@ -95,7 +95,7 @@ sub preprocess_request Getopt::Long::Configure("bundling"); Getopt::Long::Configure("pass_through"); GetOptions('l' => \$::LOCAL); - my $sn = xCAT::ServiceNodeUtils->getSNformattedhash($nodes, $service, "MN"); + my $sn = xCAT::ServiceNodeUtils->getSNformattedhash(\@nodes, $service, "MN"); my @requests; if ($::LOCAL) { #only handle the local nodes #print "process local nodes: @$nodes\n"; From 899cb5028ddfa672e9af9ba884316072ef529048 Mon Sep 17 00:00:00 2001 From: mellor Date: Tue, 3 Jun 2014 14:15:26 -0400 Subject: [PATCH 67/99] defect 4147 - allow nodeset to continue if prescript errors --- xCAT-server/lib/xcat/plugins/pxe.pm | 6 ++---- xCAT-server/lib/xcat/plugins/vsmppxe.pm | 6 ++---- xCAT-server/lib/xcat/plugins/xnba.pm | 6 ++---- xCAT-server/lib/xcat/plugins/yaboot.pm | 8 ++++++-- 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/pxe.pm b/xCAT-server/lib/xcat/plugins/pxe.pm index b9fbb2066..6a804d220 100644 --- a/xCAT-server/lib/xcat/plugins/pxe.pm +++ b/xCAT-server/lib/xcat/plugins/pxe.pm @@ -414,9 +414,8 @@ sub process_request { if ($errored) { my $rsp; $rsp->{errorcode}->[0]=1; - $rsp->{error}->[0]="Failed in running begin prescripts\n"; + $rsp->{error}->[0]="Failed in running begin prescripts. Processing will still continue.\n"; $::PXE_callback->($rsp); - return; } } @@ -577,9 +576,8 @@ sub process_request { if ($errored) { my $rsp; $rsp->{errorcode}->[0]=1; - $rsp->{error}->[0]="Failed in running end prescripts\n"; + $rsp->{error}->[0]="Failed in running end prescripts. Processing will still continue.\n"; $::PXE_callback->($rsp); - return; } } diff --git a/xCAT-server/lib/xcat/plugins/vsmppxe.pm b/xCAT-server/lib/xcat/plugins/vsmppxe.pm index 6e310fa7b..23457bd04 100644 --- a/xCAT-server/lib/xcat/plugins/vsmppxe.pm +++ b/xCAT-server/lib/xcat/plugins/vsmppxe.pm @@ -349,9 +349,8 @@ sub process_request { if ($errored) { my $rsp; $rsp->{errorcode}->[0]=1; - $rsp->{error}->[0]="Failed in running begin prescripts\n"; + $rsp->{error}->[0]="Failed in running begin prescripts. Processing will still continue.\n"; $::VSMPPXE_callback->($rsp); - return; } } @@ -466,9 +465,8 @@ sub process_request { if ($errored) { my $rsp; $rsp->{errorcode}->[0]=1; - $rsp->{error}->[0]="Failed in running end prescripts\n"; + $rsp->{error}->[0]="Failed in running end prescripts. Processing will still continue.\n"; $::VSMPPXE_callback->($rsp); - return; } } diff --git a/xCAT-server/lib/xcat/plugins/xnba.pm b/xCAT-server/lib/xcat/plugins/xnba.pm index 38e85fdbe..aee9ba9e1 100644 --- a/xCAT-server/lib/xcat/plugins/xnba.pm +++ b/xCAT-server/lib/xcat/plugins/xnba.pm @@ -435,9 +435,8 @@ sub process_request { if ($errored) { my $rsp; $rsp->{errorcode}->[0]=1; - $rsp->{error}->[0]="Failed in running begin prescripts.\n"; + $rsp->{error}->[0]="Failed in running begin prescripts. Processing will still continue.\n"; $::XNBA_callback->($rsp); - return; } } @@ -564,9 +563,8 @@ sub process_request { if ($errored) { my $rsp; $rsp->{errorcode}->[0]=1; - $rsp->{error}->[0]="Failed in running end prescripts.\n"; + $rsp->{error}->[0]="Failed in running end prescripts. Processing will still continue.\n"; $::XNBA_callback->($rsp); - return; } } diff --git a/xCAT-server/lib/xcat/plugins/yaboot.pm b/xCAT-server/lib/xcat/plugins/yaboot.pm index f76f29927..f77b86416 100644 --- a/xCAT-server/lib/xcat/plugins/yaboot.pm +++ b/xCAT-server/lib/xcat/plugins/yaboot.pm @@ -469,9 +469,8 @@ sub process_request { if ($errored) { my $rsp; $rsp->{errorcode}->[0]=1; - $rsp->{error}->[0]="Failed in running begin prescripts.\n"; + $rsp->{error}->[0]="Failed in running begin prescripts. Processing will still continue.\n"; $::YABOOT_callback->($rsp); - return; } } @@ -726,9 +725,14 @@ sub process_request { if ($errored) { my $rsp; $rsp->{errorcode}->[0]=1; +<<<<<<< HEAD $rsp->{error}->[0]="Failed in running end prescripts\n"; $::YABOOT_callback->($rsp); return; +======= + $rsp->{error}->[0]="Failed in running end prescripts. Processing will still continue.\n"; + $callback->($rsp); +>>>>>>> 78b8d21... defect 4147 - allow nodeset to continue if prescript errors } } } From f910d5bab8202453bb5f88f39886b519006e644b Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 3 Jun 2014 15:32:24 -0400 Subject: [PATCH 68/99] Avoid requesting IBM VPD data for FRU locator records that do not advertise such data. --- xCAT-server/lib/xcat/plugins/ipmi.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-server/lib/xcat/plugins/ipmi.pm b/xCAT-server/lib/xcat/plugins/ipmi.pm index c5eaa002b..9a392b5e8 100644 --- a/xCAT-server/lib/xcat/plugins/ipmi.pm +++ b/xCAT-server/lib/xcat/plugins/ipmi.pm @@ -2782,7 +2782,7 @@ sub readcurrfrudevice { shift @data; push @{$sessdata->{currfrudata}},@data; if ($sessdata->{currfrudone}) { - if ($sessdata->{isite}) { + if ($sessdata->{isite} and $sessdata->{currfrusdr} and ($sessdata->{currfrusdr}->fru_oem & 0x80)) { #IBM OEM command, d0,51,0 further qualifies the command name, we'll first take a stop at block 0, offset 2, one byte, to get VPD version number #command structured as: #d0,51,0 = command set identifier From b60378d8e427dd86a744d4fb1c8742a83249f667 Mon Sep 17 00:00:00 2001 From: daniceexi Date: Wed, 4 Jun 2014 06:18:07 -0400 Subject: [PATCH 69/99] update the doc part in xcatws.cgi for GET action against nodes/networks/osimages/policy to use keyword ALLRESOURCES --- xCAT-server/xCAT-wsapi/xcatws.cgi | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/xCAT-server/xCAT-wsapi/xcatws.cgi b/xCAT-server/xCAT-wsapi/xcatws.cgi index 17cd8faa2..1ef36af5d 100755 --- a/xCAT-server/xCAT-wsapi/xcatws.cgi +++ b/xCAT-server/xCAT-wsapi/xcatws.cgi @@ -67,6 +67,7 @@ my %URIdef = ( matcher => '^/nodes/[^/]*$', GET => { desc => "Get all the attibutes for the node {noderange}.", + desc1 => "The keyword ALLRESOURCES can be used as {noderange} which means to get node attributes for all the nodes.", usage => "||$usagemsg{objreturn}|", example => "|Get all the attibutes for node \'node1\'.|GET|/nodes/node1|{\n \"node1\":{\n \"profile\":\"compute\",\n \"netboot\":\"xnba\",\n \"arch\":\"x86_64\",\n \"mgt\":\"ipmi\",\n \"groups\":\"all\",\n ...\n }\n}|", cmd => "lsdef", @@ -103,6 +104,7 @@ my %URIdef = ( matcher => '^/nodes/[^/]*/attrs/\S+$', GET => { desc => "Get the specific attributes for the node {noderange}.", + desc1 => "The keyword ALLRESOURCES can be used as {noderange} which means to get node attributes for all the nodes.", usage => "||$usagemsg{objreturn}|", example => "|Get the attributes {groups,mgt,netboot} for node node1|GET|/nodes/node1/attrs/groups,mgt,netboot|{\n \"node1\":{\n \"netboot\":\"xnba\",\n \"mgt\":\"ipmi\",\n \"groups\":\"all\"\n }\n}|", cmd => "lsdef", @@ -123,7 +125,7 @@ my %URIdef = ( matcher => '^/nodes/[^/]*/nodestat$', GET => { desc => "Get the running status for the node {noderange}.", - usage => "||$usagemsg{objreturn}|", + usage => "||An object which includes multiple entries like: : { nodestat : }|", example => "|Get the running status for node node1|GET|/nodes/node1/nodestat|{\n \"node1\":{\n \"nodestat\":\"noping\"\n }\n}|", cmd => "nodestat", fhandler => \&actionhdl, @@ -188,7 +190,7 @@ my %URIdef = ( matcher => '^/nodes/[^/]*/power$', GET => { desc => "Get the power status for the node {noderange}.", - usage => "||$usagemsg{objreturn}|", + usage => "||An object which includes multiple entries like: : { power : }|", example => "|Get the power status.|GET|/nodes/node1/power|{\n \"node1\":{\n \"power\":\"on\"\n }\n}|", cmd => "rpower", fhandler => \&actionhdl, @@ -688,6 +690,7 @@ my %URIdef = ( matcher => '^\/networks\/[^\/]*$', GET => { desc => "Get all the attibutes for the network {netname}.", + desc1 => "The keyword ALLRESOURCES can be used as {netname} which means to get network attributes for all the networks.", usage => "||$usagemsg{objreturn}|", example => "|Get all the attibutes for network \'network1\'.|GET|/networks/network1|{\n \"network1\":{\n \"gateway\":\"\",\n \"mask\":\"255.255.255.0\",\n \"mgtifname\":\"eth2\",\n \"net\":\"10.0.0.0\",\n \"tftpserver\":\"10.0.0.119\",\n ...\n }\n}|", cmd => "lsdef", @@ -724,6 +727,7 @@ my %URIdef = ( matcher => '^\/networks\/[^\/]*/attrs/\S+$', GET => { desc => "Get the specific attributes for the network {netname}.", + desc1 => "The keyword ALLRESOURCES can be used as {netname} which means to get network attributes for all the networks.", usage => "||$usagemsg{objreturn}|", example => "|Get the attributes {groups,mgt,netboot} for network network1|GET|/networks/network1/attrs/gateway,mask,mgtifname,net,tftpserver|{\n \"network1\":{\n \"gateway\":\"9.114.34.254\",\n \"mask\":\"255.255.255.0\",\n }\n}|", cmd => "lsdef", @@ -773,6 +777,7 @@ my %URIdef = ( matcher => '^\/osimages\/[^\/]*$', GET => { desc => "Get all the attibutes for the osimage {imgname}.", + desc1 => "The keyword ALLRESOURCES can be used as {imgname} which means to get image attributes for all the osimages.", usage => "||$usagemsg{objreturn}|", example => "|Get the attributes for the specified osimage.|GET|/osimages/sles11.2-x86_64-install-compute|{\n \"sles11.2-x86_64-install-compute\":{\n \"provmethod\":\"install\",\n \"profile\":\"compute\",\n \"template\":\"/opt/xcat/share/xcat/install/sles/compute.sles11.tmpl\",\n \"pkglist\":\"/opt/xcat/share/xcat/install/sles/compute.sles11.pkglist\",\n \"osvers\":\"sles11.2\",\n \"osarch\":\"x86_64\",\n \"osname\":\"Linux\",\n \"imagetype\":\"linux\",\n \"otherpkgdir\":\"/install/post/otherpkgs/sles11.2/x86_64\",\n \"osdistroname\":\"sles11.2-x86_64\",\n \"pkgdir\":\"/install/sles11.2/x86_64\"\n }\n}|", cmd => "lsdef", @@ -810,6 +815,7 @@ my %URIdef = ( matcher => '^\/osimages\/[^\/]*/attrs/\S+$', GET => { desc => "Get the specific attributes for the osimage {imgname}.", + desc1 => "The keyword ALLRESOURCES can be used as {imgname} which means to get image attributes for all the osimages.", usage => "||Json format: An array of attr:value pairs for the specified osimage.|", example => "|Get the specified attributes.|GET|/osimages/sles11.2-ppc64-install-compute/attrs/imagetype,osarch,osname,provmethod|{\n \"sles11.2-ppc64-install-compute\":{\n \"provmethod\":\"install\",\n \"osname\":\"Linux\",\n \"osarch\":\"ppc64\",\n \"imagetype\":\"linux\"\n }\n}|", cmd => "lsdef", @@ -872,6 +878,7 @@ my %URIdef = ( GET => { desc => "Get all the attibutes for a policy {policy_priority}.", desc1 => "It will display all the policy attributes for one policy resource.", + desc2 => "The keyword ALLRESOURCES can be used as {policy_priority} which means to get policy attributes for all the policies.", usage => "||$usagemsg{objreturn}|", example => "|Get all the attribute for policy 1.|GET|/policy/1|{\n \"1\":{\n \"name\":\"root\",\n \"rule\":\"allow\"\n }\n}|", cmd => "lsdef", @@ -912,6 +919,7 @@ my %URIdef = ( GET => { desc => "Get the specific attributes for the policy {policy_priority}.", desc1 => "It will get one or more attributes of a policy.", + desc2 => "The keyword ALLRESOURCES can be used as {policy_priority} which means to get policy attributes for all the policies.", usage => "||$usagemsg{objreturn}|", example => "|Get the name and rule attributes for policy 1.|GET|/policy/1/attrs/name,rule|{\n \"1\":{\n \"name\":\"root\",\n \"rule\":\"allow\"\n }\n}|", cmd => "lsdef", From e40f69e508b7dfc11510386d73bde4f17b598cf4 Mon Sep 17 00:00:00 2001 From: daniceexi Date: Wed, 4 Jun 2014 07:37:20 -0400 Subject: [PATCH 70/99] defect 4152: fix a typo which was introduced when support rh7 that using -N for dracut command --- xCAT-server/share/xcat/netboot/rh/genimage | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-server/share/xcat/netboot/rh/genimage b/xCAT-server/share/xcat/netboot/rh/genimage index 7fc298298..ce7baeb96 100755 --- a/xCAT-server/share/xcat/netboot/rh/genimage +++ b/xCAT-server/share/xcat/netboot/rh/genimage @@ -928,7 +928,7 @@ sub mkinitrd_dracut { if ($dracutver > "033") { $additional_options .= " -N"; } - system("chroot $rootimg_dir dracut -N $additional_options -f /tmp/initrd.$$.gz $kernelver"); + system("chroot $rootimg_dir dracut $additional_options -f /tmp/initrd.$$.gz $kernelver"); print "the initial ramdisk for $mode is generated successfully.\n"; move("$rootimg_dir/tmp/initrd.$$.gz", "$destdir/initrd-$mode.gz"); } From 1b9e2b16cfd0f8df7fa10d86d415d90fa02e21e7 Mon Sep 17 00:00:00 2001 From: daniceexi Date: Wed, 4 Jun 2014 08:44:40 -0400 Subject: [PATCH 71/99] defect 4153: resolve the merge conflict which introduced by commit 899cb5028ddfa672e9af9ba884316072ef529048 --- xCAT-server/lib/xcat/plugins/yaboot.pm | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/yaboot.pm b/xCAT-server/lib/xcat/plugins/yaboot.pm index f77b86416..3ce67366f 100644 --- a/xCAT-server/lib/xcat/plugins/yaboot.pm +++ b/xCAT-server/lib/xcat/plugins/yaboot.pm @@ -725,14 +725,8 @@ sub process_request { if ($errored) { my $rsp; $rsp->{errorcode}->[0]=1; -<<<<<<< HEAD - $rsp->{error}->[0]="Failed in running end prescripts\n"; - $::YABOOT_callback->($rsp); - return; -======= $rsp->{error}->[0]="Failed in running end prescripts. Processing will still continue.\n"; - $callback->($rsp); ->>>>>>> 78b8d21... defect 4147 - allow nodeset to continue if prescript errors + $::YABOOT_callback->($rsp); } } } From b148e997e9d5fc0525cd4707fa3781057d3686f6 Mon Sep 17 00:00:00 2001 From: huweihua Date: Wed, 4 Jun 2014 22:57:23 -0400 Subject: [PATCH 72/99] fix bug: in sysclone, provmethod attribute gets cleared --- xCAT-server/lib/xcat/plugins/destiny.pm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xCAT-server/lib/xcat/plugins/destiny.pm b/xCAT-server/lib/xcat/plugins/destiny.pm index a0b5ecd6f..464dde9f4 100755 --- a/xCAT-server/lib/xcat/plugins/destiny.pm +++ b/xCAT-server/lib/xcat/plugins/destiny.pm @@ -503,7 +503,9 @@ sub setdestiny { } } } - if ($provmethod ne 'install') { + #if ($provmethod ne 'install') { + #fix bug: in sysclone, provmethod attribute gets cleared + if ($provmethod ne 'install' && $provmethod ne 'sysclone') { push(@nodestoblank, $_); } } From 3c862b24512c94a6dd922d4b7fc7d8f4866aa466 Mon Sep 17 00:00:00 2001 From: immarvin Date: Wed, 21 May 2014 01:34:43 -0700 Subject: [PATCH 73/99] fix defect #4128 [fvt]2.8.4:ubuntu 12.04 lsxcat -v could get version info --- perl-xCAT/debian/rules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/perl-xCAT/debian/rules b/perl-xCAT/debian/rules index d98c40834..e5a0aa6fd 100755 --- a/perl-xCAT/debian/rules +++ b/perl-xCAT/debian/rules @@ -48,7 +48,7 @@ binary-arch: build install chmod 644 `pwd`/debian/perl-xcat/opt/xcat/share/doc/man5/* chmod 644 `pwd`/debian/perl-xcat/opt/xcat/share/man/man7/* chmod 644 `pwd`/debian/perl-xcat/opt/xcat/share/doc/man7/* - ./modifyUtils `cat ../Version` `svn info | grep Revision | cut -d" " -f 2` + ./modifyUtils `cat ../Version` `git log -n 1 | head -n 1 | cut -f 2 -d ' '` # dh_installmenu # dh_installdebconf # dh_installlogrotate From 63497743c71a1cd6f9bfabaf37623d2e56c39c20 Mon Sep 17 00:00:00 2001 From: baiyuan Date: Thu, 5 Jun 2014 01:49:25 -0400 Subject: [PATCH 74/99] imgimport does not support kit related in 2.8.x,warning replace error for defect 4093 --- xCAT-server/lib/xcat/plugins/imgport.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-server/lib/xcat/plugins/imgport.pm b/xCAT-server/lib/xcat/plugins/imgport.pm index 8156b0a4c..836acc5a8 100644 --- a/xCAT-server/lib/xcat/plugins/imgport.pm +++ b/xCAT-server/lib/xcat/plugins/imgport.pm @@ -1412,7 +1412,7 @@ sub create_symlink { } } } else { - $callback->({error => ["osimage table or kitcomponent do not exist"],errorcode=>[1]}); + $callback->({warning => ["osimage table or kitcomponent do not exist"],errorcode=>[1]}); return 1; } } From 5487553e41f8cfc9522eec9d7a7983955ba3df5d Mon Sep 17 00:00:00 2001 From: lissav Date: Thu, 5 Jun 2014 09:08:55 -0400 Subject: [PATCH 75/99] defect 4154 --- xCAT-client/bin/mysqlsetup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-client/bin/mysqlsetup b/xCAT-client/bin/mysqlsetup index 4b00497d8..a0e020abe 100755 --- a/xCAT-client/bin/mysqlsetup +++ b/xCAT-client/bin/mysqlsetup @@ -165,7 +165,7 @@ if ($::RUNCMD_RC != 0) # is this MariaDB or MySQL $::MariaDB=0; $cmd = "rpm -qa | grep -i mariadb"; # check this is MariaDB not MySQL -xCAT::Utils->runcmd($cmd, 0); +xCAT::Utils->runcmd($cmd, -1); if ($::RUNCMD_RC == 0) { $::MariaDB=1; } From 210239303cfa7ccb8b9fb5ef845edc5dd2d1d57c Mon Sep 17 00:00:00 2001 From: Bruce Potter Date: Sat, 7 Jun 2014 09:17:52 -0400 Subject: [PATCH 76/99] improved msg for getslnodes when missing dependencies for sl api --- xCAT-SoftLayer/bin/getslnodes | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-SoftLayer/bin/getslnodes b/xCAT-SoftLayer/bin/getslnodes index d5549ad1c..5903054eb 100755 --- a/xCAT-SoftLayer/bin/getslnodes +++ b/xCAT-SoftLayer/bin/getslnodes @@ -40,7 +40,7 @@ my $hnmatch = $ARGV[0]; # if they specified a hostname match, only show svrs th readconf("$ENV{HOME}/.slconfig"); # get the userid and api key from the config file my $slinstalled = eval { push @INC, $CONFIG{apidir}; require SoftLayer::API::SOAP; }; -if (!$slinstalled) { die "Error: the SoftLayer::API::SOAP perl module is not installed. Download it using 'git clone https://github.com/softlayer/softlayer-api-perl-client' and put the directory in ~/.slconfig ."; } +if (!$slinstalled) { die "$@\nError: either the SoftLayer::API::SOAP perl module is not installed, or some dependencies are missing. Download it using 'git clone https://github.com/softlayer/softlayer-api-perl-client', put the directory in ~/.slconfig , and ensure its dependencies are installed."; } my $client = SoftLayer::API::SOAP->new('SoftLayer_Account', undef, $CONFIG{userid}, $CONFIG{apikey}); From b979de76b67cd80d87e032dbbcb49ac5022d9240 Mon Sep 17 00:00:00 2001 From: immarvin Date: Sun, 8 Jun 2014 05:42:23 -0700 Subject: [PATCH 77/99] add generic subroutine and functions for service management --- perl-xCAT/xCAT/Utils.pm | 463 +++++++++++++++++++++++++++++++++++- xCAT/postscripts/xcatlib.sh | 204 ++++++++++++++++ 2 files changed, 665 insertions(+), 2 deletions(-) diff --git a/perl-xCAT/xCAT/Utils.pm b/perl-xCAT/xCAT/Utils.pm index f9f454b10..4264e7e74 100644 --- a/perl-xCAT/xCAT/Utils.pm +++ b/perl-xCAT/xCAT/Utils.pm @@ -16,7 +16,6 @@ if ($^O =~ /^aix/i) { use lib "$::XCATROOT/lib/perl"; # do not put a use or require for xCAT::Table here. Add to each new routine # needing it to avoid reprocessing of user tables ( ExtTab.pm) for each command call -# use POSIX qw(ceil); use File::Path; use Socket; @@ -3426,10 +3425,11 @@ sub version_cmp { string of the bin file name Returns: string of the full path name of the binary executable file + string of the bin file name in the argument if failed Globals: none Error: - string of the bin file name in the argument + none Example: my $CHKCONFIG = xCAT::Utils->fullpathbin("chkconfig"); Comments: @@ -3517,4 +3517,463 @@ sub gettimezone } +#-------------------------------------------------------------------------------- + +=head3 servicemap + returns the name of service unit(for systemd) or service daemon(for SYSVinit). + Arguments: + $svcname: the name of the service + $svcmgrtype: the service manager type: + 0: SYSVinit + 1: systemd + Returns: + the name of service unit or service daemon + undef on fail + Globals: + none + Error: + None + Example: + my $svc = xCAT::Utils->servicemap($svcname,1); + Comments: + none +=cut + +#-------------------------------------------------------------------------------- +sub servicemap{ + my $svcname=shift; + if( $svcname =~ /xCAT::Utils/) + { + $svcname=shift; + } + + my $svcmgrtype=shift; + + + #hash structure: + #"service name $svcname" =>{ + #"service manager name(SYSVinit/systemd) $svcmgrtype" + #=> ["list of possible service file names for the specified $svcname under the specified $svcmgrtype "] + # } + my %svchash=( + "dhcp" => { + 0=>["dhcpd","isc-dhcp-server"], + 1=>["dhcpd.service"], + }, + "nfs" => { + 0=>["nfsserver","nfs","nfs-kernel-server"], + 1=>["nfs-server.service"], + }, + "named" => { + 0=>["named","bind9"], + 1=>["named.service"], + }, + "syslog" => { + 0=>["syslog","syslogd","rsyslog"], + 1=>["rsyslog.service"], + }, + "firewall" => { + 0=>["iptables","firewalld","SuSEfirewall2_setup"], + 1=>["firewalld.service"], + }, + "http" => { + 0=>["apache2","httpd"], + 1=>["httpd.service"], + }, + ); + + my $path=undef; + my $retdefault=$svcname; + if($svcmgrtype == 0){ + $path="/etc/init.d/"; + }elsif ($svcmgrtype == 1){ + $path="/usr/lib/systemd/system/"; + $retdefault=$svcname.".service"; + } + + + my $ret=undef; + if($svchash{$svcname} and $svchash{$svcname}{$svcmgrtype}){ + foreach my $file (@{$svchash{$svcname}{$svcmgrtype}}){ + if(-e $path.$file ){ + $ret=$file; + last; + } + } + }else{ + if(-e $path.$retdefault){ + $ret=$retdefault; + } + } + + return $ret; + +} + + +#-------------------------------------------------------------------------------- + +=head3 startservice + start a service + Arguments: + service name + Returns: + 0 on success + nonzero otherwise + Globals: + none + Error: + none + Example: + xCAT::Utils->startservice("nfs"); + Comments: + none +=cut + +#-------------------------------------------------------------------------------- +sub startservice{ + my $svcname=shift; + if( $svcname =~ /xCAT::Utils/) + { + $svcname=shift; + } + + my $cmd=""; + my $svcunit=undef; + my $svcd=undef; + + $svcunit=servicemap($svcname,1); + $svcd=servicemap($svcname,0); + if($svcunit) + { + $cmd="systemctl start $svcunit"; + } + elsif( $svcd ) + { + $cmd="service $svcd start"; + } + print "$cmd\n"; + if( $cmd eq "" ) + { + return -1; + } + + xCAT::Utils->runcmd($cmd, -1); + return $::RUNCMD_RC; +} + + +#-------------------------------------------------------------------------------- + +=head3 stopservice + stop a service + Arguments: + service name + Returns: + 0 on success + nonzero otherwise + Globals: + none + Error: + none + Example: + xCAT::Utils->stopservice("nfs"); + Comments: + none +=cut + +#-------------------------------------------------------------------------------- +sub stopservice{ + my $svcname=shift; + if( $svcname =~ /xCAT::Utils/) + { + $svcname=shift; + } + + my $cmd=""; + my $svcunit=undef; + my $svcd=undef; + + $svcunit=servicemap($svcname,1); + $svcd=servicemap($svcname,0); + if($svcunit) + { + $cmd="systemctl stop $svcunit"; + } + elsif( $svcd ) + { + $cmd="service $svcd stop"; + } + print "$cmd\n"; + if( $cmd eq "" ) + { + return -1; + } + + xCAT::Utils->runcmd($cmd, -1); + return $::RUNCMD_RC; +} + + +#-------------------------------------------------------------------------------- + +=head3 restartservice + restart a service + Arguments: + service name + Returns: + 0 on success + nonzero otherwise + Globals: + none + Error: + none + Example: + xCAT::Utils->restartservice("nfs"); + Comments: + none +=cut + +#-------------------------------------------------------------------------------- +sub restartservice{ + my $svcname=shift; + if( $svcname =~ /xCAT::Utils/) + { + $svcname=shift; + } + + my $cmd=""; + my $svcunit=undef; + my $svcd=undef; + + $svcunit=servicemap($svcname,1); + $svcd=servicemap($svcname,0); + if($svcunit) + { + $cmd="systemctl restart $svcunit"; + } + elsif( $svcd ) + { + $cmd="service $svcd restart"; + } + print "$cmd\n"; + if( $cmd eq "" ) + { + return -1; + } + + xCAT::Utils->runcmd($cmd, -1); + return $::RUNCMD_RC; +} + +#-------------------------------------------------------------------------------- + +=head3 checkservicestatus + returns theservice status. + Arguments: + $svcname: the name of the service + $outputoption[optional]: + the output option + 1: return a hashref with the keys:"retcode","retmsg" + otherwise: return retcode only + Returns: + undef on fail + a hashref if $outputoption is 1,the hash structure is: + {"retcode"=>(status code, 0 for running/active,1 for stopped/inactive,2 for failed) + "retmsg" =>(status string, running/active/stopped/inactive/failed) + } + the status code otherwise + + Globals: + none + Error: + None + Example: + my $ret = xCAT::Utils-checkservicestatus($svcname,1); + my $retcode = xCAT::Utils-checkservicestatus($svcname); + Comments: + none +=cut + +#-------------------------------------------------------------------------------- +sub checkservicestatus{ + my $svcname=shift; + if( $svcname =~ /xCAT::Utils/) + { + $svcname=shift; + } + + my $outputoption=shift; + + my $cmd=""; + my $svcunit=undef; + my $svcd=undef; + my %ret; + + $svcunit=servicemap($svcname,1); + $svcd=servicemap($svcname,0); + my $output=undef; + + if($svcunit) + { + #for systemd, parse the output since it is formatted + $cmd="systemctl show --property=ActiveState $svcunit|awk -F '=' '{print \$2}'"; + $output=xCAT::Utils->runcmd($cmd, -1); + if($output =~ /^active$/i){ + $ret{retcode}=0; + print "xxx$output\n"; + }elsif($output =~ /^failed$/i){ + $ret{retcode}=2; + + }elsif($output =~ /^inactive$/i){ + $ret{retcode}=1; + } + } + elsif( $svcd ) + { + #for SYSVinit, check the return value since the "service" command output is confused + $cmd="service $svcd status"; + $output=xCAT::Utils->runcmd($cmd, -1); + $ret{retcode}=$::RUNCMD_RC; +# if($output =~ /stopped|not running/i){ +# $ret{retcode}=1; +# }elsif($output =~ /running/i){ +# $ret{retcode}=0; +# } + } + if($output) + { + $ret{retmsg}=$output; + } + + + if(defined $outputoption and $outputoption == 1 ){ + return \%ret; + }elsif(exists $ret{retcode}){ + return $ret{retcode}; + } + + return undef; + +} + + +#-------------------------------------------------------------------------------- + +=head3 enableservice + enable a service to start it on the system bootup + Arguments: + service name + Returns: + 0 on success + nonzero otherwise + Globals: + none + Error: + none + Example: + xCAT::Utils->enableservice("nfs"); + Comments: + none +=cut + +#-------------------------------------------------------------------------------- +sub enableservice{ + my $svcname=shift; + if( $svcname =~ /xCAT::Utils/) + { + $svcname=shift; + + } + my $cmd=""; + my $svcunit=undef; + my $svcd=undef; + + $svcunit=servicemap($svcname,1); + $svcd=servicemap($svcname,0); + if($svcunit) + { + $cmd="systemctl enable $svcunit"; + } + elsif( $svcd ) + { + my $CHKCONFIG = xCAT::Utils->fullpathbin("chkconfig"); + if($CHKCONFIG ne "chkconfig"){ + $cmd="$CHKCONFIG $svcd on"; + }else{ + $CHKCONFIG = xCAT::Utils->fullpathbin("update-rc.d"); + if($CHKCONFIG ne "update-rc.d"){ + $cmd="$CHKCONFIG $svcd defaults"; + } + } + } + print "$cmd\n"; + if( $cmd eq "" ) + { + return -1; + } + + xCAT::Utils->runcmd($cmd, -1); + return $::RUNCMD_RC; +} + + +#-------------------------------------------------------------------------------- + +=head3 disableservice + disable a service to prevent it from starting on system bootup + Arguments: + service name + Returns: + 0 on success + nonzero otherwise + Globals: + none + Error: + none + Example: + xCAT::Utils->disableservice("nfs"); + Comments: + none +=cut + +#-------------------------------------------------------------------------------- +sub disableservice{ + my $svcname=shift; + if( $svcname =~ /xCAT::Utils/) + { + $svcname=shift; + + } + my $cmd=""; + my $svcunit=undef; + my $svcd=undef; + + $svcunit=servicemap($svcname,1); + $svcd=servicemap($svcname,0); + if($svcunit) + { + $cmd="systemctl disable $svcunit"; + } + elsif( $svcd ) + { + my $CHKCONFIG = xCAT::Utils->fullpathbin("chkconfig"); + if($CHKCONFIG ne "chkconfig"){ + $cmd="$CHKCONFIG $svcd off"; + }else{ + $CHKCONFIG = xCAT::Utils->fullpathbin("update-rc.d"); + if($CHKCONFIG ne "update-rc.d"){ + $cmd="$CHKCONFIG -f $svcd remove"; + } + } + } + print "$cmd\n"; + if( $cmd eq "" ) + { + return -1; + } + + xCAT::Utils->runcmd($cmd, -1); + return $::RUNCMD_RC; +} 1; diff --git a/xCAT/postscripts/xcatlib.sh b/xCAT/postscripts/xcatlib.sh index ee532258d..6bac5d0d5 100644 --- a/xCAT/postscripts/xcatlib.sh +++ b/xCAT/postscripts/xcatlib.sh @@ -266,3 +266,207 @@ function v6calcnet(){ str_v6net=`echo $str_v6net | sed 's/.$//'` echo "$str_v6net" } + + +function servicemap { + local svcname=$1 + local svcmgrtype=$2 + local svclistname= + + INIT_dhcp="dhcpd isc-dhcp-server"; + SYSTEMD_dhcp="dhcpd.service"; + + INIT_nfs="nfsserver nfs nfs-kernel-server"; + SYSTEMD_nfs="nfs-server.service"; + + INIT_named="named bind9"; + SYSTEMD_named="named.service"; + + INIT_syslog="syslog syslogd rsyslog"; + SYSTEMD_syslog="rsyslog.service"; + + INIT_firewall="iptables firewalld SuSEfirewall2_setup"; + SYSTEMD_firewall="firewalld.service"; + + INIT_http="apache2 httpd"; + SYSTEMD_http="httpd.service"; + + local path= + local retdefault=$svcname + local svcvar=${svcname//[-.]/_} + if [ "$svcmgrtype" = "0" ];then + svclistname=INIT_$svcvar + path="/etc/init.d/" + elif [ "$svcmgrtype" = "1" ];then + svclistname=SYSTEMD_$svcvar + retdefault=$svcname.service + path="/usr/lib/systemd/system/" + fi + + + local svclist=$(eval echo \$$svclistname) + + if [ -z "$svclist" ];then + svclist="$retdefault" + fi + + for name in `echo $svclist` + do + if [ -e "$path$name" ];then + echo $name + break + fi + done + +} + +function startservice { + local svcname=$1 + local cmd= + local svcunit=`servicemap $svcname 1` + local svcd=`servicemap $svcname 0` + + if [ -n "$svcunit" ];then + cmd="systemctl start $svcunit" + elif [ -n "$svcd" ];then + cmd="service $svcd start"; + fi + + if [ -z "$cmd" ];then + return 127 + fi + + eval $cmd +} + + + +function stopservice { + local svcname=$1 + local cmd= + local svcunit=`servicemap $svcname 1` + local svcd=`servicemap $svcname 0` + + if [ -n "$svcunit" ];then + cmd="systemctl stop $svcunit" + elif [ -n "$svcd" ];then + cmd="service $svcd stop"; + fi + + if [ -z "$cmd" ];then + return 127 + fi + + eval $cmd +} + + +function restartservice { + local svcname=$1 + local cmd= + local svcunit=`servicemap $svcname 1` + local svcd=`servicemap $svcname 0` + + if [ -n "$svcunit" ];then + cmd="systemctl restart $svcunit" + elif [ -n "$svcd" ];then + cmd="service $svcd restart"; + fi + + if [ -z "$cmd" ];then + return 127 + fi + + eval $cmd +} + + +function checkservicestatus { + local svcname=$1 + + local svcunit=`servicemap $svcname 1` + local svcd=`servicemap $svcname 0` + + local output= + local retcode=3 + + if [ -n "$svcunit" ];then + output=$(systemctl show --property=ActiveState $svcunit|awk -F '=' '{print $2}') + if echo $output|grep -E -i "^active$";then + retcode=0 + elif echo $output|grep -E -i "^inactive$";then + retcode=1 + elif echo $output|grep -E -i "^failed$";then + retcode=2 + fi + elif [ -n "$svcd" ];then + output=$(service $svcd status) + retcode=$? + echo $output +# if echo $output|grep -E -i "(stopped|not running)";then +# retcode=1 +# elif echo $output|grep -E -i "running";then +# retcode=0 +# fi + else + retcode=127 + fi + + return $retcode + +} + +function enableservice { + local svcname=$1 + local cmd= + local svcunit=`servicemap $svcname 1` + local svcd=`servicemap $svcname 0` + + if [ -n "$svcunit" ];then + cmd="systemctl enable $svcunit" + elif [ -n "$svcd" ];then + command -v chkconfig >/dev/null 2>&1 + if [ $? -eq 0 ];then + cmd="chkconfig $svcd on"; + else + command -v update-rc.d >/dev/null 2>&1 + if [ $? -eq 0 ];then + cmd="update-rc.d $svcd defaults" + fi + fi + fi + + if [ -z "$cmd" ];then + return 127 + fi + + eval $cmd +} + + +function disableservice { + local svcname=$1 + local cmd= + local svcunit=`servicemap $svcname 1` + local svcd=`servicemap $svcname 0` + + if [ -n "$svcunit" ];then + cmd="systemctl disable $svcunit" + elif [ -n "$svcd" ];then + command -v chkconfig >/dev/null 2>&1 + if [ $? -eq 0 ];then + cmd="chkconfig $svcd off"; + else + command -v update-rc.d >/dev/null 2>&1 + if [ $? -eq 0 ];then + cmd="update-rc.d -f $svcd remove" + fi + fi + fi + + if [ -z "$cmd" ];then + return 127 + fi + + eval $cmd +} From c02119ea540b5a7170b4dc7b48e3344d44a064e4 Mon Sep 17 00:00:00 2001 From: immarvin Date: Sun, 8 Jun 2014 08:23:10 -0700 Subject: [PATCH 78/99] replace the service stuff with new added generic routines --- perl-xCAT/xCAT/Utils.pm | 4 + xCAT-server/sbin/xcatconfig | 232 ++++++++++++++++++++---------------- 2 files changed, 130 insertions(+), 106 deletions(-) diff --git a/perl-xCAT/xCAT/Utils.pm b/perl-xCAT/xCAT/Utils.pm index 4264e7e74..576a9d7f7 100644 --- a/perl-xCAT/xCAT/Utils.pm +++ b/perl-xCAT/xCAT/Utils.pm @@ -3580,6 +3580,10 @@ sub servicemap{ 0=>["apache2","httpd"], 1=>["httpd.service"], }, + "ntpserver" => { + 0=>["ntpd","ntp"], + 1=>["ntpd.service"], + }, ); my $path=undef; diff --git a/xCAT-server/sbin/xcatconfig b/xCAT-server/sbin/xcatconfig index b55d916bb..2abb7f7fe 100755 --- a/xCAT-server/sbin/xcatconfig +++ b/xCAT-server/sbin/xcatconfig @@ -505,66 +505,74 @@ if ($::INITIALINSTALL || $::FORCE) xCAT::MsgUtils->message('E', "Failed to update /etc/ntp.conf"); } - my $ntpserv; - if (-f "/etc/redhat-release") - { - $ntpserv = "ntpd"; - } - else - { - $ntpserv = "ntp"; - } - $cmd = "service $ntpserv restart"; - $outref = xCAT::Utils->runcmd("$cmd", 0); - if ($::RUNCMD_RC != 0) + #my $ntpserv; + #if (-f "/etc/redhat-release") + #{ + # $ntpserv = "ntpd"; + #} + #else + #{ + # $ntpserv = "ntp"; + #} + #$cmd = "service $ntpserv restart"; + #$outref = xCAT::Utils->runcmd("$cmd", 0); + #if ($::RUNCMD_RC != 0) + my $ret=xCAT::Utils->restartservice("ntpserver"); + if($ret !=0) { xCAT::MsgUtils->message('E', "Failed to start ntp service"); } - if (-f "/sbin/chkconfig") - { - $cmd = "chkconfig $ntpserv on"; - $outref = xCAT::Utils->runcmd("$cmd", 0); - if ($::RUNCMD_RC != 0) + #if (-f "/sbin/chkconfig") + #{ + # $cmd = "chkconfig $ntpserv on"; + # $outref = xCAT::Utils->runcmd("$cmd", 0); + $ret=xCAT::Utils->enableservice("ntpserver"); + # if ($::RUNCMD_RC != 0) + if($ret!=0) { xCAT::MsgUtils->message('E', "Failed to enable ntp service on every boot"); } - } + #} } # Disable firewall - my $fwserv; - if(-f "/etc/SuSE-release") - { - $fwserv = "SuSEfirewall2_setup"; - } - elsif(-f "/etc/redhat-release") - { - $fwserv = "iptables"; - if( -f "/usr/sbin/firewalld" ) - { - $fwserv = "firewalld"; - } - } - else - { - #Ubuntu: FIXME - } + #my $fwserv; + #if(-f "/etc/SuSE-release") + #{ + # $fwserv = "SuSEfirewall2_setup"; + #} + #elsif(-f "/etc/redhat-release") + #{ + # $fwserv = "iptables"; + # if( -f "/usr/sbin/firewalld" ) + # { + # $fwserv = "firewalld"; + # } + #} + #else + #{ + # #Ubuntu: FIXME + #} - if($fwserv) - { - my $cmd = "service $fwserv stop"; - my $outref = xCAT::Utils->runcmd("$cmd", 0); - if ($::RUNCMD_RC != 0) + #if($fwserv) + #{ + # my $cmd = "service $fwserv stop"; + # my $outref = xCAT::Utils->runcmd("$cmd", 0); + # if ($::RUNCMD_RC != 0) + my $ret=xCAT::Utils->stopservice("firewall"); + if($ret!=0) { xCAT::MsgUtils->message('E', "Failed to stop firewall"); } - $cmd = "chkconfig $fwserv off"; - $outref = xCAT::Utils->runcmd("$cmd", 0); - if ($::RUNCMD_RC != 0) + # $cmd = "chkconfig $fwserv off"; + # $outref = xCAT::Utils->runcmd("$cmd", 0); + # if ($::RUNCMD_RC != 0) + $ret=xCAT::Utils->disableservice("firewall"); + if($ret!=0) { xCAT::MsgUtils->message('E', "Failed to disable firewall on boot"); } - } + #} # Enable ip forwarding. In most cases, # the MN itself will act as the default gateway for the compute nodes, @@ -1781,16 +1789,18 @@ sub setupLinuxexports { # restart nfs - my $cmd; - my $os = xCAT::Utils->osver(); - my $SERVICE = xCAT::Utils->fullpathbin("service"); - if ($os =~ /sles/) { - $cmd = "$SERVICE nfsserver restart"; - } else { - $cmd = "$SERVICE nfs restart"; - } - my $outref = xCAT::Utils->runcmd("$cmd", 0); - if ($::RUNCMD_RC != 0) + # my $cmd; + # my $os = xCAT::Utils->osver(); + # my $SERVICE = xCAT::Utils->fullpathbin("service"); + # if ($os =~ /sles/) { + # $cmd = "$SERVICE nfsserver restart"; + # } else { + # $cmd = "$SERVICE nfs restart"; + # } + # my $outref = xCAT::Utils->runcmd("$cmd", 0); + # if ($::RUNCMD_RC != 0) + my $ret=xCAT::Utils->restartservice("nfs"); + if($ret!=0) { xCAT::MsgUtils->message('E', "Could not restart NFS."); } @@ -1799,14 +1809,18 @@ sub setupLinuxexports xCAT::MsgUtils->message('I', "NFS has been restarted."); } - my $CHKCONFIG=xCAT::Utils->fullpathbin("chkconfig"); - if ($os =~ /sles/) { - $cmd = "$CHKCONFIG nfsserver on"; - } else { - $cmd = "$CHKCONFIG nfs on"; - } - $outref = xCAT::Utils->runcmd("$cmd", 0); - if ($::RUNCMD_RC != 0) + #my $CHKCONFIG=xCAT::Utils->fullpathbin("chkconfig"); + #if ($os =~ /sles/) { + # $cmd = "$CHKCONFIG nfsserver on"; + #} else { + # $cmd = "$CHKCONFIG nfs on"; + #} + #$outref = xCAT::Utils->runcmd("$cmd", 0); + #if ($::RUNCMD_RC != 0) + + + $ret=xCAT::Utils->enableservice("nfs"); + if($ret!=0) { xCAT::MsgUtils->message('E', "Could not enable NFS."); } @@ -1895,24 +1909,26 @@ sub makenetworks sub setuphttp { - my $cmd; - my $distro = xCAT::Utils->osver(); - # restart httpd - if (-e "/etc/init.d/apache2") - { #for sles/ubuntu - $cmd = "/etc/init.d/apache2 stop; /etc/init.d/apache2 start"; - } - elsif (-e "/etc/init.d/httpd") - { - $cmd = "/etc/init.d/httpd stop; /etc/init.d/httpd start"; - } - else - { - $cmd = "service httpd stop; service httpd start"; - } +# my $cmd; +# my $distro = xCAT::Utils->osver(); +# # restart httpd +# if (-e "/etc/init.d/apache2") +# { #for sles/ubuntu +# $cmd = "/etc/init.d/apache2 stop; /etc/init.d/apache2 start"; +# } +# elsif (-e "/etc/init.d/httpd") +# { +# $cmd = "/etc/init.d/httpd stop; /etc/init.d/httpd start"; +# } +# else +# { +# $cmd = "service httpd stop; service httpd start"; +# } - my $outref = xCAT::Utils->runcmd("$cmd", 0); - if ($::RUNCMD_RC != 0) +# my $outref = xCAT::Utils->runcmd("$cmd", 0); +# if ($::RUNCMD_RC != 0) + my $ret=xCAT::Utils->restartservice("http"); + if($ret!=0) { xCAT::MsgUtils->message('E', "Could not restart httpd."); } @@ -1922,26 +1938,28 @@ sub setuphttp } # enable httpd - if (-e "/etc/init.d/apache2") - { - if ( $distro =~ /ubuntu.*/ || $distro =~ /debian.*/i) { - $cmd = "/usr/sbin/update-rc.d apache2 enable"; - } - else - { # for sles - $cmd = "/sbin/chkconfig apache2 on"; - } - } - else - { - my $CHKCONFIG = xCAT::Utils->fullpathbin("chkconfig"); - $cmd = "$CHKCONFIG httpd on"; - } + #if (-e "/etc/init.d/apache2") + #{ + # if ( $distro =~ /ubuntu.*/ || $distro =~ /debian.*/i) { + # $cmd = "/usr/sbin/update-rc.d apache2 enable"; + # } + # else + # { # for sles + # $cmd = "/sbin/chkconfig apache2 on"; + # } + #} + #else + #{ + # my $CHKCONFIG = xCAT::Utils->fullpathbin("chkconfig"); + # $cmd = "$CHKCONFIG httpd on"; + #} - $outref = xCAT::Utils->runcmd("$cmd", 0); - if ($::RUNCMD_RC != 0) + #$outref = xCAT::Utils->runcmd("$cmd", 0); + #if ($::RUNCMD_RC != 0) + $ret=xCAT::Utils->enableservice("http"); + if($ret!=0) { xCAT::MsgUtils->message('E', "Could not enable httpd."); } @@ -2182,12 +2200,12 @@ sub startnamedonboot else { #chkconfig - my $serv = "named"; - my $cmd = "/sbin/chkconfig $serv on"; - if ( $distro =~ /ubuntu.*/ || $distro =~ /debian.*/i) { - $serv = "bind9"; - $cmd = "update-rc.d $serv enable"; - } + #my $serv = "named"; + #my $cmd = "/sbin/chkconfig $serv on"; + #if ( $distro =~ /ubuntu.*/ || $distro =~ /debian.*/i) { + # $serv = "bind9"; + # $cmd = "update-rc.d $serv enable"; + #} #"service named start" is very slowly,sometimes hang in rhels6.4 after installation #a work around is to generate /etc/rndc-key during xCAT installation @@ -2195,14 +2213,16 @@ sub startnamedonboot system("rndc-confgen -a -r /dev/urandom"); } - my $outref = xCAT::Utils->runcmd("$cmd", 0); - if ($::RUNCMD_RC != 0) + #my $outref = xCAT::Utils->runcmd("$cmd", 0); + #if ($::RUNCMD_RC != 0) + my $ret=xCAT::Utils->enableservice("named"); + if($ret!=0) { - xCAT::MsgUtils->message("E", "Could not enable $serv."); + xCAT::MsgUtils->message("E", "Could not enable dns server."); } else { - xCAT::MsgUtils->message("I", "$serv has been enabled on boot."); + xCAT::MsgUtils->message("I", "dns server has been enabled on boot."); } } } From 58dc9496cf9c073e235339da63bd119dd33c8850 Mon Sep 17 00:00:00 2001 From: huweihua Date: Sun, 8 Jun 2014 22:42:32 -0400 Subject: [PATCH 79/99] change indent and comment --- xCAT-server/lib/xcat/plugins/destiny.pm | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/destiny.pm b/xCAT-server/lib/xcat/plugins/destiny.pm index 464dde9f4..53ccd08b0 100755 --- a/xCAT-server/lib/xcat/plugins/destiny.pm +++ b/xCAT-server/lib/xcat/plugins/destiny.pm @@ -503,9 +503,8 @@ sub setdestiny { } } } - #if ($provmethod ne 'install') { - #fix bug: in sysclone, provmethod attribute gets cleared - if ($provmethod ne 'install' && $provmethod ne 'sysclone') { + #don't clean up provmethod if osimage.provmethod is install or sysclone + if ($provmethod ne 'install' && $provmethod ne 'sysclone') { push(@nodestoblank, $_); } } From 69e6dd69cfd656c27f4d7ea8c52faf89df26d835 Mon Sep 17 00:00:00 2001 From: immarvin Date: Mon, 9 Jun 2014 06:40:14 -0700 Subject: [PATCH 80/99] repleace the servcie stuff with newly added generic subroutines in xcat-client --- perl-xCAT/xCAT/Utils.pm | 4 +++ xCAT-client/bin/db2sqlsetup | 56 ++++++++++++++++++++++---------- xCAT-client/bin/mysqlsetup | 44 +++++++++++++++---------- xCAT-client/bin/pgsqlsetup | 65 ++++++++++++++++++++++++------------- 4 files changed, 111 insertions(+), 58 deletions(-) diff --git a/perl-xCAT/xCAT/Utils.pm b/perl-xCAT/xCAT/Utils.pm index 576a9d7f7..4dbaef123 100644 --- a/perl-xCAT/xCAT/Utils.pm +++ b/perl-xCAT/xCAT/Utils.pm @@ -3584,6 +3584,10 @@ sub servicemap{ 0=>["ntpd","ntp"], 1=>["ntpd.service"], }, + "mysql" => { + 0=>["mysqld","mysql"], + 1=>["mysqld.service"], + }, ); my $path=undef; diff --git a/xCAT-client/bin/db2sqlsetup b/xCAT-client/bin/db2sqlsetup index fe765ffcd..ef8e5f219 100755 --- a/xCAT-client/bin/db2sqlsetup +++ b/xCAT-client/bin/db2sqlsetup @@ -590,13 +590,16 @@ sub startxcatd } else { $xcmd = "$::XCATROOT/sbin/restartxcatd"; } + system($xcmd); } else { - $xcmd = "service xcatd restart"; + #$xcmd = "service xcatd restart"; + my $ret=xCAT::Utils->restartservice("xcatd"); + return $ret; } - system($xcmd); + } #----------------------------------------------------------------------------- @@ -618,13 +621,16 @@ sub shutdownxcatd if ($::osname eq 'AIX') { $xcmd = "stopsrc -s xcatd"; + system($xcmd); } else { - $xcmd = "service xcatd stop"; + #$xcmd = "service xcatd stop"; + my $ret=xCAT::Utils->stopservice("xcatd"); + return $ret; } - system($xcmd); + } #----------------------------------------------------------------------------- @@ -2073,11 +2079,12 @@ sub adddb2paths #----------------------------------------------------------------------------- sub remove { - my $cmd; - my @output; - my $error = 0; - #see if DB2 is installed - if (!(-e ($::installdb2dir))) + my $cmd; + my @output; + my $error = 0; + my $retcode=0; + #see if DB2 is installed + if (!(-e ($::installdb2dir))) { my $message = "\nDB2 is not installed."; @@ -2120,18 +2127,23 @@ sub remove my $cmd = "ps -elf|grep xcatd"; my @output = xCAT::Utils->runcmd($cmd, 0); + if ($::RUNCMD_RC == 0) { if ($::osname eq 'AIX') { my $cmd = "startsrc -s xcatd"; + xCAT::Utils->runcmd($cmd, -1); + $retcode=$::RUNCMD_RC; } else { - my $cmd = "service xcatd start"; + #my $cmd = "service xcatd start"; + $retcode=xCAT::Utils->startservice("xcatd"); } - xCAT::Utils->runcmd($cmd, -1); - if ($::RUNCMD_RC !=0) + #xCAT::Utils->runcmd($cmd, -1); + #if ($::RUNCMD_RC !=0) + if($retcode!=0) { my $message = "can't start xcatd"; $error += 1; @@ -2155,13 +2167,17 @@ sub remove if ($::osname eq 'AIX') { my $cmd = "stopsrc -s xcatd"; + xCAT::Utils->runcmd($cmd, -1); + $retcode=$::RUNCMD_RC; } else { - my $cmd = "service xcatd stop"; + #my $cmd = "service xcatd stop"; + $retcode=xCAT::Utils->stopservice("xcatd"); } - xCAT::Utils->runcmd($cmd, -1); - if ($::RUNCMD_RC !=0) + #xCAT::Utils->runcmd($cmd, -1); + #if ($::RUNCMD_RC !=0) + if($retcode!=0) { my $message = "can't stop xcatd"; xCAT::MsgUtils->message("E", "$message"); @@ -2198,13 +2214,17 @@ sub remove if ($::osname eq 'AIX') { my $cmd = "startsrc -s xcatd"; + xCAT::Utils->runcmd($cmd, -1); + $retcode=$::RUNCMD_RC; } else { - my $cmd = "service xcatd start"; + #my $cmd = "service xcatd start"; + $retcode=xCAT::Utils->startservice("xcatd"); } - xCAT::Utils->runcmd($cmd, -1); - if ($::RUNCMD_RC !=0) + #xCAT::Utils->runcmd($cmd, -1); + #if ($::RUNCMD_RC !=0) + if($retcode!=0) { my $message = "can't start xcatd"; xCAT::MsgUtils->message("E", "$message"); diff --git a/xCAT-client/bin/mysqlsetup b/xCAT-client/bin/mysqlsetup index a0e020abe..5c78f2fd4 100755 --- a/xCAT-client/bin/mysqlsetup +++ b/xCAT-client/bin/mysqlsetup @@ -608,13 +608,16 @@ sub shutdownxcatd if ($::osname eq 'AIX') { $xcmd = "stopsrc -s xcatd"; + system($xcmd); } else { - $xcmd = "service xcatd stop"; + #$xcmd = "service xcatd stop"; + my $ret=xCAT::Utils->stopservice("xcatd"); + return $ret; } - system($xcmd); + } #----------------------------------------------------------------------------- @@ -861,6 +864,7 @@ sub initmysqldb sub mysqlstart { my $cmd; + my $ret=0; if ($::osname eq 'AIX') { my $hostname = `hostname`; @@ -872,28 +876,32 @@ sub mysqlstart $cmd = $cmd2; $cmd .= "$::installdir/bin/mysqld --user=mysql --basedir=$::installdir --datadir=/var/lib/mysql --user=mysql --log-error=/var/lib/mysql/$hostname.err --pid-file=/var/lib/mysql/$hostname.pid --socket=/tmp/mysql.sock --port=3306 &"; + $ret=xCAT::Utils->runcmd($cmd, 0); + + } else { if ($::MariaDB==1) { # running MariaDB - $cmd = "service mariadb start"; + #$cmd = "service mariadb start"; + $ret=xCAT::Utils->startservice("mariadb"); } else { # it is mysql - if ($::linuxos =~ /rh.*/) - { - $cmd = "service mysqld start"; - } - else - { # sles - $cmd = "service mysql start"; - } + #if ($::linuxos =~ /rh.*/) + #{ + # $cmd = "service mysqld start"; + #} + #else + #{ # sles + # $cmd = "service mysql start"; + #} + $ret=xCAT::Utils->startservice("mysql"); } } - xCAT::Utils->runcmd($cmd, 0); - if ($::RUNCMD_RC != 0) + if ($ret != 0) { - xCAT::MsgUtils->message("E", " $cmd failed."); + xCAT::MsgUtils->message("E", " failed to start mysql/mariadb."); exit(1); } @@ -1809,12 +1817,14 @@ sub restorexcatdb if ($::osname eq 'AIX') { $xcmd = "$::XCATROOT/sbin/restartxcatd"; - + system($xcmd); } else { - $xcmd = "service xcatd restart"; + #$xcmd = "service xcatd restart"; + my $ret=xCAT::Utils->restartservie("xcatd"); + return $ret; } - system($xcmd); + } diff --git a/xCAT-client/bin/pgsqlsetup b/xCAT-client/bin/pgsqlsetup index 9731c6973..94db9a888 100755 --- a/xCAT-client/bin/pgsqlsetup +++ b/xCAT-client/bin/pgsqlsetup @@ -444,13 +444,16 @@ sub shutdownxcatd if ($::osname eq 'AIX') { $xcmd = "stopsrc -s xcatd"; + system($xcmd); } else { - $xcmd = "service xcatd stop"; + # $xcmd = "service xcatd stop"; + my $ret=xCAT::Utils->stopservice("xcatd"); + return $ret; } - system($xcmd); + } #----------------------------------------------------------------------------- @@ -832,6 +835,7 @@ sub initpgdb sub pgstart { my $cmd; + my $ret=0; xCAT::MsgUtils->message("I", "Starting the PosgreSQL Server"); if ($::osname eq 'AIX') { @@ -843,27 +847,35 @@ sub pgstart else # linux { if (defined($::postgres9)) { # set to the PTF level of postgresql 9.X - $cmd = "service postgresql-9.$::postgres9 start"; + #$cmd = "service postgresql-9.$::postgres9 start"; + $cmd = "postgresql-9.$::postgres9"; } else { - $cmd = "service postgresql start"; + #$cmd = "service postgresql start"; + $cmd = "postgresql"; } - system($cmd); - if ($? > 0) { - xCAT::MsgUtils->message("E", " $cmd failed."); + #system($cmd) + #if ($? > 0) { + $ret=xCAT::Utils->startservice($cmd); + if ($ret != 0) { + xCAT::MsgUtils->message("E", " failed to start $cmd."); exit(1); } # check to see if running before continuing my $retries =0; my $pgstarted =0; - if (defined($::postgres9)) { # set to the PTF level of postgresql 9.X - $cmd = "service postgresql-9.$::postgres9 status"; - } else { - $cmd = "service postgresql status"; - } + #if (defined($::postgres9)) { # set to the PTF level of postgresql 9.X + # #$cmd = "service postgresql-9.$::postgres9 status"; + # $ret=xCAT::Utils->checkservicestatus("postgresql-9.$::postgres9"); + #} else { + # #$cmd = "service postgresql status"; + # $ret=xCAT::Utils->checkservicestatus("postgresql"); + #} while ($retries < 30) { $retries++; - my @status=xCAT::Utils->runcmd($cmd, -1); - if (grep(/[r|R]unning/, @status)) { + #my @status=xCAT::Utils->runcmd($cmd, -1); + #if (grep(/[r|R]unning/, @status)) { + $ret=xCAT::Utils->checkservicestatus($cmd); + if($ret == 0){ $pgstarted=1; last; } @@ -903,15 +915,19 @@ sub pgreboot else # linux { if (defined($::postgres9)) { # set to the postgresql ptf level - $cmd = "chkconfig postgresql-9.$::postgres9 on"; + # $cmd = "chkconfig postgresql-9.$::postgres9 on"; + $cmd = "postgresql-9.$::postgres9"; } else { - $cmd = "chkconfig postgresql on"; + #$cmd = "chkconfig postgresql on"; + $cmd = "postgresql"; } - if ($debianflag){ - $cmd = "update-rc.d postgresql defaults"; - } - xCAT::Utils->runcmd($cmd, 0); - if ($::RUNCMD_RC != 0) + #if ($debianflag){ + #$cmd = "update-rc.d postgresql defaults"; + #} + #xCAT::Utils->runcmd($cmd, 0); + #if ($::RUNCMD_RC != 0) + my $ret=xCAT::Utils->enableservice($cmd); + if($cmd !=0 ) { xCAT::MsgUtils->message("E", " $cmd failed. PostgreSQL will not restart on reboot."); @@ -1347,12 +1363,15 @@ sub restorexcatdb if ($::osname eq 'AIX') { $xcmd = "startsrc -s xcatd"; + system($xcmd); } else { - $xcmd = "service xcatd start"; + #$xcmd = "service xcatd start"; + my $ret=xCAT::Utils->startservice("xcatd"); + return $ret; } - system($xcmd); + } From 7beb515aa0e78a446a71dd9dee4a2ce28e3ca2ee Mon Sep 17 00:00:00 2001 From: immarvin Date: Mon, 9 Jun 2014 06:52:07 -0700 Subject: [PATCH 81/99] correct the message --- xCAT-client/bin/pgsqlsetup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-client/bin/pgsqlsetup b/xCAT-client/bin/pgsqlsetup index 94db9a888..5624f65f7 100755 --- a/xCAT-client/bin/pgsqlsetup +++ b/xCAT-client/bin/pgsqlsetup @@ -930,7 +930,7 @@ sub pgreboot if($cmd !=0 ) { xCAT::MsgUtils->message("E", - " $cmd failed. PostgreSQL will not restart on reboot."); + "enable service $cmd failed. PostgreSQL will not restart on reboot."); } } From 580ffb203fa78a30504505c93df79c3762ea2cb6 Mon Sep 17 00:00:00 2001 From: immarvin Date: Mon, 9 Jun 2014 08:58:56 -0700 Subject: [PATCH 82/99] add systemctl support for xCAT-sn --- xCATsn/xCATsn.spec | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/xCATsn/xCATsn.spec b/xCATsn/xCATsn.spec index 0fd02f9f0..ecc449369 100644 --- a/xCATsn/xCATsn.spec +++ b/xCATsn/xCATsn.spec @@ -179,14 +179,17 @@ fi %ifos linux if [ -e "/etc/redhat-release" ]; then apachedaemon='httpd' + apacheserviceunit='httpd.service' else # SuSE apachedaemon='apache2' fi # start xcatd on linux - chkconfig $apachedaemon on +[ -e "/etc/init.d/$apachedaemon" ] && chkconfig $apachedaemon on +[ -e "/usr/lib/systemd/system/$apacheserviceunit" ] && systemctl enable $apacheserviceunit if [ -f "/proc/cmdline" ]; then # prevent running it during install into chroot image - XCATROOT=$RPM_INSTALL_PREFIX0 /etc/init.d/xcatd restart - /etc/init.d/$apachedaemon reload + XCATROOT=$RPM_INSTALL_PREFIX0 /etc/init.d/xcatd restart + [ -e "/etc/init.d/$apachedaemon" ] && /etc/init.d/$apachedaemon reload + [ -e "/usr/lib/systemd/system/$apacheserviceunit" ] && systemctl reload $apacheserviceunit fi echo "xCATsn is now installed" %else From e7e8a28f7fdeec51b73b907e7c393d34bbe26ec8 Mon Sep 17 00:00:00 2001 From: immarvin Date: Mon, 9 Jun 2014 20:18:05 -0700 Subject: [PATCH 83/99] replace the service stuff with newly added systemd subroutines --- xCAT-rmc/scripts/monerrorlog | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/xCAT-rmc/scripts/monerrorlog b/xCAT-rmc/scripts/monerrorlog index 54e1d4354..d0908d720 100755 --- a/xCAT-rmc/scripts/monerrorlog +++ b/xCAT-rmc/scripts/monerrorlog @@ -10,12 +10,17 @@ checks for errors. =cut #------------------------------------------------------------------------------# - +BEGIN +{ + $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat'; +} +use lib "$::XCATROOT/lib/perl"; use strict; use locale; use Getopt::Long; use IPC::SysV qw(IPC_STAT S_IRWXU IPC_PRIVATE IPC_CREAT S_IRUSR S_IWUSR ); use IPC::Msg; +use xCAT::Utils; BEGIN { @@ -109,8 +114,9 @@ if (&first_time_run) runcmd("/usr/bin/mkfifo $fifo"); } runcmd("echo \"$embedinfo\" >> $syslogconf"); - my $cmd = service("syslog", "restart"); - runcmd($cmd); + #my $cmd = service("syslog", "restart"); + #runcmd($cmd); + xCAT::Utils->restartservice("syslog"); } touchFile($runfile); } @@ -512,6 +518,9 @@ sub createRandomName 'stop' or 'status'. Returns: A full cli for the service script. + Comment: + this subroutine is deprecated, use service subroutines in xCAT::Utils + instead =cut #-------------------------------------------------------------------------------- From 862f1459a1f92c8c47d2f896d7ba892dd59a9a4a Mon Sep 17 00:00:00 2001 From: daniceexi Date: Tue, 10 Jun 2014 08:16:37 -0400 Subject: [PATCH 84/99] restructure the code in Template.pm->subvars to handle recusive #INCLUDE. It also fixed the support of #INCLUDE in osimage.partitionfile --- xCAT-server/lib/perl/xCAT/Template.pm | 293 ++++++++++++-------------- 1 file changed, 140 insertions(+), 153 deletions(-) diff --git a/xCAT-server/lib/perl/xCAT/Template.pm b/xCAT-server/lib/perl/xCAT/Template.pm index a99a2e9f8..b5822e0c3 100644 --- a/xCAT-server/lib/perl/xCAT/Template.pm +++ b/xCAT-server/lib/perl/xCAT/Template.pm @@ -154,166 +154,153 @@ sub subvars { #do *all* includes, recursive and all my $doneincludes=0; while (not $doneincludes) { - $doneincludes=1; - if ($inc =~ /#INCLUDE_PKGLIST:[^#^\n]+#/) { - $doneincludes=0; - $inc =~ s/#INCLUDE_PKGLIST:([^#^\n]+)#/includefile($1, 0, 1)/eg; - } - if ($inc =~ /#INCLUDE_PTRNLIST:[^#^\n]+#/) { - $doneincludes=0; - $inc =~ s/#INCLUDE_PTRNLIST:([^#^\n]+)#/includefile($1, 0, 2)/eg; - } - if ($inc =~ /#INCLUDE_RMPKGLIST:[^#^\n]+#/) { - $doneincludes=0; - $inc =~ s/#INCLUDE_RMPKGLIST:([^#^\n]+)#/includefile($1, 0, 3)/eg; - } - if ($inc =~ /#INCLUDE:[^#^\n]+#/) { - $doneincludes=0; - $inc =~ s/#INCLUDE:([^#^\n]+)#/includefile($1, 0, 0)/eg; - } - } - - #support multiple paths of osimage in rh/sles diskfull installation - my @pkgdirs; - if ( defined($media_dir) ) { - @pkgdirs = split(",", $media_dir); - my $source; - my $source_in_pre; - my $c = 0; - foreach my $pkgdir(@pkgdirs) { - if( $platform =~ /^(rh|SL|centos|fedora)$/ ) { - if ( $c == 0 ) { - # After some tests, if we put the repo in pre scripts in the kickstart like for rhels6.x - # the rhels5.9 will not be installed successfully. So put in kickstart directly. - $source_in_pre .= "echo 'url --url http://'\$nextserver'/$pkgdir' >> /tmp/repos"; - $source .= "url --url http://#TABLE:noderes:\$NODE:nfsserver#/$pkgdir\n"; #For rhels5.9 - } else { - $source_in_pre .= "\necho 'repo --name=pkg$c --baseurl=http://'\$nextserver'/$pkgdir' >> /tmp/repos"; - $source .= "repo --name=pkg$c --baseurl=http://#TABLE:noderes:\$NODE:nfsserver#/$pkgdir\n"; #for rhels5.9 + #support multiple paths of osimage in rh/sles diskfull installation + my @pkgdirs; + if ( defined($media_dir) ) { + @pkgdirs = split(",", $media_dir); + my $source; + my $source_in_pre; + my $c = 0; + foreach my $pkgdir(@pkgdirs) { + if( $platform =~ /^(rh|SL|centos|fedora)$/ ) { + if ( $c == 0 ) { + # After some tests, if we put the repo in pre scripts in the kickstart like for rhels6.x + # the rhels5.9 will not be installed successfully. So put in kickstart directly. + $source_in_pre .= "echo 'url --url http://'\$nextserver'/$pkgdir' >> /tmp/repos"; + $source .= "url --url http://#TABLE:noderes:\$NODE:nfsserver#/$pkgdir\n"; #For rhels5.9 + } else { + $source_in_pre .= "\necho 'repo --name=pkg$c --baseurl=http://'\$nextserver'/$pkgdir' >> /tmp/repos"; + $source .= "repo --name=pkg$c --baseurl=http://#TABLE:noderes:\$NODE:nfsserver#/$pkgdir\n"; #for rhels5.9 + } + } elsif ($platform =~ /^(sles|suse)/) { + my $http = "http://#TABLE:noderes:\$NODE:nfsserver#$pkgdir"; + $source .= " + $http + SuSE-Linux-pkg$c + / + false + SuSE-Linux-pkg$c + "; + $source_in_pre .="http://'\$nextserver'$pkgdirSuSE-Linux-pkg$c/falseSuSE-Linux-pkg$c"; + } + $c++; + } + + $inc =~ s/#INSTALL_SOURCES#/$source/g; + $inc =~ s/#INSTALL_SOURCES_IN_PRE#/$source_in_pre/g; + } + + #ok, now do everything else.. + my $shortname = $node; + $shortname =~ s/\..*//; + $inc =~ s/#TABLE:([^:]+):([^:]+):([^#]+)#/tabdb($1,$2,$3)/eg; + $inc =~ s/#TABLEBLANKOKAY:([^:]+):([^:]+):([^#]+)#/tabdb($1,$2,$3,'1')/eg; + $inc =~ s/#INCLUDE_NOP:([^#^\n]+)#/includefile($1,1,0)/eg; + $inc =~ s/#XCATVAR:([^#]+)#/envvar($1)/eg; + $inc =~ s/#ENV:([^#]+)#/envvar($1)/eg; + $inc =~ s/#MACHINEPASSWORD#/machinepassword()/eg; + $inc =~ s/#CRYPT:([^:]+):([^:]+):([^#]+)#/crydb($1,$2,$3)/eg; + $inc =~ s/#COMMAND:([^#]+)#/command($1)/eg; + $inc =~ s/#KICKSTARTNET#/kickstartnetwork()/eg; + $inc =~ s/#YAST2NET#/yast2network()/eg; + $inc =~ s/#ESXIPV6SETUP#/esxipv6setup()/eg; + $inc =~ s/#WINTIMEZONE#/xCAT::TZUtils::get_wintimezone()/eg; + $inc =~ s/#WINPRODKEY:([^#]+)#/get_win_prodkey($1)/eg; + $inc =~ s/#WINNETCFG#/windows_net_cfg()/eg; + $inc =~ s/#WINADJOIN#/windows_join_data()/eg; + $inc =~ s/#WINDNSCFG#/windows_dns_cfg()/eg; + $inc =~ s/#WINACCOUNTDATA#/windows_account_data()/eg; + $inc =~ s/#WINDISABLENULLADMIN#/windows_disable_null_admin()/eg; + $inc =~ s/#MANAGEDADDRESSMODE#/managed_address_mode()/eg; + $inc =~ s/#HOSTNAME#/$node/g; + $inc =~ s/#SHORTNAME#/$shortname/g; + $inc =~ s/#GETNODEDOMAIN:([^#]+)#/get_node_domain($1)/eg; + + my $nrtab = xCAT::Table->new("noderes"); + my $tftpserver = $nrtab->getNodeAttribs($node, ['tftpserver']); + my $sles_sdk_media = "http://" . $tftpserver->{tftpserver} . $media_dir . "/sdk1"; + + $inc =~ s/#SLES_SDK_MEDIA#/$sles_sdk_media/eg; + + #if user specify the partion file, replace the default partition strategy + if ($partitionfile){ + #if the content of the partition file is definition replace the default is ok + my $partcontent = ''; + my $scriptflag = 0; + + if ($partitionfile =~ /^s:(.*)/){ + $scriptflag = 1; + $partitionfile = $1; + } + + if (-r $partitionfile){ + open ($inh, "<", $partitionfile); + while (<$inh>){ + $partcontent .= $_; + } + close ($inh); + + #the content of the specified file is a script which can write partition definition into /tmp/partitionfile + if ($scriptflag){ + #for redhat/sl/centos/kvm/fedora + if ($inc =~ /#XCAT_PARTITION_START#/) { + my $tempstr = "%include /tmp/partitionfile\n"; + $inc =~ s/#XCAT_PARTITION_START#[\s\S]*#XCAT_PARTITION_END#/$tempstr/; + #modify the content in the file, and write into %pre part + #$partcontent = "cat > /tmp/partscript << EOFEOF\n" . $partcontent . "\nEOFEOF\n"; + $partcontent = "echo " . "'". $partcontent . "'" . ">/tmp/partscript\n"; + + $partcontent .= "chmod 755 /tmp/partscript\n"; + $partcontent .= "/tmp/partscript\n"; + #replace the #XCA_PARTITION_SCRIPT# + $inc =~ s/#XCA_PARTITION_SCRIPT#/$partcontent/; + } + #for sles/suse + elsif ($inc =~ //){ + my $tempstr = "XCATPARTITIONTEMP"; + $inc =~ s/[\s\S]*/$tempstr/; + #$partcontent = "cat > /tmp/partscript << EOFEOF\n" . $partcontent . "\nEOFEOF\n"; + $partcontent = "echo " . "'". $partcontent . "'" . ">/tmp/partscript\n"; + $partcontent .= "chmod 755 /tmp/partscript\n"; + $partcontent .= "/tmp/partscript\n"; + $inc =~ s/#XCA_PARTITION_SCRIPT#/$partcontent/; + } + } + else{ + $partcontent =~ s/\s$//; + if ($inc =~ /#XCAT_PARTITION_START#/){ + $inc =~ s/#XCAT_PARTITION_START#[\s\S]*#XCAT_PARTITION_END#/$partcontent/; + } + elsif ($inc =~ //){ + $inc =~ s/[\s\S]*/$partcontent/; + } } - } elsif ($platform =~ /^(sles|suse)/) { - my $http = "http://#TABLE:noderes:\$NODE:nfsserver#$pkgdir"; - $source .= " - $http - SuSE-Linux-pkg$c - / - false - SuSE-Linux-pkg$c - "; - $source_in_pre .="http://'\$nextserver'$pkgdirSuSE-Linux-pkg$c/falseSuSE-Linux-pkg$c"; } - $c++; } - $inc =~ s/#INSTALL_SOURCES#/$source/g; - $inc =~ s/#INSTALL_SOURCES_IN_PRE#/$source_in_pre/g; - } - - - - - #Support hierarchical include - $inc =~ s/#ENV:([^#]+)#/envvar($1)/eg; - if ($inc =~ /#INCLUDE:[^#^\n]+#/) { - $inc =~ s/#INCLUDE:([^#^\n]+)#/includefile($1, 0, 0)/eg; - } - - #ok, now do everything else.. - my $shortname = $node; - $shortname =~ s/\..*//; - $inc =~ s/#TABLE:([^:]+):([^:]+):([^#]+)#/tabdb($1,$2,$3)/eg; - $inc =~ s/#TABLEBLANKOKAY:([^:]+):([^:]+):([^#]+)#/tabdb($1,$2,$3,'1')/eg; - $inc =~ s/#INCLUDE_NOP:([^#^\n]+)#/includefile($1,1,0)/eg; - $inc =~ s/#INCLUDE_PKGLIST:([^#^\n]+)#/includefile($1,0,1)/eg; - $inc =~ s/#INCLUDE_PTRNLIST:([^#^\n]+)#/includefile($1,0,2)/eg; - $inc =~ s/#INCLUDE_RMPKGLIST:([^#^\n]+)#/includefile($1,0,3)/eg; - $inc =~ s/#INCLUDE:([^#^\n]+)#/includefile($1, 0, 0)/eg; - $inc =~ s/#XCATVAR:([^#]+)#/envvar($1)/eg; - $inc =~ s/#ENV:([^#]+)#/envvar($1)/eg; - $inc =~ s/#MACHINEPASSWORD#/machinepassword()/eg; - $inc =~ s/#CRYPT:([^:]+):([^:]+):([^#]+)#/crydb($1,$2,$3)/eg; - $inc =~ s/#COMMAND:([^#]+)#/command($1)/eg; - $inc =~ s/#KICKSTARTNET#/kickstartnetwork()/eg; - $inc =~ s/#YAST2NET#/yast2network()/eg; - $inc =~ s/#ESXIPV6SETUP#/esxipv6setup()/eg; - $inc =~ s/#WINTIMEZONE#/xCAT::TZUtils::get_wintimezone()/eg; - $inc =~ s/#WINPRODKEY:([^#]+)#/get_win_prodkey($1)/eg; - $inc =~ s/#WINNETCFG#/windows_net_cfg()/eg; - $inc =~ s/#WINADJOIN#/windows_join_data()/eg; - $inc =~ s/#WINDNSCFG#/windows_dns_cfg()/eg; - $inc =~ s/#WINACCOUNTDATA#/windows_account_data()/eg; - $inc =~ s/#WINDISABLENULLADMIN#/windows_disable_null_admin()/eg; - $inc =~ s/#MANAGEDADDRESSMODE#/managed_address_mode()/eg; - $inc =~ s/#HOSTNAME#/$node/g; - $inc =~ s/#SHORTNAME#/$shortname/g; - $inc =~ s/#GETNODEDOMAIN:([^#]+)#/get_node_domain($1)/eg; - - my $nrtab = xCAT::Table->new("noderes"); - my $tftpserver = $nrtab->getNodeAttribs($node, ['tftpserver']); - my $sles_sdk_media = "http://" . $tftpserver->{tftpserver} . $media_dir . "/sdk1"; - - $inc =~ s/#SLES_SDK_MEDIA#/$sles_sdk_media/eg; - - #if user specify the partion file, replace the default partition strategy - if ($partitionfile){ - #if the content of the partition file is definition replace the default is ok - my $partcontent = ''; - my $scriptflag = 0; - - if ($partitionfile =~ /^s:(.*)/){ - $scriptflag = 1; - $partitionfile = $1; - } - - if (-r $partitionfile){ - open ($inh, "<", $partitionfile); - while (<$inh>){ - $partcontent .= $_; - } - close ($inh); - - #the content of the specified file is a script which can write partition definition into /tmp/partitionfile - if ($scriptflag){ - #for redhat/sl/centos/kvm/fedora - if ($inc =~ /#XCAT_PARTITION_START#/) { - my $tempstr = "%include /tmp/partitionfile\n"; - $inc =~ s/#XCAT_PARTITION_START#[\s\S]*#XCAT_PARTITION_END#/$tempstr/; - #modify the content in the file, and write into %pre part - #$partcontent = "cat > /tmp/partscript << EOFEOF\n" . $partcontent . "\nEOFEOF\n"; - $partcontent = "echo " . "'". $partcontent . "'" . ">/tmp/partscript\n"; - - $partcontent .= "chmod 755 /tmp/partscript\n"; - $partcontent .= "/tmp/partscript\n"; - #replace the #XCA_PARTITION_SCRIPT# - $inc =~ s/#XCA_PARTITION_SCRIPT#/$partcontent/; - } - #for sles/suse - elsif ($inc =~ //){ - my $tempstr = "XCATPARTITIONTEMP"; - $inc =~ s/[\s\S]*/$tempstr/; - #$partcontent = "cat > /tmp/partscript << EOFEOF\n" . $partcontent . "\nEOFEOF\n"; - $partcontent = "echo " . "'". $partcontent . "'" . ">/tmp/partscript\n"; - $partcontent .= "chmod 755 /tmp/partscript\n"; - $partcontent .= "/tmp/partscript\n"; - $inc =~ s/#XCA_PARTITION_SCRIPT#/$partcontent/; - } - } - else{ - $partcontent =~ s/\s$//; - if ($inc =~ /#XCAT_PARTITION_START#/){ - $inc =~ s/#XCAT_PARTITION_START#[\s\S]*#XCAT_PARTITION_END#/$partcontent/; - } - elsif ($inc =~ //){ - $inc =~ s/[\s\S]*/$partcontent/; - } - } - } + $doneincludes=1; + if ($inc =~ /#INCLUDE_PKGLIST:[^#^\n]+#/) { + $doneincludes=0; + $inc =~ s/#INCLUDE_PKGLIST:([^#^\n]+)#/includefile($1, 0, 1)/eg; + } + if ($inc =~ /#INCLUDE_PTRNLIST:[^#^\n]+#/) { + $doneincludes=0; + $inc =~ s/#INCLUDE_PTRNLIST:([^#^\n]+)#/includefile($1, 0, 2)/eg; + } + if ($inc =~ /#INCLUDE_RMPKGLIST:[^#^\n]+#/) { + $doneincludes=0; + $inc =~ s/#INCLUDE_RMPKGLIST:([^#^\n]+)#/includefile($1, 0, 3)/eg; + } + if ($inc =~ /#INCLUDE:[^#^\n]+#/) { + $doneincludes=0; + $inc =~ s/#INCLUDE:([^#^\n]+)#/includefile($1, 0, 0)/eg; + } } if ($tmplerr) { - close ($outh); - return $tmplerr; - } + close ($outh); + return $tmplerr; + } print $outh $inc; close($outh); return 0; From c764fe725c439faf5c22cb30a02e39aa0f719fd9 Mon Sep 17 00:00:00 2001 From: huweihua Date: Tue, 10 Jun 2014 04:33:52 -0400 Subject: [PATCH 85/99] add rootimgdir attr for sysclone osimage definition --- xCAT-server/lib/xcat/plugins/imgcapture.pm | 65 +++++++++++++++++++++- 1 file changed, 62 insertions(+), 3 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/imgcapture.pm b/xCAT-server/lib/xcat/plugins/imgcapture.pm index bd4f881de..26e58572f 100644 --- a/xCAT-server/lib/xcat/plugins/imgcapture.pm +++ b/xCAT-server/lib/xcat/plugins/imgcapture.pm @@ -130,7 +130,7 @@ sub process_request { my $shortname = xCAT::InstUtils->myxCATname(); my $rc; - $rc = sysclone_configserver($shortname, $callback, $doreq); + $rc = sysclone_configserver($shortname, $osimg, $callback, $doreq); if($rc){ my $rsp = {}; $rsp->{data}->[0] = qq{Can not configure Imager Server on $shortname.}; @@ -467,7 +467,7 @@ sub getplatform { } sub sysclone_configserver{ - my ($server, $callback, $subreq) = @_; + my ($server, $osimage, $callback, $subreq) = @_; # check if systemimager is installed on the imager server my $rsp = {}; @@ -514,9 +514,40 @@ sub sysclone_configserver{ { mkpath($sysclone_overrides); } + + my $imagedir; + my $osimgtab = xCAT::Table->new('osimage'); + my $entry = ($osimgtab->getAllAttribsWhere("imagename = '$osimage'", 'ALL' ))[0]; + if(!$entry){ + $imagedir = $sysclone_home . "/images/" . $osimage; + }else{ + my $osimagetab = xCAT::Table->new('linuximage'); + my $osimageentry = $osimagetab->getAttribs({imagename => $osimage}, 'rootimgdir'); + if($osimageentry){ + $imagedir = $osimageentry->{rootimgdir}; + if (!(-e $imagedir)){ + mkpath($imagedir); + } + }else{ + $imagedir = $sysclone_home . "/images/" . $osimage; + $cmd = "chdef -t osimage $osimage rootimgdir=$imagedir"; + $rc = `$cmd`; + } + } + $imagedir =~ s/^(\/.*)\/.+\/?$/$1/; + $imagedir =~ s/\//\\\\\//g; + $imagedir = "DEFAULT_IMAGE_DIR = ".$imagedir; + + my $olddir = `more /etc/systemimager/systemimager.conf |grep DEFAULT_IMAGE_DIR`; + $olddir =~ s/\//\\\\\//g; + chomp($olddir); + + $cmd= "sed -i \"s/$olddir/$imagedir/\" /etc/systemimager/systemimager.conf"; + $rc = `$cmd`; + # update /etc/systemimager/rsync_stubs/10header to generate new /etc/systemimager/rsyncd.conf - my $rc = `sed -i "s/\\/var\\/lib\\/systemimager/\\/install\\/sysclone/g" /etc/systemimager/rsync_stubs/10header`; + $rc = `sed -i "s/\\/var\\/lib\\/systemimager/\\/install\\/sysclone/g" /etc/systemimager/rsync_stubs/10header`; $rc = `export PERL5LIB=/usr/lib/perl5/site_perl/;LANG=C si_mkrsyncd_conf`; return 0; @@ -678,6 +709,22 @@ sub sysclone_createosimgdef{ $osimgdef{$osimage}{template} = ""; $osimgdef{$osimage}{otherpkglist} = ""; $osimgdef{$osimage}{pkglist} = ""; + + if(!($imagedef{$oldimg}{rootimgdir})){ + $imagedef{$oldimg}{rootimgdir} = $sysclone_home . "/images/" . $osimage; + + my $imagedir = $imagedef{$oldimg}{rootimgdir}; + $imagedir =~ s/^(\/.*)\/.+\/?$/$1/; + $imagedir =~ s/\//\\\\\//g; + $imagedir = "DEFAULT_IMAGE_DIR = ".$imagedir; + + my $olddir = `more /etc/systemimager/systemimager.conf |grep DEFAULT_IMAGE_DIR`; + $olddir =~ s/\//\\\\\//g; + chomp($olddir); + + my $cmd= "sed -i \"s/$olddir/$imagedir/\" /etc/systemimager/systemimager.conf"; + my $rc = `$cmd`; + } } } else { $createnew = 1; @@ -701,6 +748,18 @@ sub sysclone_createosimgdef{ $osimgdef{$osimage}{osname} = "Linux"; $osimgdef{$osimage}{osvers} = $osver; $osimgdef{$osimage}{osdistroname} = "$osver-$arch"; + + $osimgdef{$osimage}{rootimgdir} = $sysclone_home . "/images/" . $osimage; + my $imagedir = $osimgdef{$osimage}{rootimgdir}; + $imagedir =~ s/^(\/.*)\/.+\/?$/$1/; + $imagedir =~ s/\//\\\\\//g; + $imagedir = "DEFAULT_IMAGE_DIR = ".$imagedir; + my $olddir = `more /etc/systemimager/systemimager.conf |grep DEFAULT_IMAGE_DIR`; + $olddir =~ s/\//\\\\\//g; + chomp($olddir); + my $cmd= "sed -i \"s/$olddir/$imagedir/\" /etc/systemimager/systemimager.conf"; + my $rc = `$cmd`; + #$osimgdef{$osimage}{pkgdir} = "/install/$osver/$arch"; #$osimgdef{$osimage}{otherpkgdir} = "/install/post/otherpkgs/$osver/$arch"; } From a5cf74fa664ae346b977b8dd3ffeafa777a7fffe Mon Sep 17 00:00:00 2001 From: huweihua Date: Tue, 10 Jun 2014 05:07:59 -0400 Subject: [PATCH 86/99] add rootimgdir attr for sysclone osimage definition --- xCAT-server/lib/xcat/plugins/anaconda.pm | 37 +++++++++++++++++++++--- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/anaconda.pm b/xCAT-server/lib/xcat/plugins/anaconda.pm index 7ac9f7c61..863ef8302 100644 --- a/xCAT-server/lib/xcat/plugins/anaconda.pm +++ b/xCAT-server/lib/xcat/plugins/anaconda.pm @@ -1978,12 +1978,41 @@ sub mksysclone } my $cmd =qq{echo "$node:compute:$imagename:" >> $clusterfile}; - my $out = xCAT::Utils->runcmd($cmd, -1); + my $rc = xCAT::Utils->runcmd($cmd, -1); + + my $imagedir; + my $osimagetab = xCAT::Table->new('linuximage'); + my $osimageentry = $osimagetab->getAttribs({imagename => $imagename}, 'rootimgdir'); + if($osimageentry){ + $imagedir = $osimageentry->{rootimgdir}; + $imagedir =~ s/^(\/.*)\/.+\/?$/$1/; + }else{ + $imagedir = "$installroot/sysclone/images"; + $cmd = "chdef -t osimage $imagename rootimgdir=$imagedir/$imagename"; + $rc = `$cmd`; + } + + my $cfgimagedir = `cat /etc/systemimager/rsync_stubs/40$imagename|grep path`; + chomp($cfgimagedir); + $cfgimagedir =~ s/^\s+path=(\/.*)\/.+$/$1/g; + + if($imagedir ne $cfgimagedir){ + my $oldstr = `cat /etc/systemimager/rsync_stubs/40$imagename|grep path`; + chomp($oldstr); + $oldstr =~ s/\//\\\\\//g; - unless (-r "$installroot/sysclone/images/$imagename/opt/xcat/xcatdsklspost") + my $targetstr="\tpath=".$imagedir."/".$imagename; + $targetstr =~ s/\//\\\\\//g; + $cmd= "sed -i \"s/$oldstr/$targetstr/\" /etc/systemimager/rsync_stubs/40$imagename"; + $rc = `$cmd`; + } + + $rc = `export PERL5LIB=/usr/lib/perl5/site_perl/;LANG=C si_mkrsyncd_conf`; + + unless (-r "$imagedir/$imagename/opt/xcat/xcatdsklspost") { - mkpath("$installroot/sysclone/images/$imagename/opt/xcat/"); - copy("$installroot/postscripts/xcatdsklspost","$installroot/sysclone/images/$imagename/opt/xcat/"); + mkpath("$imagedir/$imagename/opt/xcat/"); + copy("$installroot/postscripts/xcatdsklspost","$imagedir/$imagename/opt/xcat/"); } } From b9bee92289530421a399cf83927c44b285fac9fc Mon Sep 17 00:00:00 2001 From: mellor Date: Tue, 10 Jun 2014 08:53:14 -0400 Subject: [PATCH 87/99] defect 4035 fix merge error in previous checkin to handle multiple servicenode entries --- xCAT-server/lib/xcat/plugins/mic.pm | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/xCAT-server/lib/xcat/plugins/mic.pm b/xCAT-server/lib/xcat/plugins/mic.pm index 6da7c7395..add9c0726 100644 --- a/xCAT-server/lib/xcat/plugins/mic.pm +++ b/xCAT-server/lib/xcat/plugins/mic.pm @@ -4,11 +4,13 @@ # This plugin is used to handle the command requests for Xeon Phi (mic) support # + package xCAT_plugin::mic; BEGIN { $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat'; } +use lib "$::XCATROOT/lib/perl"; use strict; use Getopt::Long; @@ -612,6 +614,11 @@ sub rflash { # run the cmd on the host to flash the mic my @args = ("-s", "-v", "-e"); push @args, "$::XCATROOT/sbin/flashmic"; + my $master = $request->{'_xcatdest'}; + # in case there are multiple servicenode entries, assume the first entry + # is the master + ($master) = split (/,/,$master); + # assume that all hosts are on the same network connected to this master # (otherwise, will need to move this call into loop above for each host # and build separate miccfg calls for each unique returned value from @@ -630,7 +637,6 @@ sub rflash { return; } -} push @args, ("-m", "$master"); push @args, ("-p", "$tftpdir/xcat/miccfg"); @@ -930,6 +936,11 @@ sub nodeset { # run the cmd on the host to configure the mic my @args = ("-s", "-v", "-e"); push @args, "$::XCATROOT/sbin/configmic"; + my $master = $request->{'_xcatdest'}; + # in case there are multiple servicenode entries, assume the first entry + # is the master + ($master) = split (/,/,$master); + # assume that all hosts are on the same network connected to this master # (otherwise, will need to move this call into loop above for each host # and build separate miccfg calls for each unique returned value from From 0b4e207e737a028eb15a218390f797777a3861d0 Mon Sep 17 00:00:00 2001 From: immarvin Date: Tue, 10 Jun 2014 06:11:07 -0700 Subject: [PATCH 88/99] replace service stuff with newly added subrotines in xCAT::Utils --- perl-xCAT/xCAT/Utils.pm | 6 +- xCAT-server/lib/xcat/monitoring/nagiosmon.pm | 6 +- xCAT-server/lib/xcat/monitoring/rrdutil.pm | 6 +- xCAT-server/lib/xcat/plugins/AAsn.pm | 170 ++++++++++++------- xCAT-server/lib/xcat/plugins/anaconda.pm | 8 +- xCAT-server/lib/xcat/plugins/ddns.pm | 71 +++++--- xCAT-server/lib/xcat/plugins/dhcp.pm | 60 ++++--- xCAT-server/lib/xcat/plugins/nimol.pm | 9 +- xCAT-server/lib/xcat/plugins/sles.pm | 8 +- xCAT-server/sbin/xcatconfig | 4 +- 10 files changed, 221 insertions(+), 127 deletions(-) diff --git a/perl-xCAT/xCAT/Utils.pm b/perl-xCAT/xCAT/Utils.pm index 4dbaef123..12fb29ff0 100644 --- a/perl-xCAT/xCAT/Utils.pm +++ b/perl-xCAT/xCAT/Utils.pm @@ -1850,7 +1850,9 @@ sub get_image_name Example: if (xCAT::Utils->startService("named") { ...} Comments: - none + this subroutine is deprecated, + will be used as an internal function to process AIX service, + for linux, use xCAT::Utils->startservice instead =cut @@ -3557,7 +3559,7 @@ sub servicemap{ # } my %svchash=( "dhcp" => { - 0=>["dhcpd","isc-dhcp-server"], + 0=>["dhcp3-server","dhcpd","isc-dhcp-server"], 1=>["dhcpd.service"], }, "nfs" => { diff --git a/xCAT-server/lib/xcat/monitoring/nagiosmon.pm b/xCAT-server/lib/xcat/monitoring/nagiosmon.pm index 24ded6ddd..4f0acb8cc 100644 --- a/xCAT-server/lib/xcat/monitoring/nagiosmon.pm +++ b/xCAT-server/lib/xcat/monitoring/nagiosmon.pm @@ -66,12 +66,14 @@ sub start { my $mychildren_cfg="/etc/nagios/objects/mychildren.cfg"; if ($isSN) { #start nagios daemon only when mychildren exists on the sn if (-f $mychildren_cfg) { - my $rc=`service nagios restart 2>&1`; + #my $rc=`service nagios restart 2>&1`; + my $rc=xCAT::Utils->restartservice("nagios"); reportError("$localhostname: $rc", $callback); } } else { #always start nagios daemon on mn - my $rc=`service nagios restart 2>&1`; + #my $rc=`service nagios restart 2>&1`; + my $rc=xCAT::Utils->restartservice("nagios"); reportError("$localhostname: $rc", $callback); } diff --git a/xCAT-server/lib/xcat/monitoring/rrdutil.pm b/xCAT-server/lib/xcat/monitoring/rrdutil.pm index 840615203..57c25ddd5 100755 --- a/xCAT-server/lib/xcat/monitoring/rrdutil.pm +++ b/xCAT-server/lib/xcat/monitoring/rrdutil.pm @@ -122,7 +122,8 @@ sub start_RRD_server print FILE "\tserver_args = - /var/rrd\n"; print FILE "}\n"; close FILE; - xCAT::Utils->runcmd("service xinetd restart", 0); + #xCAT::Utils->runcmd("service xinetd restart", 0); + xCAT::Utils->restartservice("xinetd"); } return 0; } @@ -188,7 +189,8 @@ sub stop_RRD_server } else { xCAT::Utils->runcmd("rm -f /etc/xinetd.d/rrdsrv", 0); } - xCAT::Utils->runcmd("service xinetd restart", 0); + #xCAT::Utils->runcmd("service xinetd restart", 0); + xCAT::Utils->restartservice("xinetd"); } return 0; } diff --git a/xCAT-server/lib/xcat/plugins/AAsn.pm b/xCAT-server/lib/xcat/plugins/AAsn.pm index f06ded0b0..540e0bdce 100755 --- a/xCAT-server/lib/xcat/plugins/AAsn.pm +++ b/xCAT-server/lib/xcat/plugins/AAsn.pm @@ -509,8 +509,13 @@ sub setup_CONS "conserver cannot be started because the file $ca_file2 cannot be found\n"; } else - { - my $rc = xCAT::Utils->startService("conserver"); + { + if (xCAT::Utils->isAIX()){ + $rc=xCAT::Utils->startService("conserver"); + }elsif(xCAT::Utils->isLinux()){ + #my $rc = xCAT::Utils->startService("conserver"); + $rc=xCAT::Utils->startservice("conserver"); + } if ($rc != 0) { return 1; @@ -537,9 +542,11 @@ sub setup_DHCP my $snonly = 0; # if on the MN check to see if dhcpd is running, and start it if not. if (xCAT::Utils->isMN()) { # on the MN - my @output = xCAT::Utils->runcmd("service dhcpd status", -1); - if ($::RUNCMD_RC != 0) { # not running - $rc = xCAT::Utils->startService("dhcpd"); + #my @output = xCAT::Utils->runcmd("service dhcpd status", -1); + #if ($::RUNCMD_RC != 0) { # not running + my $retcode= xCAT::Utils->checkservicestatus("dhcpd"); + if($retcode!=0){ + $rc = xCAT::Utils->startservice("dhcpd"); if ($rc != 0) { return 1; @@ -573,12 +580,18 @@ sub setup_DHCP ->($cmdref, \&xCAT::Client::handle_response); my $distro = xCAT::Utils->osver(); - my $serv = "dhcpd"; - if ( $distro =~ /ubuntu.*/i || $distro =~ /debian.*/i ){ - $serv = "isc-dhcp-server"; - } + #my $serv = "dhcpd"; + #if ( $distro =~ /ubuntu.*/i || $distro =~ /debian.*/i ){ + # $serv = "isc-dhcp-server"; + #} - my $rc = xCAT::Utils->startService($serv); + #my $rc = xCAT::Utils->startService($serv); + my $rc=0; + if(xCAT::Utils->isAIX()){ + $rc = xCAT::Utils->startService("dhcpd"); + } elsif(xCAT::Utils->isLinux()){ + $rc = xCAT::Utils->startservice("dhcp"); + } if ($rc != 0) { return 1; @@ -672,7 +685,13 @@ sub setup_FTP # start ftp - my $rc = xCAT::Utils->startService("vsftpd"); + #my $rc = xCAT::Utils->startService("vsftpd"); + my $rc = 0; + if(xCAT::Utils->isAIX()){ + $rc = xCAT::Utils->startService("vsftpd"); + }elsif(xCAT::Utils->isLinux()){ + $rc = xCAT::Utils->startservice("vsftpd"); + } if ($rc != 0) { return 1; @@ -723,12 +742,19 @@ sub setup_DNS # turn DNS on my $distro = xCAT::Utils->osver(); - my $serv = "named"; - if ( $distro =~ /ubuntu.*/i || $distro =~ /debian.*/i ){ - $serv = "bind9"; + #my $serv = "named"; + #if ( $distro =~ /ubuntu.*/i || $distro =~ /debian.*/i ){ + # $serv = "bind9"; + #} + + #my $rc = xCAT::Utils->startService($serv); + my $rc = 0; + if(xCAT::Utils->isAIX()){ + $rc = xCAT::Utils->startService("named"); + }elsif(xCAT::Utils->isLinux()){ + $rc=xCAT::Utils->startservice("named"); } - my $rc = xCAT::Utils->startService($serv); if ($rc != 0) { return 1; @@ -751,15 +777,17 @@ sub setup_DNS else { #chkconfig - my $cmd = "/sbin/chkconfig $serv on"; - my $outref = xCAT::Utils->runcmd("$cmd", 0); - if ($::RUNCMD_RC != 0) + #my $cmd = "/sbin/chkconfig $serv on"; + #my $outref = xCAT::Utils->runcmd("$cmd", 0); + #if ($::RUNCMD_RC != 0) + my $retcode=xCAT::Utils->enableservice("named"); + if($retcode!=0) { - xCAT::MsgUtils->message("SE", " Error: Could not enable $serv."); + xCAT::MsgUtils->message("SE", " Error: Could not enable dns server."); } else { - xCAT::MsgUtils->message("SI", " $serv has been enabled on boot."); + xCAT::MsgUtils->message("SI", " dns server has been enabled on boot."); } } @@ -778,7 +806,14 @@ sub setup_DNS sub setup_LDAP { - my $rc = xCAT::Utils->startService("ldap"); + #my $rc = xCAT::Utils->startService("ldap"); + my $rc = 0; + + if(xCAT::Utils->isAIX()){ + $rc = xCAT::Utils->startService("ldap"); + }elsif(xCAT::Utils->isLinux()){ + $rc=xCAT::Utils->startservice("ldap"); + } if ($rc != 0) { return 1; @@ -805,16 +840,17 @@ sub setup_NFS my $rc = 0; if (xCAT::Utils->isLinux()) { - my $os = xCAT::Utils->osver(); - if ($os =~ /sles.*/) - { - $rc = xCAT::Utils->startService("nfs"); - $rc = xCAT::Utils->startService("nfsserver"); - } - else - { - $rc = xCAT::Utils->startService("nfs"); - } + #my $os = xCAT::Utils->osver(); + #if ($os =~ /sles.*/) + #{ + # $rc = xCAT::Utils->startService("nfs"); + # $rc = xCAT::Utils->startService("nfsserver"); + #} + #else + #{ + # $rc = xCAT::Utils->startService("nfs"); + #} + $rc = xCAT::Utils->startservice("nfs"); } else { #AIX @@ -944,7 +980,14 @@ sub setup_NTPmn sub start_NTP { - my $rc = xCAT::Utils->startService("ntpd"); + my $rc =0; + if (xCAT::Utils->isAIX()){ + $rc=xCAT::Utils->startService("ntpd"); + }elsif(xCAT::Utils->isLinux()){ + #my $rc = xCAT::Utils->startService("conserver"); + $rc=xCAT::Utils->startservice("ntpd"); + } + if ($rc != 0) { return 1; @@ -1271,15 +1314,16 @@ sub setup_HTTP if (xCAT::Utils->isLinux()) { - my $os = xCAT::Utils->osver(); - if ($os =~ /sles.*/) - { - $rc = xCAT::Utils->startService("apache2"); - } - else - { - $rc = xCAT::Utils->startService("httpd"); - } + #my $os = xCAT::Utils->osver(); + #if ($os =~ /sles.*/) + #{ + # $rc = xCAT::Utils->startService("apache2"); + #} + #else + #{ + # $rc = xCAT::Utils->startService("httpd"); + #} + $rc=xCAT::Utils->startservice("http"); } return $rc; } @@ -1385,24 +1429,33 @@ sub enable_TFTPhpa } print FILE @newcfgfile; close (FILE); - my @output = xCAT::Utils->runcmd("service xinetd status", -1); - if ($::RUNCMD_RC == 0) { - if (grep(/running/, @output)) - { - print ' '; # indent service output to separate it from the xcatd service output - system "service xinetd stop"; - if ($? > 0) - { # error + #my @output = xCAT::Utils->runcmd("service xinetd status", -1); + #if ($::RUNCMD_RC == 0) {} + my $retcode=xCAT::Utils->checkservicestatus("xinetd"); + if($retcode==0){ + my $retcode=xCAT::Utils->restartservice("xinetd"); + if($retcode !=0 ) + { xCAT::MsgUtils->message("S", - "Error on command: service xinetd stop\n"); + "Error on restart xinetd\n"); + } - system "service xinetd start"; - if ($? > 0) - { # error - xCAT::MsgUtils->message("S", - "Error on command: service xinetd start\n"); - } - } + #if (grep(/running/, @output)) + #{ + # print ' '; # indent service output to separate it from the xcatd service output + # system "service xinetd stop"; + # if ($? > 0) + # { # error + # xCAT::MsgUtils->message("S", + # "Error on command: service xinetd stop\n"); + # } + # system "service xinetd start"; + # if ($? > 0) + # { # error + # xCAT::MsgUtils->message("S", + # "Error on command: service xinetd start\n"); + # } + #} } } } @@ -1449,7 +1502,8 @@ sub enable_TFTPhpa sleep 1; my @checkproc=`ps axf|grep -v grep|grep in.tftpd`; if (@checkproc){ - system("service tftpd-hpa stop"); + #system("service tftpd-hpa stop"); + xCAT::Utils->stopservice("tftpd-hpa"); } } my @tftpprocs=`ps axf|grep -v grep|grep in.tftpd`; diff --git a/xCAT-server/lib/xcat/plugins/anaconda.pm b/xCAT-server/lib/xcat/plugins/anaconda.pm index 863ef8302..96fb59291 100644 --- a/xCAT-server/lib/xcat/plugins/anaconda.pm +++ b/xCAT-server/lib/xcat/plugins/anaconda.pm @@ -2018,9 +2018,11 @@ sub mksysclone } # check systemimager-server-rsyncd to make sure it's running. - my $out = xCAT::Utils->runcmd("service systemimager-server-rsyncd status", -1); - if ($::RUNCMD_RC != 0) { # not running - my $rc = xCAT::Utils->startService("systemimager-server-rsyncd"); + #my $out = xCAT::Utils->runcmd("service systemimager-server-rsyncd status", -1); + # if ($::RUNCMD_RC != 0) { # not running + my $retcode=xCAT::Utils->checkservicestatus("systemimager-server-rsyncd"); + if($retcode!=0){ + my $rc = xCAT::Utils->startservice("systemimager-server-rsyncd"); if ($rc != 0) { return 1; } diff --git a/xCAT-server/lib/xcat/plugins/ddns.pm b/xCAT-server/lib/xcat/plugins/ddns.pm index ddda1a6a8..58c5659f6 100755 --- a/xCAT-server/lib/xcat/plugins/ddns.pm +++ b/xCAT-server/lib/xcat/plugins/ddns.pm @@ -571,7 +571,8 @@ sub process_request { } else { - system("service $service stop"); #named may otherwise hold on to stale journal filehandles + #system("service $service stop"); #named may otherwise hold on to stale journal filehandles + xCAT::Utils->stopservice("named"); } my $conf = get_conf(); unlink $conf; @@ -614,24 +615,31 @@ sub process_request { } else { - my $cmd = "service $service stop"; - my @output=xCAT::Utils->runcmd($cmd, 0); - my $outp = join('', @output); - if ($::RUNCMD_RC != 0) - { - my $rsp = {}; - $rsp->{data}->[0] = "Command failed: $cmd. Error message: $outp.\n"; - xCAT::MsgUtils->message("E", $rsp, $callback); - return; - } + #my $cmd = "service $service stop"; + #my @output=xCAT::Utils->runcmd($cmd, 0); + #my $outp = join('', @output); + #if ($::RUNCMD_RC != 0) + #{ + # my $rsp = {}; + # $rsp->{data}->[0] = "Command failed: $cmd. Error message: $outp.\n"; + # xCAT::MsgUtils->message("E", $rsp, $callback); + # return; + #} - $cmd = "service $service start"; - @output=xCAT::Utils->runcmd($cmd, 0); - $outp = join('', @output); - if ($::RUNCMD_RC != 0) - { + #$cmd = "service $service start"; + #@output=xCAT::Utils->runcmd($cmd, 0); + #$outp = join('', @output); + #if ($::RUNCMD_RC != 0) + #{ + # my $rsp = {}; + # $rsp->{data}->[0] = "Command failed: $cmd. Error message: $outp.\n"; + # xCAT::MsgUtils->message("E", $rsp, $callback); + # return; + #} + my $retcode=xCAT::Utils->restartservice("named"); + if($retcode!=0){ my $rsp = {}; - $rsp->{data}->[0] = "Command failed: $cmd. Error message: $outp.\n"; + $rsp->{data}->[0] = "failed to start named.\n"; xCAT::MsgUtils->message("E", $rsp, $callback); return; } @@ -673,20 +681,29 @@ sub process_request { } else { - my $cmd = "service $service status|grep running"; - my @output=xCAT::Utils->runcmd($cmd, 0); - if ($::RUNCMD_RC != 0) + #my $cmd = "service $service status|grep running"; + #my @output=xCAT::Utils->runcmd($cmd, 0); + #if ($::RUNCMD_RC != 0) + #{ + # $cmd = "service $service start"; + # @output=xCAT::Utils->runcmd($cmd, 0); + # my $outp = join('', @output); + # if ($::RUNCMD_RC != 0) + # { + # my $rsp = {}; + # $rsp->{data}->[0] = "Command failed: $cmd. Error message: $outp.\n"; + # xCAT::MsgUtils->message("E", $rsp, $callback); + # return; + # } + #} + my $retcode=xCAT::Utils->startservice("named"); + if($retcode!=0) { - $cmd = "service $service start"; - @output=xCAT::Utils->runcmd($cmd, 0); - my $outp = join('', @output); - if ($::RUNCMD_RC != 0) - { my $rsp = {}; - $rsp->{data}->[0] = "Command failed: $cmd. Error message: $outp.\n"; + $rsp->{data}->[0] = "failed to start named.\n"; xCAT::MsgUtils->message("E", $rsp, $callback); return; - } + } } } diff --git a/xCAT-server/lib/xcat/plugins/dhcp.pm b/xCAT-server/lib/xcat/plugins/dhcp.pm index 22c6dcdb6..150dd4955 100755 --- a/xCAT-server/lib/xcat/plugins/dhcp.pm +++ b/xCAT-server/lib/xcat/plugins/dhcp.pm @@ -884,15 +884,19 @@ sub check_options # if not help and not -n, dhcpd needs to be running if (!($opt->{h})&& (!($opt->{n}))) { if (xCAT::Utils->isLinux()) { - my $DHCPSERVER="dhcpd"; - if( -e "/etc/init.d/isc-dhcp-server" ){ - $DHCPSERVER="isc-dhcp-server"; - } + #my $DHCPSERVER="dhcpd"; + #if( -e "/etc/init.d/isc-dhcp-server" ){ + # $DHCPSERVER="isc-dhcp-server"; + #} - my @output = xCAT::Utils->runcmd("service $DHCPSERVER status", -1); - if ($::RUNCMD_RC != 0) { # not running + #my @output = xCAT::Utils->runcmd("service $DHCPSERVER status", -1); + #if ($::RUNCMD_RC != 0) { # not running + my $ret=0; + $ret=xCAT::Utils->checkservicestatus("dhcp"); + if($ret!=0) + { my $rsp = {}; - $rsp->{data}->[0] = "$DHCPSERVER is not running. Run service $DHCPSERVER start and rerun your command."; + $rsp->{data}->[0] = "dhcp server is not running. please start the dhcp server."; xCAT::MsgUtils->message("E", $rsp, $callback, 1); return 1; } @@ -1840,25 +1844,29 @@ sub process_request { restart_dhcpd_aix(); } - elsif ( $distro =~ /ubuntu.*/ || $distro =~ /debian.*/i) - { - if (-e '/etc/dhcp/dhcpd.conf') { - system("chmod a+r /etc/dhcp/dhcpd.conf"); - system("/etc/init.d/isc-dhcp-server restart"); - } - else { - #ubuntu config - system("chmod a+r /etc/dhcp3/dhcpd.conf"); - system("/etc/init.d/dhcp3-server restart"); - } - } - else - { - system("/etc/init.d/dhcpd restart"); - # should not chkconfig dhcpd on every makedhcp invoation - # it is not appropriate and will cause problem for HAMN - # do it in xcatconfig instead - #system("chkconfig dhcpd on"); + else { + if ( $distro =~ /ubuntu.*/ || $distro =~ /debian.*/i) + { + if (-e '/etc/dhcp/dhcpd.conf') { + system("chmod a+r /etc/dhcp/dhcpd.conf"); + #system("/etc/init.d/isc-dhcp-server restart"); + } + else { + #ubuntu config + system("chmod a+r /etc/dhcp3/dhcpd.conf"); + #system("/etc/init.d/dhcp3-server restart"); + } + } + #else + #{ + # system("/etc/init.d/dhcpd restart"); + # # should not chkconfig dhcpd on every makedhcp invoation + # # it is not appropriate and will cause problem for HAMN + # # do it in xcatconfig instead + # #system("chkconfig dhcpd on"); + #} + xCAT::Utils->restartservice("dhcp"); + print "xx"; } } flock($dhcplockfd,LOCK_UN); diff --git a/xCAT-server/lib/xcat/plugins/nimol.pm b/xCAT-server/lib/xcat/plugins/nimol.pm index afc2a9336..46f206364 100644 --- a/xCAT-server/lib/xcat/plugins/nimol.pm +++ b/xCAT-server/lib/xcat/plugins/nimol.pm @@ -25,6 +25,7 @@ Getopt::Long::Configure("pass_through"); use xCAT::Table; use xCAT::MsgUtils; use xCAT::DBobjUtils; +use xCAT::Utils; sub handled_commands { return { @@ -376,7 +377,9 @@ sub update_export { for my $l (@new_export) { print $new_export_fd $l; } flock($new_export_fd,LOCK_UN); close($new_export_fd); - system("service nfs restart"); + #system("service nfs restart"); + my $retcode=xCAT::Utils->restartservice("nfs"); + return $retcode; } sub update_syslog { @@ -391,7 +394,9 @@ sub update_syslog { open($new_syslog_fd, ">>", "/etc/exports"); print $new_syslog_fd "local2.* /var/log/nimol.log\n"; close($new_syslog_fd); - system("service rsyslog restart"); + #system("service rsyslog restart"); + my $retcode=xCAT::Utils->restartservice("rsyslog"); + return $retcode; } else { print "Don't need to update syslog configure file.\n"; } diff --git a/xCAT-server/lib/xcat/plugins/sles.pm b/xCAT-server/lib/xcat/plugins/sles.pm index 786dcbfd0..0f69e07b7 100755 --- a/xCAT-server/lib/xcat/plugins/sles.pm +++ b/xCAT-server/lib/xcat/plugins/sles.pm @@ -1521,9 +1521,11 @@ sub mksysclone } # check systemimager-server-rsyncd to make sure it's running. - my $out = xCAT::Utils->runcmd("service systemimager-server-rsyncd status", -1); - if ($::RUNCMD_RC != 0) { # not running - my $rc = xCAT::Utils->startService("systemimager-server-rsyncd"); + #my $out = xCAT::Utils->runcmd("service systemimager-server-rsyncd status", -1); + #if ($::RUNCMD_RC != 0) { # not running + my $retcode=xCAT::Utils->checkservicestatus("systemimager-server-rsyncd"); + if($retcode !=0){ + my $rc = xCAT::Utils->startservice("systemimager-server-rsyncd"); if ($rc != 0) { return 1; } diff --git a/xCAT-server/sbin/xcatconfig b/xCAT-server/sbin/xcatconfig index 2abb7f7fe..096e70cee 100755 --- a/xCAT-server/sbin/xcatconfig +++ b/xCAT-server/sbin/xcatconfig @@ -453,8 +453,8 @@ if ($::INITIALINSTALL || $::FORCE) &setuphttp; # chkconfig dhcpd on - system("chkconfig dhcpd on"); - + #system("chkconfig dhcpd on"); + xCAT::Utils->enableservice("dhcp"); # Turn off selinux on RedHat if (-f "/etc/redhat-release") From 5065feab5abd5eb7f23274db1f7c60b99fbe164a Mon Sep 17 00:00:00 2001 From: immarvin Date: Tue, 10 Jun 2014 08:54:31 -0700 Subject: [PATCH 89/99] replace the service/chkconfig related stuff with newly added subroutine in xCAT::Utils --- xCAT/postscripts/config_chef_server | 12 +++++-- xCAT/postscripts/configfirewall | 34 ++++++++++++------ xCAT/postscripts/configib | 27 +++++++++----- xCAT/postscripts/enablekdump | 11 ++++-- xCAT/postscripts/install_puppet_server | 10 ++++-- xCAT/postscripts/remoteshell | 12 +++++-- xCAT/postscripts/setupntp | 50 ++++++++++++++++---------- xCAT/postscripts/sudoer | 17 ++++++--- xCAT/postscripts/syslog | 32 ++++++++++------- xCAT/postscripts/xcatlib.sh | 11 +++++- 10 files changed, 152 insertions(+), 64 deletions(-) diff --git a/xCAT/postscripts/config_chef_server b/xCAT/postscripts/config_chef_server index b1ac1ce15..b1bb266ca 100755 --- a/xCAT/postscripts/config_chef_server +++ b/xCAT/postscripts/config_chef_server @@ -2,6 +2,12 @@ # IBM(c) 2013 EPL license http://www.eclipse.org/legal/epl-v10.html + +str_dir_name=`dirname $0` + +. $str_dir_name/xcatlib.sh + + #------------------------------------------------------------------------------- #=head1 configure_chef_server #=head2 This command configures the chef server on a xCAT node. @@ -35,7 +41,8 @@ then then echo -e "\n/etc/chef-server *(rw,no_root_squash,sync,no_subtree_check)\n" >> /etc/exports fi - sudo /etc/init.d/nfs-kernel-server restart + #sudo /etc/init.d/nfs-kernel-server restart + sudo restartservice nfs-kernel-server if [ $? -ne 0 ] then errmsg="Failed to run sudo /etc/init.d/nfs-kernel-server restart on $node" @@ -43,7 +50,8 @@ then echo $errmsg exit 1 fi - service portmap restart + #service portmap restart + startservice portmap if [ $? -ne 0 ] then errmsg="Failed to run service portmap restart on $node" diff --git a/xCAT/postscripts/configfirewall b/xCAT/postscripts/configfirewall index ddd864794..22a5bf5e6 100755 --- a/xCAT/postscripts/configfirewall +++ b/xCAT/postscripts/configfirewall @@ -1,8 +1,16 @@ #!/usr/bin/perl +BEGIN +{ + $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat'; +} +use lib "$::XCATROOT/lib/perl"; + use strict; use Getopt::Long; +use xCAT::Utils; + Getopt::Long::Configure("bundling"); $Getopt::Long::ignorecase = 0; @@ -83,12 +91,14 @@ if (-f "/etc/redhat-release") system($cmd); # restart iptables - $cmd = "service iptables restart"; - system($cmd); + #$cmd = "service iptables restart"; + #system($cmd); + xCAT::Utils->restartservice("firewall"); # iptables should be stared on reboot - $cmd = "chkconfig iptables on"; - system($cmd); + #$cmd = "chkconfig iptables on"; + #system($cmd); + xCAT::Utils->enableservice("firewall"); } elsif (-f "/etc/SuSE-release") { @@ -129,14 +139,18 @@ elsif (-f "/etc/SuSE-release") close(CONFFILE); # restart firewall - my $cmd = "service SuSEfirewall2_setup restart"; - system($cmd); + #my $cmd = "service SuSEfirewall2_setup restart"; + #system($cmd); + xCAT::Utils->restartservice("SuSEfirewall2_setup"); # SuSEfirewall2_setup should be stared on reboot - $cmd = "chkconfig SuSEfirewall2_init on"; - system($cmd); - $cmd = "chkconfig SuSEfirewall2_setup on"; - system($cmd); + #$cmd = "chkconfig SuSEfirewall2_init on"; + #system($cmd); + #$cmd = "chkconfig SuSEfirewall2_setup on"; + #system($cmd); + xCAT::Utils->enableservice("SuSEfirewall2_init"); + xCAT::Utils->enableservice("SuSEfirewall2_setup"); + } else { diff --git a/xCAT/postscripts/configib b/xCAT/postscripts/configib index da721559e..905cbe351 100755 --- a/xCAT/postscripts/configib +++ b/xCAT/postscripts/configib @@ -18,6 +18,10 @@ # NETWORKS_LINE3='netname=ib3||net=15.0.3.0||mask=255.255.255.0||mgtifname=||gateway=||dhcpserver=||tftpserver=||nameservers=||ntpservers=||logservers=||dynamicrange=||staticrange=||staticrangeincrement=||nodehostname=||ddnsdomain=||vlanid=||domain=||disable=||comments=' +str_dir_name=`dirname $0` + +. $str_dir_name/xcatlib.sh + #This is the number of ports for each ib adpator. portnum=1 if [ -n "$NIC_IBAPORTS" ]; then @@ -68,15 +72,19 @@ PLTFRM=`uname` if [[ $OSVER == rhels5* || "$OSVER" == rhels6* ]] then ib_driver="rdma" - /sbin/service $ib_driver status - if [ $? -eq 1 ] + #/sbin/service $ib_driver status + checkservicestatus $ib_driver + #if [ $? -eq 1 ] + if [ $? -ne 0 ] then ib_driver="openibd" - /sbin/service $ib_driver status - if [ $? -eq 1 ] + #/sbin/service $ib_driver status + checkservicestatus $ib_driver + #if [ $? -eq 1 ] + if [ $? -ne 0 ] then echo "Not found the driver dameon: rdma or openibd" - logger -p local4.info -t xcat "Not found the driver dameon: rdma or openibd" + logger -p local4.info -t xcat "Not found the driver dameon: rdma or openibd" exit fi fi @@ -111,8 +119,10 @@ then echo "$TMP3" > /etc/modprobe.conf echo 'options ib_ehca lock_hcalls=0' >> /etc/modprobe.conf fi - /sbin/chkconfig --level 2345 $ib_driver on > /dev/null 2>&1 - /sbin/service $ib_driver restart + #/sbin/chkconfig --level 2345 $ib_driver on > /dev/null 2>&1 + enableservice $ib_driver > /dev/null 2>&1 + #/sbin/service $ib_driver restart + restartservice $ib_driver sysctl -p fi @@ -490,7 +500,8 @@ done # end for nic if [ $PLTFRM == "Linux" ] then - /sbin/service $ib_driver restart + #/sbin/service $ib_driver restart + restartservice $ib_driver for nic in `echo "$goodnics" | tr "," "\n"` do sleep 5 diff --git a/xCAT/postscripts/enablekdump b/xCAT/postscripts/enablekdump index 92d628982..1c6ad2d92 100755 --- a/xCAT/postscripts/enablekdump +++ b/xCAT/postscripts/enablekdump @@ -3,6 +3,11 @@ #(C)IBM Corp # + +str_dir_name=`dirname $0` + +. $str_dir_name/xcatlib.sh + # create /etc/sysconfig/network-scripts/ pmatch () { @@ -175,7 +180,8 @@ EOF /usr/bin/find . | cpio -H newc -o|gzip -9 -c - > /boot/${KDUMPINIT} cd / /bin/rm -rf "/var/tmp/tempinit" - service kdump restart + #service kdump restart + restartservice kdump else /bin/mount -o nolock $KDIP:$KDPATH $MOUNTPATH KDTEMPPATH=${KDPATH//\//\\\/} @@ -208,7 +214,8 @@ EOF /bin/mount -o nolock $KDIP:$KDPATH $MOUNTPATH echo "net $KDIP:$KDPATH" > /etc/kdump.conf echo "link_delay 180" >> /etc/kdump.conf - /etc/init.d/kdump restart + #/etc/init.d/kdump restart + restartservice kdump fi fi fi diff --git a/xCAT/postscripts/install_puppet_server b/xCAT/postscripts/install_puppet_server index 2db004532..ac7cf9201 100755 --- a/xCAT/postscripts/install_puppet_server +++ b/xCAT/postscripts/install_puppet_server @@ -2,6 +2,10 @@ # IBM(c) 2013 EPL license http://www.eclipse.org/legal/epl-v10.html +str_dir_name=`dirname $0` + +. $str_dir_name/xcatlib.sh + #------------------------------------------------------------------------------- #=head1 install_puppet_server #=head2 This command installs the puppet server on a xCAT server or node. @@ -82,9 +86,11 @@ if [ "$os" == "Ubuntu" ]; then ${result}/config_puppet_server "$@" #restart puppet master - service puppetmaster stop + #service puppetmaster stop + stopservice puppetmaster kill $(ps auxww | grep puppet | grep master | grep -v grep | awk '{print $2}') - service puppetmaster start + #service puppetmaster start + startservice puppetmaster elif [ "$os" == "RedHat" ]; then echo "Puppet server installation with xCAT on RedHat is through a kit. Please refer to ... for details.". diff --git a/xCAT/postscripts/remoteshell b/xCAT/postscripts/remoteshell index 928e7bcf5..e411245a7 100755 --- a/xCAT/postscripts/remoteshell +++ b/xCAT/postscripts/remoteshell @@ -11,6 +11,12 @@ # id.rsa # # if on the Management Node, exit + + +str_dir_name=`dirname $0` + +. $str_dir_name/xcatlib.sh + if [ -e /etc/xCATMN ]; then logger -t xcat -p local4.info "remoteshell:Running on the Management Node , exiting " exit 0 @@ -376,10 +382,12 @@ then chmod 0755 /var/run/sshd /usr/sbin/sshd -f /etc/ssh/sshd_config else - service ssh restart + #service ssh restart + restartservice ssh fi else - service sshd restart + #service sshd restart + restartservice sshd fi kill -9 $CREDPID diff --git a/xCAT/postscripts/setupntp b/xCAT/postscripts/setupntp index f58595801..db75578b4 100755 --- a/xCAT/postscripts/setupntp +++ b/xCAT/postscripts/setupntp @@ -5,6 +5,12 @@ # setup NTP configuration on the compute nodes # #--------------------------------------------------------------------------- + + +str_dir_name=`dirname $0` + +. $str_dir_name/xcatlib.sh + # if on the Management Node, exit if [ -e /etc/xCATMN ]; then logger -t xcat -p local4.info "setupntp:Running on the Management Node , exiting " @@ -120,15 +126,17 @@ if [ $OS_TYPE = Linux ]; then disable auth restrict 127.0.0.1" >>$conf_file # default service for redhat/fedora - SERVICE=ntpd - if ( pmatch $OSVER "sles*" ) || ( pmatch $OSVER "suse*" ) || [ -f /etc/SuSE-release ] || ( pmatch $OSVER "ubuntu*" ) || ( is_lsb_ubuntu ); then - SERVICE=ntp - fi + #SERVICE=ntpd + #if ( pmatch $OSVER "sles*" ) || ( pmatch $OSVER "suse*" ) || [ -f /etc/SuSE-release ] || ( pmatch $OSVER "ubuntu*" ) || ( is_lsb_ubuntu ); then + # SERVICE=ntp + #fi #ntpdate/sntp conflict with ntpd, stop the service first - service $SERVICE status +# service $SERVICE status + checkservicestatus ntpserver if [ $? -eq 0 ];then - service $SERVICE stop +# service $SERVICE stop + stopservice ntpserver fi #ntpdate program is deprecated on SuSE if ( pmatch $OSVER "sles*" ) || ( pmatch $OSVER "suse*" ) || [ -f /etc/SuSE-release ]; then @@ -178,23 +186,27 @@ restrict 127.0.0.1" >>$conf_file echo "#!/bin/sh" > $cron_file echo "/sbin/hwclock --systohc --utc" >> $cron_file chmod a+x $cron_file - service cron restart + #service cron restart + restartservice cron fi fi - service $SERVICE start + #service $SERVICE start + startservice ntpserver #start ntp and crontab automaticlly - if [ -f "/etc/debian_version" ];then - update-rc.d cron defaults - update-rc.d $SERVICE defaults - else - chkconfig --add $SERVICE >/dev/null 2>&1 - chkconfig --level 345 $SERVICE on >/dev/null 2>&1 - if ( pmatch $OSVER "sles*" ) || ( pmatch $OSVER "suse*" ) || [ -f /etc/SuSE-release ];then - chkconfig --add cron >/dev/null 2>&1 - chkconfig --level 345 cron on >/dev/null 2>&1 - fi - fi + #if [ -f "/etc/debian_version" ];then + # update-rc.d cron defaults + # update-rc.d $SERVICE defaults + #else + # chkconfig --add $SERVICE >/dev/null 2>&1 + # chkconfig --level 345 $SERVICE on >/dev/null 2>&1 + # if ( pmatch $OSVER "sles*" ) || ( pmatch $OSVER "suse*" ) || [ -f /etc/SuSE-release ];then + # chkconfig --add cron >/dev/null 2>&1 + # chkconfig --level 345 cron on >/dev/null 2>&1 + # fi + #fi + enableservice cron + enableservice ntpserver else # stop and start AIX ntp echo "driftfile /etc/ntp.drift diff --git a/xCAT/postscripts/sudoer b/xCAT/postscripts/sudoer index 65c540c27..c15166c2d 100755 --- a/xCAT/postscripts/sudoer +++ b/xCAT/postscripts/sudoer @@ -7,6 +7,12 @@ # #------------------------------------------------------------------------------ + +str_dir_name=`dirname $0` + +. $str_dir_name/xcatlib.sh + + # Configuration for the sudoer SUDOER="xcat" SUDOERPW="rootpw" @@ -53,8 +59,9 @@ chown $SUDOER:users $HOME/.ssh/authorized_keys # Restart the SSHD for syncfiles postscript to do the sync work logger -t xCAT -p local4.info "Restarting SSHD" -if [ -f "/etc/debian_version" ];then - service ssh restart -else - service sshd restart -fi +#if [ -f "/etc/debian_version" ];then +# service ssh restart +#else +# service sshd restart +#fi +restartservice ssh diff --git a/xCAT/postscripts/syslog b/xCAT/postscripts/syslog index bab90406a..41ddbe389 100755 --- a/xCAT/postscripts/syslog +++ b/xCAT/postscripts/syslog @@ -14,6 +14,11 @@ #=cut #------------------------------------------------------------------------------- + +str_dir_name=`dirname $0` + +. $str_dir_name/xcatlib.sh + master=$MASTER conf_file="/etc/syslog.conf" sysconfig="/etc/sysconfig/syslog" @@ -23,7 +28,7 @@ isSN=0 isLinux=1 isRsyslog=0 isC3=0 -systemdEnabled=0 +#systemdEnabled=0 # pmatch determines if 1st argument string is matched by 2nd argument pattern pmatch () @@ -115,19 +120,19 @@ if [ "$NTYPE" = service ]; then isSN=1 fi -if [ -e /etc/systemd ]; then - systemdEnabled=1 -fi +#if [ -e /etc/systemd ]; then +# systemdEnabled=1 +#fi if [ "$(uname -s)" = "Linux" ]; then if ( pmatch $OSVER "fedora*" ) || ( pmatch $OSVER "rhels5*" ) || ( pmatch $OSVER "rhel6*" ) || ( pmatch $OSVER "rhels6*" ) || [ -f /etc/fedora-release ] || [ -f /etc/redhat-release ] || ( pmatch $OSVER "ubuntu*" ) || ( is_lsb_ubuntu ) || ( pmatch $OSVER "debian*" ); then if [ -e /etc/rsyslog.conf ]; then conf_file="/etc/rsyslog.conf" sysconfig="/etc/sysconfig/rsyslog" - init="/etc/init.d/rsyslog" - if [ $systemdEnabled -eq 1 ]; then - init="rsyslog" - fi + #init="/etc/init.d/rsyslog" + #if [ $systemdEnabled -eq 1 ]; then + # init="rsyslog" + #fi isRsyslog=1 if ( pmatch $OSVER "ubuntu*" ) || ( is_lsb_ubuntu ) || ( pmatch $OSVER "debian*" ); then sysconfig="/etc/default/rsyslog" @@ -328,11 +333,12 @@ if [ $isLinux -eq 0 ]; then fi done else - if [ $systemdEnabled -eq 1 ]; then - systemctl restart $init.service - else - $init restart - fi + #if [ $systemdEnabled -eq 1 ]; then + # systemctl restart $init.service + #else + # $init restart + #fi + restartservice syslog fi #keep a record diff --git a/xCAT/postscripts/xcatlib.sh b/xCAT/postscripts/xcatlib.sh index 6bac5d0d5..2eb70760b 100644 --- a/xCAT/postscripts/xcatlib.sh +++ b/xCAT/postscripts/xcatlib.sh @@ -273,7 +273,7 @@ function servicemap { local svcmgrtype=$2 local svclistname= - INIT_dhcp="dhcpd isc-dhcp-server"; + INIT_dhcp="dhcp3-server dhcpd isc-dhcp-server"; SYSTEMD_dhcp="dhcpd.service"; INIT_nfs="nfsserver nfs nfs-kernel-server"; @@ -291,6 +291,15 @@ function servicemap { INIT_http="apache2 httpd"; SYSTEMD_http="httpd.service"; + INIT_ntpserver="ntpd ntp"; + SYSTEMD_ntpserver="ntpd.service"; + + INIT_mysql="mysqld mysql"; + SYSTEMD_mysql="mysqld.service"; + + INIT_ssh="sshd ssh"; + SYSTEMD_ssh="sshd.service"; + local path= local retdefault=$svcname local svcvar=${svcname//[-.]/_} From 5b71f2638aa4abc89b4bf6127bf6b39040eb7c41 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 10 Jun 2014 14:06:27 -0400 Subject: [PATCH 90/99] Elaborate upon ipmi.bmcport behavior for a number of IBM system x systems --- perl-xCAT/xCAT/Schema.pm | 41 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/perl-xCAT/xCAT/Schema.pm b/perl-xCAT/xCAT/Schema.pm index 0c638b901..45785b601 100755 --- a/perl-xCAT/xCAT/Schema.pm +++ b/perl-xCAT/xCAT/Schema.pm @@ -389,7 +389,46 @@ ipmi => { descriptions => { node => 'The node name or group name.', bmc => 'The hostname of the BMC adapater.', - bmcport => 'In systems with selectable shared/dedicated ethernet ports, this parameter can be used to specify the preferred port. 0 means use the shared port, 1 means dedicated, blank is to not assign', + bmcport => ' In systems with selectable shared/dedicated ethernet ports, + this parameter can be used to specify the preferred port. 0 + means use the shared port, 1 means dedicated, blank is to not + assign. + + The following special cases exist for IBM System x servers: + + For x3755 M3 systems, 0 means use the dedicated port, 1 means + shared, blank is to not assign. + + For certain systems which have a mezzaine or ML2 adapter, there is a second + value to include: + + + For x3750 M4 (Model 8722): + + + 0 2 1st 1Gbps interface for LOM + + 0 0 1st 10Gbps interface for LOM + + 0 3 2nd 1Gbps interface for LOM + + 0 1 2nd 10Gbps interface for LOM + + + For x3750 M4 (Model 8752), x3850/3950 X6, dx360 M4, x3550 M4, and x3650 M4: + + + 0 Shared (1st onboard interface) + + 1 Dedicated + + 2 0 First interface on ML2 or mezzanine adapter + + 2 1 Second interface on ML2 or mezzanine adapter + + 2 2 Third interface on ML2 or mezzanine adapter + + 2 3 Fourth interface on ML2 or mezzanine adapter', taggedvlan => 'Have bmcsetup place the BMC on the specified vlan tag on a shared netwirk interface. Some network devices may be incompatible with this option', bmcid => 'Unique identified data used by discovery processes to distinguish known BMCs from unrecognized BMCs', username => 'The BMC userid. If not specified, the key=ipmi row in the passwd table is used as the default.', From 32c39eb1e9304ce837381dbe9cb036be7f9c4838 Mon Sep 17 00:00:00 2001 From: mellor Date: Tue, 10 Jun 2014 16:46:46 -0400 Subject: [PATCH 91/99] defect 4147 fix snmove route add and updatenode calls --- xCAT-server/lib/xcat/plugins/snmove.pm | 34 +++++++++++++++++--------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/snmove.pm b/xCAT-server/lib/xcat/plugins/snmove.pm index d7de746e1..149261ee8 100644 --- a/xCAT-server/lib/xcat/plugins/snmove.pm +++ b/xCAT-server/lib/xcat/plugins/snmove.pm @@ -416,13 +416,8 @@ sub process_request ) ) { - - # get the short hostname - my $xcatmaster = xCAT::NetworkUtils->gethostname($IP); - $xcatmaster =~ s/\..*//; - # add the value to the hash - $newxcatmaster{$node} = $xcatmaster; + $newxcatmaster{$node} = $IP; last; } } @@ -1342,9 +1337,11 @@ sub process_request $sub_req, -1, 1 ); - if ($::RUNCMD_RC != 0) + if (($::RUNCMD_RC != 0) && + !grep(/ File exists/,@$ret) ) # ignore already set error { my $rsp; + $rsp->{data} = $ret; push @{$rsp->{data}}, $ret; push @{$rsp->{data}}, "Could not set default route.\n"; xCAT::MsgUtils->message("E", $rsp, $callback); @@ -1559,27 +1556,42 @@ sub process_request xCAT::MsgUtils->message("I", $rsp, $callback); foreach my $scripts (keys(%$pos_hash)) { - my $pos_nodes = $pos_hash->{$scripts}; + # need to run updatenode -s first as a separate call + # before running updatenode -P. The flags cannot be run together. my $ret = xCAT::Utils->runxcmd( { command => ['updatenode'], node => $pos_nodes, - arg => ["-P", "$scripts", "-s"], + arg => ["-s"], }, $sub_req, -1, 1 ); if ($::RUNCMD_RC != 0) { $error++; - } - my $rsp; $rsp->{data} = $ret; xCAT::MsgUtils->message("I", $rsp, $callback); + + $ret = + xCAT::Utils->runxcmd( + { + command => ['updatenode'], + node => $pos_nodes, + arg => ["-P", "$scripts"], + }, + $sub_req, -1, 1 + ); + if ($::RUNCMD_RC != 0) + { + $error++; + } + $rsp->{data} = $ret; + xCAT::MsgUtils->message("I", $rsp, $callback); } } # end -for both AIX and Linux systems From 991e039470f0b35c5df5ab1b22f3ad73f7529063 Mon Sep 17 00:00:00 2001 From: daniceexi Date: Wed, 11 Jun 2014 07:13:42 -0400 Subject: [PATCH 92/99] support replace operation for routeop postscript. So far only supports the persistent route setting for sles. --- xCAT/postscripts/routeop | 231 +++++++++++++++++++++++++++------------ 1 file changed, 162 insertions(+), 69 deletions(-) diff --git a/xCAT/postscripts/routeop b/xCAT/postscripts/routeop index 2cf80a3f1..45c57b3b7 100755 --- a/xCAT/postscripts/routeop +++ b/xCAT/postscripts/routeop @@ -7,6 +7,13 @@ # setup a route on a node. # The syntax is: # routeop add/delete net mask gateway ifname +# routeop replace net mask gateway ifname #NOTE: it only works for sles so far +# net - IP of net like 192.168.1.0. The keyword +# 'default' is used to set the default route. +# mask - The length of the netmask +# gatewasy - The next hop. It could be set to "" or 0.0.0.0 +# ifname - The interface to route to the next hop +# example: routeop replace default 0 10.1.0.209 eth0 #=cut #------------------------------------------------------------------------------- @@ -19,6 +26,14 @@ if [ -n "$5" ]; then ifname=$5 fi +# use nummask to know whether the netmask format is 255.255.255.0 or 24 (a number) +nummask=0 +echo $mask | grep '\.' > /dev/null +if [ $? -ne 0 ]; then + nummask=1 # the netmask is the length of network mask. +fi + + function debianpreconf(){ #create the config sub dir if [ ! -d "/etc/network/interfaces.d" ];then @@ -143,6 +158,7 @@ route_exists() echo $ret } +# handle the route add/replace operation that adding the setting to configuration file add_persistent_route() { net=$1; @@ -168,6 +184,14 @@ add_persistent_route() OS_name="debian" fi + # The replace operation does not support redhat and debain so far + if [ "$op" = "replace" ]; then + if [ "$OS_name" = "redhat" -o "$OS_name" = "debain" ]; then + echo "Warning: replace operation only supports to add persistent route for sles by now." + return + fi + fi + case $OS_name in sles) #echo "sles" @@ -175,36 +199,56 @@ add_persistent_route() filename="/etc/sysconfig/network/routes"; if echo $net | grep : 2>&1 1>/dev/null then - if [ $gw_ip = "" -o $gw_ip = "::" ] ; then + if [ "$gw" = "" -o "$gw" = "::" ] ; then route="$net/$mask :: - $ifname" route1="$net\/$mask :: - $ifname"; - else + else route="$net/$mask $gw - -" route1="$net\/$mask $gw - -"; - fi + fi else - if [ $gw_ip = "" -o $gw_ip = "0.0.0.0" ] ; then - route="$net 0.0.0.0 $mask $ifname"; - route1="$net 0.0.0.0 $mask $ifname"; - else - route="$net $gw $mask $ifname"; - route1="$net $gw $mask $ifname"; - fi + if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then + if [ $nummask -eq 1 ]; then + if [ "$net" = "default" ]; then + route="default - - $ifname"; + route1="default - - $ifname"; + else + route="$net/$mask - - $ifname"; + route1="$net\/$mask - - $ifname"; + fi + else + route="$net 0.0.0.0 $mask $ifname"; + route1="$net 0.0.0.0 $mask $ifname"; + fi + else + if [ $nummask -eq 1 ]; then + if [ "$net" = "default" ]; then + route="default $gw - $ifname"; + route1="default $gw - $ifname"; + else + route="$net/$mask $gw - $ifname"; + route1="$net\/$mask $gw - $ifname"; + fi + else + route="$net $gw $mask $ifname"; + route1="$net $gw $mask $ifname"; + fi + fi fi if [ -f $filename ]; then grep "$route" $filename 2>&1 1>/dev/null if [ $? -ne 0 ]; then #route does not exist - grep "$xcat_config_start" $filename 2>&1 1>/dev/null - if [ $? -ne 0 ]; then #no xCAT section - echo $xcat_config_start >> $filename - echo $route >> $filename - echo $xcat_config_end >> $filename - else - sed -i -e s/"$xcat_config_end"/"$route1\n$xcat_config_end"/g $filename - fi - echo "Persistent route \"$route\" added in $filename." + grep "$xcat_config_start" $filename 2>&1 1>/dev/null + if [ $? -ne 0 ]; then #no xCAT section + echo $xcat_config_start >> $filename + echo $route >> $filename + echo $xcat_config_end >> $filename + else + sed -i -e s/"$xcat_config_end"/"$route1\n$xcat_config_end"/g $filename + fi + echo "Persistent route \"$route\" added in $filename." else - echo "Persistent route \"$route\" already exists in $filename." + echo "Persistent route \"$route\" already exists in $filename." fi else #echo "got here" @@ -232,18 +276,18 @@ add_persistent_route() echo $net | grep : 2>&1 1>/dev/null #ipv6 if [ $? -eq 0 ];then - if [ "$gw" = "" -o "$gw" = "::" ] ; then + if [ "$gw" = "" -o "$gw" = "::" ] ; then matchstr="$net/$mask dev $ifname" - else + else matchstr="$net/$mask gw $gw" fi v6flag=1 else - if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then + if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then matchstr="net $net netmask $mask dev $ifname" - else + else matchstr="net $net netmask $mask gw $gw" - fi + fi fi grep "$matchstr" $filename 2>&1 1>/dev/null @@ -256,21 +300,21 @@ add_persistent_route() if [ $? -eq 0 -a $foundflag -eq 1 ];then foundflag=0 if [ $v6flag -eq 1 ];then - if [ "$gw" = "" -o "$gw" = "::" ] ; then + if [ "$gw" = "" -o "$gw" = "::" ] ; then echo " up route -A inet6 add $net/$mask dev $ifname" >> $tempfile echo " down route -A inet6 del $net/$mask dev $ifname" >> $tempfile - else + else echo " up route -A inet6 add $net/$mask gw $gw" >> $tempfile echo " down route -A inet6 del $net/$mask gw $gw" >> $tempfile - fi + fi else - if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then - echo " up route add -net $net netmask $mask dev $ifname" >> $tempfile - echo " down route del -net $net netmask $mask dev $ifname" >> $tempfile - else + if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then + echo " up route add -net $net netmask $mask dev $ifname" >> $tempfile + echo " down route del -net $net netmask $mask dev $ifname" >> $tempfile + else echo " up route add -net $net netmask $mask gw $gw" >> $tempfile echo " down route del -net $net netmask $mask gw $gw" >> $tempfile - fi + fi fi fi echo $LINE | grep "iface $ifname " 2>&1 1>/dev/null @@ -284,21 +328,21 @@ add_persistent_route() #the insert place is the last line of the config file if [ $foundflag -eq 1 ];then if [ $v6flag -eq 1 ];then - if [ "$gw" = "" -o "$gw" = "::" ] ; then + if [ "$gw" = "" -o "$gw" = "::" ] ; then echo " up route -A inet6 add $net/$mask dev $ifname" >> $tempfile echo " down route -A inet6 del $net/$mask dev $ifname" >> $tempfile - else + else echo " up route -A inet6 add $net/$mask gw $gw" >> $tempfile echo " down route -A inet6 del $net/$mask gw $gw" >> $tempfile - fi + fi else - if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then - echo " up route add -net $net netmask $mask dev $ifname" >> $tempfile - echo " down route del -net $net netmask $mask dev $ifname" >> $tempfile - else + if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then + echo " up route add -net $net netmask $mask dev $ifname" >> $tempfile + echo " down route del -net $net netmask $mask dev $ifname" >> $tempfile + else echo " up route add -net $net netmask $mask gw $gw" >> $tempfile echo " down route del -net $net netmask $mask gw $gw" >> $tempfile - fi + fi fi fi mv -f $tempfile $filename @@ -313,7 +357,7 @@ add_persistent_route() if echo $net | grep : 2>&1 1>/dev/null then if [ "$gw" = "" ] ; then - $gw = "::"; + $gw = "::"; fi filename="/etc/sysconfig/static-routes-ipv6"; route="$ifname $net/$mask $gw"; @@ -324,10 +368,10 @@ add_persistent_route() if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then route="any net $net netmask $mask dev $ifname"; route1="any net $net netmask $mask dev $ifname"; - else + else route="any net $net netmask $mask gw $gw $ifname"; route1="any net $net netmask $mask gw $gw $ifname"; - fi + fi fi if [ -f $filename ]; then grep "$route" $filename 2>&1 1>/dev/null @@ -387,16 +431,16 @@ rm_persistent_route() # ipv6 net if echo $net | grep : 2>&1 1>/dev/null then - if [ $gw = "" -o $gw = "::" ] ; then + if [ $gw = "" -o $gw = "::" ] ; then route="$net/$mask :: - $ifname"; route1="$net\/$mask :: - $ifname"; - else + else route="$net/$mask $gw - -"; route1="$net\/$mask $gw - -"; - fi + fi else - if [ $gw = "" ] ; then - $gw = "0.0.0.0"; + if [ $gw = "" ] ; then + $gw = "0.0.0.0"; fi if [ -n "$ifname" ]; then route="$net $gw $mask $ifname"; @@ -431,18 +475,18 @@ rm_persistent_route() echo $net | grep : 2>&1 1>/dev/null #ipv6 if [ $? -eq 0 ];then - if [ $gw = "" -o $gw = "::" ] ; then + if [ $gw = "" -o $gw = "::" ] ; then matchstr="$net/$mask dev $ifname" - else + else matchstr="$net/$mask gw $gw" - fi + fi v6flag=1 else - if [ $gw = "" -o $gw = "0.0.0.0" ] ; then + if [ $gw = "" -o $gw = "0.0.0.0" ] ; then matchstr="net $net netmask $mask dev $ifname" - else + else matchstr="net $net netmask $mask gw $gw" - fi + fi fi grep "$matchstr" $filename @@ -463,10 +507,10 @@ rm_persistent_route() if [ "$gw" = "" -o "$gw" = "::" ] ; then route="$ifname $net\/$mask ::" route1="$ifname $net/$mask ::" - else + else route="$ifname $net\/$mask $gw" route1="$ifname $net/$mask $gw" - fi + fi else filename="/etc/sysconfig/static-routes"; if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then @@ -504,22 +548,22 @@ if [ "$op" = "add" ]; then if echo $net | grep : 2>&1 1>/dev/null then if [ "$(uname -s)" = "Linux" ]; then - if [ "$gw" = "" -o "$gw" = "::" ] ; then + if [ "$gw" = "" -o "$gw" = "::" ] ; then cmd="ip -6 route add $net/$mask dev $ifname" - else + else cmd="ip -6 route add $net/$mask via $gw" - fi + fi else # AIX TODO cmd="ip -6 route add $net/$mask via $gw" fi else if [ "$(uname -s)" = "Linux" ]; then - if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then + if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then cmd="route add -net $net netmask $mask dev $ifname" - else + else cmd="route add -net $net netmask $mask gw $gw" - fi + fi else cmd="route add -net $net -netmask $mask $gw" fi @@ -553,22 +597,22 @@ elif [ "$op" = "delete" ]; then if echo $net | grep : 2>&1 1>/dev/null then if [ "$(uname -s)" = "Linux" ]; then - if [ "$gw" = "" -o "$gw" = "::" ] ; then + if [ "$gw" = "" -o "$gw" = "::" ] ; then cmd="ip -6 route delete $net/$mask dev $ifname" - else + else cmd="ip -6 route delete $net/$mask via $gw" - fi + fi else # AIX TODO cmd="ip -6 route delete $net/$mask via $gw" fi else if [ "$(uname -s)" = "Linux" ]; then - if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then + if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then cmd="route delete -net $net netmask $mask dev $ifname" - else + else cmd="route delete -net $net netmask $mask gw $gw" - fi + fi else cmd="route delete -net $net -netmask $mask $gw" fi @@ -587,5 +631,54 @@ elif [ "$op" = "delete" ]; then #remove the persistent route rm_persistent_route $net $mask $gw $ifname +elif [ "$op" = "replace" ]; then + if echo $net | grep : 2>&1 1>/dev/null + then # ipv6 + if [ "$(uname -s)" = "Linux" ]; then + if [ "$gw" = "" -o "$gw" = "::" ] ; then + if [ "$net" = "default" ]; then + cmd="ip -6 route replace default dev $ifname" + else + cmd="ip -6 route replace $net/$mask dev $ifname" + fi + else + if [ "$net" = "default" ]; then + cmd="ip -6 route replace default via $gw" + else + cmd="ip -6 route replace $net/$mask via $gw" + fi + fi + fi + else #ipv4 + if [ "$(uname -s)" = "Linux" ]; then + if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then + if [ "$net" = "default" ]; then + cmd="ip route replace default dev $ifname" + else + cmd="ip route replace $net/$mask dev $ifname" + fi + else + if [ "$net" = "default" ]; then + cmd="ip route replace default via $gw" + else + cmd="ip route replace $net/$mask via $gw" + fi + fi + fi + fi + + echo "Adding temporary route: $cmd" + result=`$cmd 2>&1` + code=$? + if [ $code -ne 0 ]; then + logger -t xCAT -p local4.err "$cmd\nerror code=$code, result=$result." + echo " error code=$code, result=$result." + if [ -f "/etc/debian_version" ];then + exit 1; + fi + fi + + #replace the persistent route + add_persistent_route $net $mask $gw $ifname fi exit 0 From 3e3be8425bf79869f6695569013f4dd78b911bd5 Mon Sep 17 00:00:00 2001 From: immarvin Date: Wed, 11 Jun 2014 01:38:16 -0700 Subject: [PATCH 93/99] replace sysvinit with newly added subroutines in xCAT::Utils --- xCAT-server/sbin/xcatconfig | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/xCAT-server/sbin/xcatconfig b/xCAT-server/sbin/xcatconfig index 096e70cee..34d55d1f4 100755 --- a/xCAT-server/sbin/xcatconfig +++ b/xCAT-server/sbin/xcatconfig @@ -418,12 +418,14 @@ if ($::INITIALINSTALL || $::FORCE || $::UPDATEINSTALL || $::genCredentials) if ($::osname eq 'AIX') { $xcmd = "$::XCATROOT/sbin/restartxcatd"; + system($xcmd); } else { - $xcmd = "/etc/init.d/xcatd restart"; + #$xcmd = "/etc/init.d/xcatd restart"; + xCAT::Utils->restartservice("xcatd"); } - system($xcmd); + } # more config needed after xcatd start From 66ca2f0003361ec39fff246cc601aef7075fe4fd Mon Sep 17 00:00:00 2001 From: junxiaw Date: Wed, 11 Jun 2014 01:54:03 -0700 Subject: [PATCH 94/99] modify xcattest code for autotest code --- xCAT-test/xcattest | 61 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 53 insertions(+), 8 deletions(-) diff --git a/xCAT-test/xcattest b/xCAT-test/xcattest index a4cff3ae3..7506bf2b8 100755 --- a/xCAT-test/xcattest +++ b/xCAT-test/xcattest @@ -86,6 +86,7 @@ $ret = &init; if($ret != 0){ goto EXIT; } +my @filespath = (); #loading and check cases $ret = &loadcase; if($ret != 0){ @@ -410,6 +411,34 @@ sub uninit &runcmd("rm -rf /tmp/xCATdbbackup"); return 0; } +sub Get_Files_Recursive +{ + my $dir = $_[0]; + foreach $dir (@_) + { + opendir(my $d, $dir) ; + for (;;) + { + my $direntry = readdir($d); + last unless defined $direntry; + next if $direntry =~ m/^\.\w*/; + next if $direntry eq '..'; + if ( -d $dir."/".$direntry) + { + Get_Files_Recursive ($dir."/".$direntry); + } + else + { my $dirpath = $dir.'/'.$direntry."\n"; + print $dir.'/'.$direntry."\n"; + #print $dir."\n"; + push (@filespath, glob("$dirpath")); + + } + } + closedir($d); + } +} + sub loadcase { @@ -418,14 +447,30 @@ sub loadcase log_this("******************************"); my $casedir = "/opt/xcat/share/xcat/tools/autotest/testcase"; my @files = (); - if($cmd_list){ - my @cmds = split /,/,$cmd_list; - for my $cmd (@cmds){ - push (@files, glob("$casedir/$cmd/*")); - } - } else { - @files = glob("$casedir/*/*"); - } + #if($cmd_list){ + # my @cmds = split /,/,$cmd_list; + # for my $cmd (@cmds){ + # push (@files, glob("$casedir/$cmd/*")); + # } + #} else { + # @files = glob("$casedir/*/*"); + #} + Get_Files_Recursive("$casedir"); + for(my $countfile = 0; $countfile<@filespath; $countfile++) + { + if ($cmd_list){ + my @cmds = split /,/,$cmd_list; + for( my $countcmd = 0; $countcmd<@cmds; $countcmd++){ + if ($filespath[$countfile] =~ m/\/$cmds[$countcmd]\/case/){ + push (@files, glob("$filespath[$countfile]")); + } + } + } else{ + push (@files, glob("$filespath[$countfile]")); + } + } + + my $file; my $line; my $i = 0; From ee1521f080eab6726fd07ca382adf9b28d858b10 Mon Sep 17 00:00:00 2001 From: immarvin Date: Wed, 11 Jun 2014 02:53:37 -0700 Subject: [PATCH 95/99] fix 4132 [DEV]sles11.3 provision hang when site.managedaddressmode=static --- xCAT-server/lib/xcat/plugins/sles.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/xCAT-server/lib/xcat/plugins/sles.pm b/xCAT-server/lib/xcat/plugins/sles.pm index 0f69e07b7..171415e7b 100755 --- a/xCAT-server/lib/xcat/plugins/sles.pm +++ b/xCAT-server/lib/xcat/plugins/sles.pm @@ -1191,6 +1191,7 @@ sub mkinstall my $domain=$nodedomains{$node}; $kcmdline .=" Domain=$domain "; + $kcmdline .=" netwait=10 "; } From 7e4fa98e009037d4ced45811d007cd25d65909b4 Mon Sep 17 00:00:00 2001 From: lissav Date: Wed, 11 Jun 2014 08:27:44 -0400 Subject: [PATCH 96/99] fix 4161 --- xCAT-server/lib/xcat/plugins/updatenode.pm | 239 ++++++++++++++------- 1 file changed, 159 insertions(+), 80 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/updatenode.pm b/xCAT-server/lib/xcat/plugins/updatenode.pm index c39693c92..9adc0baeb 100644 --- a/xCAT-server/lib/xcat/plugins/updatenode.pm +++ b/xCAT-server/lib/xcat/plugins/updatenode.pm @@ -209,27 +209,28 @@ sub preprocess_updatenode } # parse the options + my ($ALLSW,$CMDLINE,$ALTSRC,$HELP,$VERSION,$VERBOSE,$FILESYNC,$GENMYPOST,$USER,$SNFILESYNC,$SWMAINTENANCE,$SETSERVER,$RERUNPS,$SECURITY,$OS,$fanout,$timeout); Getopt::Long::Configure("bundling"); Getopt::Long::Configure("no_pass_through"); if ( !GetOptions( - 'A|updateallsw' => \$::ALLSW, - 'c|cmdlineonly' => \$::CMDLINE, - 'd=s' => \$::ALTSRC, - 'h|help' => \$::HELP, - 'v|version' => \$::VERSION, - 'V|verbose' => \$::VERBOSE, - 'F|sync' => \$::FILESYNC, - 'g|genmypost' => \$::GENMYPOST, - 'l|user:s' => \$::USER, - 'f|snsync' => \$::SNFILESYNC, - 'S|sw' => \$::SWMAINTENANCE, - 's|sn' => \$::SETSERVER, - 'P|scripts:s' => \$::RERUNPS, - 'k|security' => \$::SECURITY, - 'o|os:s' => \$::OS, - 'fanout=i' => \$::fanout, - 't|timetout=i' => \$::timeout, + 'A|updateallsw' => \$ALLSW, + 'c|cmdlineonly' => \$CMDLINE, + 'd=s' => \$ALTSRC, + 'h|help' => \$HELP, + 'v|version' => \$VERSION, + 'V|verbose' => \$VERBOSE, + 'F|sync' => \$FILESYNC, + 'g|genmypost' => \$GENMYPOST, + 'l|user:s' => \$USER, + 'f|snsync' => \$SNFILESYNC, + 'S|sw' => \$SWMAINTENANCE, + 's|sn' => \$SETSERVER, + 'P|scripts:s' => \$RERUNPS, + 'k|security' => \$SECURITY, + 'o|os:s' => \$OS, + 'fanout=i' => \$fanout, + 't|timetout=i' => \$timeout, ) ) @@ -237,16 +238,55 @@ sub preprocess_updatenode &updatenode_usage($callback); return; } + # These globals are used in the updatenode subroutines, + # need to undefine them if not defined in GetOpts + # to make updatenode be able to be called multiple times in one process. + # $RERUNPS can be set later in the logic based on other input + if (defined($VERBOSE)) { + $::VERBOSE=$VERBOSE; + } else { + undef $::VERBOSE; + } + if (defined($timeout)) { + $::timeout=$timeout; + } else { + undef $::timeout; + } + if (defined($fanout)) { + $::fanout=$fanout; + } else { + undef $::fanout; + } + if (defined($USER)) { + $::USER=$USER; + } else { + undef $::USER; + } + if (defined($ALTSRC)) { + $::ALTSRC=$ALTSRC; + } else { + undef $::ALTSRC; + } + if (defined($ALLSW)) { + $::ALLSW=$ALLSW; + } else { + undef $::ALLSW; + } + if (defined($SETSERVER)) { + $::SETSERVER=$SETSERVER; + } else { + undef $::SETSERVER; + } # display the usage if -h or --help is specified - if ($::HELP) + if ($HELP) { &updatenode_usage($callback); return; } # display the version statement if -v or --verison is specified - if ($::VERSION) + if ($VERSION) { my $rsp = {}; $rsp->{data}->[0] = xCAT::Utils->Version(); @@ -258,7 +298,7 @@ sub preprocess_updatenode # if no sharedtftp then we need to broadcast this updatenode -g to all service nodes inorder # to be able to support service node pools # - if ($::GENMYPOST) + if ($GENMYPOST) { # precreatemypostscript has to be yes/1 or do nothing my @entries = xCAT::TableUtils->get_site_attribute("precreatemypostscripts"); @@ -308,7 +348,7 @@ sub preprocess_updatenode # -c must work with -S for AIX node - if ($::CMDLINE && !$::SWMAINTENANCE) + if ($CMDLINE && !$SWMAINTENANCE) { my $rsp = {}; $rsp->{data}->[0] = @@ -318,7 +358,7 @@ sub preprocess_updatenode } # -s must not be with any other flag, this updates xcatinfo and run setuppostbootscripts - if ($::SETSERVER && ($::SWMAINTENANCE || $::RERUNPS || $::SECURITY)) + if ($SETSERVER && ($SWMAINTENANCE || $RERUNPS || $SECURITY)) { my $rsp = {}; $rsp->{data}->[0] = @@ -328,11 +368,11 @@ sub preprocess_updatenode return; } # For -s flag just run this one script - if ($::SETSERVER) { - $::RERUNPS = "setuppostbootscripts"; + if ($SETSERVER) { + $RERUNPS = "setuppostbootscripts"; } # -f or -F not both - if (($::FILESYNC) && ($::SNFILESYNC)) + if (($FILESYNC) && ($SNFILESYNC)) { my $rsp = {}; $rsp->{data}->[0] = "You can not specify both the -f and -F flags."; @@ -340,7 +380,7 @@ sub preprocess_updatenode return; } # -f must not be with any other flag, this updates service nodes syncfiles - if ($::SNFILESYNC && ($::SWMAINTENANCE || $::RERUNPS || defined($::RERUNPS) || $::SECURITY || $::FILESYNC)) + if ($SNFILESYNC && ($SWMAINTENANCE || $RERUNPS || defined($RERUNPS) || $SECURITY || $FILESYNC)) { my $rsp = {}; $rsp->{data}->[0] = @@ -351,8 +391,8 @@ sub preprocess_updatenode } # --security cannot work with -S -P -F -f - if ($::SECURITY - && ($::SWMAINTENANCE || $::RERUNPS || defined($::RERUNPS) || $::FILESYNC || $::SNFILESYNC)) + if ($SECURITY + && ($SWMAINTENANCE || $RERUNPS || defined($RERUNPS) || $FILESYNC || $SNFILESYNC)) { my $rsp = {}; $rsp->{data}->[0] = @@ -371,11 +411,11 @@ sub preprocess_updatenode if ( $#ARGV == 0 && !( - $::FILESYNC - || $::SNFILESYNC - || $::SWMAINTENANCE - || defined($::RERUNPS) - || $::SECURITY + $FILESYNC + || $SNFILESYNC + || $SWMAINTENANCE + || defined($RERUNPS) + || $SECURITY ) ) { @@ -384,7 +424,7 @@ sub preprocess_updatenode # if it doesn't contain an = sign then it must be postscripts if (!($ARGV[0] =~ /=/)) { - $::RERUNPS = $ARGV[0]; + $RERUNPS = $ARGV[0]; $ARGV[0] = ""; } @@ -394,22 +434,22 @@ sub preprocess_updatenode { # if not syncing Service Node - if (!($::SNFILESYNC)) + if (!($SNFILESYNC)) { # no flags and no operands, set defaults if ( !( - $::FILESYNC - || $::SWMAINTENANCE - || defined($::RERUNPS) - || $::SECURITY + $FILESYNC + || $SWMAINTENANCE + || defined($RERUNPS) + || $SECURITY ) ) { - $::FILESYNC = 1; - $::SWMAINTENANCE = 1; - $::RERUNPS = ""; + $FILESYNC = 1; # these are the defaults when no flags input to updatenode + $SWMAINTENANCE = 1; + $RERUNPS = ""; } } } @@ -424,7 +464,7 @@ sub preprocess_updatenode $callback->($rsp); return; } - if ($::SECURITY) + if ($SECURITY) { # check to see if the Management Node is in the noderange and @@ -456,7 +496,7 @@ sub preprocess_updatenode { $request->{node} = \@CN; $request->{noderange} = \@CN; - $::RERUNPS = "remoteshell"; + $RERUNPS = "remoteshell"; } else { # no more nodes @@ -473,7 +513,7 @@ sub preprocess_updatenode # - put attr=val operands in %attrvals hash my %attrvals; - if ($::SWMAINTENANCE) + if ($SWMAINTENANCE) { while (my $a = shift(@ARGV)) { @@ -501,7 +541,7 @@ sub preprocess_updatenode my $postscripts; # Handle updating operating system - if (defined($::OS)) + if (defined($OS)) { my $reqcopy = {%$request}; $reqcopy->{os}->[0] = "yes"; @@ -515,15 +555,15 @@ sub preprocess_updatenode # postscripts-start-here,postbootscripts-start-here, # defaults-postbootscripts-start-here, osimage-postbootscripts-start-here, # etc - if (defined($::RERUNPS)) + if (defined($RERUNPS)) { - if ($::RERUNPS eq "") + if ($RERUNPS eq "") { $postscripts = ""; } else { - $postscripts = $::RERUNPS; + $postscripts = $RERUNPS; my @posts = split(',', $postscripts); if (!grep(/start-here/, @posts)) { @@ -560,11 +600,11 @@ sub preprocess_updatenode # If -F or -f option specified, sync files to the noderange and their # service nodes. - if ($::FILESYNC) + if ($FILESYNC) { $request->{FileSyncing}->[0] = "yes"; } - if ($::SNFILESYNC) # either sync service node + if ($SNFILESYNC) # either sync service node { $request->{SNFileSyncing}->[0] = "yes"; } @@ -572,7 +612,7 @@ sub preprocess_updatenode # If -F or -f then, call CFMUtils to check if any PCM CFM data is to be # built for the node. This will also create the synclists attribute in # the osimage for each node in the noderange - if (($::FILESYNC) || ($::SNFILESYNC)) + if (($FILESYNC) || ($SNFILESYNC)) { # determine the list of osimages names in the noderange to pass into @@ -602,7 +642,7 @@ sub preprocess_updatenode # for AIX nodes we need to copy software to SNs first - if needed my ($imagedef, $updateinfo); - if (defined($::SWMAINTENANCE) && scalar(@aixnodes)) + if (defined($SWMAINTENANCE) && scalar(@aixnodes)) { ($rc, $imagedef, $updateinfo) = &doAIXcopy($callback, \%attrvals, $AIXnodes, $subreq); @@ -649,7 +689,7 @@ sub preprocess_updatenode } } # check if no servicenodes for noderange and using the -f flag - if ($::SNFILESYNC) { + if ($SNFILESYNC) { if (!(scalar(@sns))) { my $rsp; $rsp->{data}->[0] = @@ -659,12 +699,12 @@ sub preprocess_updatenode } } # process the -F or -f flags - if (($::FILESYNC) || ($::SNFILESYNC)) + if (($FILESYNC) || ($SNFILESYNC)) { # If it is only -F or -f in the command, which are always run on the MN, # then run it now and you are # finished. - if ((!defined($::SWMAINTENANCE)) && (!defined($::RERUNPS))) { + if ((!defined($SWMAINTENANCE)) && (!defined($RERUNPS))) { $request->{_xcatpreprocessed}->[0] = 1; &updatenode($request, $callback, $subreq); return; @@ -690,7 +730,7 @@ sub preprocess_updatenode } - if (defined($::SWMAINTENANCE)) + if (defined($SWMAINTENANCE)) { $request->{swmaintenance}->[0] = "yes"; @@ -706,7 +746,7 @@ sub preprocess_updatenode $request->{updateinfo} = [$updateinfo]; } } - if (defined($::RERUNPS)) + if (defined($RERUNPS)) { $request->{rerunps}->[0] = "yes"; $request->{postscripts} = [$postscripts]; @@ -716,7 +756,7 @@ sub preprocess_updatenode } } - if (defined($::SECURITY)) + if (defined($SECURITY)) { $request->{security}->[0] = "yes"; } @@ -724,7 +764,7 @@ sub preprocess_updatenode # # Handle updating OS # - if (defined($::OS)) + if (defined($OS)) { $request->{os}->[0] = "yes"; } @@ -821,11 +861,11 @@ sub update_SN_security # setup the ssh keys on the service nodes # run the postscripts: remoteshell, servicenode # These are all servicenodes - $::RERUNPS = "remoteshell,servicenode"; + my $RERUNPS = "remoteshell,servicenode"; my $req_rs = {%$request}; my $ps; - $ps = $::RERUNPS; + $ps = $RERUNPS; $req_rs->{rerunps}->[0] = "yes"; $req_rs->{security}->[0] = "yes"; $req_rs->{rerunps4security}->[0] = "yes"; @@ -1038,31 +1078,70 @@ sub updatenode chomp $nimprime; # parse the options + my ($ALLSW,$CMDLINE,$ALTSRC,$HELP,$VERSION,$VERBOSE,$FILESYNC,$GENMYPOST,$USER,$SNFILESYNC,$SWMAINTENANCE,$SETSERVER,$RERUNPS,$SECURITY,$OS,$fanout,$timeout); Getopt::Long::Configure("bundling"); Getopt::Long::Configure("no_pass_through"); if ( !GetOptions( - 'A|updateallsw' => \$::ALLSW, - 'c|cmdlineonly' => \$::CMDLINE, - 'd=s' => \$::ALTSRC, - 'g|genmypost' => \$::GENMYPOST, - 'h|help' => \$::HELP, - 'v|version' => \$::VERSION, - 'V|verbose' => \$::VERBOSE, - 'F|sync' => \$::FILESYNC, - 'l|user:s' => \$::USER, - 'f|snsync' => \$::SNFILESYNC, - 'S|sw' => \$::SWMAINTENANCE, - 's|sn' => \$::SETSERVER, - 'P|scripts:s' => \$::RERUNPS, - 'k|security' => \$::SECURITY, - 'o|os:s' => \$::OS, - 'fanout=i' => \$::fanout, - 't|timetout=i' => \$::timeout, + 'A|updateallsw' => \$ALLSW, + 'c|cmdlineonly' => \$CMDLINE, + 'd=s' => \$ALTSRC, + 'g|genmypost' => \$GENMYPOST, + 'h|help' => \$HELP, + 'v|version' => \$VERSION, + 'V|verbose' => \$VERBOSE, + 'F|sync' => \$FILESYNC, + 'l|user:s' => \$USER, + 'f|snsync' => \$SNFILESYNC, + 'S|sw' => \$SWMAINTENANCE, + 's|sn' => \$SETSERVER, + 'P|scripts:s' => \$RERUNPS, + 'k|security' => \$SECURITY, + 'o|os:s' => \$OS, + 'fanout=i' => \$fanout, + 't|timetout=i' => \$timeout, ) ) { } + # These globals are used in the updatenode subroutines, + # need to undefine them if not defined in GetOpts + # to make updatenode be able to be called multiple times in one process. + if (defined($VERBOSE)) { + $::VERBOSE=$VERBOSE; + } else { + undef $::VERBOSE; + } + if (defined($timeout)) { + $::timeout=$timeout; + } else { + undef $::timeout; + } + if (defined($fanout)) { + $::fanout=$fanout; + } else { + undef $::fanout; + } + if (defined($USER)) { + $::USER=$USER; + } else { + undef $::USER; + } + if (defined($ALTSRC)) { + $::ALTSRC=$ALTSRC; + } else { + undef $::ALTSRC; + } + if (defined($ALLSW)) { + $::ALLSW=$ALLSW; + } else { + undef $::ALLSW; + } + if (defined($SETSERVER)) { + $::SETSERVER=$SETSERVER; + } else { + undef $::SETSERVER; + } # # process @ARGV @@ -1089,7 +1168,7 @@ sub updatenode } } # Just generate mypostscripts file and get out - if ($::GENMYPOST) + if ($GENMYPOST) { my @entries = xCAT::TableUtils->get_site_attribute("precreatemypostscripts"); if ($entries[0] ) { From 3795edd2a826d717ff60543d4c4ad1c9cdcfbd01 Mon Sep 17 00:00:00 2001 From: mellor Date: Wed, 11 Jun 2014 13:20:42 -0400 Subject: [PATCH 97/99] defect 4082 - disable warnings when calling setlogsock --- xCAT-server/sbin/xcatd | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/xCAT-server/sbin/xcatd b/xCAT-server/sbin/xcatd index b971854c6..45563860e 100755 --- a/xCAT-server/sbin/xcatd +++ b/xCAT-server/sbin/xcatd @@ -104,7 +104,12 @@ use Data::Dumper; use Getopt::Long; use Sys::Syslog qw(:DEFAULT setlogsock); openlog("xcatd",,"local4"); +# turn off warnings for call to setlogsock. puts out warning message if +# syslog tcp port not defined in /etc/services. this can safely be ignored. +no warnings qw(Sys::Syslog); setlogsock(["tcp","unix","stream"]); +use warnings qw(Sys::Syslog); + use xCAT::NotifHandler; use xCAT_monitoring::monitorctrl; From e7168c2d0049054b062f03e00e8b4b7ba6e6c16b Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Wed, 11 Jun 2014 15:54:04 -0400 Subject: [PATCH 98/99] Try failing over to another syntax for wvid http call --- xCAT-server/lib/xcat/plugins/ipmi.pm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/xCAT-server/lib/xcat/plugins/ipmi.pm b/xCAT-server/lib/xcat/plugins/ipmi.pm index 9a392b5e8..4717a57e1 100644 --- a/xCAT-server/lib/xcat/plugins/ipmi.pm +++ b/xCAT-server/lib/xcat/plugins/ipmi.pm @@ -1146,6 +1146,12 @@ sub getrvidparms_imm2 { $response = $browser->request(GET $baseurl."designs/imm/viewer(".$sessdata->{ipmisession}->{bmc}.'@'.$httpport.'@'.$ip6mode.'@'.time().'@1@0@1@jnlp'.'@USERID@0@0@0@0'.')'); #arguments are host, then ipv6 or not, then timestamp, then whether to encrypte or not, singleusermode, finally 'notwin32' $jnlp = $response->content; + if ($jnlp =~ /Failed to parse ip format for request/) { + $response = $browser->request(GET $baseurl."designs/imm/viewer(".$sessdata->{ipmisession}->{bmc}.'@'.$httpport.'@'.$ip6mode.'@'.time().'@1@0@1@jnlp'.'@USERID@0@0@0@0@0'.')'); + #arguments are host, then ipv6 or not, then timestamp, then whether to encrypte or not, singleusermode, 'notwin32', and one more (unknown) + $jnlp = $response->content; + } + } $response = $browser->request(GET $baseurl."data/logout"); my $currnode = $sessdata->{node}; From 5e3832753f282ebffb7881b8e2883a7d1274b6fa Mon Sep 17 00:00:00 2001 From: daniceexi Date: Wed, 11 Jun 2014 04:37:49 -0400 Subject: [PATCH 99/99] Make ping test in SMS could accept timeout value which exported from ENV:TIMEOUT4PINGTEST --- perl-xCAT/xCAT/LparNetbootExp.pm | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/perl-xCAT/xCAT/LparNetbootExp.pm b/perl-xCAT/xCAT/LparNetbootExp.pm index 007767b0e..5b6a88940 100644 --- a/perl-xCAT/xCAT/LparNetbootExp.pm +++ b/perl-xCAT/xCAT/LparNetbootExp.pm @@ -1240,6 +1240,12 @@ sub ping_server{ $msg[3] = "Status: ping return code now on stack\n"; $newstate[3] = 4; + # get the timeout for ping test + my $to4pt; + if ( $ENV{TIMEOUT4PINGTEST} =~ /^\d+$/ ) { + $to4pt = ",$ENV{TIMEOUT4PINGTEST}"; + } + #IPv6 if ( $server_ip =~ /:/ ) { #::1, calculate link local address @@ -1249,9 +1255,9 @@ sub ping_server{ } else { $linklocal_ip = $client_ip; } - $cmd[3] = "ping $full_path_name:ipv6,$server_ip,$linklocal_ip,$gateway_ip\r"; + $cmd[3] = "ping $full_path_name:ipv6,$server_ip,$linklocal_ip,$gateway_ip$to4pt\r"; } else { - $cmd[3] = "ping $full_path_name:$server_ip,$client_ip,$gateway_ip\r"; + $cmd[3] = "ping $full_path_name:$server_ip,$client_ip,$gateway_ip$to4pt\r"; } $pattern[3] = ".*ping(.*)ok(.*)0 >(.*)";