From 2dfe943310f1dcba7ec81f3e1988c8b18663801f Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Sat, 11 Aug 2018 12:56:56 -0400 Subject: [PATCH 001/139] Draft stateless support for SLE15 --- .../netboot/sle/compute.sle15.x86_64.exlist | 36 + .../netboot/sle/compute.sle15.x86_64.pkglist | 44 + .../sle/compute.sle15.x86_64.postinstall | 46 + .../share/xcat/netboot/sle/dracut_033/check | 3 + .../netboot/sle/dracut_033/install.netboot | 9 + .../netboot/sle/dracut_033/install.statelite | 8 + .../xcat/netboot/sle/dracut_033/installkernel | 2 + .../dracut_033/patch/syslog/module-setup.sh | 41 + .../dracut_033/patch/syslog/rsyslogd-start.sh | 51 + .../patch/syslog/syslog-genrules.sh | 97 + .../netboot/sle/dracut_033/xcat-cmdline.sh | 4 + .../netboot/sle/dracut_033/xcat-premount.sh | 18 + .../netboot/sle/dracut_033/xcat-prepivot.sh | 177 ++ .../xcat/netboot/sle/dracut_033/xcatroot | 342 +++ xCAT-server/share/xcat/netboot/sle/genimage | 2437 +++++++++++++++++ xCAT-server/share/xcat/netboot/sle/geninitrd | 2437 +++++++++++++++++ .../xcat/netboot/sle/service.sle15.pkglist | 70 + .../netboot/sle/service.sle15.postinstall | 68 + .../service.sle15.x86_64.otherpkgs.pkglist | 3 + xCAT/postscripts/xcatpostinit.service | 12 + 20 files changed, 5905 insertions(+) create mode 100644 xCAT-server/share/xcat/netboot/sle/compute.sle15.x86_64.exlist create mode 100644 xCAT-server/share/xcat/netboot/sle/compute.sle15.x86_64.pkglist create mode 100755 xCAT-server/share/xcat/netboot/sle/compute.sle15.x86_64.postinstall create mode 100755 xCAT-server/share/xcat/netboot/sle/dracut_033/check create mode 100755 xCAT-server/share/xcat/netboot/sle/dracut_033/install.netboot create mode 100755 xCAT-server/share/xcat/netboot/sle/dracut_033/install.statelite create mode 100755 xCAT-server/share/xcat/netboot/sle/dracut_033/installkernel create mode 100755 xCAT-server/share/xcat/netboot/sle/dracut_033/patch/syslog/module-setup.sh create mode 100755 xCAT-server/share/xcat/netboot/sle/dracut_033/patch/syslog/rsyslogd-start.sh create mode 100755 xCAT-server/share/xcat/netboot/sle/dracut_033/patch/syslog/syslog-genrules.sh create mode 100644 xCAT-server/share/xcat/netboot/sle/dracut_033/xcat-cmdline.sh create mode 100644 xCAT-server/share/xcat/netboot/sle/dracut_033/xcat-premount.sh create mode 100755 xCAT-server/share/xcat/netboot/sle/dracut_033/xcat-prepivot.sh create mode 100755 xCAT-server/share/xcat/netboot/sle/dracut_033/xcatroot create mode 100755 xCAT-server/share/xcat/netboot/sle/genimage create mode 100755 xCAT-server/share/xcat/netboot/sle/geninitrd create mode 100644 xCAT-server/share/xcat/netboot/sle/service.sle15.pkglist create mode 100755 xCAT-server/share/xcat/netboot/sle/service.sle15.postinstall create mode 100644 xCAT-server/share/xcat/netboot/sle/service.sle15.x86_64.otherpkgs.pkglist create mode 100755 xCAT/postscripts/xcatpostinit.service diff --git a/xCAT-server/share/xcat/netboot/sle/compute.sle15.x86_64.exlist b/xCAT-server/share/xcat/netboot/sle/compute.sle15.x86_64.exlist new file mode 100644 index 000000000..c7678ccd7 --- /dev/null +++ b/xCAT-server/share/xcat/netboot/sle/compute.sle15.x86_64.exlist @@ -0,0 +1,36 @@ +./boot* +./etc/bootsplash/themes/SLES/images* +./opt/sci/include* +./usr/include* +./usr/lib/locale* +./usr/lib/perl5/5.10.0/x86_64-linux-thread-multi/auto/Encode/CN* +./usr/lib/perl5/5.10.0/x86_64-linux-thread-multi/auto/Encode/JP* +./usr/lib/perl5/5.10.0/x86_64-linux-thread-multi/auto/Encode/TW* +./usr/lib/perl5/5.10.0/x86_64-linux-thread-multi/auto/Encode/KR* +./usr/lib/perl5/5.10.0/x86_64-linux-thread-multi/Encode/CN* +./usr/lib/perl5/5.10.0/x86_64-linux-thread-multi/Encode/JP* +./usr/lib/perl5/5.10.0/x86_64-linux-thread-multi/Encode/KR* +./usr/lib/perl5/5.10.0/x86_64-linux-thread-multi/Encode/TW* +./usr/lib64/gcc/x86_64-suse-linux/4.3/include* +./usr/local/include* +./usr/local/man* +./usr/x86_64-suse-linux/include* +./usr/share/X11/locale/* ++./usr/share/X11/locale/en_US.UTF-8* ++./usr/share/X11/locale/C* +./usr/share/cracklib* +./usr/share/doc* +./usr/share/doc/packages/cyrus-sasl/doc* +./usr/share/gnome* +./usr/share/i18n* +./usr/share/info* +./usr/share/locale/* ++./usr/share/locale/en_US* ++./usr/share/locale/C* +./usr/share/man* +./usr/share/omf* +./usr/share/vim/site/doc* +./usr/share/vim/vim72/doc* +./var/cache/man* +./var/cache/yum* + diff --git a/xCAT-server/share/xcat/netboot/sle/compute.sle15.x86_64.pkglist b/xCAT-server/share/xcat/netboot/sle/compute.sle15.x86_64.pkglist new file mode 100644 index 000000000..d0b4c3a0e --- /dev/null +++ b/xCAT-server/share/xcat/netboot/sle/compute.sle15.x86_64.pkglist @@ -0,0 +1,44 @@ +aaa_base +coreutils +bash +nfs-kernel-server +keyutils +lvm2 +openssl +dhcp-client +openssh +procps +psmisc +wget +sysconfig +rsyslog +vim +rsync +timezone +bc +ntp +gzip +e2fsprogs +parted +binutils +tar +open-iscsi +curl +plymouth +btrfsprogs +cryptsetup +dmraid +mdadm +multipath-tools +gpg2 +which +cifs-utils +open-lldp +fcoe-utils +util-linux-systemd +plymouth-dracut +udev +kernel-default +kernel-firmware +adaptec-firmware +xz diff --git a/xCAT-server/share/xcat/netboot/sle/compute.sle15.x86_64.postinstall b/xCAT-server/share/xcat/netboot/sle/compute.sle15.x86_64.postinstall new file mode 100755 index 000000000..c75134560 --- /dev/null +++ b/xCAT-server/share/xcat/netboot/sle/compute.sle15.x86_64.postinstall @@ -0,0 +1,46 @@ +#!/bin/sh +#-- Do not remove following line if you want to make use of CVS version tracking +#-- $Id: compute.postinstall,v 1.21 2008/09/04 12:05:45 sikorsky Exp $ +#-- jurij.sikorsky@t-systems.cz +#-- +#-- this script is run after all packages from $profile.pkglist are installed +#-- +#-- it gets these arguments: +#-- +#-- $1 = install root (chroot directory for profile) +#-- $2 = OS version +#-- $3 = architecture +#-- $4 = profile name +#-- $5 = work dir (where genimage is located) +#-- +#-- +installroot=$1 +osver=$2 +arch=$3 +profile=$4 +workdir=$5 + +#-- Example how /etc/fstab can be automatically generated during image generation: +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 +#cons:12345:respawn:/sbin/smart_agetty -L 38400 console +TMP_inittab=`sed 's/\(#\)\(cons:12345.*\)$/\2/' $installroot/etc/inittab` +echo "$TMP_inittab" > $installroot/etc/inittab + + +#-- Example of booted image versioning +#-- We want to know, with what configuration (version of the image) each node was booted. +#-- Hence, we keep image definition files and postscripts in CVS. During image generation we create file /etc/IMGVERSION and fill it with CVS "$Id$" of files with image definition (.pkglist, .exlist, .repolist, .postinstall). Then, during boot, each "CVS enabled" postscript (see /install/postscripts/cvs_template.sh and /install/postscripts/cvs_template.pl) adds one line to /etc/IMGVERSION. Then you can determine in any time what image you are running and what postscipts in which versions were run. +#cat /dev/null > $installroot/etc/IMGVERSION +#for ext in pkglist exlist postinstall repolist; do +# [ -r $workdir/$profile.$ext ] && cat $workdir/$profile.$ext | grep -E '^[[:space:]]*#.*[[:space:]]\$Id' >> $installroot/etc/IMGVERSION +#done + diff --git a/xCAT-server/share/xcat/netboot/sle/dracut_033/check b/xCAT-server/share/xcat/netboot/sle/dracut_033/check new file mode 100755 index 000000000..d7cc89ce0 --- /dev/null +++ b/xCAT-server/share/xcat/netboot/sle/dracut_033/check @@ -0,0 +1,3 @@ +#!/bin/sh +[ "$1" = "-d" ] && echo network +exit 0 diff --git a/xCAT-server/share/xcat/netboot/sle/dracut_033/install.netboot b/xCAT-server/share/xcat/netboot/sle/dracut_033/install.netboot new file mode 100755 index 000000000..d82e9502c --- /dev/null +++ b/xCAT-server/share/xcat/netboot/sle/dracut_033/install.netboot @@ -0,0 +1,9 @@ +#!/bin/sh +echo $drivers +dracut_install wget tar cpio gzip modprobe touch echo cut wc xz +dracut_install grep ip 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/sle/dracut_033/install.statelite b/xCAT-server/share/xcat/netboot/sle/dracut_033/install.statelite new file mode 100755 index 000000000..1ef4a721a --- /dev/null +++ b/xCAT-server/share/xcat/netboot/sle/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 ip 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/sle/dracut_033/installkernel b/xCAT-server/share/xcat/netboot/sle/dracut_033/installkernel new file mode 100755 index 000000000..7902ce5f7 --- /dev/null +++ b/xCAT-server/share/xcat/netboot/sle/dracut_033/installkernel @@ -0,0 +1,2 @@ +#!/bin/bash +instmods nfs sunrpc diff --git a/xCAT-server/share/xcat/netboot/sle/dracut_033/patch/syslog/module-setup.sh b/xCAT-server/share/xcat/netboot/sle/dracut_033/patch/syslog/module-setup.sh new file mode 100755 index 000000000..386a3a40b --- /dev/null +++ b/xCAT-server/share/xcat/netboot/sle/dracut_033/patch/syslog/module-setup.sh @@ -0,0 +1,41 @@ +#!/bin/bash +# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- +# ex: ts=8 sw=4 sts=4 et filetype=sh + +check() { + # do not add this module by default + return 255 +} + +depends() { + return 0 +} + +install() { + local _i + local _installs + if type -P rsyslogd >/dev/null; then + _installs="rsyslogd" + inst_libdir_file rsyslog/lmnet.so rsyslog/imklog.so rsyslog/imuxsock.so + elif type -P syslogd >/dev/null; then + _installs="syslogd" + elif type -P syslog-ng >/dev/null; then + _installs="syslog-ng" + else + derror "Could not find any syslog binary although the syslogmodule" \ + "is selected to be installed. Please check." + fi + if [ -n "$_installs" ]; then + inst_multiple cat $_installs + inst_hook cmdline 90 "$moddir/parse-syslog-opts.sh" + inst_hook pre-udev 61 "$moddir/syslog-genrules.sh" + inst_hook cleanup 99 "$moddir/syslog-cleanup.sh" + inst_simple "$moddir/rsyslogd-start.sh" /sbin/rsyslogd-start + inst_simple "$moddir/rsyslogd-stop.sh" /sbin/rsyslogd-stop + mkdir -m 0755 -p ${initdir}/etc/templates + inst_simple "${moddir}/rsyslog.conf" /etc/templates/rsyslog.conf + fi + dracut_install logger + dracut_need_initqueue +} + diff --git a/xCAT-server/share/xcat/netboot/sle/dracut_033/patch/syslog/rsyslogd-start.sh b/xCAT-server/share/xcat/netboot/sle/dracut_033/patch/syslog/rsyslogd-start.sh new file mode 100755 index 000000000..9589af436 --- /dev/null +++ b/xCAT-server/share/xcat/netboot/sle/dracut_033/patch/syslog/rsyslogd-start.sh @@ -0,0 +1,51 @@ +#!/bin/sh +# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- +# ex: ts=8 sw=4 sts=4 et filetype=sh + +# Triggered by udev and starts rsyslogd with bootparameters + +type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh + +rsyslog_config() { + local server=$1 + shift + local syslog_template=$1 + shift + local filters=$* + local filter= + local confline= + + cat $syslog_template + +# for filter in $filters; do +# echo "${filter} @${server}" +# done + + + if [ -n "$filters" ];then + confline="${filters}"; + else + confline="*.*" + fi + + if [ -n "$server" ];then + confline="$confline @${server}" + else + confline="$confline /var/log/messages" + fi + + echo "$confline" +# echo "*.* /tmp/syslog" +} + +[ -f /tmp/syslog.server ] && read server < /tmp/syslog.server +[ -f /tmp/syslog.filters ] && read filters < /tmp/syslog.filters +[ -z "$filters" ] && filters="kern.*" +[ -f /tmp/syslog.conf ] && read conf < /tmp/syslog.conf +[ -z "$conf" ] && conf="/etc/rsyslog.conf" && echo "$conf" > /tmp/syslog.conf + +template=/etc/templates/rsyslog.conf +if [ -n "$server" ]; then + rsyslog_config "$server" "$template" "$filters" > $conf + rsyslogd -i /var/run/syslogd.pid +fi diff --git a/xCAT-server/share/xcat/netboot/sle/dracut_033/patch/syslog/syslog-genrules.sh b/xCAT-server/share/xcat/netboot/sle/dracut_033/patch/syslog/syslog-genrules.sh new file mode 100755 index 000000000..09a58c574 --- /dev/null +++ b/xCAT-server/share/xcat/netboot/sle/dracut_033/patch/syslog/syslog-genrules.sh @@ -0,0 +1,97 @@ +#!/bin/sh +# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- +# ex: ts=8 sw=4 sts=4 et filetype=sh + +# Creates the syslog udev rules to be triggered when interface becomes online. +type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh + +detect_syslog() { + syslogtype="" + if [ -e /sbin/rsyslogd ]; then + syslogtype="rsyslogd" + elif [ -e /sbin/syslogd ]; then + syslogtype="syslogd" + elif [ /sbin/syslog-ng ]; then + syslogtype="syslog-ng" + else + warn "Could not find any syslog binary although the syslogmodule is selected to be installed. Please check." + fi + echo "$syslogtype" + [ -n "$syslogtype" ] +} + +#the initqueue.sh shipped does not support --online option and +#there are some problem when processing --onetime option +#implement a patched initqueue function here, named initqueue_enhanced +initqueue_enhanced() { + local onetime= + local qname= + local unique= + local name= + local env= + while [ $# -gt 0 ]; do + case "$1" in + --onetime) + onetime="yes";; + --settled) + qname="/settled";; + --finished) + qname="/finished";; + --timeout) + qname="/timeout";; + --online) + qname="/online";; + --unique) + unique="yes";; + --name) + name="$2";shift;; + --env) + env="$2"; shift;; + *) + break;; + esac + shift + done + + local job= + if [ -z "$unique" ]; then + job="${name}$$" + else + job="${name:-$1}" + job=${job##*/} + fi + + local exe= + exe=$1 + shift + + [ -x "$exe" ] || exe=$(command -v $exe) + if [ -z "$exe" ] ; then + echo "Invalid command" + return 1 + fi + + { + [ -n "$env" ] && echo "$env" + echo "$exe $@" + [ -n "$onetime" ] && echo "[ -e $hookdir/initqueue${qname}/${job}.sh ] && rm -f -- $hookdir/initqueue${qname}/${job}.sh" + } > "/tmp/$$-${job}.sh" + + mv -f "/tmp/$$-${job}.sh" "$hookdir/initqueue${qname}/${job}.sh" + [ -z "$qname" ] && >> $hookdir/initqueue/work + + return 0 +} + +[ -f /tmp/syslog.type ] && read syslogtype < /tmp/syslog.type +if [ -z "$syslogtype" ]; then + syslogtype=$(detect_syslog) + echo $syslogtype > /tmp/syslog.type +fi +if [ -e "/sbin/${syslogtype}-start" ]; then + #printf 'ACTION=="online", SUBSYSTEM=="net", RUN+="/sbin/initqueue --onetime /sbin/'${syslogtype}'-start $env{INTERFACE}"\n' > /etc/udev/rules.d/70-syslog.rules + #printf 'ATTR{operstate}!="down", SUBSYSTEM=="net", RUN+="/sbin/initqueue --onetime /sbin/'${syslogtype}'-start $env{INTERFACE}"\n' > /etc/udev/rules.d/70-syslog.rules + initqueue_enhanced --online --onetime /sbin/${syslogtype}-start +else + warn "syslog-genrules: Could not find binary to start syslog of type \"$syslogtype\". Syslog will not be started." +fi diff --git a/xCAT-server/share/xcat/netboot/sle/dracut_033/xcat-cmdline.sh b/xCAT-server/share/xcat/netboot/sle/dracut_033/xcat-cmdline.sh new file mode 100644 index 000000000..80d088557 --- /dev/null +++ b/xCAT-server/share/xcat/netboot/sle/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/sle/dracut_033/xcat-premount.sh b/xCAT-server/share/xcat/netboot/sle/dracut_033/xcat-premount.sh new file mode 100644 index 000000000..40c1dbbe5 --- /dev/null +++ b/xCAT-server/share/xcat/netboot/sle/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/sle/dracut_033/xcat-prepivot.sh b/xCAT-server/share/xcat/netboot/sle/dracut_033/xcat-prepivot.sh new file mode 100755 index 000000000..b5114ef43 --- /dev/null +++ b/xCAT-server/share/xcat/netboot/sle/dracut_033/xcat-prepivot.sh @@ -0,0 +1,177 @@ +#!/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 + +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 [ -f $NEWROOT/etc/hostname ]; then + echo `hostname -s` > $NEWROOT/etc/hostname +fi + +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/ifcfg-$ETHX ]; then + touch $NEWROOT/etc/sysconfig/network/ifcfg-$ETHX + fi + echo "DEVICE=$ETHX" > $NEWROOT/etc/sysconfig/network/ifcfg-$ETHX + echo "BOOTPROTO=dhcp" >> $NEWROOT/etc/sysconfig/network/ifcfg-$ETHX + echo "HWADDR=$MACX" >> $NEWROOT/etc/sysconfig/network/ifcfg-$ETHX + echo "ONBOOT=yes" >> $NEWROOT/etc/sysconfig/network/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 + +# 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/sle/dracut_033/xcatroot b/xCAT-server/share/xcat/netboot/sle/dracut_033/xcatroot new file mode 100755 index 000000000..a6839b69f --- /dev/null +++ b/xCAT-server/share/xcat/netboot/sle/dracut_033/xcatroot @@ -0,0 +1,342 @@ +#!/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 + +xcatdebugmode="$(getarg xcatdebugmode=)" + +[ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "running xcatroot...." + +[ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "MASTER=$MASTER XCATIPORT=$XCATIPORT" + +if [ $NODESTATUS -ne 0 ];then +[ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "nodestatus: netbooting,reporting..." +/tmp/updateflag $MASTER $XCATIPORT "installstatus netbooting" +fi + +if [ ! -z "$imgurl" ]; then + if [ xhttp = x${imgurl%%:*} ]; then + NFS=0 + FILENAME=${imgurl##*/} + while [ ! -r "$FILENAME" ]; do + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "downloading $imgurl...." + echo Getting $imgurl... + if ! wget -nv $imgurl; then + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "downloading $imgurl failed,retrying...." + 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.cpio.gz ] || [ -r /rootimg.cpio.xz ]; then + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "rootimg downloaded,setting up RAM-root tmpfs...." + 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 + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "Extracting root filesystem:" + echo -n "Extracting root filesystem:" + if [ -r /rootimg.cpio.gz ]; then + if [ -x /bin/cpio ]; then + gzip -cd /rootimg.cpio.gz |/bin/cpio -idum + else + gzip -cd /rootimg.cpio.gz |cpio -idum + fi + elif [ -r /rootimg.cpio.xz ]; then + if [ -x /bin/cpio ]; then + xz -cd /rootimg.cpio.xz |/bin/cpio -idum + else + xz -cd /rootimg.cpio.xz |cpio -idum + fi + fi + [ -x $NEWROOT/etc/init.d/localdisk ] && $NEWROOT/etc/init.d/localdisk + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "Done...." + echo Done +elif [ -r /rootimg.tar.gz ] || [ -r /rootimg.tar.xz ]; then + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "rootimg downloaded,setting up RAM-root tmpfs...." + 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 + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "Extracting root filesystem:" + echo -n "Extracting root filesystem:" + if [ -r /rootimg.tar.gz ]; then + tar --selinux --xattrs-include='*' -zxf /rootimg.tar.gz + if [ $? -ne 0 ]; then + tar -zxf /rootimg.tar.gz + fi + elif [ -r /rootimg.tar.xz ]; then + tar --selinux --xattrs-include='*' -Jxf /rootimg.tar.xz + if [ $? -ne 0 ]; then + tar -Jxf /rootimg.tar.xz + fi + fi + $NEWROOT/etc/init.d/localdisk + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "Done...." + 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 + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "Failed to download image, panicing in 5..." + echo -n Failed to download image, panicing in 5... + for i in 4 3 2 1 0; do + /bin/sleep 1 + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "$i..." + echo -n $i... + done + + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "You're dead. rpower nodename reset to play again." + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "* Did you packimage with -m cpio, -m squashfs, or -m nfs?" + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "* If using -m squashfs did you include aufs.ko with geninitrd? e.g.: -n tg3,squashfs,aufs,loop" + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "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" + 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 / + +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#*.} + netif=${netif%.*} + cp $lf "$NEWROOT/var/lib/dhclient/dhclient-$netif.leases" + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "saving $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/ifcfg-$ETHX ]; then + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "creating $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX" + touch $NEWROOT/etc/sysconfig/network/ifcfg-$ETHX + fi + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "writing $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX: DEVICE=$ETHX;BOOTPROTO=dhcp;HWADDR=$MACX;ONBOOT=yes" + echo "DEVICE=$ETHX" > $NEWROOT/etc/sysconfig/network/ifcfg-$ETHX + echo "BOOTPROTO=dhcp" >> $NEWROOT/etc/sysconfig/network/ifcfg-$ETHX + echo "HWADDR=$MACX" >> $NEWROOT/etc/sysconfig/network/ifcfg-$ETHX + echo "ONBOOT=yes" >> $NEWROOT/etc/sysconfig/network/ifcfg-$ETHX + fi +fi + +[ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "saving $NEWROOT/etc/resolv.conf" +cp /etc/resolv.conf "$NEWROOT/etc/" + +if [ -d "$NEWROOT/etc/sysconfig" -a ! -e "$NEWROOT/etc/sysconfig/selinux" ]; then + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "disable selinux ..." + echo "SELINUX=disabled" >> "$NEWROOT/etc/sysconfig/selinux" +fi + +[ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "setting hostname..." +echo `hostname` > $NEWROOT/etc/hostname + +[ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "exiting xcatroot..." + +# 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/sle/genimage b/xCAT-server/share/xcat/netboot/sle/genimage new file mode 100755 index 000000000..baf3746f6 --- /dev/null +++ b/xCAT-server/share/xcat/netboot/sle/genimage @@ -0,0 +1,2437 @@ +#!/usr/bin/env perl +BEGIN +{ + $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat'; +} +use lib "$::XCATROOT/lib/perl"; + +use File::Basename; +use File::Path; +use File::Copy qw/copy cp mv move/; +use File::Find; +use Getopt::Long; +use Cwd qw(realpath); +use File::Temp qw/mkdtemp/; + +use FindBin; +use lib "$FindBin::Bin/../imgutils"; +use imgutils; + +#use strict; +Getopt::Long::Configure("bundling"); +Getopt::Long::Configure("pass_through"); + +my $dracutmode; #Indicate whether this is a dracut style initrd +my $dracutdir = "dracut"; # The default directory name of dracut +my $dracutver; +my $prinic; #TODO be flexible on node primary nic +my $othernics; #TODO be flexible on node primary nic +my $netdriver; +my @yumdirs; +my $arch; +my %libhash; +my @filestoadd; +my $profile; +my $osver; +my $pathtofiles = dirname($0); +my $fullpath = realpath($pathtofiles); +my $name = basename($0); +my $onlyinitrd = 0; + +#that this method of calling genimage is no longer used +if ($name =~ /geninitrd/) { + $onlyinitrd = 1; +} +my $rootlimit; +my $tmplimit; +my $installroot = "/install"; +my $kerneldir; +my $kernelver = ""; +my $basekernelver; +my $customdir = $fullpath; +$customdir =~ s/.*share\/xcat/$installroot\/custom/; +my $imagename; +my $pkglist; +my $srcdir; +my $destdir; +my $srcdir_otherpkgs; +my $otherpkglist; +my $postinstall_filename; +my $rootimg_dir; +my $mode; +my $permission; #the permission works only for statelite mode currently +my $krpmver; +my $tempfile; +my $prompt; +my $timezone; #the TIMEZONE of the stateless and statelite node +my $ignorekernelchk; +my $noupdate; + +sub xdie { + system("rm -rf /tmp/xcatinitrd.$$"); + die @_; +} + +#-- fetch current version form CVS (overwrite locally changed versions) +# if (opendir(CVS,"$pathtofiles/CVS")){ +# close CVS; +# my $cvsout = qx/cd $pathtofiles; cvs update -C 2>&1/; +# chomp $cvsout; +# if ( $cvsout ne "cvs update: Updating ." ) { +# print "Difference of local copy from CVS detected\n"; +# print $cvsout,"\n"; +# print "Trying to re-run $name\n"; +# print("$pathtofiles/$name ",join(" ",@ARGV),"\n"); +# exec("$pathtofiles/$name",@ARGV); +# } +# } + + +$SIG{INT} = $SIG{TERM} = sub { xdie "Interrupted" }; +GetOptions( + 'a=s' => \$arch, + 'p=s' => \$profile, + 'o=s' => \$osver, + 'n=s' => \$netdriver, + 'i=s' => \$prinic, + 'r=s' => \$othernics, + 'l=s' => \$rootlimit, + 't=s' => \$tmplimit, + 'k=s' => \$kernelver, + 'g=s' => \$krpmver, + 'permission=s' => \$permission, + 'kerneldir=s' => \$kerneldir, + 'timezone=s' => \$timezone, + 'tempfile=s' => \$tempfile, #internal flag + 'pkglist=s' => \$pkglist, #internal flag + 'srcdir=s' => \$srcdir, #internal flag + 'otherpkgdir=s' => \$srcdir_otherpkgs, #internal flag + 'otherpkglist=s' => \$otherpkglist, #internal flag + 'postinstall=s' => \$postinstall_filename, #internal flag + 'rootimgdir=s' => \$destdir, #internal flag + 'driverupdatesrc=s' => \$driverupdatesrc, #internal flag + 'interactive' => \$prompt, + 'onlyinitrd' => \$onlyinitrd, + 'ignorekernelchk' => \$ignorekernelchk, + 'noupdate' => \$noupdate, +); + +if (@ARGV > 0) { + $imagename = $ARGV[0]; +} + + +my %updates_os = (); # the hash for updating osimage table +my %updates = (); # the hash for updating linuximage table + + +$permission = "755" unless ($permission); +$updates{'permission'} = $permission if ($tempfile); + +unless ($arch) { + $arch = `uname -m`; + chomp($arch); + $arch = "x86" if ($arch =~ /i.86$/); +} + +$srcdir = "$installroot/$osver/$arch" unless ($srcdir); +$updates{'pkgdir'} = $srcdir if ($tempfile); + +#$srcdir = $srcdir . "/1"; + +$srcdir_otherpkgs = "$installroot/post/otherpkgs/$osver/$arch" unless ($srcdir_otherpkgs); +#$updates{'otherpkgdir'} = $srcdir_otherpkgs if ($tempfile); + +$destdir = "$installroot/netboot/$osver/$arch/$profile" unless ($destdir); +$updates{'rootimgdir'} = $destdir if ($tempfile); + +$rootimg_dir = "$destdir/rootimg"; + +if ($kernelver && (!$krpmver)) { + print "The -g flag for the rpm version of kernel packages needs to be specified when kernel version has been specified.\n"; + exit 1; +} +$kerneldir = "$installroot/kernels" unless ($kerneldir); # the default directory for 3rd-party kernel is "$installroot/kernels"; + +#$updates{'kerneldir'} = $kerneldir if ($tempfile); + +unless ($osver and $profile) { + usage(); + exit 1; +} +my @ndrivers; + +if ($netdriver) { + foreach (split /,/, $netdriver) { + if (/^allupdate$/) { + next; + } + unless (/\.ko$/) { + s/$/.ko/; + } + next if (/^$/); + + # Do not include qeth module here + # This module is included later on + unless ($_ =~ m/qeth/i) { + push @ndrivers, $_; + } + } + + if (($updates{'netdrivers'} ne $netdriver) and $tempfile) { + $updates{'netdrivers'} = $netdriver; + } +} + +# Add the default driver list +if ($arch eq 'x86' or $arch eq 'x86_64') { + push @ndrivers, qw/tg3 bnx2 bnx2x e1000 e1000e virtio_net virtio_balloon igb mlx4_en be2net/; +} elsif ($arch eq 'ppc64') { + push @ndrivers, qw/tg3 e1000 e1000e igb ibmveth ehea be2net/; +} elsif ($arch eq "s390x") { + push @ndrivers, qw/qdio ccwgroup qeth qeth_l2 qeth_l3/; +} + +foreach (@ndrivers) { + unless (/\.ko$/) { + s/$/.ko/; + } +} + +unless (grep /af_packet/, @ndrivers) { + unshift(@ndrivers, "af_packet.ko"); +} + +my $osver_host; +if (`grep VERSION /etc/os-release` =~ /VERSION = (\d+)/) { + $osver_host = $1; +} else { + $osver_host = 11; +} + +unless ($onlyinitrd) { + + # now, let's handle the extra packages + unless ($imagename) { + $otherpkglist = imgutils::get_profile_def_filename($osver, $profile, $arch, $customdir, "otherpkgs.pkglist"); + unless ($otherpkglist) { $otherpkglist = imgutils::get_profile_def_filename($osver, $profile, $arch, $pathtofiles, "otherpkgs.pkglist"); } + $updates{'otherpkglist'} = $otherpkglist if ($tempfile and $otherpkglist); + } + my %extra_hash = (); + %extra_hash = imgutils::get_package_names($otherpkglist) if ($otherpkglist); + + + # prepare the chroot environment for the root image + + mkpath "$rootimg_dir/etc"; + mkpath "$rootimg_dir/dev"; + + #system "mount -o bind /dev $rootimg_dir/dev"; + unless (-e "$rootimg_dir/dev/zero") { + system "mknod $rootimg_dir/dev/zero c 1 5"; + } + unless (-e "$rootimg_dir/dev/null") { + system "mknod $rootimg_dir/dev/null c 1 3"; #that's neccessary for SLES11 + } + + unless (-e "$rootimg_dir/dev/random") { + system "mknod $rootimg_dir/dev/random c 1 8"; #that's neccessary for SLES11 + } + unless (-e "$rootimg_dir/dev/urandom") { + system "mknod $rootimg_dir/dev/urandom c 1 9"; #that's neccessary for SLES11 + } + + for (my $i = 0 ; $i <= 12 ; $i++) + { + unless (-e "$rootimg_dir/dev/tty$i") { + system "mknod $rootimg_dir/dev/tty$i c 4 $i"; #that's neccessary for SLES11 + } + } + + open($fd, ">>", "$rootimg_dir/etc/fstab"); # TODO: is it necessary? + print $fd "#Dummy fstab for rpm postscripts to see\n"; + close($fd); + + my $non_interactive; + if (!$prompt) { $non_interactive = "--non-interactive --no-gpg-checks --gpg-auto-import-keys"; } + + if ($osver_host >= 11) { #zypper in SLES11 is different + + system("rm -rf $rootimg_dir/etc/zypp/repos.d/$osver-*.repo"); + my @pkgdirs = split(",", $srcdir); + my $dir; + my $i = 0; + + # To support multiple paths for osimage.pkgdir + foreach $dir (@pkgdirs) { + my $ddir = $dir; + if (-d "$dir/1") { + $ddir .= "/1"; + } + system("zypper -R $rootimg_dir $non_interactive ar file:$ddir $osver-$i"); + $i++; + if (-d "$dir/2") { + $ddir = $dir . "/2"; + system("zypper -R $rootimg_dir $non_interactive ar file:$ddir $osver-$i"); + $i++; + } + } + + #if(-e "$rootimg_dir/etc/zypp/repos.d/$osver.repo") { + # system("rm -rf $rootimg_dir/etc/zypp/repos.d/$osver.repo"); + #} + #system("zypper -R $rootimg_dir $non_interactive ar file:$srcdir $osver"); + #if(-e "$rootimg_dir/etc/zypp/repos.d/${osver}sdk.repo") { + # system("rm -rf $rootimg_dir/etc/zypp/repos.d/${osver}sdk.repo"); + #} + if (opendir(SRCDIR, "$installroot/$osver/$arch/")) { + while (my $tmpfile = readdir(SRCDIR)) { + if ($tmpfile =~ m/^sdk/) { + my $srcdir_sdk = "$installroot/$osver/$arch/${tmpfile}"; + if (-d "$srcdir_sdk") { + system("zypper -R $rootimg_dir $non_interactive ar file:$srcdir_sdk ${osver}${tmpfile}"); + } + } + } + } + } else { + $srcdir = $srcdir . "/1"; + system("zypper -R $rootimg_dir $non_interactive sa file:$srcdir"); + } + + # Add the rep for kernel packages + if ($kernelver) { + if (!-d $kerneldir) { + print "Cannot find the directory for the kernel at $kerneldir.\n"; + exit 1; + } + if ($osver_host >= 11) { + if (-e "$rootimg_dir/etc/zypp/repos.d/$kernelver.repo") { + system("rm -rf $rootimg_dir/etc/zypp/repos.d/$kernelver.repo"); + } + system("zypper -R $rootimg_dir $non_interactive ar file:$kerneldir $kernelver"); + } else { + system("zypper -R $rootimg_dir $non_interactive sa file:$kerneldir"); + } + } + + #remove the old repository for extra packages + if ($osver_host >= 11) { + my $result = `zypper -R $rootimg_dir $non_interactive lr |grep otherpkg|cut -f2 -d '|'|tr "\n" " "`; + if ($result =~ /\S/) { + system("zypper -R $rootimg_dir $non_interactive rr $result"); + } + } else { + my $result = `zypper -R $rootimg_dir $non_interactive sl |grep otherpkg|cut -f2 -d '|'|tr "\n" " "`; + if ($result =~ /\S/) { + system("zypper -R $rootimg_dir $non_interactive sd $result"); + } + } + + #add the new repository for extra packages + my %extrapkgnames; + if ($osver_host >= 11) { #SLES11 + if (-e "$rootimg_dir/etc/zypp/repos.d/otherpkg.repo") { + system("rm -rf $rootimg_dir/etc/zypp/repos.d/otherpkg.repo"); + } + } + my $index = 1; + my $pass; + foreach $pass (sort { $a <=> $b } (keys(%extra_hash))) { + foreach (keys(%{ $extra_hash{$pass} })) { + + if ($_ eq "INCLUDEBAD") { + print "Unable to open the following pkglist files:\n" . join("\n", @{ $extra_hash{$pass}{INCLUDEBAD} }); + exit 1; + } + + if (($_ eq "PRE_REMOVE") || ($_ eq "POST_REMOVE") || ($_ eq "ENVLIST")) { next; } + my $whole_path = "$srcdir_otherpkgs/$_"; + if (-r "$srcdir_otherpkgs/$_/repodata/repomd.xml") { + if ($osver_host >= 11) { + system("zypper -R $rootimg_dir $non_interactive ar file:$srcdir_otherpkgs/$_ otherpkg$index"); + } else { + system("zypper -R $rootimg_dir $non_interactive sa file:$srcdir_otherpkgs/$_"); + } + } else { + if ($osver_host >= 11) { + system("zypper -R $rootimg_dir $non_interactive ar -t Plaindir file:$srcdir_otherpkgs/$_ otherpkg$index"); + } else { + system("zypper -R $rootimg_dir $non_interactive sa -t Plaindir file:$srcdir_otherpkgs/$_"); + } + } + $index++; + + my $pa = $extra_hash{$pass}{$_}; + $extrapkgnames{$pass} .= " " . join(' ', @$pa); + } + } + + #-- add custom repositories to the image + #TODO: should we add the support to otherpkgs for this? we have too many list files and it seems only SLES supports this + # not sure, but it is convenient + my $repolist; + $repolist = imgutils::get_profile_def_filename($osver, $profile, $arch, $customdir, "repolist"); + unless ($repolist) { + $repolist = imgutils::get_profile_def_filename($osver, $profile, $arch, $pathtofiles, "repolist"); + } + + if (-r "$repolist") { + print "Reading custom repositories\n"; + open($repoconfig, "<", "$repolist"); + while (<$repoconfig>) { + chomp; + next if /^\s*#/; + my ($repotype, $repourl, $repoalias) = split m/\|/; + if ($osver_host >= 11) { + system("zypper -R $rootimg_dir $non_interactive ar $repourl $repoalias"); + } else { + system("zypper -R $rootimg_dir $non_interactive sa $repourl $repoalias"); + } + } + } + + # Refresh the zypper cache in case there is still old data out there + system("zypper -R $rootimg_dir $non_interactive refresh"); + + #my $yumcmd = "yum -y -c /tmp/genimage.$$.yum.conf --installroot=$rootimg_dir --disablerepo=* "; + #$yumcmd .= "install "; + #mkpath("$rootimg_dir/var/lib/yum"); + mkpath("$rootimg_dir/etc/"); + my $passwdfile; + open($passwdfile, ">", "$rootimg_dir/etc/passwd"); + print $passwdfile "root:x:0:0:root:/root:/bin/bash\n"; + my $yumcmd; + if ($osver_host < 11) { + $yumcmd = "zypper -R $rootimg_dir $non_interactive install "; + } else { + $yumcmd = "zypper -R $rootimg_dir $non_interactive install -l --no-recommends "; #add -l for SLES11 + } + + #install packages from pkglist file + my $pkgnames; + unless ($imagename) { + $pkglist = imgutils::get_profile_def_filename($osver, $profile, $arch, $customdir, "pkglist"); + unless ($pkglist) { $pkglist = imgutils::get_profile_def_filename($osver, $profile, $arch, $pathtofiles, "pkglist"); } + } + + if ($pkglist) { + $updates{'pkglist'} = $pkglist if ($tempfile); + } else { + print "Unable to find package list for $profile!"; + exit 1; + } + + my %pkg_hash = imgutils::get_package_names($pkglist); + my $index = 1; + foreach $pass (sort { $a <=> $b } (keys(%pkg_hash))) { + $pkgnames = ""; + $group_pkgnames = ""; + foreach (keys(%{ $pkg_hash{$pass} })) { + + if ($_ eq "INCLUDEBAD") { + print "Unable to open the following pkglist files:\n" . join("\n", @{ $pkg_hash{$pass}{INCLUDEBAD} }); + exit 1; + } + + if (($_ eq "PRE_REMOVE") || ($_ eq "POST_REMOVE") || ($_ eq "ENVLIST")) { next; } + my $pa = $pkg_hash{$pass}{$_}; + + # replace the kernel package with the name has the specific version + my @npa = (); + my @npa_group = (); + foreach my $p (@$pa) { + if ($p =~ /^kernel/ && $kernelver) { + + # get all files in $srcdir and $kerneldir + my @alldirs = ("$srcdir", "$kerneldir"); + my @allrpms = (); + foreach my $dir (@alldirs) { + my @files = `find $dir -name *.rpm`; + push @allrpms, @files; + } + my @kernelpkgs = (); + if ($p =~ /^kernel$/) { + @kernelpkgs = ("kernel-default", "kernel-default-base"); + } elsif ($p =~ /^kernel-ppc64$/) { + @kernelpkgs = ($p, $p . "-base"); + } else { + @kernelpkgs = ($p); + } + foreach my $kern (@kernelpkgs) { + my @rpm = grep /$kern-$krpmver/, @allrpms; + if (!@rpm) { + print "Cannot find the kernel package with the versioin $krpmver.\n"; + exit 1; + } + my $kernelname = "$kern-" . $krpmver; + push @npa, $kernelname; + } + } else { + if ($p =~ s/^@//) + { + push @npa_group, $p; + } + else + { + push @npa, $p; + } + } + } + if (@npa) { + $pkgnames .= " " . join(' ', @npa); + } + if (@npa_group) { + $group_pkgnames .= " " . join(' ', @npa_group); + } + } + my $envlist; + if (exists $pkg_hash{$pass}{ENVLIST}) { + $envlist = join(' ', @{ $pkg_hash{$pass}{ENVLIST} }); + } + if ($pkgnames) + { + print "$envlist $yumcmd $pkgnames\n"; + $rc = system("$envlist $yumcmd $pkgnames"); + $rc = $rc >> 8; + if (($rc) && ($rc != '104')) { + print "zypper invocation failed with rc: $rc\n"; + exit 1; + } + } + if ($group_pkgnames) + { + print "$envlist $yumcmd -t pattern $group_pkgnames\n"; + $rc = system("$envlist $yumcmd -t pattern $group_pkgnames"); + $rc = $rc >> 8; + if (($rc) && ($rc != '104')) { + print "zypper invocation failed with rc: $rc\n"; + exit 1; + } + } + } + + foreach $pass (sort { $a <=> $b } (keys(%extra_hash))) { + + my $index = 1; + + #remove the old repository for extra packages + if ($osver_host >= 11) { + my $result = `zypper -R $rootimg_dir $non_interactive lr |grep otherpkg|cut -f2 -d '|'|tr "\n" " "`; + if ($result =~ /\S/) { + system("zypper -R $rootimg_dir $non_interactive rr $result"); + } + } else { + my $result = `zypper -R $rootimg_dir $non_interactive sl |grep otherpkg|cut -f2 -d '|'|tr "\n" " "`; + if ($result =~ /\S/) { + system("zypper -R $rootimg_dir $non_interactive sd $result"); + } + } + + foreach (keys(%{ $extra_hash{$pass} })) { + if (($_ eq "PRE_REMOVE") || ($_ eq "POST_REMOVE") || ($_ eq "ENVLIST")) { next; } + if (-r "$srcdir_otherpkgs/$_/repodata/repomd.xml") { + if ($osver_host >= 11) { + system("zypper -R $rootimg_dir $non_interactive ar file:$srcdir_otherpkgs/$_ otherpkg$index"); + } else { + system("zypper -R $rootimg_dir $non_interactive sa file:$srcdir_otherpkgs/$_"); + } + } else { + if ($osver_host >= 11) { + system("zypper -R $rootimg_dir $non_interactive ar -t Plaindir file:$srcdir_otherpkgs/$_ otherpkg$index"); + } else { + system("zypper -R $rootimg_dir $non_interactive sa -t Plaindir file:$srcdir_otherpkgs/$_"); + } + } + $index++; + } + + # Refresh the zypper cache in case there is still old data out there + system("zypper -R $rootimg_dir $non_interactive refresh"); + + #remove the packages that are specified in the otherpkgs.list files with leading '-' + my $envlist; + if (exists $extra_hash{$pass}{ENVLIST}) { + $envlist = join(' ', @{ $extra_hash{$pass}{ENVLIST} }); + } + + my $yumcmd_remove = "zypper -R $rootimg_dir $non_interactive remove "; + if (exists($extra_hash{$pass}{'PRE_REMOVE'})) { + my $pa = $extra_hash{$pass}{'PRE_REMOVE'}; + my $rm_packges = join(' ', @$pa); + if ($rm_packges) { + print "$envlist $yumcmd_remove $rm_packges"; + $rc = system("$envlist $yumcmd_remove $rm_packges"); + } + } + + + #add extra packages in the list + if ($extrapkgnames{$pass}) { + print "$envlist $yumcmd $extrapkgnames{$pass}\n"; + $rc = system("$envlist $yumcmd $extrapkgnames{$pass}"); + $rc = $rc >> 8; + if (($rc) && ($rc != '104')) { + print "zypper invocation failed with rc: $rc\n"; + exit 1; + } + } + + #remove the packages that are specified in the otherpkgs.list files with leading '--' + if (exists($extra_hash{$pass}{'POST_REMOVE'})) { + my $pa = $extra_hash{$pass}{'POST_REMOVE'}; + my $rm_packges = join(' ', @$pa); + if ($rm_packges) { + print "$envlist $yumcmd_remove $rm_packges"; + $rc = system("$envlist $yumcmd_remove $rm_packges"); + } + } + + if (!$noupdate) { + + # run zypper update to update any installed rpms + # needed when running genimage again after updating software in repositories + my $yumcmd_update; + if ($osver_host >= 11) { + $yumcmd_update = "zypper -R $rootimg_dir $non_interactive update "; + } else { + $yumcmd_update = "zypper -R $rootimg_dir $non_interactive update "; + } + $rc = system("$yumcmd_update"); + } + } + + #remove the old repository for extra packages + if ($osver_host >= 11) { + my $result = `zypper -R $rootimg_dir $non_interactive lr |grep otherpkg|cut -f2 -d '|'|tr "\n" " "`; + if ($result =~ /\S/) { + system("zypper -R $rootimg_dir $non_interactive rr $result"); + } + } else { + my $result = `zypper -R $rootimg_dir $non_interactive sl |grep otherpkg|cut -f2 -d '|'|tr "\n" " "`; + if ($result =~ /\S/) { + system("zypper -R $rootimg_dir $non_interactive sd $result"); + } + } + + # ignore any return code + + postscripts(); #run 'postscripts' +} +unlink "/tmp/genimage.$$.yum.conf"; + +# added dracut mode +if ((-d "$rootimg_dir/usr/share/dracut") or (-d "$rootimg_dir/usr/lib/dracut")) { + $dracutmode = 1; + + # get dracut version + $dracutver = `chroot $rootimg_dir rpm -qi dracut | awk '/Version/{print \$3}' | awk -F. '{print \$1}'`; + chomp($dracutver); + if ($dracutver =~ /^\d\d\d$/) { + if ($dracutver >= "033") { + $dracutdir = "dracut_033"; + } else { + $dracutdir = "dracut"; # The default directory + } + } + print "Enter the dracut mode. Dracut version: $dracutver. Dracut directory: $dracutdir.\n"; +} + +# default to the first kernel found in the install image if nothing specified explicitly. +# A more accurate guess than whatever the image build server happens to be running +# If specified, that takes precedence. +# If image has one, that is used +# If all else fails, resort to uname -r like this script did before + +if (-e "$rootimg_dir/boot/vmlinux") { + $basekernelver = basename(readlink "$rootimg_dir/boot/vmlinux"); + if ($basekernelver eq "vmlinux") { + $basekernelver = ""; + } else { + $basekernelver =~ s/vmlinu.-//; + $basekernelver =~ s/image-//; + } +} + +unless ($basekernelver) { + my @KVERS = <$rootimg_dir/boot/vmlinu[xz]-*>; + + # The kernel name is different on s390x, e.g. image-2.6.32.9-0.5-default + @KVERS = <$rootimg_dir/boot/image-*> if $arch eq "s390x"; + foreach (@KVERS) { + s/vmlinu.-//; + s/image-//; + } + unless (scalar @KVERS) { + @KVERS = <$rootimg_dir/lib/modules/*>; + } + if (scalar @KVERS) { + foreach my $kver (@KVERS) { + unless ($kver =~ m/.gz$/) { + $basekernelver = basename($kver); + last; + } + } + } + + @KVERS = <$rootimg_dir/lib/modules/*> unless (scalar @KVERS); + $basekernelver = basename(pop @KVERS) if (scalar @KVERS); + $basekernelver = `uname -r` unless ($basekernelver); +} + +$kernelver = $basekernelver unless ($kernelver); +chomp $kernelver; + +#$updates{kernelver} = $kernelver if ($tempfile); + +# copy the kernel to $destdir +if (-e "$rootimg_dir/boot/vmlinux-$kernelver") { + copy("$rootimg_dir/boot/vmlinux-$kernelver", "$destdir/kernel"); +} elsif (-e "$rootimg_dir/boot/vmlinuz-$kernelver") { + copy("$rootimg_dir/boot/vmlinuz-$kernelver", "$destdir/kernel"); +} elsif (-e "$rootimg_dir/boot/image-$kernelver") { + copy("$rootimg_dir/boot/image-$kernelver", "$destdir/kernel"); +} else { + xdie "couldn't find the kernel file matched $kernelver in $rootimg_dir/boot !"; +} + +#-- run postinstall script +unless ($imagename) { + $postinstall_filename = imgutils::get_profile_def_filename($osver, $profile, $arch, $customdir, "postinstall"); + unless ($postinstall_filename) { + $postinstall_filename = imgutils::get_profile_def_filename($osver, $profile, $arch, $pathtofiles, "postinstall"); + } +} + +if ($postinstall_filename) { + + #print "postinstall_filename=$postinstall_filename\n"; + + #For Mellonax IB script. In diskless image, the uname -r not returning the rootimg level, + #because the "uname -r" only returns the version of the kernel in use + #create a temporary uname script. for every flag except for -r, it should just call the real + #uname with the same flags and return that info. + if (!(-e "$rootimg_dir/bin/orig_uname")) { + system("mv $rootimg_dir/bin/uname $rootimg_dir/bin/orig_uname"); + } + my $tmpuname; + open($tmpuname, ">", "$rootimg_dir/bin/uname"); + print $tmpuname <>$tempfile"); + if ($imagename) { + if (keys(%updates) > 0) { + print FILE "The output for table updates starts here\n"; + print FILE "table::linuximage\n"; + print FILE "imagename::$imagename\n"; + my @a = %updates; + print FILE join('::', @a) . "\n"; + print FILE "The output for table updates ends here\n"; + } + } else { + $updates_os{'profile'} = $profile; + $updates_os{'imagetype'} = 'linux'; + $updates_os{'provmethod'} = 'netboot'; + $updates_os{'osname'} = 'Linux'; + $updates_os{'osvers'} = $osver; + $updates_os{'osdistroname'} = 'sle'; # not used currently + $updates_os{'osarch'} = $arch; + + # update the imagename for stateless + print FILE "The output for table updates starts here\n"; + print FILE "table::osimage\n"; + print FILE "imagename::$osver-$arch-netboot-$profile\n"; + my @a = %updates_os; + print FILE join('::', @a) . "\n"; + print FILE "The output for table updates ends here\n"; + + print FILE "The output for table updates starts here\n"; + print FILE "table::linuximage\n"; + print FILE "imagename::$osver-$arch-netboot-$profile\n"; + my @a = %updates; + print FILE join('::', @a) . "\n"; + print FILE "The output for table updates ends here\n"; + + # update the imagename for statelite + $updates_os{'provmethod'} = 'statelite'; + print FILE "The output for table updates starts here\n"; + print FILE "table::osimage\n"; + print FILE "imagename::$osver-$arch-statelite-$profile\n"; + my @a = %updates_os; + print FILE join('::', @a) . "\n"; + print FILE "The output for table updates ends here\n"; + + print FILE "The output for table updates starts here\n"; + print FILE "table::linuximage\n"; + print FILE "imagename::$osver-$arch-statelite-$profile\n"; + my @a = %updates; + print FILE join('::', @a) . "\n"; + print FILE "The output for table updates ends here\n"; + } + close FILE; +} + +#END + + + +mkpath "$rootimg_dir/.statelite"; # create place for NFS mounts; +mkpath "$rootimg_dir/.sllocal/localmnt"; # create place for localdisk mount +mkpath "$rootimg_dir/.sllocal/log"; # create place for localdisk log + +mkpath "$rootimg_dir/root/.ssh"; # create place for NFS mounts for ssh; #TODO is necessary? + +# this script will get the directories; +# TODO: it seems it is re-copied in liteimg.pm +unless (-r "$pathtofiles/../add-on/statelite/rc.statelite") { + print "Can't find $pathtofiles/../add-on/statelite/rc.statelite!\n"; + exit; +} +system("cp $pathtofiles/../add-on/statelite/rc.statelite $rootimg_dir/etc/init.d/statelite"); +system("cp $pathtofiles/../add-on/statelite/rc.localdisk $rootimg_dir/etc/init.d/localdisk"); + +# added dracutmode +unless ($dracutmode) { #in dracut mode, we delegate all this activity + unless (-l "$rootimg_dir/var/lib/dhclient") { + mkpath "$rootimg_dir/var/lib/dhclient/"; + system("touch $rootimg_dir/var/lib/dhclient/dhclient-$prinic.leases"); + } + + unless (-l "$rootimg_dir/var/lib/dhcp") { + mkpath "$rootimg_dir/var/lib/dhcp/"; + system("touch $rootimg_dir/var/lib/dhcp/dhclient-$prinic.leases"); + } +} + + +# the dhcp client information stores in the directory "/var/lib/dhcpcd/" +unless (-l "$rootimg_dir/var/lib/dhcpcd") { + mkpath "$rootimg_dir/var/lib/dhcpcd/"; + system("touch $rootimg_dir/var/lib/dhcpcd/dhcpcd-$prinic.info"); +} + +#keyctl moved to /bin for newer release +system("cd $rootimg_dir/usr/bin/; ln -s ../../bin/keyctl $rootimg_dir/usr/bin/keyctl"); + +# which is different from the Redhat family + +# some rpms mounts the imageroot/proc on the /proc, need to release it, +# otherwise got kernal panic when installing +# sometimes, the proc fs is not mounted, so one warning/error message will display, +# and I add one check point here. +my $MFD; +open MFD, "/proc/mounts"; +my @lines = ; +close MFD; + +my $ret = grep m{$rootimg_dir/proc}, @lines; +if ($ret > 0) { + system("umount -l $rootimg_dir/proc"); +} + +# Load driver update disk, and copy them to the root image +my @dd_drivers = &load_dd(); + +# Push the drivers into the @ndrivers base on the order +my @new_order = (); +foreach my $dd (@dd_drivers) { + unless (grep { $_ eq $dd } @ndrivers) { + push @new_order, $dd; + } + print "Added driver $dd from driver update disk or driver rpm\n"; +} + +if (@new_order) { + @ndrivers = (@new_order, @ndrivers); +} + +# add drivers for local disk support +push @ndrivers, ("ext3.ko", "ext4.ko", "virtio_pci.ko", "virtio_blk.ko", "libata.ko", "scsi_mod.ko", "scsi_dh.ko", "ahci.ko", "megaraid_sas.ko", "sd_mod.ko"); + +if ($osver_host >= 12) { + push @ndrivers, ("ibmvscsi.ko"); +} else { # for sles11 or lower + push @ndrivers, ("ibmvscsic.ko", "ata_piix.ko", "pcieport.ko"); +} + +if (-f "$rootimg_dir/lib/modules/$kernelver/kernel/drivers/net/ethernet/mellanox/mlx4/mlx4_en.ko") { + for (@ndrivers) { + s/mlx_en/mlx4_en/; + } +} + +open($moddeps, "<", "$rootimg_dir/lib/modules/$kernelver/modules.dep"); +my @moddeps = <$moddeps>; +my @checkdeps = @ndrivers; +while (scalar @checkdeps) { + my $driver = pop @checkdeps; + my @lines = grep /\/$driver:/, @moddeps; + foreach (@lines) { + chomp; + s/.*://; + s/^\s*//; + my @deps = split /\s+/, $_; + if ($driver =~ /libcrc32c.ko/) { + push @deps, 'crc32c.ko'; + } + my $dep; + foreach $dep (@deps) { + $dep =~ s/.*\///; + unless (grep { $_ eq $dep } @ndrivers) { #only add if not added + print "Added $dep as an autodetected dependency\n"; + } + unshift(@checkdeps, $dep); #recursively check dependencies + unshift(@ndrivers, $dep); + } + } +} +close($moddeps); + +#remove the duplicated drivers +my @fulldrivers; +foreach my $dn (@ndrivers) { + unless (grep { $_ eq $dn } @fulldrivers) { + push @fulldrivers, $dn; + } +} +@ndrivers = @fulldrivers; + +# before mkinitrd, run depmod to generate the modules.dep +system("chroot $rootimg_dir depmod $kernelver"); + +if ($dracutmode) { + mkinitrd_dracut("stateless"); + mkinitrd_dracut("statelite"); +} else { + my @drivers; # backup of @ndrivers + push @drivers, @ndrivers; + mkinitrd("statelite"); + @ndrivers = (); + push @ndrivers, @drivers; + mkinitrd("stateless"); +} +print "It is safe to ignore message 'Failed to connect to bus: No such file or directory' that may have appeared above one or more times.\n"; + +sub getlibs { + my $file = shift; + my $liblist = `chroot $rootimg_dir ldd $file`; + if ($liblist =~ /not a dynamic executable/) { + return; + } + my @libs = split /\n/, $liblist; + my @return; + foreach (@libs) { + unless (/=>/) { + (my $wjnk, my $lib, my $jnk) = split /\s+/, $_, 3; + $lib =~ s/^\///; + $libhash{$lib} = 1; + next; + } + (my $temp1, my $temp2) = split />/, $_, 2; + (my $whitespace, $temp1, $temp2) = split /\s+/, $temp2, 4; + unless ($temp1 =~ /\//) { + next; + } + $temp1 =~ s/^\///; + $libhash{$temp1} = 1; + } +} + +#added dracut +sub mkinitrd_dracut { + my ($mode) = @_; # the mode is for statelite or stateless + + my $dracutmoduledir = "$rootimg_dir/usr/share/dracut/modules.d/"; + if ((!-d $dracutmoduledir) and (-d "$rootimg_dir/usr/lib/dracut/modules.d/")) + { + $dracutmoduledir = "$rootimg_dir/usr/lib/dracut/modules.d/"; + } + + if ($dracutver >= "033") { + + my $perm = (stat("$fullpath/$dracutdir/patch/syslog/module-setup.sh"))[2]; + cp("$fullpath/$dracutdir/patch/syslog/module-setup.sh", $dracutmoduledir . "98syslog/"); + chmod($perm & 07777, $dracutmoduledir . "98syslog/" . "module-setup.sh"); + + $perm = (stat("$fullpath/$dracutdir/patch/syslog/rsyslogd-start.sh"))[2]; + cp("$fullpath/$dracutdir/patch/syslog/rsyslogd-start.sh", $dracutmoduledir . "98syslog/"); + chmod($perm & 07777, $dracutmoduledir . "98syslog/" . "rsyslogd-start.sh"); + + $perm = (stat("$fullpath/$dracutdir/patch/syslog/syslog-genrules.sh"))[2]; + cp("$fullpath/$dracutdir/patch/syslog/syslog-genrules.sh", $dracutmoduledir . "98syslog/"); + chmod($perm & 07777, $dracutmoduledir . "98syslog/" . "syslog-genrules.sh"); + + } + + my $dracutmpath = $dracutmoduledir . "97xcat/"; + mkpath($dracutmpath); + + my $perm = (stat("$fullpath/$dracutdir/check"))[2]; + cp("$fullpath/$dracutdir/check", $dracutmpath); + chmod($perm & 07777, "$dracutmpath/check"); + + foreach (@ndrivers) { s/\.ko$//; } + + # Add drivers to support local disk + push @ndrivers, "ext3"; + push @ndrivers, "ext4"; + + #remove the duplicated drivers + my @fulldrivers; + foreach my $dn (@ndrivers) { + unless (grep { $_ eq $dn } @fulldrivers) { + push @fulldrivers, $dn; + } + } + @ndrivers = @fulldrivers; + + my $add_drivers = join(' ', @ndrivers); + print "Try to load drivers: $add_drivers to initrd.\n"; + my $DRACUTCONF; + + if ($mode eq "statelite") { + + # for statelite + cp("$fullpath/$dracutdir/install.statelite", "$dracutmpath/install"); + $perm = (stat("$fullpath/$dracutdir/install.statelite"))[2]; + chmod($perm & 07777, "$dracutmpath/install"); + + cp("$installroot/postscripts/updateflag.awk", "$dracutmpath/xcat-updateflag"); + $perm = (stat("$installroot/postscripts/updateflag.awk"))[2]; + chmod($perm & 07777, "$dracutmpath/xcat-updateflag"); + + cp("$fullpath/$dracutdir/xcat-prepivot.sh", $dracutmpath); + $perm = (stat("$fullpath/$dracutdir/xcat-prepivot.sh"))[2]; + chmod($perm & 07777, "$dracutmpath/xcat-prepivot.sh"); + + cp("$fullpath/$dracutdir/xcat-premount.sh", $dracutmpath); + $perm = (stat("$fullpath/$dracutdir/xcat-premount.sh"))[2]; + chmod($perm & 07777, "$dracutmpath/xcat-premount.sh"); + + #update etc/dracut.conf + open($DRACUTCONF, '>', "$rootimg_dir/etc/dracut.conf"); + if (-d glob($dracutmoduledir . "[0-9]*fadump")) { + print $DRACUTCONF qq{dracutmodules+="xcat nfs base network kernel-modules lvm fadump"\n}; + } + else { + print $DRACUTCONF qq{dracutmodules+="xcat nfs base network kernel-modules lvm"\n}; + } + print $DRACUTCONF qq{add_drivers+="$add_drivers"\n}; + print $DRACUTCONF qq{filesystems+="nfs"\n}; + close $DRACUTCONF; + } elsif ($mode eq "stateless") { + cp("$fullpath/$dracutdir/install.netboot", "$dracutmpath/install"); + $perm = (stat("$fullpath/$dracutdir/install.netboot"))[2]; + chmod($perm & 07777, "$dracutmpath/install"); + + cp("$fullpath/$dracutdir/xcat-cmdline.sh", "$dracutmpath/"); + $perm = (stat("$fullpath/$dracutdir/xcat-cmdline.sh"))[2]; + chmod($perm & 07777, "$dracutmpath/xcat-cmdline.sh"); + + cp("$installroot/postscripts/updateflag.awk", "$dracutmpath/xcat-updateflag"); + $perm = (stat("$installroot/postscripts/updateflag.awk"))[2]; + chmod($perm & 07777, "$dracutmpath/xcat-updateflag"); + if ($prinic) { + my $optspec; + open($optspec, '>>', "$dracutmpath/xcat-cmdline.sh"); + print $optspec "PRINIC=$prinic\n"; + close $optspec; + } + + cp("$fullpath/$dracutdir/xcatroot", "$dracutmpath/"); + $perm = (stat("$fullpath/$dracutdir/xcatroot"))[2]; + chmod($perm & 07777, "$dracutmpath/xcatroot"); + + cp("$fullpath/$dracutdir/installkernel", "$dracutmpath/"); + $perm = (stat("$fullpath/$dracutdir/installkernel"))[2]; + chmod($perm & 07777, "$dracutmpath/installkernel"); + + # update etc/dracut.conf + open($DRACUTCONF, '>', "$rootimg_dir/etc/dracut.conf"); + if (-d glob($dracutmoduledir . "[0-9]*fadump")) { + print $DRACUTCONF qq{dracutmodules+="xcat nfs base network kernel-modules lvm fadump syslog"\n}; + } + else { + print $DRACUTCONF qq{dracutmodules+="xcat nfs base network kernel-modules lvm syslog"\n}; + } + print $DRACUTCONF qq{add_drivers+="$add_drivers"\n}; + close $DRACUTCONF; + } else { + xdie "the mode: $mode is not supported by genimage"; + } + + my $additional_options = undef; + if ($rootlimit) + { + open(my $ETC_CMDLINE, ">", "$rootimg_dir/tmp/cmdline"); + print $ETC_CMDLINE qq{rootlimit=$rootlimit\n}; + close $ETC_CMDLINE; + $additional_options = qq{--include /tmp/cmdline /etc/cmdline}; + } + + # force the dracut run in non-hostonly mode for dracut higher than version 033 + if ($dracutver > "033") { + $additional_options .= " -N"; + } + + #if "pigz" is available in the rootimg, use "pigz" instead of "gzip" + my $compress = qx(chroot $rootimg_dir bash -c "type -p pigz"|tr -d "\n"); + if ($compress) { + + #take the online cpu numerber as the pigz processes number + my $processnum = qx(lscpu -p=cpu --online|grep -v '#'|wc -l|tr -d "\n"); + $additional_options .= " --compress \"$compress -p $processnum \""; + } + + print "\nchroot $rootimg_dir dracut $additional_options -f /tmp/initrd.$$.gz $kernelver\n"; + !system("chroot $rootimg_dir dracut $additional_options -f /tmp/initrd.$$.gz $kernelver") + or die("Error: failed to generate the initial ramdisk for $mode.\n"); + print "the initial ramdisk for $mode is generated successfully.\n"; + move("$rootimg_dir/tmp/initrd.$$.gz", "$destdir/initrd-$mode.gz"); +} + + +sub mkinitrd { + my ($mode) = @_; # statelite or stateless + + if ($mode eq "statelite") { + + # additional modules needed on s390x + push @ndrivers, qw{qdio.ko ccwgroup.ko qeth.ko qeth_l2.ko qeth_l3.ko} if ($arch eq "s390x"); + + # for nfs + my @modlist = qw{sunrpc.ko lockd.ko nfs_acl.ko fscache.ko auth_rpcgss.ko exportfs.ko nfsd.ko nfs.ko}; + unshift(@ndrivers, @modlist); + } + + mkpath("/tmp/xcatinitrd.$$/bin"); + symlink("bin", "/tmp/xcatinitrd.$$/sbin"); + mkpath("/tmp/xcatinitrd.$$/usr/bin"); + mkpath("/tmp/xcatinitrd.$$/usr/sbin"); + mkpath("/tmp/xcatinitrd.$$/usr/lib"); + mkpath("/tmp/xcatinitrd.$$/usr/lib64"); + mkpath("/tmp/xcatinitrd.$$/lib/firmware"); + mkpath("/tmp/xcatinitrd.$$/tmp"); + mkpath("/tmp/xcatinitrd.$$/var/run"); + mkpath("/tmp/xcatinitrd.$$/lib64/firmware"); + mkpath("/tmp/xcatinitrd.$$/lib/power6"); #SLES10 + mkpath("/tmp/xcatinitrd.$$/lib/power7"); #SLES10 + mkpath("/tmp/xcatinitrd.$$/lib/mkinitrd/bin"); + mkpath("/tmp/xcatinitrd.$$/proc"); + mkpath("/tmp/xcatinitrd.$$/sys"); + mkpath("/tmp/xcatinitrd.$$/dev/mapper"); + mkpath("/tmp/xcatinitrd.$$/sysroot"); + mkpath("/tmp/xcatinitrd.$$/etc/ld.so.conf.d"); + mkpath("/tmp/xcatinitrd.$$/var/lib/dhcpcd"); + my $inifile; + open($inifile, ">", "/tmp/xcatinitrd.$$/init"); + print $inifile "#!/bin/bash\n"; + + # copied from genimage for rh + # add some functions + print $inifile < <\\ \\____/ | \\ | + /__/\\_ \\\\______ /\\____|__ /____| + \\/ \\/ \\/ +' + echo -e "\$RESET" +} + + +EOS1 + + print $inifile "mount -t proc /proc /proc\n"; + print $inifile "mount -t sysfs /sys /sys\n"; + print $inifile "mount -o mode=0755 -t tmpfs /dev /dev\n"; + print $inifile "mkdir /dev/pts\n"; + print $inifile "mount -t devpts -o gid=5,mode=620 /dev/pts /dev/pts\n"; + print $inifile "mkdir /dev/shm\n"; + print $inifile "mkdir /dev/mapper\n"; + + print $inifile "mknod /dev/random c 1 8\n"; + print $inifile "mknod /dev/urandom c 1 9\n"; + print $inifile "mknod /dev/null c 1 3\n"; + print $inifile "mknod /dev/zero c 1 5\n"; + print $inifile "mknod /dev/systty c 4 0\n"; + print $inifile "mknod /dev/tty c 5 0\n"; + print $inifile "mknod /dev/console c 5 1\n"; + print $inifile "mknod /dev/ptmx c 5 2\n"; + print $inifile "mknod /dev/rtc c 10 135\n"; + print $inifile "mknod /dev/tty0 c 4 0\n"; + print $inifile "mknod /dev/tty1 c 4 1\n"; + print $inifile "mknod /dev/tty2 c 4 2\n"; + print $inifile "mknod /dev/tty3 c 4 3\n"; + print $inifile "mknod /dev/tty4 c 4 4\n"; + print $inifile "mknod /dev/tty5 c 4 5\n"; + print $inifile "mknod /dev/tty6 c 4 6\n"; + print $inifile "mknod /dev/tty7 c 4 7\n"; + print $inifile "mknod /dev/tty8 c 4 8\n"; + print $inifile "mknod /dev/tty9 c 4 9\n"; + print $inifile "mknod /dev/tty10 c 4 10\n"; + print $inifile "mknod /dev/tty11 c 4 11\n"; + print $inifile "mknod /dev/tty12 c 4 12\n"; + print $inifile "mknod /dev/ttyS0 c 4 64\n"; + print $inifile "mknod /dev/ttyS1 c 4 65\n"; + print $inifile "mknod /dev/ttyS2 c 4 66\n"; + print $inifile "mknod /dev/ttyS3 c 4 67\n"; + + # Install modules before starting udev + # because networking modules (qeth/qeth_l2/qeth_l3) are needed + foreach (@ndrivers) { + print $inifile "insmod /lib/$_\n"; + } + + # Start udev + print $inifile < /dev/null && export DEBUG=1\n"; + } + + print $inifile < /tmp/ifcfg-\$IFACE + +ip addr add dev lo 127.0.0.1/8 +ip link set lo up + + +XCATMASTER=`echo \$XCATSERVER|awk -F: '{print \$1}'` + +if [ -z \$XCATIPORT ]; then + XCATIPORT="3002" +fi + +if [ \$NODESTATUS != 'n' ]; then + /tmp/updateflag \$XCATMASTER \$XCATIPORT "installstatus netbooting" +fi + +cd / +for i in `cat /proc/cmdline`; do + KEY=`echo \$i |awk -F= '{print \$1}'` + if [ "\$KEY" == 'imgurl' ]; then + VALUE=`echo \$i |awk -F= '{print \$2}'` + if [ "http" == "`echo \$VALUE|awk -F: '{print \$1}'`" ]; then + #NOTE needs FT retry code to scale + #NOTE: should prob have max count + FILENAME=`echo \$VALUE|awk -F/ '{print \$NF}'` + while [ ! -r "\$FILENAME" ]; do + echo Getting \$VALUE... + if ! wget \$VALUE; then + sleep 5 #should be random, exponential for scale + rm -f \$FILENAME + fi + done + fi + elif [[ "\$KEY" == NFSROOT ]]; then # for NFSROOT + NFSROOT=1 + VALUE=`echo \$i |awk -F= '{print \$2}'` + SERVER=`echo \$VALUE|awk -F: '{print \$1}'` + ROOTDIR=`echo \$VALUE|awk -F/ '{for(i=2;i<=NF;i++) printf "/%s",\$i}'` + elif [ "\$KEY" == 'STATEMNT' ]; then + STATELITE=1 + VALUE=`echo \$i |awk -F= '{print \$2}'` + # VALUE may be null + if [ ! -z \$VALUE ]; then + SNAPSHOTSERVER=`echo \$VALUE|awk -F: '{print \$1}'` + SNAPSHOTROOT=`echo \$VALUE|awk -F/ '{for(i=2;i<=NF;i++) printf "/%s",\$i}'` + # may be that there is not server and just a directory. + if [ -z \$SNAPSHOTROOT ]; then + SNAPSHOTROOT=\$SNAPSHOTSERVER + SNAPSHOTSERVER= + fi + fi + elif [ "\$KEY" == 'NODE' ]; then + NODENAME=`echo \$i |awk -F= '{print \$2}'` + fi +done + +# show xCAT logo +fancydisplay + +# Statelite code is here +if [ "\$STATELITE" = "1" ]; then + echo Setting up Statelite + mknod /dev/loop0 b 7 0 + mkdir -p \$NEWROOT + MAXTRIES=15 + ITER=0 + ME=`hostname` + if [ ! -z "$NODENAME" ]; then + ME=$NODENAME + fi + if [ "\$NFSROOT" = "1" ]; then + while ! mount.nfs \${SERVER}:\${ROOTDIR}/rootimg \$NEWROOT -r -n -o nolock,rsize=32768,tcp,nfsvers=3,timeo=14; do + ITER=\$(expr \$ITER + 1) + if [ "\$ITER" = "\$MAXTRIES" ]; then + echo "You're dead. rpower \$ME boot to play again." + echo "Possible problems: +1. This initrd wan't created for the statelite node? +2. IS DNS set up? Maybe that's why I can't mount \${SERVER}. +3. The nfs modules aren't set right in this initial ramdisk?" + shell + exit + fi + echo -e "\${RED}Couldn't mount \$SERVER:\$ROOTDIR on \$NEWROOT \$RESET" + RS=\$(expr \$RANDOM % 30) + echo -e "Trying again in \$RS seconds" + sleep \$RS + done + else + # for statelite mode on top of the ramdisk +EOMS + + print $inifile "if [ -r /rootimg-statelite.gz ]; then \n"; + print $inifile "echo Setting up RAM-root tmpfs.\n"; + if ($rootlimit) { + print $inifile " mount -o size=$rootlimit,mode=755 -t tmpfs rootfs \$NEWROOT \n"; + } else { + print $inifile " mount -o mode=755 -t tmpfs rootfs \$NEWROOT \n"; + } + + print $inifile </dev/null && shell + mount -t tmpfs rw -o mode=$permission \$NEWROOT/\$RWDIR + mkdir -p \$NEWROOT/\$RWDIR/tmpfs + + #mount the /root/.ssh, it needs more strict permission in order for ssh work + #if [ ! -e "\$NEWROOT/root/.ssh" ] + #then + # mkdir -p \$NEWROOT/root/.ssh + #fi + #mount -t tmpfs -o mode=755 ssh \$NEWROOT/root/.ssh + + # mount the SNAPSHOT directory here for persistent use. + if [ ! -z \$SNAPSHOTSERVER ] + then + mkdir -p \$NEWROOT/\$RWDIR/persistent + MAXTRIES=5 + ITER=0 + while ! mount \$SNAPSHOTSERVER:\$SNAPSHOTROOT \$NEWROOT/\$RWDIR/persistent -o nolock,\$XCATMNTOPTS + do + ITER=\$(expr \$ITER + 1) + if [ "\$ITER" == "\$MAXTRIES" ] + then + echo "You're 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." + shell + exit + fi + echo -e "\${RED}Hmmm... Can't mount \$SNAPSHOTSERVER:\$SNAPSHOTROOT. \${NORMAL} \$XCATMNTOPTS" + RS=`expr \$RANDOM % 20` + echo -e "Trying again in \$RS seconds" + sleep \$RS + done + + # create directory which is named after my node name + mkdir -p \$NEWROOT/\$RWDIR/persistent/\$ME + ITER=0 + # umount current persistent mount + while ! umount -l \$NEWROOT/\$RWDIR/persistent; do + ITER=\$(( ITER + 1 )) + if [ "\$ITER" == "\$MAXTRIES" ]; then + echo "Your are dead, rpower \$ME boot to play again." + echo "Cannot umount \$NEWROOT/\$RWDIR/persistent." + /bin/sh + exit + fi + RS= \$(( \$RANDOM % 20 )) + echo "Trying again in \$RS seconds..." + sleep \$RS + done + + # mount persistent to server:/rootpath/nodename + ITER=0 + while ! mount \$SNAPSHOTSERVER:/\$SNAPSHOTROOT/\$ME \$NEWROOT/\$RWDIR/persistent -o nolock,\$XCATMNTOPTS; do + ITER=\$(( ITER + 1 )) + if [ "\$ITER" == "\$MAXTRIES" ]; then + echo "Your are dead, rpower \$ME boot to play again." + echo "Possible problems: cannot mount to \$SNAPSHOTSERVER:/\$SNAPSHOTROOT/\$ME." + /bin/sh + exit + fi + RS= \$(( \$RANDOM % 20 )) + echo "Trying again in \$RS seconds..." + sleep \$RS + done + fi + + grep '\\(shell\\)' /proc/cmdline >/dev/null && shell + + # have to preserve the initial DHCP request. So we link it. + # SLES uses different file to store DHCP info + if [ ! -d \$NEWROOT/\$RWDIR/tmpfs/var/lib/dhcpcd ] + then + mkdir -p \$NEWROOT/\$RWDIR/tmpfs/var/lib/dhcpcd + fi + cp -fp /var/lib/dhcpcd/dhcpcd-\$IFACE.info \${NEWROOT}/\${RWDIR}/tmpfs/var/lib/dhcpcd/dhcpcd-\$IFACE.info + + [ -e /etc/ntp.conf ] && mkdir -p \$NEWROOT/\$RWDIR/tmpfs/etc && cp /etc/ntp.conf \$NEWROOT/\$RWDIR/tmpfs/etc/ + + [ -e /etc/resolv.conf ] && mkdir -p \$NEWROOT/\$RWDIR/tmpfs/etc && cp /etc/resolv.conf \$NEWROOT/\$RWDIR/tmpfs/etc/ + + # now that everything is mounted, lets do this + # hmmm, apparently I'm checking this twice... so I'd better + # be really sure the file is there. + while [ ! -e \$NEWROOT/etc/init.d/statelite ] + do + echo "\$NEWROOT/etc/init.d/statelite does not exist in image!" + shell + done + + # try to configure the local disk + \$NEWROOT/etc/init.d/localdisk + + # do all the mounts: + \$NEWROOT/etc/init.d/statelite +EOMS + + # udevd needed by s390x for networking + # but for other type of machine, udevd will affect the start of devices which detected + # after the chroot, so kill it before the switching root + if ($arch ne "s390x") { + print $inifile "\n killall -9 udevd\n"; + } + + print $inifile < /dev/null && shell + + echo 0x100 > /proc/sys/kernel/real-root-dev + export keep_old_ip=yes + export fastboot=yes + export READONLY=yes + grep '\\(shell\\)' /proc/cmdline >/dev/null && shell + mount -n --bind /dev /sysroot/dev + umount /sys + umount /proc + + # sles use the standard utility to chroot + if ! exec /usr/bin/chroot \$NEWROOT /sbin/init + then + echo "" + echo -e "\${RED}Couldn't chroot. Something must be wrong with NFS root image.\${RESET}" + shell + fi + exit +fi +# end NFSROOT/Statelite code + +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 /sysroot + mkdir -p /sysroot/ro + mkdir -p /sysroot/rw + mount --move /ro /sysroot/ro + mount --move /rw /sysroot/rw +EOMS + print $inifile "elif [ -r /rootimg.cpio.gz ] || [ -r /rootimg.cpio.xz ]; then\n"; + print $inifile "echo Setting up RAM-root tmpfs.\n"; + if ($rootlimit) { + print $inifile " mount -o size=$rootlimit,mode=755 -t tmpfs rootfs \$NEWROOT\n"; + } else { + print $inifile " mount -o mode=755 -t tmpfs rootfs \$NEWROOT\n"; + } + print $inifile " cd /sysroot\n"; + print $inifile " echo -n \"Extracting root filesystem:\"\n"; + print $inifile " if [ -r /rootimg.cpio.gz ]; then\n"; + print $inifile " if [ -x /bin/cpio ]; then\n"; + print $inifile " zcat /rootimg.cpio.gz |/bin/cpio -idum\n"; + print $inifile " else\n"; + print $inifile " zcat /rootimg.cpio.gz |cpio -idum\n"; + print $inifile " fi\n"; + print $inifile " elif [ -r /rootimg.cpio.xz ]; then\n"; + print $inifile " if [ -x /bin/cpio ]; then\n"; + print $inifile " xz -cd /rootimg.cpio.xz |/bin/cpio -idum\n"; + print $inifile " else\n"; + print $inifile " xz -cd /rootimg.cpio.xz |cpio -idum\n"; + print $inifile " fi\n"; + print $inifile " fi\n"; + print $inifile " echo Done\n"; + print $inifile "elif [ -r /rootimg.tar.gz ] || [ -r /rootimg.tar.xz ]; then\n"; + print $inifile " echo Setting up RAM-root tmpfs.\n"; + + if ($rootlimit) { + print $inifile " mount -o \"size=$rootlimit,mode=755\" -t tmpfs rootfs \$NEWROOT\n"; + } else { + print $inifile " mount -o mode=755 -t tmpfs rootfs \$NEWROOT\n"; + } + print $inifile " cd \$NEWROOT\n"; + print $inifile " echo -n \"Extracting root filesystem:\"\n"; + print $inifile " if [ -r /rootimg.tar.gz ]; then\n"; + print $inifile " tar --selinux --xattrs-include='*' -zxf /rootimg.tar.gz\n"; + print $inifile " if [ \$? -ne 0 ]; then\n"; + print $inifile " tar -zxf /rootimg.tar.gz\n"; + print $inifile " fi\n"; + print $inifile " elif [ -r /rootimg.tar.xz ]; then\n"; + print $inifile " tar --selinux --xattrs-include='*' -Jxf /rootimg.tar.xz\n"; + print $inifile " if [ \$? -ne 0 ]; then\n"; + print $inifile " tar -Jxf /rootimg.tar.xz\n"; + print $inifile " fi\n"; + print $inifile " fi\n"; + print $inifile " echo Done\n"; + print $inifile "else\n"; + print $inifile " echo -n Failed to download image, panicing in 5...\n"; + print $inifile " for i in 4 3 2 1 0; do\n"; + print $inifile " /bin/sleep 1\n"; + print $inifile " echo -n \$i...\n"; + print $inifile " done\n"; + print $inifile " echo\n"; + print $inifile <" . "/tmp/xcatinitrd.$$/bin/netstart"); + print $inifile "#!/bin/bash \n"; + if ($osver_host == 10) { + print $inifile "dhcpcd \${1}\n"; + } else { # for sles11 or higher + # -p is used to keep the network connection during the shutdown. Used for nfs-based statelite shutdown + print $inifile "dhcpcd \${1} -p\n"; + } + + #-- Bring other NICs up in /bin/netstart in initrd for NIC failover + foreach (split /,/, $othernics) { + if (/^$/) { next; } + print $inifile "dhcpcd $_\n"; + } + + print $inifile <> /etc/HOSTNAME +END + + close($inifile); + + #if "nonodestatus" specified,do not update the nodestatus + system("mkdir -p /tmp/xcatinitrd.$$/tmp/"); + cp("$installroot/postscripts/updateflag.awk","/tmp/xcatinitrd.$$/tmp/updateflag"); + $perm = (stat("$installroot/postscripts/updateflag.awk"))[2]; + chmod($perm & 07777, "/tmp/xcatinitrd.$$/tmp/updateflag"); + + chmod(0755, "/tmp/xcatinitrd.$$/init"); + chmod(0755, "/tmp/xcatinitrd.$$/bin/netstart"); + + @filestoadd = (); + foreach (@ndrivers) { + if (-f "$customdir/$_") { + push @filestoadd, [ $_, "lib/$_" ]; + } elsif (-f "$pathtofiles/$_") { + push @filestoadd, [ $_, "lib/$_" ]; + } + } + if ($mode eq "statelite") { + foreach ("sbin/ifconfig", "usr/bin/clear", "usr/bin/touch", "usr/bin/cut", "usr/bin/rm", "bin/hostname", "usr/bin/egrep", "bin/ln", "bin/ls", "usr/bin/dirname", "usr/bin/expr", "usr/bin/chroot", "usr/bin/grep", "bin/cpio", "bin/sleep", "bin/mount", "bin/umount", "sbin/dhcpcd", "bin/bash", "sbin/insmod", "bin/mkdir", "bin/mknod", "sbin/ip", "bin/cat", "usr/bin/awk", "usr/bin/wget", "bin/cp", "usr/bin/cpio", "usr/bin/zcat", "usr/bin/gzip", "lib/mkinitrd/bin/run-init", "usr/bin/uniq", "usr/bin/sed", "usr/bin/wc", "bin/sed", "sbin/udevd", "usr/bin/readlink", "usr/sbin/parted", "sbin/mke2fs", "sbin/mkswap", "sbin/swapon", "bin/chmod", "usr/bin/bc", "usr/bin/xz", "usr/bin/gzip", "bin/tar") { + getlibs($_); + push @filestoadd, $_; + } + if ($osver_host >= 11) { + foreach ("sbin/mount.nfs", "sbin/umount.nfs", "sbin/udevadm") { + getlibs($_); + push @filestoadd, $_; + } + } + + } else { + foreach ("sbin/ifconfig", "usr/bin/clear", "usr/bin/touch", "usr/bin/grep", "usr/bin/egrep", "bin/cpio", "bin/sleep", "bin/mount", "sbin/dhcpcd", "bin/bash", "sbin/insmod", "bin/mkdir", "bin/mknod", "sbin/ip", "bin/cat", "usr/bin/awk", "usr/bin/wget", "bin/cp", "usr/bin/cpio", "usr/bin/zcat", "usr/bin/gzip", "lib/mkinitrd/bin/run-init", "usr/bin/uniq", "usr/bin/sed", "sbin/udevd", "usr/bin/readlink", "usr/bin/expr", "usr/sbin/parted", "sbin/mke2fs", "sbin/mkswap", "sbin/swapon", "bin/chmod", "usr/bin/bc", "usr/bin/xz", "usr/bin/gzip", "bin/tar") { + getlibs($_); + push @filestoadd, $_; + } + if ($osver_host >= 11) { + getlibs("sbin/udevadm"); + push @filestoadd, "sbin/udevadm"; + } + } + + if ($arch =~ /64/) { + push @filestoadd, "lib64/libnss_dns.so.2"; + push @filestoadd, "lib64/libnss_files.so.2"; + } + else { + push @filestoadd, "lib/libnss_dns.so.2"; + push @filestoadd, "lib/libnss_files.so.2"; + } + + # cross-platfrom support on power6&7 etc + # ldd can't handle such one scenario: mn is power6, the target platform is power7 + if ($arch =~ /ppc64/) { + system("cp -a -r $rootimg_dir/lib64/* /tmp/xcatinitrd.$$/lib64/"); + } + + + push @filestoadd, keys %libhash; + + find(\&isnetdriver, <$rootimg_dir/lib/modules/$kernelver/*>); + my $pathonrootimage = "$rootimg_dir/tmpfiles"; + my $pathinrootimage = "/tmpfiles"; + mkpath($pathonrootimage); + foreach (@filestoadd) { + if (ref($_)) { + + #print "$_->[0], $_->[1]\n"; + my $srcfile = $_->[0]; + system("chroot $rootimg_dir cp $srcfile $pathinrootimage"); + my $srcpath = "$pathonrootimage/" . basename($_->[0]); + if (-f "$customdir/" . $_->[0]) { + $srcpath = "$customdir/" . $_->[0]; + } elsif (-f "$pathtofiles/" . $_->[0]) { + $srcpath = "$pathtofiles/" . $_->[0]; + } + mkpath(dirname("/tmp/xcatinitrd.$$/" . $_->[1])); + copy($srcpath, "/tmp/xcatinitrd.$$/" . $_->[1]); + chmod 0755, "/tmp/xcatinitrd.$$/" . $_->[1]; + } else { + + #print "$_\n"; + system("chroot $rootimg_dir cp $_ $pathinrootimage"); + my $srcpath = "$pathonrootimage/" . basename($_); + if (-f "$customdir/$_") { + $srcpath = "$customdir/$_"; + } elsif (-f "$pathtofiles/$_") { + $srcpath = "$pathtofiles/$_"; + } + mkpath(dirname("/tmp/xcatinitrd.$$/$_")); + copy("$srcpath", "/tmp/xcatinitrd.$$/$_"); + chmod 0755, "/tmp/xcatinitrd.$$/" . $_; + } + } + rmtree($pathonrootimage); + + #copy conf files needed by nfs mount in sles11.2 + if ($osver_host >= 11) + { + system("cp -r $rootimg_dir/etc/protocols /tmp/xcatinitrd.$$/etc/"); + system("cp -r $rootimg_dir/etc/netconfig /tmp/xcatinitrd.$$/etc/"); + } + + + # Copy udev libraries + system("mkdir -p /tmp/xcatinitrd.$$/etc/udev"); + system("mkdir -p /tmp/xcatinitrd.$$/lib/firmware"); + system("cp -r $rootimg_dir/etc/udev/* /tmp/xcatinitrd.$$/etc/udev"); + system("cp -r $rootimg_dir/bin/uname /tmp/xcatinitrd.$$/bin/"); + if (-d "$rootimg_dir/lib/firmware/") { + system("cp -r $rootimg_dir/lib/firmware/* /tmp/xcatinitrd.$$/lib/firmware"); + } + system("cp -r $rootimg_dir/usr/bin/killall /tmp/xcatinitrd.$$/usr/bin"); + + # Copy rules for network adapter + #my $name = `cat /etc/sysconfig/network/ifcfg-$prinic | grep NAME`; + #my $nic = ''; + #if ($name =~ m/(\d+\.\d+\.\d+)/g) { + # $nic = $&; + #} + + # Somehow checking for *$nic.rules does not work + #if ( -f "/etc/udev/rules.d/*$nic.rules" ) { + # system("cp -r /etc/udev/rules.d/*$nic.rules /tmp/xcatinitrd.$$/etc/udev/rules.d"); + #} + #if ( -f "/etc/udev/rules.d/*persistent-net.rules" ) { + # system("cp -r /etc/udev/rules.d/*persistent-net.rules /tmp/xcatinitrd.$$/etc/udev/rules.d"); + #} + + system("mkdir -p /tmp/xcatinitrd.$$/lib/udev"); + system("cp -r $rootimg_dir/lib/udev/* /tmp/xcatinitrd.$$/lib/udev"); + + #copy("$rootimg_dir/lib/modules/*d","/tmp/xcatinitrd.$$/$_"); + system("cd /tmp/xcatinitrd.$$/bin/; ln -sf bash sh"); #neccessary for SLES11 + if ($mode eq "statelite") { + system("cd /tmp/xcatinitrd.$$;find .|cpio -H newc -o|gzip -9 -c - > $destdir/initrd-statelite.gz"); + print "The initial ramdisk for statelite has been generated successfully!\n"; + } else { + system("cd /tmp/xcatinitrd.$$;find .|cpio -H newc -o|gzip -9 -c - > $destdir/initrd-stateless.gz"); + print "The initial ramdisk for stateless has been generated successfully!\n"; + } + system("rm -rf /tmp/xcatinitrd.$$"); + +} + +sub isyumdir { + if ($File::Find::name =~ /\/repodata$/) { + my $location = $File::Find::name; + $location =~ s/\/repodata$//; + push @yumdirs, $location; + } +} + +sub isnetdriver { + foreach (@ndrivers) { + if ($File::Find::name =~ /\/$_/) { + my $filetoadd = $File::Find::name; + $filetoadd =~ s!$rootimg_dir!!; + push @filestoadd, [ $filetoadd, "lib/$_" ]; + print "Added driver $_ to initrd\n"; + } + } +} + + + + + + + +sub postscripts { # TODO: customized postscripts + generic_post(); + unless (-d "$rootimg_dir/opt/xcat/") { + mkdir "$rootimg_dir/opt/xcat/"; + } + copy("$installroot/postscripts/xcatdsklspost", "$rootimg_dir/opt/xcat/"); #TODO: it is not used in stateless + chmod '0755', "$rootimg_dir/opt/xcat/xcatdsklspost"; +} + +sub generic_post { # This function is meant to leave the image in a state approximating a normal install + my $cfgfile; + + #modify /etc/sysconfig/clock in the image:HWCLOCK="--local", TIMEZONE=site:timezone + if ($timezone) { + if (-e "$rootimg_dir/etc/sysconfig/clock") { + system("sed -i '" . 's!\(TIMEZONE=\).*!\1' . "\"$timezone\"!" . "' $rootimg_dir/etc/sysconfig/clock"); + } + system("chroot $rootimg_dir zic -l $timezone"); + } + + if (-e "$rootimg_dir/etc/sysconfig/clock") { + system("sed -i 's!\\(HWCLOCK=\\).*!\\1\"--localtime\"!' $rootimg_dir/etc/sysconfig/clock"); + } + + unlink("$rootimg_dir/dev/null"); + system("mknod $rootimg_dir/dev/null c 1 3"); + open($cfgfile, ">", "$rootimg_dir/etc/fstab"); + print $cfgfile "devpts /dev/pts devpts gid=5,mode=620 0 0\n"; + print $cfgfile "tmpfs /dev/shm tmpfs defaults 0 0\n"; + print $cfgfile "proc /proc proc defaults 0 0\n"; + print $cfgfile "sysfs /sys sysfs defaults 0 0\n"; + if ($tmplimit) { + print $cfgfile "tmpfs /tmp tmpfs defaults,size=$tmplimit 0 2\n"; + print $cfgfile "tmpfs /var/tmp tmpfs defaults,size=$tmplimit 0 2\n"; + } else { + print $cfgfile "tmpfs /tmp tmpfs defaults,size=10m 0 2\n"; + print $cfgfile "tmpfs /var/tmp tmpfs defaults,size=10m 0 2\n"; + } + + my $rootfs_name = $profile . "_" . $arch; + print $cfgfile "$rootfs_name / tmpfs rw 0 1\n"; + + close($cfgfile); + + open($cfgfile, ">", "$rootimg_dir/etc/sysconfig/network"); + print $cfgfile "NETWORKING=yes\n"; + close($cfgfile); + + open($cfgfile, ">", "$rootimg_dir/etc/resolv.conf"); + print $cfgfile "#Dummy resolv.conf to make boot cleaner"; + close($cfgfile); + + # Create the ifcfg-x file for diskless node. But keep the ONBOOT=no + # to skip the break of nfs-based boot + if ($prinic) { + open($cfgfile, ">", "$rootimg_dir/etc/sysconfig/network/ifcfg-$prinic"); + print $cfgfile "ONBOOT=no\nBOOTPROTO=dhcp\nDEVICE=$prinic\nSTARTMODE=auto\n"; + close($cfgfile); + } + + foreach (split /,/, $othernics) { + next if (/^$/); + open($cfgfile, ">", "$rootimg_dir/etc/sysconfig/network/ifcfg-$_"); + print $cfgfile "ONBOOT=yes\nBOOTPROTO=dhcp\nDEVICE=$_\nSTARTMODE=auto\n"; + close($cfgfile); + } + + # securetty not needed on s390x + if ($arch ne "s390x") { + open($cfgfile, ">>", "$rootimg_dir/etc/securetty"); + print $cfgfile "ttyS0\n"; + print $cfgfile "ttyS1\n"; + print $cfgfile "console\n"; + close($cfgfile); + } + + my @passwd; + open($cfgfile, "<", "$rootimg_dir/etc/passwd"); + @passwd = <$cfgfile>; + close($cfgfile); + open($cfgfile, ">", "$rootimg_dir/etc/passwd"); + foreach (@passwd) { + if (/^root:/) { + s/^root:\*/root:x/; + } + print $cfgfile $_; + } + close($cfgfile); + foreach (<$rootimg_dir/etc/skel/.*>) { + next if (basename($_) eq '.' or basename($_) eq '..'); + copy $_, "$rootimg_dir/root/"; + } + + # gettyset is not found on s390x + if ($arch ne "s390x") { + open($cfgfile, ">", "$rootimg_dir/etc/init.d/gettyset"); + print $cfgfile "#!/bin/bash\n"; + print $cfgfile "### BEGIN INIT INFO\n"; + print $cfgfile "# Provides: gettyset\n"; + print $cfgfile "# Required-Start: sshd\n"; + print $cfgfile "# Required-Stop:\n"; + print $cfgfile "# Default-Start: 3\n"; + print $cfgfile "# Default-Stop: 0 1 2 6\n"; + print $cfgfile "# Short-Description: gettyset\n"; + print $cfgfile "# Description:\n"; + print $cfgfile "### END INIT INFO\n"; + print $cfgfile "VERS=`grep VERSION /etc/SuSE-release`\n"; + print $cfgfile "if [ -n \"\$VERS\" ]; then\n"; + print $cfgfile " VERNUM=`echo \$VERS|awk -F= \'{print \$2}\'|sed -e \'s/ //g\'`\n"; + print $cfgfile "fi\n"; + print $cfgfile "if [ \"\$VERNUM\" -gt 10 ]; then\n"; + print $cfgfile " exit\n"; + print $cfgfile "fi\n"; + print $cfgfile "\n"; + print $cfgfile "for i in `cat /proc/cmdline`; do\n"; + print $cfgfile ' KEY=`echo $i|cut -d= -f 1`' . "\n"; + print $cfgfile " if [ \"\$KEY\" == \"console\" -a \"\$i\" != \"console=tty0\" ]; then\n"; + print $cfgfile " VALUE=`echo \$i | cut -d= -f 2`\n"; + print $cfgfile " COTTY=`echo \$VALUE|cut -d, -f 1`\n"; + print $cfgfile " COSPEED=`echo \$VALUE|cut -d, -f 2|cut -dn -f 1`\n"; + print $cfgfile " if echo \$VALUE | grep n8r; then\n"; + print $cfgfile " FLOWFLAG=\"-h\"\n"; + print $cfgfile " fi\n"; + print $cfgfile " echo xco:2345:respawn:/sbin/agetty \$FLOWFLAG \$COTTY \$COSPEED xterm >> /etc/inittab\n"; + print $cfgfile " init q\n"; + print $cfgfile " fi\n"; + print $cfgfile "done\n"; + print $cfgfile "/etc/init.d/boot.localnet start\n"; + + close($cfgfile); + chmod(0755, "$rootimg_dir/etc/init.d/gettyset"); + } + + copy("$installroot/postscripts/xcatpostinit", "$rootimg_dir/etc/init.d/xcatpostinit"); + chmod(0755, "$rootimg_dir/etc/init.d/xcatpostinit"); + copy("$installroot/postscripts/xcatpostinit.service", "$rootimg_dir/usr/lib/systemd/system/xcatpostinit.service"); + + # + # set certain system services to start on boot, if the file exists in /etc/init.d as a script, + # use insserv to start it. If not, assume that the service is controlled by systemctl + # + # note: insserv is passed the -f option to ignore the dependency on sles10.4 + # + print "[genimage] setting services to start at boot time...\n"; + my @services; + push @services, qw/sshd network gettyset xcatpostinit/; + + foreach my $service (@services) { + my $cmd = "chroot $rootimg_dir "; + $cmd = $cmd . "systemctl enable $service.service"; + system("$cmd"); + } + + # + # Check if .depend.start file exists. For SLES12 and later OS, this does not apply + # + if (-r '$rootimg_dir/etc/init.d/.depend.start') { + my $rc = system("grep sshd $rootimg_dir/etc/init.d/.depend.start | grep TARGETS"); + if ($rc) { + system("sed -i '" . 's/^\(TARGETS = .*\)$/\1 sshd/' . "' $rootimg_dir/etc/init.d/.depend.start"); + system("ln -s ../sshd $rootimg_dir/etc/init.d/rc3.d/S20sshd"); + } + my $rc = system("grep gettyset $rootimg_dir/etc/init.d/.depend.start | grep TARGETS"); + if ($rc) { + system("sed -i '" . 's/^\(TARGETS = .*\)$/\1 gettyset/' . "' $rootimg_dir/etc/init.d/.depend.start"); + system("ln -s ../gettyset $rootimg_dir/etc/init.d/rc3.d/S60gettyset"); + } + } +} + + +my $driver_name; +my $real_path; + +sub get_path () +{ + if ($File::Find::name =~ /\/$driver_name/) { + $real_path = $File::Find::name; + } +} + +my @all_real_path; + +sub get_all_path () +{ + if ($File::Find::name =~ /\/$driver_name/) { + push @all_real_path, $File::Find::name; + } +} + +# Load driver disk and driver rpm to the initrd +# Get the driver disk or driver rpm from the osimage.driverupdatesrc +# The valid value: dud:/install/dud/dd.img,rpm:/install/rpm/d.rpm, if missing the tag: 'dud'/'rpm' +# the 'rpm' is default. +# +# If cannot find the driver disk from osimage.driverupdatesrc, will try to search driver disk +# from /install/driverdisk// +# +# For driver rpm, the driver list will be gotten from osimage.netdrivers. If not set, copy all the drivers from driver +# rpm to the initrd. +# +# Return the driver names by loading order + +sub load_dd() +{ + my @dd_list; + my @rpm_list; + my @driver_list; + + my $Injectalldriver; + my @rpm_drivers; + + # Parse the parameters to the the source of Driver update disk and Driver rpm, and driver list as well + if ($driverupdatesrc) { + my @srcs = split(',', $driverupdatesrc); + foreach my $src (@srcs) { + if ($src =~ /dud:(.*)/i) { + push @dd_list, $1; + } elsif ($src =~ /rpm:(.*)/i) { + push @rpm_list, $1; + } else { + push @rpm_list, $src; + } + } + } + if (!@dd_list) { + + # get Driver update disk from the default path if not specified in osimage + # check the Driver Update Disk images, it can be .img or .iso + if (-d "$installroot/driverdisk/$osver/$arch") { + @dd_list = `find $installroot/driverdisk/$osver/$arch -type f`; + } + } + + foreach (split /,/, $netdriver) { + if (/^allupdate$/) { + $Injectalldriver = 1; + next; + } + unless (/\.ko$/) { + s/$/.ko/; + } + push @driver_list, $_; + } + + chomp(@dd_list); + chomp(@rpm_list); + + unless (@dd_list || (@rpm_list && ($Injectalldriver || @driver_list))) { + return (); + } + + # Create the work space, it should be cleaned at end of genimage + my $dd_dir = mkdtemp("/tmp/ddtmpXXXXXXX"); + mkpath "$dd_dir/mnt"; + mkpath "$dd_dir/mods"; + + my @dd_drivers = (); #driver names + + # Load drivers from each Driver Disk + # For multiple dd, if want to make it has order, rename the dd with a number + # ahead of the name like 0_xx, 1_xx + foreach my $dd (sort(@dd_list)) { + my $rc = system("mount -o loop $dd $dd_dir/mnt"); + if ($rc) { + print "mount the Driver Disk $dd failed.\n"; + next; + } + + mkpath "$dd_dir/full"; + + # Copy out the drivers + opendir(DIR, "$dd_dir/mnt") || die "Cannot open dir $dd_dir/mnt"; + while (my $dir = readdir(DIR)) { + if ($dir =~ /^\./) { next; } + + # Every driver update disk can have multiple directories, each directory + # has the directory format like /linux/[distribution]/[architechture]-[version]/ + # If the directory name is numeric, then it will be used as order to load the + # the dirviers inside. + # For the directory name which is not numeric, copy them to directory 0. It will be + # loaled first. + if ($dir !~ /^\d*$/) { + mkpath "$dd_dir/full/0"; + system("cp -rf $dd_dir/mnt/$dir $dd_dir/full/0"); + } else { + system("cp -rf $dd_dir/mnt/$dir $dd_dir/full/"); + } + } + closedir(DIR); + + # Get all the kernel modules base on the order of directory name. + + # The structure of dd: /linux/[distribution]/[architechture]-[version]/ + + # The supported arch: i386, ia64, ppc, ppc64, s390, s390x sparc or x86_64. + my $darch = $arch; + if ($darch =~ /^x86$/) { + $darch = "i386"; + } + + # If the version is os version. If the os is "sles11.1", the possible os version + # could be "sles11.1", "11.1", "11", "sles11" + my @distro = ($osver); + my $distro1 = $osver; + $distro1 =~ s/[^\d]*//; + push @distro, $distro1; + my $distro2 = $distro1; + $distro2 =~ s/\..*//; + push @distro, $distro2; + my $distro3 = $osver; + $distro3 =~ s/\..*//; + push @distro, $distro3; + + opendir(FDIR, "$dd_dir/full") || die "Cannot open dir $dd_dir/full"; + my @fulldir = readdir(FDIR); + closedir(FDIR); + + # Create the directory for drivers from driver disk + if (!-d "$rootimg_dir/lib/modules/$kernelver/kernel/drivers/driverdisk") { + mkpath "$rootimg_dir/lib/modules/$kernelver/kernel/drivers/driverdisk"; + } + + # Copy the drivers to the root image and get the driver loading order + foreach my $dir (sort(@fulldir)) { + if ($dir =~ /^\./) { next; } + my $vdir; + foreach (@distro) { + if (-d "$dd_dir/full/$dir/linux/suse/$darch-$_") { + $vdir = "$dd_dir/full/$dir/linux/suse/$darch-$_"; + } + } + if (!$vdir) { next; } + + # Use the module_order if it has + if (-f "$vdir/modules/module.order") { + open(ORDER, "<", "$vdir/modules/module.order"); + while (my $file = ) { + chomp($file); + if (-f "$vdir/modules/$file") { + $driver_name = $file; + $real_path = ""; + find(\&get_path, <$rootimg_dir/lib/modules/$kernelver/*>); + if ($real_path eq "") { + system("cp $vdir/modules/$file $rootimg_dir/lib/modules/$kernelver/kernel/drivers/driverdisk"); + } else { + system("cp $vdir/modules/$file $real_path"); + } + + push @dd_drivers, $file; + } + } + } else { + opendir(MDIR, "$vdir/modules") || die "Cannot open dir $vdir/modules"; + while (my $file = readdir(MDIR)) { + if (-f "$vdir/modules/$file" && $file =~ /\.ko/) { + $driver_name = $file; + $real_path = ""; + find(\&get_path, <$rootimg_dir/lib/modules/$kernelver/*>); + if ($real_path eq "") { + system("cp $vdir/modules/$file $rootimg_dir/lib/modules/$kernelver/kernel/drivers/driverdisk"); + } else { + system("cp $vdir/modules/$file $real_path"); + } + + push @dd_drivers, $file; + } + } + } + } + + rmtree "$dd_dir/full"; + + my $rc = system("umount -f $dd_dir/mnt"); + if ($rc) { + print "umount the directory $dd_dir/mnt failed\n"; + exit 1; + } + } + + # Loading the drivers from rpm packages + if (@rpm_list && ($Injectalldriver || @driver_list)) { + + # Extract the files from rpm to the tmp dir + mkpath "$dd_dir/rpm"; + foreach my $rpm (@rpm_list) { + if (-r $rpm) { + if (system("cd $dd_dir/rpm; rpm2cpio $rpm | cpio -idum")) { + print "Error: Cannot extract the files from the rpm $rpm.\n"; + } + } else { + print "Error: Cannot read the rpm $rpm.\n"; + } + } + + # To skip the conflict of files that some rpm uses the xxx.ko.new as the name of the driver + # Change it back to xxx.ko here + $driver_name = "\*ko.new"; + @all_real_path = (); + find(\&get_all_path, <$dd_dir/rpm/*>); + foreach my $file (@all_real_path) { + my $newname = $file; + $newname =~ s/\.new$//; + if (system("mv -f $file $newname")) { + print "Error: Could not rename $file\n"; + + } + } + + # Copy the firmware to the rootimage + if (-d "$dd_dir/rpm/lib/firmware") { + system("cp -rf $dd_dir/rpm/lib/firmware $rootimg_dir/lib"); + } + + # if $ignorekernelchk is specified, copy all driver files to target kernel dir + if ($ignorekernelchk) { + my @kernelpath4vrpm = <$dd_dir/rpm/lib/modules/*>; + foreach my $path (@kernelpath4vrpm) { + if ($path eq "$dd_dir/rpm/lib/modules/$kernelver") { + next; + } + + unless (-d "$dd_dir/rpm/lib/modules/$kernelver") { + mkpath "$dd_dir/rpm/lib/modules/$kernelver"; + } + system("/bin/cp -rf $path/* $dd_dir/rpm/lib/modules/$kernelver"); + } + } + + # Copy the drivers to the rootimage + if (-d "$dd_dir/rpm/lib/modules/$kernelver") { + + #mkpath "$rootimg_dir/lib/modules/$kernelver/updates/"; + if (@driver_list) { + foreach my $driver (@driver_list) { + $driver_name = $driver; + $real_path = ""; + find(\&get_path, <$dd_dir/rpm/lib/modules/$kernelver/*>); + if ($real_path && $real_path =~ m!$dd_dir/rpm(/lib/modules/$kernelver/.*?)[^\/]*$!) { + + # remove the old one if existing + @all_real_path = (); + find(\&get_all_path, <$rootimg_dir/lib/modules/$kernelver/*>); + foreach (@all_real_path) { + if (-r $_) { + unlink($_); + } + } + + if (!-d "$rootimg_dir$1") { + mkpath "$rootimg_dir$1"; + } + system("cp -rf $real_path $rootimg_dir$1"); + push @rpm_drivers, $driver; + } else { + print "Warning: cannot find the driver $driver from the driver rpms\n"; + } + } + } elsif ($Injectalldriver) { + + # copy all the drviers to the rootimage + $driver_name = "\*\.ko"; + @all_real_path = (); + find(\&get_all_path, <$dd_dir/rpm/lib/modules/$kernelver/*>); + my @all_drivers = @all_real_path; + foreach my $new_driver (@all_drivers) { + if (basename($new_driver) =~ /\.ko$/) { + + # remove the old one if existing + $driver_name = basename($new_driver); + @all_real_path = (); + find(\&get_all_path, <$rootimg_dir/lib/modules/$kernelver/*>); + foreach my $old_driver (@all_real_path) { + if (-r $old_driver) { + unlink($old_driver); + } + } + push @rpm_drivers, basename($new_driver); + } + } + + system("cp -rf $dd_dir/rpm/lib/modules/$kernelver $rootimg_dir/lib/modules/"); + } + } else { + print "Warning: cannot find the kernel $kernelver from drvier rpms\n"; + } + + push @dd_drivers, @rpm_drivers; + } + + # Generate the dependency relationship + system("chroot '$rootimg_dir' depmod $kernelver"); + + # Clean the env + rmtree "$dd_dir"; + + return @dd_drivers; +} + +sub usage { + print 'Usage: genimage -o [-a ] -p -i -n [-r ] [-k ] [-g ] [-l rootlimitsize] [--permission ] [--interactive]' . "\n"; + print " --permission is used for statelite only\n"; + print "Examples:\n"; + print " genimage -i eth0 -n tg3 -o sles11 -p compute\n"; + print " genimage -i eth0 -r eth1,eth2 -n tg3,bnx2 -o sles11 -p compute --interactive\n"; + print " genimage -i eth0 -n tg3,bnx2 -o sles11 -p compute\n"; + print " genimage -i eth0 -n tg3,bnx2 -o sles11 -p compute --permission 777\n"; + return 0; +} + diff --git a/xCAT-server/share/xcat/netboot/sle/geninitrd b/xCAT-server/share/xcat/netboot/sle/geninitrd new file mode 100755 index 000000000..baf3746f6 --- /dev/null +++ b/xCAT-server/share/xcat/netboot/sle/geninitrd @@ -0,0 +1,2437 @@ +#!/usr/bin/env perl +BEGIN +{ + $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat'; +} +use lib "$::XCATROOT/lib/perl"; + +use File::Basename; +use File::Path; +use File::Copy qw/copy cp mv move/; +use File::Find; +use Getopt::Long; +use Cwd qw(realpath); +use File::Temp qw/mkdtemp/; + +use FindBin; +use lib "$FindBin::Bin/../imgutils"; +use imgutils; + +#use strict; +Getopt::Long::Configure("bundling"); +Getopt::Long::Configure("pass_through"); + +my $dracutmode; #Indicate whether this is a dracut style initrd +my $dracutdir = "dracut"; # The default directory name of dracut +my $dracutver; +my $prinic; #TODO be flexible on node primary nic +my $othernics; #TODO be flexible on node primary nic +my $netdriver; +my @yumdirs; +my $arch; +my %libhash; +my @filestoadd; +my $profile; +my $osver; +my $pathtofiles = dirname($0); +my $fullpath = realpath($pathtofiles); +my $name = basename($0); +my $onlyinitrd = 0; + +#that this method of calling genimage is no longer used +if ($name =~ /geninitrd/) { + $onlyinitrd = 1; +} +my $rootlimit; +my $tmplimit; +my $installroot = "/install"; +my $kerneldir; +my $kernelver = ""; +my $basekernelver; +my $customdir = $fullpath; +$customdir =~ s/.*share\/xcat/$installroot\/custom/; +my $imagename; +my $pkglist; +my $srcdir; +my $destdir; +my $srcdir_otherpkgs; +my $otherpkglist; +my $postinstall_filename; +my $rootimg_dir; +my $mode; +my $permission; #the permission works only for statelite mode currently +my $krpmver; +my $tempfile; +my $prompt; +my $timezone; #the TIMEZONE of the stateless and statelite node +my $ignorekernelchk; +my $noupdate; + +sub xdie { + system("rm -rf /tmp/xcatinitrd.$$"); + die @_; +} + +#-- fetch current version form CVS (overwrite locally changed versions) +# if (opendir(CVS,"$pathtofiles/CVS")){ +# close CVS; +# my $cvsout = qx/cd $pathtofiles; cvs update -C 2>&1/; +# chomp $cvsout; +# if ( $cvsout ne "cvs update: Updating ." ) { +# print "Difference of local copy from CVS detected\n"; +# print $cvsout,"\n"; +# print "Trying to re-run $name\n"; +# print("$pathtofiles/$name ",join(" ",@ARGV),"\n"); +# exec("$pathtofiles/$name",@ARGV); +# } +# } + + +$SIG{INT} = $SIG{TERM} = sub { xdie "Interrupted" }; +GetOptions( + 'a=s' => \$arch, + 'p=s' => \$profile, + 'o=s' => \$osver, + 'n=s' => \$netdriver, + 'i=s' => \$prinic, + 'r=s' => \$othernics, + 'l=s' => \$rootlimit, + 't=s' => \$tmplimit, + 'k=s' => \$kernelver, + 'g=s' => \$krpmver, + 'permission=s' => \$permission, + 'kerneldir=s' => \$kerneldir, + 'timezone=s' => \$timezone, + 'tempfile=s' => \$tempfile, #internal flag + 'pkglist=s' => \$pkglist, #internal flag + 'srcdir=s' => \$srcdir, #internal flag + 'otherpkgdir=s' => \$srcdir_otherpkgs, #internal flag + 'otherpkglist=s' => \$otherpkglist, #internal flag + 'postinstall=s' => \$postinstall_filename, #internal flag + 'rootimgdir=s' => \$destdir, #internal flag + 'driverupdatesrc=s' => \$driverupdatesrc, #internal flag + 'interactive' => \$prompt, + 'onlyinitrd' => \$onlyinitrd, + 'ignorekernelchk' => \$ignorekernelchk, + 'noupdate' => \$noupdate, +); + +if (@ARGV > 0) { + $imagename = $ARGV[0]; +} + + +my %updates_os = (); # the hash for updating osimage table +my %updates = (); # the hash for updating linuximage table + + +$permission = "755" unless ($permission); +$updates{'permission'} = $permission if ($tempfile); + +unless ($arch) { + $arch = `uname -m`; + chomp($arch); + $arch = "x86" if ($arch =~ /i.86$/); +} + +$srcdir = "$installroot/$osver/$arch" unless ($srcdir); +$updates{'pkgdir'} = $srcdir if ($tempfile); + +#$srcdir = $srcdir . "/1"; + +$srcdir_otherpkgs = "$installroot/post/otherpkgs/$osver/$arch" unless ($srcdir_otherpkgs); +#$updates{'otherpkgdir'} = $srcdir_otherpkgs if ($tempfile); + +$destdir = "$installroot/netboot/$osver/$arch/$profile" unless ($destdir); +$updates{'rootimgdir'} = $destdir if ($tempfile); + +$rootimg_dir = "$destdir/rootimg"; + +if ($kernelver && (!$krpmver)) { + print "The -g flag for the rpm version of kernel packages needs to be specified when kernel version has been specified.\n"; + exit 1; +} +$kerneldir = "$installroot/kernels" unless ($kerneldir); # the default directory for 3rd-party kernel is "$installroot/kernels"; + +#$updates{'kerneldir'} = $kerneldir if ($tempfile); + +unless ($osver and $profile) { + usage(); + exit 1; +} +my @ndrivers; + +if ($netdriver) { + foreach (split /,/, $netdriver) { + if (/^allupdate$/) { + next; + } + unless (/\.ko$/) { + s/$/.ko/; + } + next if (/^$/); + + # Do not include qeth module here + # This module is included later on + unless ($_ =~ m/qeth/i) { + push @ndrivers, $_; + } + } + + if (($updates{'netdrivers'} ne $netdriver) and $tempfile) { + $updates{'netdrivers'} = $netdriver; + } +} + +# Add the default driver list +if ($arch eq 'x86' or $arch eq 'x86_64') { + push @ndrivers, qw/tg3 bnx2 bnx2x e1000 e1000e virtio_net virtio_balloon igb mlx4_en be2net/; +} elsif ($arch eq 'ppc64') { + push @ndrivers, qw/tg3 e1000 e1000e igb ibmveth ehea be2net/; +} elsif ($arch eq "s390x") { + push @ndrivers, qw/qdio ccwgroup qeth qeth_l2 qeth_l3/; +} + +foreach (@ndrivers) { + unless (/\.ko$/) { + s/$/.ko/; + } +} + +unless (grep /af_packet/, @ndrivers) { + unshift(@ndrivers, "af_packet.ko"); +} + +my $osver_host; +if (`grep VERSION /etc/os-release` =~ /VERSION = (\d+)/) { + $osver_host = $1; +} else { + $osver_host = 11; +} + +unless ($onlyinitrd) { + + # now, let's handle the extra packages + unless ($imagename) { + $otherpkglist = imgutils::get_profile_def_filename($osver, $profile, $arch, $customdir, "otherpkgs.pkglist"); + unless ($otherpkglist) { $otherpkglist = imgutils::get_profile_def_filename($osver, $profile, $arch, $pathtofiles, "otherpkgs.pkglist"); } + $updates{'otherpkglist'} = $otherpkglist if ($tempfile and $otherpkglist); + } + my %extra_hash = (); + %extra_hash = imgutils::get_package_names($otherpkglist) if ($otherpkglist); + + + # prepare the chroot environment for the root image + + mkpath "$rootimg_dir/etc"; + mkpath "$rootimg_dir/dev"; + + #system "mount -o bind /dev $rootimg_dir/dev"; + unless (-e "$rootimg_dir/dev/zero") { + system "mknod $rootimg_dir/dev/zero c 1 5"; + } + unless (-e "$rootimg_dir/dev/null") { + system "mknod $rootimg_dir/dev/null c 1 3"; #that's neccessary for SLES11 + } + + unless (-e "$rootimg_dir/dev/random") { + system "mknod $rootimg_dir/dev/random c 1 8"; #that's neccessary for SLES11 + } + unless (-e "$rootimg_dir/dev/urandom") { + system "mknod $rootimg_dir/dev/urandom c 1 9"; #that's neccessary for SLES11 + } + + for (my $i = 0 ; $i <= 12 ; $i++) + { + unless (-e "$rootimg_dir/dev/tty$i") { + system "mknod $rootimg_dir/dev/tty$i c 4 $i"; #that's neccessary for SLES11 + } + } + + open($fd, ">>", "$rootimg_dir/etc/fstab"); # TODO: is it necessary? + print $fd "#Dummy fstab for rpm postscripts to see\n"; + close($fd); + + my $non_interactive; + if (!$prompt) { $non_interactive = "--non-interactive --no-gpg-checks --gpg-auto-import-keys"; } + + if ($osver_host >= 11) { #zypper in SLES11 is different + + system("rm -rf $rootimg_dir/etc/zypp/repos.d/$osver-*.repo"); + my @pkgdirs = split(",", $srcdir); + my $dir; + my $i = 0; + + # To support multiple paths for osimage.pkgdir + foreach $dir (@pkgdirs) { + my $ddir = $dir; + if (-d "$dir/1") { + $ddir .= "/1"; + } + system("zypper -R $rootimg_dir $non_interactive ar file:$ddir $osver-$i"); + $i++; + if (-d "$dir/2") { + $ddir = $dir . "/2"; + system("zypper -R $rootimg_dir $non_interactive ar file:$ddir $osver-$i"); + $i++; + } + } + + #if(-e "$rootimg_dir/etc/zypp/repos.d/$osver.repo") { + # system("rm -rf $rootimg_dir/etc/zypp/repos.d/$osver.repo"); + #} + #system("zypper -R $rootimg_dir $non_interactive ar file:$srcdir $osver"); + #if(-e "$rootimg_dir/etc/zypp/repos.d/${osver}sdk.repo") { + # system("rm -rf $rootimg_dir/etc/zypp/repos.d/${osver}sdk.repo"); + #} + if (opendir(SRCDIR, "$installroot/$osver/$arch/")) { + while (my $tmpfile = readdir(SRCDIR)) { + if ($tmpfile =~ m/^sdk/) { + my $srcdir_sdk = "$installroot/$osver/$arch/${tmpfile}"; + if (-d "$srcdir_sdk") { + system("zypper -R $rootimg_dir $non_interactive ar file:$srcdir_sdk ${osver}${tmpfile}"); + } + } + } + } + } else { + $srcdir = $srcdir . "/1"; + system("zypper -R $rootimg_dir $non_interactive sa file:$srcdir"); + } + + # Add the rep for kernel packages + if ($kernelver) { + if (!-d $kerneldir) { + print "Cannot find the directory for the kernel at $kerneldir.\n"; + exit 1; + } + if ($osver_host >= 11) { + if (-e "$rootimg_dir/etc/zypp/repos.d/$kernelver.repo") { + system("rm -rf $rootimg_dir/etc/zypp/repos.d/$kernelver.repo"); + } + system("zypper -R $rootimg_dir $non_interactive ar file:$kerneldir $kernelver"); + } else { + system("zypper -R $rootimg_dir $non_interactive sa file:$kerneldir"); + } + } + + #remove the old repository for extra packages + if ($osver_host >= 11) { + my $result = `zypper -R $rootimg_dir $non_interactive lr |grep otherpkg|cut -f2 -d '|'|tr "\n" " "`; + if ($result =~ /\S/) { + system("zypper -R $rootimg_dir $non_interactive rr $result"); + } + } else { + my $result = `zypper -R $rootimg_dir $non_interactive sl |grep otherpkg|cut -f2 -d '|'|tr "\n" " "`; + if ($result =~ /\S/) { + system("zypper -R $rootimg_dir $non_interactive sd $result"); + } + } + + #add the new repository for extra packages + my %extrapkgnames; + if ($osver_host >= 11) { #SLES11 + if (-e "$rootimg_dir/etc/zypp/repos.d/otherpkg.repo") { + system("rm -rf $rootimg_dir/etc/zypp/repos.d/otherpkg.repo"); + } + } + my $index = 1; + my $pass; + foreach $pass (sort { $a <=> $b } (keys(%extra_hash))) { + foreach (keys(%{ $extra_hash{$pass} })) { + + if ($_ eq "INCLUDEBAD") { + print "Unable to open the following pkglist files:\n" . join("\n", @{ $extra_hash{$pass}{INCLUDEBAD} }); + exit 1; + } + + if (($_ eq "PRE_REMOVE") || ($_ eq "POST_REMOVE") || ($_ eq "ENVLIST")) { next; } + my $whole_path = "$srcdir_otherpkgs/$_"; + if (-r "$srcdir_otherpkgs/$_/repodata/repomd.xml") { + if ($osver_host >= 11) { + system("zypper -R $rootimg_dir $non_interactive ar file:$srcdir_otherpkgs/$_ otherpkg$index"); + } else { + system("zypper -R $rootimg_dir $non_interactive sa file:$srcdir_otherpkgs/$_"); + } + } else { + if ($osver_host >= 11) { + system("zypper -R $rootimg_dir $non_interactive ar -t Plaindir file:$srcdir_otherpkgs/$_ otherpkg$index"); + } else { + system("zypper -R $rootimg_dir $non_interactive sa -t Plaindir file:$srcdir_otherpkgs/$_"); + } + } + $index++; + + my $pa = $extra_hash{$pass}{$_}; + $extrapkgnames{$pass} .= " " . join(' ', @$pa); + } + } + + #-- add custom repositories to the image + #TODO: should we add the support to otherpkgs for this? we have too many list files and it seems only SLES supports this + # not sure, but it is convenient + my $repolist; + $repolist = imgutils::get_profile_def_filename($osver, $profile, $arch, $customdir, "repolist"); + unless ($repolist) { + $repolist = imgutils::get_profile_def_filename($osver, $profile, $arch, $pathtofiles, "repolist"); + } + + if (-r "$repolist") { + print "Reading custom repositories\n"; + open($repoconfig, "<", "$repolist"); + while (<$repoconfig>) { + chomp; + next if /^\s*#/; + my ($repotype, $repourl, $repoalias) = split m/\|/; + if ($osver_host >= 11) { + system("zypper -R $rootimg_dir $non_interactive ar $repourl $repoalias"); + } else { + system("zypper -R $rootimg_dir $non_interactive sa $repourl $repoalias"); + } + } + } + + # Refresh the zypper cache in case there is still old data out there + system("zypper -R $rootimg_dir $non_interactive refresh"); + + #my $yumcmd = "yum -y -c /tmp/genimage.$$.yum.conf --installroot=$rootimg_dir --disablerepo=* "; + #$yumcmd .= "install "; + #mkpath("$rootimg_dir/var/lib/yum"); + mkpath("$rootimg_dir/etc/"); + my $passwdfile; + open($passwdfile, ">", "$rootimg_dir/etc/passwd"); + print $passwdfile "root:x:0:0:root:/root:/bin/bash\n"; + my $yumcmd; + if ($osver_host < 11) { + $yumcmd = "zypper -R $rootimg_dir $non_interactive install "; + } else { + $yumcmd = "zypper -R $rootimg_dir $non_interactive install -l --no-recommends "; #add -l for SLES11 + } + + #install packages from pkglist file + my $pkgnames; + unless ($imagename) { + $pkglist = imgutils::get_profile_def_filename($osver, $profile, $arch, $customdir, "pkglist"); + unless ($pkglist) { $pkglist = imgutils::get_profile_def_filename($osver, $profile, $arch, $pathtofiles, "pkglist"); } + } + + if ($pkglist) { + $updates{'pkglist'} = $pkglist if ($tempfile); + } else { + print "Unable to find package list for $profile!"; + exit 1; + } + + my %pkg_hash = imgutils::get_package_names($pkglist); + my $index = 1; + foreach $pass (sort { $a <=> $b } (keys(%pkg_hash))) { + $pkgnames = ""; + $group_pkgnames = ""; + foreach (keys(%{ $pkg_hash{$pass} })) { + + if ($_ eq "INCLUDEBAD") { + print "Unable to open the following pkglist files:\n" . join("\n", @{ $pkg_hash{$pass}{INCLUDEBAD} }); + exit 1; + } + + if (($_ eq "PRE_REMOVE") || ($_ eq "POST_REMOVE") || ($_ eq "ENVLIST")) { next; } + my $pa = $pkg_hash{$pass}{$_}; + + # replace the kernel package with the name has the specific version + my @npa = (); + my @npa_group = (); + foreach my $p (@$pa) { + if ($p =~ /^kernel/ && $kernelver) { + + # get all files in $srcdir and $kerneldir + my @alldirs = ("$srcdir", "$kerneldir"); + my @allrpms = (); + foreach my $dir (@alldirs) { + my @files = `find $dir -name *.rpm`; + push @allrpms, @files; + } + my @kernelpkgs = (); + if ($p =~ /^kernel$/) { + @kernelpkgs = ("kernel-default", "kernel-default-base"); + } elsif ($p =~ /^kernel-ppc64$/) { + @kernelpkgs = ($p, $p . "-base"); + } else { + @kernelpkgs = ($p); + } + foreach my $kern (@kernelpkgs) { + my @rpm = grep /$kern-$krpmver/, @allrpms; + if (!@rpm) { + print "Cannot find the kernel package with the versioin $krpmver.\n"; + exit 1; + } + my $kernelname = "$kern-" . $krpmver; + push @npa, $kernelname; + } + } else { + if ($p =~ s/^@//) + { + push @npa_group, $p; + } + else + { + push @npa, $p; + } + } + } + if (@npa) { + $pkgnames .= " " . join(' ', @npa); + } + if (@npa_group) { + $group_pkgnames .= " " . join(' ', @npa_group); + } + } + my $envlist; + if (exists $pkg_hash{$pass}{ENVLIST}) { + $envlist = join(' ', @{ $pkg_hash{$pass}{ENVLIST} }); + } + if ($pkgnames) + { + print "$envlist $yumcmd $pkgnames\n"; + $rc = system("$envlist $yumcmd $pkgnames"); + $rc = $rc >> 8; + if (($rc) && ($rc != '104')) { + print "zypper invocation failed with rc: $rc\n"; + exit 1; + } + } + if ($group_pkgnames) + { + print "$envlist $yumcmd -t pattern $group_pkgnames\n"; + $rc = system("$envlist $yumcmd -t pattern $group_pkgnames"); + $rc = $rc >> 8; + if (($rc) && ($rc != '104')) { + print "zypper invocation failed with rc: $rc\n"; + exit 1; + } + } + } + + foreach $pass (sort { $a <=> $b } (keys(%extra_hash))) { + + my $index = 1; + + #remove the old repository for extra packages + if ($osver_host >= 11) { + my $result = `zypper -R $rootimg_dir $non_interactive lr |grep otherpkg|cut -f2 -d '|'|tr "\n" " "`; + if ($result =~ /\S/) { + system("zypper -R $rootimg_dir $non_interactive rr $result"); + } + } else { + my $result = `zypper -R $rootimg_dir $non_interactive sl |grep otherpkg|cut -f2 -d '|'|tr "\n" " "`; + if ($result =~ /\S/) { + system("zypper -R $rootimg_dir $non_interactive sd $result"); + } + } + + foreach (keys(%{ $extra_hash{$pass} })) { + if (($_ eq "PRE_REMOVE") || ($_ eq "POST_REMOVE") || ($_ eq "ENVLIST")) { next; } + if (-r "$srcdir_otherpkgs/$_/repodata/repomd.xml") { + if ($osver_host >= 11) { + system("zypper -R $rootimg_dir $non_interactive ar file:$srcdir_otherpkgs/$_ otherpkg$index"); + } else { + system("zypper -R $rootimg_dir $non_interactive sa file:$srcdir_otherpkgs/$_"); + } + } else { + if ($osver_host >= 11) { + system("zypper -R $rootimg_dir $non_interactive ar -t Plaindir file:$srcdir_otherpkgs/$_ otherpkg$index"); + } else { + system("zypper -R $rootimg_dir $non_interactive sa -t Plaindir file:$srcdir_otherpkgs/$_"); + } + } + $index++; + } + + # Refresh the zypper cache in case there is still old data out there + system("zypper -R $rootimg_dir $non_interactive refresh"); + + #remove the packages that are specified in the otherpkgs.list files with leading '-' + my $envlist; + if (exists $extra_hash{$pass}{ENVLIST}) { + $envlist = join(' ', @{ $extra_hash{$pass}{ENVLIST} }); + } + + my $yumcmd_remove = "zypper -R $rootimg_dir $non_interactive remove "; + if (exists($extra_hash{$pass}{'PRE_REMOVE'})) { + my $pa = $extra_hash{$pass}{'PRE_REMOVE'}; + my $rm_packges = join(' ', @$pa); + if ($rm_packges) { + print "$envlist $yumcmd_remove $rm_packges"; + $rc = system("$envlist $yumcmd_remove $rm_packges"); + } + } + + + #add extra packages in the list + if ($extrapkgnames{$pass}) { + print "$envlist $yumcmd $extrapkgnames{$pass}\n"; + $rc = system("$envlist $yumcmd $extrapkgnames{$pass}"); + $rc = $rc >> 8; + if (($rc) && ($rc != '104')) { + print "zypper invocation failed with rc: $rc\n"; + exit 1; + } + } + + #remove the packages that are specified in the otherpkgs.list files with leading '--' + if (exists($extra_hash{$pass}{'POST_REMOVE'})) { + my $pa = $extra_hash{$pass}{'POST_REMOVE'}; + my $rm_packges = join(' ', @$pa); + if ($rm_packges) { + print "$envlist $yumcmd_remove $rm_packges"; + $rc = system("$envlist $yumcmd_remove $rm_packges"); + } + } + + if (!$noupdate) { + + # run zypper update to update any installed rpms + # needed when running genimage again after updating software in repositories + my $yumcmd_update; + if ($osver_host >= 11) { + $yumcmd_update = "zypper -R $rootimg_dir $non_interactive update "; + } else { + $yumcmd_update = "zypper -R $rootimg_dir $non_interactive update "; + } + $rc = system("$yumcmd_update"); + } + } + + #remove the old repository for extra packages + if ($osver_host >= 11) { + my $result = `zypper -R $rootimg_dir $non_interactive lr |grep otherpkg|cut -f2 -d '|'|tr "\n" " "`; + if ($result =~ /\S/) { + system("zypper -R $rootimg_dir $non_interactive rr $result"); + } + } else { + my $result = `zypper -R $rootimg_dir $non_interactive sl |grep otherpkg|cut -f2 -d '|'|tr "\n" " "`; + if ($result =~ /\S/) { + system("zypper -R $rootimg_dir $non_interactive sd $result"); + } + } + + # ignore any return code + + postscripts(); #run 'postscripts' +} +unlink "/tmp/genimage.$$.yum.conf"; + +# added dracut mode +if ((-d "$rootimg_dir/usr/share/dracut") or (-d "$rootimg_dir/usr/lib/dracut")) { + $dracutmode = 1; + + # get dracut version + $dracutver = `chroot $rootimg_dir rpm -qi dracut | awk '/Version/{print \$3}' | awk -F. '{print \$1}'`; + chomp($dracutver); + if ($dracutver =~ /^\d\d\d$/) { + if ($dracutver >= "033") { + $dracutdir = "dracut_033"; + } else { + $dracutdir = "dracut"; # The default directory + } + } + print "Enter the dracut mode. Dracut version: $dracutver. Dracut directory: $dracutdir.\n"; +} + +# default to the first kernel found in the install image if nothing specified explicitly. +# A more accurate guess than whatever the image build server happens to be running +# If specified, that takes precedence. +# If image has one, that is used +# If all else fails, resort to uname -r like this script did before + +if (-e "$rootimg_dir/boot/vmlinux") { + $basekernelver = basename(readlink "$rootimg_dir/boot/vmlinux"); + if ($basekernelver eq "vmlinux") { + $basekernelver = ""; + } else { + $basekernelver =~ s/vmlinu.-//; + $basekernelver =~ s/image-//; + } +} + +unless ($basekernelver) { + my @KVERS = <$rootimg_dir/boot/vmlinu[xz]-*>; + + # The kernel name is different on s390x, e.g. image-2.6.32.9-0.5-default + @KVERS = <$rootimg_dir/boot/image-*> if $arch eq "s390x"; + foreach (@KVERS) { + s/vmlinu.-//; + s/image-//; + } + unless (scalar @KVERS) { + @KVERS = <$rootimg_dir/lib/modules/*>; + } + if (scalar @KVERS) { + foreach my $kver (@KVERS) { + unless ($kver =~ m/.gz$/) { + $basekernelver = basename($kver); + last; + } + } + } + + @KVERS = <$rootimg_dir/lib/modules/*> unless (scalar @KVERS); + $basekernelver = basename(pop @KVERS) if (scalar @KVERS); + $basekernelver = `uname -r` unless ($basekernelver); +} + +$kernelver = $basekernelver unless ($kernelver); +chomp $kernelver; + +#$updates{kernelver} = $kernelver if ($tempfile); + +# copy the kernel to $destdir +if (-e "$rootimg_dir/boot/vmlinux-$kernelver") { + copy("$rootimg_dir/boot/vmlinux-$kernelver", "$destdir/kernel"); +} elsif (-e "$rootimg_dir/boot/vmlinuz-$kernelver") { + copy("$rootimg_dir/boot/vmlinuz-$kernelver", "$destdir/kernel"); +} elsif (-e "$rootimg_dir/boot/image-$kernelver") { + copy("$rootimg_dir/boot/image-$kernelver", "$destdir/kernel"); +} else { + xdie "couldn't find the kernel file matched $kernelver in $rootimg_dir/boot !"; +} + +#-- run postinstall script +unless ($imagename) { + $postinstall_filename = imgutils::get_profile_def_filename($osver, $profile, $arch, $customdir, "postinstall"); + unless ($postinstall_filename) { + $postinstall_filename = imgutils::get_profile_def_filename($osver, $profile, $arch, $pathtofiles, "postinstall"); + } +} + +if ($postinstall_filename) { + + #print "postinstall_filename=$postinstall_filename\n"; + + #For Mellonax IB script. In diskless image, the uname -r not returning the rootimg level, + #because the "uname -r" only returns the version of the kernel in use + #create a temporary uname script. for every flag except for -r, it should just call the real + #uname with the same flags and return that info. + if (!(-e "$rootimg_dir/bin/orig_uname")) { + system("mv $rootimg_dir/bin/uname $rootimg_dir/bin/orig_uname"); + } + my $tmpuname; + open($tmpuname, ">", "$rootimg_dir/bin/uname"); + print $tmpuname <>$tempfile"); + if ($imagename) { + if (keys(%updates) > 0) { + print FILE "The output for table updates starts here\n"; + print FILE "table::linuximage\n"; + print FILE "imagename::$imagename\n"; + my @a = %updates; + print FILE join('::', @a) . "\n"; + print FILE "The output for table updates ends here\n"; + } + } else { + $updates_os{'profile'} = $profile; + $updates_os{'imagetype'} = 'linux'; + $updates_os{'provmethod'} = 'netboot'; + $updates_os{'osname'} = 'Linux'; + $updates_os{'osvers'} = $osver; + $updates_os{'osdistroname'} = 'sle'; # not used currently + $updates_os{'osarch'} = $arch; + + # update the imagename for stateless + print FILE "The output for table updates starts here\n"; + print FILE "table::osimage\n"; + print FILE "imagename::$osver-$arch-netboot-$profile\n"; + my @a = %updates_os; + print FILE join('::', @a) . "\n"; + print FILE "The output for table updates ends here\n"; + + print FILE "The output for table updates starts here\n"; + print FILE "table::linuximage\n"; + print FILE "imagename::$osver-$arch-netboot-$profile\n"; + my @a = %updates; + print FILE join('::', @a) . "\n"; + print FILE "The output for table updates ends here\n"; + + # update the imagename for statelite + $updates_os{'provmethod'} = 'statelite'; + print FILE "The output for table updates starts here\n"; + print FILE "table::osimage\n"; + print FILE "imagename::$osver-$arch-statelite-$profile\n"; + my @a = %updates_os; + print FILE join('::', @a) . "\n"; + print FILE "The output for table updates ends here\n"; + + print FILE "The output for table updates starts here\n"; + print FILE "table::linuximage\n"; + print FILE "imagename::$osver-$arch-statelite-$profile\n"; + my @a = %updates; + print FILE join('::', @a) . "\n"; + print FILE "The output for table updates ends here\n"; + } + close FILE; +} + +#END + + + +mkpath "$rootimg_dir/.statelite"; # create place for NFS mounts; +mkpath "$rootimg_dir/.sllocal/localmnt"; # create place for localdisk mount +mkpath "$rootimg_dir/.sllocal/log"; # create place for localdisk log + +mkpath "$rootimg_dir/root/.ssh"; # create place for NFS mounts for ssh; #TODO is necessary? + +# this script will get the directories; +# TODO: it seems it is re-copied in liteimg.pm +unless (-r "$pathtofiles/../add-on/statelite/rc.statelite") { + print "Can't find $pathtofiles/../add-on/statelite/rc.statelite!\n"; + exit; +} +system("cp $pathtofiles/../add-on/statelite/rc.statelite $rootimg_dir/etc/init.d/statelite"); +system("cp $pathtofiles/../add-on/statelite/rc.localdisk $rootimg_dir/etc/init.d/localdisk"); + +# added dracutmode +unless ($dracutmode) { #in dracut mode, we delegate all this activity + unless (-l "$rootimg_dir/var/lib/dhclient") { + mkpath "$rootimg_dir/var/lib/dhclient/"; + system("touch $rootimg_dir/var/lib/dhclient/dhclient-$prinic.leases"); + } + + unless (-l "$rootimg_dir/var/lib/dhcp") { + mkpath "$rootimg_dir/var/lib/dhcp/"; + system("touch $rootimg_dir/var/lib/dhcp/dhclient-$prinic.leases"); + } +} + + +# the dhcp client information stores in the directory "/var/lib/dhcpcd/" +unless (-l "$rootimg_dir/var/lib/dhcpcd") { + mkpath "$rootimg_dir/var/lib/dhcpcd/"; + system("touch $rootimg_dir/var/lib/dhcpcd/dhcpcd-$prinic.info"); +} + +#keyctl moved to /bin for newer release +system("cd $rootimg_dir/usr/bin/; ln -s ../../bin/keyctl $rootimg_dir/usr/bin/keyctl"); + +# which is different from the Redhat family + +# some rpms mounts the imageroot/proc on the /proc, need to release it, +# otherwise got kernal panic when installing +# sometimes, the proc fs is not mounted, so one warning/error message will display, +# and I add one check point here. +my $MFD; +open MFD, "/proc/mounts"; +my @lines = ; +close MFD; + +my $ret = grep m{$rootimg_dir/proc}, @lines; +if ($ret > 0) { + system("umount -l $rootimg_dir/proc"); +} + +# Load driver update disk, and copy them to the root image +my @dd_drivers = &load_dd(); + +# Push the drivers into the @ndrivers base on the order +my @new_order = (); +foreach my $dd (@dd_drivers) { + unless (grep { $_ eq $dd } @ndrivers) { + push @new_order, $dd; + } + print "Added driver $dd from driver update disk or driver rpm\n"; +} + +if (@new_order) { + @ndrivers = (@new_order, @ndrivers); +} + +# add drivers for local disk support +push @ndrivers, ("ext3.ko", "ext4.ko", "virtio_pci.ko", "virtio_blk.ko", "libata.ko", "scsi_mod.ko", "scsi_dh.ko", "ahci.ko", "megaraid_sas.ko", "sd_mod.ko"); + +if ($osver_host >= 12) { + push @ndrivers, ("ibmvscsi.ko"); +} else { # for sles11 or lower + push @ndrivers, ("ibmvscsic.ko", "ata_piix.ko", "pcieport.ko"); +} + +if (-f "$rootimg_dir/lib/modules/$kernelver/kernel/drivers/net/ethernet/mellanox/mlx4/mlx4_en.ko") { + for (@ndrivers) { + s/mlx_en/mlx4_en/; + } +} + +open($moddeps, "<", "$rootimg_dir/lib/modules/$kernelver/modules.dep"); +my @moddeps = <$moddeps>; +my @checkdeps = @ndrivers; +while (scalar @checkdeps) { + my $driver = pop @checkdeps; + my @lines = grep /\/$driver:/, @moddeps; + foreach (@lines) { + chomp; + s/.*://; + s/^\s*//; + my @deps = split /\s+/, $_; + if ($driver =~ /libcrc32c.ko/) { + push @deps, 'crc32c.ko'; + } + my $dep; + foreach $dep (@deps) { + $dep =~ s/.*\///; + unless (grep { $_ eq $dep } @ndrivers) { #only add if not added + print "Added $dep as an autodetected dependency\n"; + } + unshift(@checkdeps, $dep); #recursively check dependencies + unshift(@ndrivers, $dep); + } + } +} +close($moddeps); + +#remove the duplicated drivers +my @fulldrivers; +foreach my $dn (@ndrivers) { + unless (grep { $_ eq $dn } @fulldrivers) { + push @fulldrivers, $dn; + } +} +@ndrivers = @fulldrivers; + +# before mkinitrd, run depmod to generate the modules.dep +system("chroot $rootimg_dir depmod $kernelver"); + +if ($dracutmode) { + mkinitrd_dracut("stateless"); + mkinitrd_dracut("statelite"); +} else { + my @drivers; # backup of @ndrivers + push @drivers, @ndrivers; + mkinitrd("statelite"); + @ndrivers = (); + push @ndrivers, @drivers; + mkinitrd("stateless"); +} +print "It is safe to ignore message 'Failed to connect to bus: No such file or directory' that may have appeared above one or more times.\n"; + +sub getlibs { + my $file = shift; + my $liblist = `chroot $rootimg_dir ldd $file`; + if ($liblist =~ /not a dynamic executable/) { + return; + } + my @libs = split /\n/, $liblist; + my @return; + foreach (@libs) { + unless (/=>/) { + (my $wjnk, my $lib, my $jnk) = split /\s+/, $_, 3; + $lib =~ s/^\///; + $libhash{$lib} = 1; + next; + } + (my $temp1, my $temp2) = split />/, $_, 2; + (my $whitespace, $temp1, $temp2) = split /\s+/, $temp2, 4; + unless ($temp1 =~ /\//) { + next; + } + $temp1 =~ s/^\///; + $libhash{$temp1} = 1; + } +} + +#added dracut +sub mkinitrd_dracut { + my ($mode) = @_; # the mode is for statelite or stateless + + my $dracutmoduledir = "$rootimg_dir/usr/share/dracut/modules.d/"; + if ((!-d $dracutmoduledir) and (-d "$rootimg_dir/usr/lib/dracut/modules.d/")) + { + $dracutmoduledir = "$rootimg_dir/usr/lib/dracut/modules.d/"; + } + + if ($dracutver >= "033") { + + my $perm = (stat("$fullpath/$dracutdir/patch/syslog/module-setup.sh"))[2]; + cp("$fullpath/$dracutdir/patch/syslog/module-setup.sh", $dracutmoduledir . "98syslog/"); + chmod($perm & 07777, $dracutmoduledir . "98syslog/" . "module-setup.sh"); + + $perm = (stat("$fullpath/$dracutdir/patch/syslog/rsyslogd-start.sh"))[2]; + cp("$fullpath/$dracutdir/patch/syslog/rsyslogd-start.sh", $dracutmoduledir . "98syslog/"); + chmod($perm & 07777, $dracutmoduledir . "98syslog/" . "rsyslogd-start.sh"); + + $perm = (stat("$fullpath/$dracutdir/patch/syslog/syslog-genrules.sh"))[2]; + cp("$fullpath/$dracutdir/patch/syslog/syslog-genrules.sh", $dracutmoduledir . "98syslog/"); + chmod($perm & 07777, $dracutmoduledir . "98syslog/" . "syslog-genrules.sh"); + + } + + my $dracutmpath = $dracutmoduledir . "97xcat/"; + mkpath($dracutmpath); + + my $perm = (stat("$fullpath/$dracutdir/check"))[2]; + cp("$fullpath/$dracutdir/check", $dracutmpath); + chmod($perm & 07777, "$dracutmpath/check"); + + foreach (@ndrivers) { s/\.ko$//; } + + # Add drivers to support local disk + push @ndrivers, "ext3"; + push @ndrivers, "ext4"; + + #remove the duplicated drivers + my @fulldrivers; + foreach my $dn (@ndrivers) { + unless (grep { $_ eq $dn } @fulldrivers) { + push @fulldrivers, $dn; + } + } + @ndrivers = @fulldrivers; + + my $add_drivers = join(' ', @ndrivers); + print "Try to load drivers: $add_drivers to initrd.\n"; + my $DRACUTCONF; + + if ($mode eq "statelite") { + + # for statelite + cp("$fullpath/$dracutdir/install.statelite", "$dracutmpath/install"); + $perm = (stat("$fullpath/$dracutdir/install.statelite"))[2]; + chmod($perm & 07777, "$dracutmpath/install"); + + cp("$installroot/postscripts/updateflag.awk", "$dracutmpath/xcat-updateflag"); + $perm = (stat("$installroot/postscripts/updateflag.awk"))[2]; + chmod($perm & 07777, "$dracutmpath/xcat-updateflag"); + + cp("$fullpath/$dracutdir/xcat-prepivot.sh", $dracutmpath); + $perm = (stat("$fullpath/$dracutdir/xcat-prepivot.sh"))[2]; + chmod($perm & 07777, "$dracutmpath/xcat-prepivot.sh"); + + cp("$fullpath/$dracutdir/xcat-premount.sh", $dracutmpath); + $perm = (stat("$fullpath/$dracutdir/xcat-premount.sh"))[2]; + chmod($perm & 07777, "$dracutmpath/xcat-premount.sh"); + + #update etc/dracut.conf + open($DRACUTCONF, '>', "$rootimg_dir/etc/dracut.conf"); + if (-d glob($dracutmoduledir . "[0-9]*fadump")) { + print $DRACUTCONF qq{dracutmodules+="xcat nfs base network kernel-modules lvm fadump"\n}; + } + else { + print $DRACUTCONF qq{dracutmodules+="xcat nfs base network kernel-modules lvm"\n}; + } + print $DRACUTCONF qq{add_drivers+="$add_drivers"\n}; + print $DRACUTCONF qq{filesystems+="nfs"\n}; + close $DRACUTCONF; + } elsif ($mode eq "stateless") { + cp("$fullpath/$dracutdir/install.netboot", "$dracutmpath/install"); + $perm = (stat("$fullpath/$dracutdir/install.netboot"))[2]; + chmod($perm & 07777, "$dracutmpath/install"); + + cp("$fullpath/$dracutdir/xcat-cmdline.sh", "$dracutmpath/"); + $perm = (stat("$fullpath/$dracutdir/xcat-cmdline.sh"))[2]; + chmod($perm & 07777, "$dracutmpath/xcat-cmdline.sh"); + + cp("$installroot/postscripts/updateflag.awk", "$dracutmpath/xcat-updateflag"); + $perm = (stat("$installroot/postscripts/updateflag.awk"))[2]; + chmod($perm & 07777, "$dracutmpath/xcat-updateflag"); + if ($prinic) { + my $optspec; + open($optspec, '>>', "$dracutmpath/xcat-cmdline.sh"); + print $optspec "PRINIC=$prinic\n"; + close $optspec; + } + + cp("$fullpath/$dracutdir/xcatroot", "$dracutmpath/"); + $perm = (stat("$fullpath/$dracutdir/xcatroot"))[2]; + chmod($perm & 07777, "$dracutmpath/xcatroot"); + + cp("$fullpath/$dracutdir/installkernel", "$dracutmpath/"); + $perm = (stat("$fullpath/$dracutdir/installkernel"))[2]; + chmod($perm & 07777, "$dracutmpath/installkernel"); + + # update etc/dracut.conf + open($DRACUTCONF, '>', "$rootimg_dir/etc/dracut.conf"); + if (-d glob($dracutmoduledir . "[0-9]*fadump")) { + print $DRACUTCONF qq{dracutmodules+="xcat nfs base network kernel-modules lvm fadump syslog"\n}; + } + else { + print $DRACUTCONF qq{dracutmodules+="xcat nfs base network kernel-modules lvm syslog"\n}; + } + print $DRACUTCONF qq{add_drivers+="$add_drivers"\n}; + close $DRACUTCONF; + } else { + xdie "the mode: $mode is not supported by genimage"; + } + + my $additional_options = undef; + if ($rootlimit) + { + open(my $ETC_CMDLINE, ">", "$rootimg_dir/tmp/cmdline"); + print $ETC_CMDLINE qq{rootlimit=$rootlimit\n}; + close $ETC_CMDLINE; + $additional_options = qq{--include /tmp/cmdline /etc/cmdline}; + } + + # force the dracut run in non-hostonly mode for dracut higher than version 033 + if ($dracutver > "033") { + $additional_options .= " -N"; + } + + #if "pigz" is available in the rootimg, use "pigz" instead of "gzip" + my $compress = qx(chroot $rootimg_dir bash -c "type -p pigz"|tr -d "\n"); + if ($compress) { + + #take the online cpu numerber as the pigz processes number + my $processnum = qx(lscpu -p=cpu --online|grep -v '#'|wc -l|tr -d "\n"); + $additional_options .= " --compress \"$compress -p $processnum \""; + } + + print "\nchroot $rootimg_dir dracut $additional_options -f /tmp/initrd.$$.gz $kernelver\n"; + !system("chroot $rootimg_dir dracut $additional_options -f /tmp/initrd.$$.gz $kernelver") + or die("Error: failed to generate the initial ramdisk for $mode.\n"); + print "the initial ramdisk for $mode is generated successfully.\n"; + move("$rootimg_dir/tmp/initrd.$$.gz", "$destdir/initrd-$mode.gz"); +} + + +sub mkinitrd { + my ($mode) = @_; # statelite or stateless + + if ($mode eq "statelite") { + + # additional modules needed on s390x + push @ndrivers, qw{qdio.ko ccwgroup.ko qeth.ko qeth_l2.ko qeth_l3.ko} if ($arch eq "s390x"); + + # for nfs + my @modlist = qw{sunrpc.ko lockd.ko nfs_acl.ko fscache.ko auth_rpcgss.ko exportfs.ko nfsd.ko nfs.ko}; + unshift(@ndrivers, @modlist); + } + + mkpath("/tmp/xcatinitrd.$$/bin"); + symlink("bin", "/tmp/xcatinitrd.$$/sbin"); + mkpath("/tmp/xcatinitrd.$$/usr/bin"); + mkpath("/tmp/xcatinitrd.$$/usr/sbin"); + mkpath("/tmp/xcatinitrd.$$/usr/lib"); + mkpath("/tmp/xcatinitrd.$$/usr/lib64"); + mkpath("/tmp/xcatinitrd.$$/lib/firmware"); + mkpath("/tmp/xcatinitrd.$$/tmp"); + mkpath("/tmp/xcatinitrd.$$/var/run"); + mkpath("/tmp/xcatinitrd.$$/lib64/firmware"); + mkpath("/tmp/xcatinitrd.$$/lib/power6"); #SLES10 + mkpath("/tmp/xcatinitrd.$$/lib/power7"); #SLES10 + mkpath("/tmp/xcatinitrd.$$/lib/mkinitrd/bin"); + mkpath("/tmp/xcatinitrd.$$/proc"); + mkpath("/tmp/xcatinitrd.$$/sys"); + mkpath("/tmp/xcatinitrd.$$/dev/mapper"); + mkpath("/tmp/xcatinitrd.$$/sysroot"); + mkpath("/tmp/xcatinitrd.$$/etc/ld.so.conf.d"); + mkpath("/tmp/xcatinitrd.$$/var/lib/dhcpcd"); + my $inifile; + open($inifile, ">", "/tmp/xcatinitrd.$$/init"); + print $inifile "#!/bin/bash\n"; + + # copied from genimage for rh + # add some functions + print $inifile < <\\ \\____/ | \\ | + /__/\\_ \\\\______ /\\____|__ /____| + \\/ \\/ \\/ +' + echo -e "\$RESET" +} + + +EOS1 + + print $inifile "mount -t proc /proc /proc\n"; + print $inifile "mount -t sysfs /sys /sys\n"; + print $inifile "mount -o mode=0755 -t tmpfs /dev /dev\n"; + print $inifile "mkdir /dev/pts\n"; + print $inifile "mount -t devpts -o gid=5,mode=620 /dev/pts /dev/pts\n"; + print $inifile "mkdir /dev/shm\n"; + print $inifile "mkdir /dev/mapper\n"; + + print $inifile "mknod /dev/random c 1 8\n"; + print $inifile "mknod /dev/urandom c 1 9\n"; + print $inifile "mknod /dev/null c 1 3\n"; + print $inifile "mknod /dev/zero c 1 5\n"; + print $inifile "mknod /dev/systty c 4 0\n"; + print $inifile "mknod /dev/tty c 5 0\n"; + print $inifile "mknod /dev/console c 5 1\n"; + print $inifile "mknod /dev/ptmx c 5 2\n"; + print $inifile "mknod /dev/rtc c 10 135\n"; + print $inifile "mknod /dev/tty0 c 4 0\n"; + print $inifile "mknod /dev/tty1 c 4 1\n"; + print $inifile "mknod /dev/tty2 c 4 2\n"; + print $inifile "mknod /dev/tty3 c 4 3\n"; + print $inifile "mknod /dev/tty4 c 4 4\n"; + print $inifile "mknod /dev/tty5 c 4 5\n"; + print $inifile "mknod /dev/tty6 c 4 6\n"; + print $inifile "mknod /dev/tty7 c 4 7\n"; + print $inifile "mknod /dev/tty8 c 4 8\n"; + print $inifile "mknod /dev/tty9 c 4 9\n"; + print $inifile "mknod /dev/tty10 c 4 10\n"; + print $inifile "mknod /dev/tty11 c 4 11\n"; + print $inifile "mknod /dev/tty12 c 4 12\n"; + print $inifile "mknod /dev/ttyS0 c 4 64\n"; + print $inifile "mknod /dev/ttyS1 c 4 65\n"; + print $inifile "mknod /dev/ttyS2 c 4 66\n"; + print $inifile "mknod /dev/ttyS3 c 4 67\n"; + + # Install modules before starting udev + # because networking modules (qeth/qeth_l2/qeth_l3) are needed + foreach (@ndrivers) { + print $inifile "insmod /lib/$_\n"; + } + + # Start udev + print $inifile < /dev/null && export DEBUG=1\n"; + } + + print $inifile < /tmp/ifcfg-\$IFACE + +ip addr add dev lo 127.0.0.1/8 +ip link set lo up + + +XCATMASTER=`echo \$XCATSERVER|awk -F: '{print \$1}'` + +if [ -z \$XCATIPORT ]; then + XCATIPORT="3002" +fi + +if [ \$NODESTATUS != 'n' ]; then + /tmp/updateflag \$XCATMASTER \$XCATIPORT "installstatus netbooting" +fi + +cd / +for i in `cat /proc/cmdline`; do + KEY=`echo \$i |awk -F= '{print \$1}'` + if [ "\$KEY" == 'imgurl' ]; then + VALUE=`echo \$i |awk -F= '{print \$2}'` + if [ "http" == "`echo \$VALUE|awk -F: '{print \$1}'`" ]; then + #NOTE needs FT retry code to scale + #NOTE: should prob have max count + FILENAME=`echo \$VALUE|awk -F/ '{print \$NF}'` + while [ ! -r "\$FILENAME" ]; do + echo Getting \$VALUE... + if ! wget \$VALUE; then + sleep 5 #should be random, exponential for scale + rm -f \$FILENAME + fi + done + fi + elif [[ "\$KEY" == NFSROOT ]]; then # for NFSROOT + NFSROOT=1 + VALUE=`echo \$i |awk -F= '{print \$2}'` + SERVER=`echo \$VALUE|awk -F: '{print \$1}'` + ROOTDIR=`echo \$VALUE|awk -F/ '{for(i=2;i<=NF;i++) printf "/%s",\$i}'` + elif [ "\$KEY" == 'STATEMNT' ]; then + STATELITE=1 + VALUE=`echo \$i |awk -F= '{print \$2}'` + # VALUE may be null + if [ ! -z \$VALUE ]; then + SNAPSHOTSERVER=`echo \$VALUE|awk -F: '{print \$1}'` + SNAPSHOTROOT=`echo \$VALUE|awk -F/ '{for(i=2;i<=NF;i++) printf "/%s",\$i}'` + # may be that there is not server and just a directory. + if [ -z \$SNAPSHOTROOT ]; then + SNAPSHOTROOT=\$SNAPSHOTSERVER + SNAPSHOTSERVER= + fi + fi + elif [ "\$KEY" == 'NODE' ]; then + NODENAME=`echo \$i |awk -F= '{print \$2}'` + fi +done + +# show xCAT logo +fancydisplay + +# Statelite code is here +if [ "\$STATELITE" = "1" ]; then + echo Setting up Statelite + mknod /dev/loop0 b 7 0 + mkdir -p \$NEWROOT + MAXTRIES=15 + ITER=0 + ME=`hostname` + if [ ! -z "$NODENAME" ]; then + ME=$NODENAME + fi + if [ "\$NFSROOT" = "1" ]; then + while ! mount.nfs \${SERVER}:\${ROOTDIR}/rootimg \$NEWROOT -r -n -o nolock,rsize=32768,tcp,nfsvers=3,timeo=14; do + ITER=\$(expr \$ITER + 1) + if [ "\$ITER" = "\$MAXTRIES" ]; then + echo "You're dead. rpower \$ME boot to play again." + echo "Possible problems: +1. This initrd wan't created for the statelite node? +2. IS DNS set up? Maybe that's why I can't mount \${SERVER}. +3. The nfs modules aren't set right in this initial ramdisk?" + shell + exit + fi + echo -e "\${RED}Couldn't mount \$SERVER:\$ROOTDIR on \$NEWROOT \$RESET" + RS=\$(expr \$RANDOM % 30) + echo -e "Trying again in \$RS seconds" + sleep \$RS + done + else + # for statelite mode on top of the ramdisk +EOMS + + print $inifile "if [ -r /rootimg-statelite.gz ]; then \n"; + print $inifile "echo Setting up RAM-root tmpfs.\n"; + if ($rootlimit) { + print $inifile " mount -o size=$rootlimit,mode=755 -t tmpfs rootfs \$NEWROOT \n"; + } else { + print $inifile " mount -o mode=755 -t tmpfs rootfs \$NEWROOT \n"; + } + + print $inifile </dev/null && shell + mount -t tmpfs rw -o mode=$permission \$NEWROOT/\$RWDIR + mkdir -p \$NEWROOT/\$RWDIR/tmpfs + + #mount the /root/.ssh, it needs more strict permission in order for ssh work + #if [ ! -e "\$NEWROOT/root/.ssh" ] + #then + # mkdir -p \$NEWROOT/root/.ssh + #fi + #mount -t tmpfs -o mode=755 ssh \$NEWROOT/root/.ssh + + # mount the SNAPSHOT directory here for persistent use. + if [ ! -z \$SNAPSHOTSERVER ] + then + mkdir -p \$NEWROOT/\$RWDIR/persistent + MAXTRIES=5 + ITER=0 + while ! mount \$SNAPSHOTSERVER:\$SNAPSHOTROOT \$NEWROOT/\$RWDIR/persistent -o nolock,\$XCATMNTOPTS + do + ITER=\$(expr \$ITER + 1) + if [ "\$ITER" == "\$MAXTRIES" ] + then + echo "You're 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." + shell + exit + fi + echo -e "\${RED}Hmmm... Can't mount \$SNAPSHOTSERVER:\$SNAPSHOTROOT. \${NORMAL} \$XCATMNTOPTS" + RS=`expr \$RANDOM % 20` + echo -e "Trying again in \$RS seconds" + sleep \$RS + done + + # create directory which is named after my node name + mkdir -p \$NEWROOT/\$RWDIR/persistent/\$ME + ITER=0 + # umount current persistent mount + while ! umount -l \$NEWROOT/\$RWDIR/persistent; do + ITER=\$(( ITER + 1 )) + if [ "\$ITER" == "\$MAXTRIES" ]; then + echo "Your are dead, rpower \$ME boot to play again." + echo "Cannot umount \$NEWROOT/\$RWDIR/persistent." + /bin/sh + exit + fi + RS= \$(( \$RANDOM % 20 )) + echo "Trying again in \$RS seconds..." + sleep \$RS + done + + # mount persistent to server:/rootpath/nodename + ITER=0 + while ! mount \$SNAPSHOTSERVER:/\$SNAPSHOTROOT/\$ME \$NEWROOT/\$RWDIR/persistent -o nolock,\$XCATMNTOPTS; do + ITER=\$(( ITER + 1 )) + if [ "\$ITER" == "\$MAXTRIES" ]; then + echo "Your are dead, rpower \$ME boot to play again." + echo "Possible problems: cannot mount to \$SNAPSHOTSERVER:/\$SNAPSHOTROOT/\$ME." + /bin/sh + exit + fi + RS= \$(( \$RANDOM % 20 )) + echo "Trying again in \$RS seconds..." + sleep \$RS + done + fi + + grep '\\(shell\\)' /proc/cmdline >/dev/null && shell + + # have to preserve the initial DHCP request. So we link it. + # SLES uses different file to store DHCP info + if [ ! -d \$NEWROOT/\$RWDIR/tmpfs/var/lib/dhcpcd ] + then + mkdir -p \$NEWROOT/\$RWDIR/tmpfs/var/lib/dhcpcd + fi + cp -fp /var/lib/dhcpcd/dhcpcd-\$IFACE.info \${NEWROOT}/\${RWDIR}/tmpfs/var/lib/dhcpcd/dhcpcd-\$IFACE.info + + [ -e /etc/ntp.conf ] && mkdir -p \$NEWROOT/\$RWDIR/tmpfs/etc && cp /etc/ntp.conf \$NEWROOT/\$RWDIR/tmpfs/etc/ + + [ -e /etc/resolv.conf ] && mkdir -p \$NEWROOT/\$RWDIR/tmpfs/etc && cp /etc/resolv.conf \$NEWROOT/\$RWDIR/tmpfs/etc/ + + # now that everything is mounted, lets do this + # hmmm, apparently I'm checking this twice... so I'd better + # be really sure the file is there. + while [ ! -e \$NEWROOT/etc/init.d/statelite ] + do + echo "\$NEWROOT/etc/init.d/statelite does not exist in image!" + shell + done + + # try to configure the local disk + \$NEWROOT/etc/init.d/localdisk + + # do all the mounts: + \$NEWROOT/etc/init.d/statelite +EOMS + + # udevd needed by s390x for networking + # but for other type of machine, udevd will affect the start of devices which detected + # after the chroot, so kill it before the switching root + if ($arch ne "s390x") { + print $inifile "\n killall -9 udevd\n"; + } + + print $inifile < /dev/null && shell + + echo 0x100 > /proc/sys/kernel/real-root-dev + export keep_old_ip=yes + export fastboot=yes + export READONLY=yes + grep '\\(shell\\)' /proc/cmdline >/dev/null && shell + mount -n --bind /dev /sysroot/dev + umount /sys + umount /proc + + # sles use the standard utility to chroot + if ! exec /usr/bin/chroot \$NEWROOT /sbin/init + then + echo "" + echo -e "\${RED}Couldn't chroot. Something must be wrong with NFS root image.\${RESET}" + shell + fi + exit +fi +# end NFSROOT/Statelite code + +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 /sysroot + mkdir -p /sysroot/ro + mkdir -p /sysroot/rw + mount --move /ro /sysroot/ro + mount --move /rw /sysroot/rw +EOMS + print $inifile "elif [ -r /rootimg.cpio.gz ] || [ -r /rootimg.cpio.xz ]; then\n"; + print $inifile "echo Setting up RAM-root tmpfs.\n"; + if ($rootlimit) { + print $inifile " mount -o size=$rootlimit,mode=755 -t tmpfs rootfs \$NEWROOT\n"; + } else { + print $inifile " mount -o mode=755 -t tmpfs rootfs \$NEWROOT\n"; + } + print $inifile " cd /sysroot\n"; + print $inifile " echo -n \"Extracting root filesystem:\"\n"; + print $inifile " if [ -r /rootimg.cpio.gz ]; then\n"; + print $inifile " if [ -x /bin/cpio ]; then\n"; + print $inifile " zcat /rootimg.cpio.gz |/bin/cpio -idum\n"; + print $inifile " else\n"; + print $inifile " zcat /rootimg.cpio.gz |cpio -idum\n"; + print $inifile " fi\n"; + print $inifile " elif [ -r /rootimg.cpio.xz ]; then\n"; + print $inifile " if [ -x /bin/cpio ]; then\n"; + print $inifile " xz -cd /rootimg.cpio.xz |/bin/cpio -idum\n"; + print $inifile " else\n"; + print $inifile " xz -cd /rootimg.cpio.xz |cpio -idum\n"; + print $inifile " fi\n"; + print $inifile " fi\n"; + print $inifile " echo Done\n"; + print $inifile "elif [ -r /rootimg.tar.gz ] || [ -r /rootimg.tar.xz ]; then\n"; + print $inifile " echo Setting up RAM-root tmpfs.\n"; + + if ($rootlimit) { + print $inifile " mount -o \"size=$rootlimit,mode=755\" -t tmpfs rootfs \$NEWROOT\n"; + } else { + print $inifile " mount -o mode=755 -t tmpfs rootfs \$NEWROOT\n"; + } + print $inifile " cd \$NEWROOT\n"; + print $inifile " echo -n \"Extracting root filesystem:\"\n"; + print $inifile " if [ -r /rootimg.tar.gz ]; then\n"; + print $inifile " tar --selinux --xattrs-include='*' -zxf /rootimg.tar.gz\n"; + print $inifile " if [ \$? -ne 0 ]; then\n"; + print $inifile " tar -zxf /rootimg.tar.gz\n"; + print $inifile " fi\n"; + print $inifile " elif [ -r /rootimg.tar.xz ]; then\n"; + print $inifile " tar --selinux --xattrs-include='*' -Jxf /rootimg.tar.xz\n"; + print $inifile " if [ \$? -ne 0 ]; then\n"; + print $inifile " tar -Jxf /rootimg.tar.xz\n"; + print $inifile " fi\n"; + print $inifile " fi\n"; + print $inifile " echo Done\n"; + print $inifile "else\n"; + print $inifile " echo -n Failed to download image, panicing in 5...\n"; + print $inifile " for i in 4 3 2 1 0; do\n"; + print $inifile " /bin/sleep 1\n"; + print $inifile " echo -n \$i...\n"; + print $inifile " done\n"; + print $inifile " echo\n"; + print $inifile <" . "/tmp/xcatinitrd.$$/bin/netstart"); + print $inifile "#!/bin/bash \n"; + if ($osver_host == 10) { + print $inifile "dhcpcd \${1}\n"; + } else { # for sles11 or higher + # -p is used to keep the network connection during the shutdown. Used for nfs-based statelite shutdown + print $inifile "dhcpcd \${1} -p\n"; + } + + #-- Bring other NICs up in /bin/netstart in initrd for NIC failover + foreach (split /,/, $othernics) { + if (/^$/) { next; } + print $inifile "dhcpcd $_\n"; + } + + print $inifile <> /etc/HOSTNAME +END + + close($inifile); + + #if "nonodestatus" specified,do not update the nodestatus + system("mkdir -p /tmp/xcatinitrd.$$/tmp/"); + cp("$installroot/postscripts/updateflag.awk","/tmp/xcatinitrd.$$/tmp/updateflag"); + $perm = (stat("$installroot/postscripts/updateflag.awk"))[2]; + chmod($perm & 07777, "/tmp/xcatinitrd.$$/tmp/updateflag"); + + chmod(0755, "/tmp/xcatinitrd.$$/init"); + chmod(0755, "/tmp/xcatinitrd.$$/bin/netstart"); + + @filestoadd = (); + foreach (@ndrivers) { + if (-f "$customdir/$_") { + push @filestoadd, [ $_, "lib/$_" ]; + } elsif (-f "$pathtofiles/$_") { + push @filestoadd, [ $_, "lib/$_" ]; + } + } + if ($mode eq "statelite") { + foreach ("sbin/ifconfig", "usr/bin/clear", "usr/bin/touch", "usr/bin/cut", "usr/bin/rm", "bin/hostname", "usr/bin/egrep", "bin/ln", "bin/ls", "usr/bin/dirname", "usr/bin/expr", "usr/bin/chroot", "usr/bin/grep", "bin/cpio", "bin/sleep", "bin/mount", "bin/umount", "sbin/dhcpcd", "bin/bash", "sbin/insmod", "bin/mkdir", "bin/mknod", "sbin/ip", "bin/cat", "usr/bin/awk", "usr/bin/wget", "bin/cp", "usr/bin/cpio", "usr/bin/zcat", "usr/bin/gzip", "lib/mkinitrd/bin/run-init", "usr/bin/uniq", "usr/bin/sed", "usr/bin/wc", "bin/sed", "sbin/udevd", "usr/bin/readlink", "usr/sbin/parted", "sbin/mke2fs", "sbin/mkswap", "sbin/swapon", "bin/chmod", "usr/bin/bc", "usr/bin/xz", "usr/bin/gzip", "bin/tar") { + getlibs($_); + push @filestoadd, $_; + } + if ($osver_host >= 11) { + foreach ("sbin/mount.nfs", "sbin/umount.nfs", "sbin/udevadm") { + getlibs($_); + push @filestoadd, $_; + } + } + + } else { + foreach ("sbin/ifconfig", "usr/bin/clear", "usr/bin/touch", "usr/bin/grep", "usr/bin/egrep", "bin/cpio", "bin/sleep", "bin/mount", "sbin/dhcpcd", "bin/bash", "sbin/insmod", "bin/mkdir", "bin/mknod", "sbin/ip", "bin/cat", "usr/bin/awk", "usr/bin/wget", "bin/cp", "usr/bin/cpio", "usr/bin/zcat", "usr/bin/gzip", "lib/mkinitrd/bin/run-init", "usr/bin/uniq", "usr/bin/sed", "sbin/udevd", "usr/bin/readlink", "usr/bin/expr", "usr/sbin/parted", "sbin/mke2fs", "sbin/mkswap", "sbin/swapon", "bin/chmod", "usr/bin/bc", "usr/bin/xz", "usr/bin/gzip", "bin/tar") { + getlibs($_); + push @filestoadd, $_; + } + if ($osver_host >= 11) { + getlibs("sbin/udevadm"); + push @filestoadd, "sbin/udevadm"; + } + } + + if ($arch =~ /64/) { + push @filestoadd, "lib64/libnss_dns.so.2"; + push @filestoadd, "lib64/libnss_files.so.2"; + } + else { + push @filestoadd, "lib/libnss_dns.so.2"; + push @filestoadd, "lib/libnss_files.so.2"; + } + + # cross-platfrom support on power6&7 etc + # ldd can't handle such one scenario: mn is power6, the target platform is power7 + if ($arch =~ /ppc64/) { + system("cp -a -r $rootimg_dir/lib64/* /tmp/xcatinitrd.$$/lib64/"); + } + + + push @filestoadd, keys %libhash; + + find(\&isnetdriver, <$rootimg_dir/lib/modules/$kernelver/*>); + my $pathonrootimage = "$rootimg_dir/tmpfiles"; + my $pathinrootimage = "/tmpfiles"; + mkpath($pathonrootimage); + foreach (@filestoadd) { + if (ref($_)) { + + #print "$_->[0], $_->[1]\n"; + my $srcfile = $_->[0]; + system("chroot $rootimg_dir cp $srcfile $pathinrootimage"); + my $srcpath = "$pathonrootimage/" . basename($_->[0]); + if (-f "$customdir/" . $_->[0]) { + $srcpath = "$customdir/" . $_->[0]; + } elsif (-f "$pathtofiles/" . $_->[0]) { + $srcpath = "$pathtofiles/" . $_->[0]; + } + mkpath(dirname("/tmp/xcatinitrd.$$/" . $_->[1])); + copy($srcpath, "/tmp/xcatinitrd.$$/" . $_->[1]); + chmod 0755, "/tmp/xcatinitrd.$$/" . $_->[1]; + } else { + + #print "$_\n"; + system("chroot $rootimg_dir cp $_ $pathinrootimage"); + my $srcpath = "$pathonrootimage/" . basename($_); + if (-f "$customdir/$_") { + $srcpath = "$customdir/$_"; + } elsif (-f "$pathtofiles/$_") { + $srcpath = "$pathtofiles/$_"; + } + mkpath(dirname("/tmp/xcatinitrd.$$/$_")); + copy("$srcpath", "/tmp/xcatinitrd.$$/$_"); + chmod 0755, "/tmp/xcatinitrd.$$/" . $_; + } + } + rmtree($pathonrootimage); + + #copy conf files needed by nfs mount in sles11.2 + if ($osver_host >= 11) + { + system("cp -r $rootimg_dir/etc/protocols /tmp/xcatinitrd.$$/etc/"); + system("cp -r $rootimg_dir/etc/netconfig /tmp/xcatinitrd.$$/etc/"); + } + + + # Copy udev libraries + system("mkdir -p /tmp/xcatinitrd.$$/etc/udev"); + system("mkdir -p /tmp/xcatinitrd.$$/lib/firmware"); + system("cp -r $rootimg_dir/etc/udev/* /tmp/xcatinitrd.$$/etc/udev"); + system("cp -r $rootimg_dir/bin/uname /tmp/xcatinitrd.$$/bin/"); + if (-d "$rootimg_dir/lib/firmware/") { + system("cp -r $rootimg_dir/lib/firmware/* /tmp/xcatinitrd.$$/lib/firmware"); + } + system("cp -r $rootimg_dir/usr/bin/killall /tmp/xcatinitrd.$$/usr/bin"); + + # Copy rules for network adapter + #my $name = `cat /etc/sysconfig/network/ifcfg-$prinic | grep NAME`; + #my $nic = ''; + #if ($name =~ m/(\d+\.\d+\.\d+)/g) { + # $nic = $&; + #} + + # Somehow checking for *$nic.rules does not work + #if ( -f "/etc/udev/rules.d/*$nic.rules" ) { + # system("cp -r /etc/udev/rules.d/*$nic.rules /tmp/xcatinitrd.$$/etc/udev/rules.d"); + #} + #if ( -f "/etc/udev/rules.d/*persistent-net.rules" ) { + # system("cp -r /etc/udev/rules.d/*persistent-net.rules /tmp/xcatinitrd.$$/etc/udev/rules.d"); + #} + + system("mkdir -p /tmp/xcatinitrd.$$/lib/udev"); + system("cp -r $rootimg_dir/lib/udev/* /tmp/xcatinitrd.$$/lib/udev"); + + #copy("$rootimg_dir/lib/modules/*d","/tmp/xcatinitrd.$$/$_"); + system("cd /tmp/xcatinitrd.$$/bin/; ln -sf bash sh"); #neccessary for SLES11 + if ($mode eq "statelite") { + system("cd /tmp/xcatinitrd.$$;find .|cpio -H newc -o|gzip -9 -c - > $destdir/initrd-statelite.gz"); + print "The initial ramdisk for statelite has been generated successfully!\n"; + } else { + system("cd /tmp/xcatinitrd.$$;find .|cpio -H newc -o|gzip -9 -c - > $destdir/initrd-stateless.gz"); + print "The initial ramdisk for stateless has been generated successfully!\n"; + } + system("rm -rf /tmp/xcatinitrd.$$"); + +} + +sub isyumdir { + if ($File::Find::name =~ /\/repodata$/) { + my $location = $File::Find::name; + $location =~ s/\/repodata$//; + push @yumdirs, $location; + } +} + +sub isnetdriver { + foreach (@ndrivers) { + if ($File::Find::name =~ /\/$_/) { + my $filetoadd = $File::Find::name; + $filetoadd =~ s!$rootimg_dir!!; + push @filestoadd, [ $filetoadd, "lib/$_" ]; + print "Added driver $_ to initrd\n"; + } + } +} + + + + + + + +sub postscripts { # TODO: customized postscripts + generic_post(); + unless (-d "$rootimg_dir/opt/xcat/") { + mkdir "$rootimg_dir/opt/xcat/"; + } + copy("$installroot/postscripts/xcatdsklspost", "$rootimg_dir/opt/xcat/"); #TODO: it is not used in stateless + chmod '0755', "$rootimg_dir/opt/xcat/xcatdsklspost"; +} + +sub generic_post { # This function is meant to leave the image in a state approximating a normal install + my $cfgfile; + + #modify /etc/sysconfig/clock in the image:HWCLOCK="--local", TIMEZONE=site:timezone + if ($timezone) { + if (-e "$rootimg_dir/etc/sysconfig/clock") { + system("sed -i '" . 's!\(TIMEZONE=\).*!\1' . "\"$timezone\"!" . "' $rootimg_dir/etc/sysconfig/clock"); + } + system("chroot $rootimg_dir zic -l $timezone"); + } + + if (-e "$rootimg_dir/etc/sysconfig/clock") { + system("sed -i 's!\\(HWCLOCK=\\).*!\\1\"--localtime\"!' $rootimg_dir/etc/sysconfig/clock"); + } + + unlink("$rootimg_dir/dev/null"); + system("mknod $rootimg_dir/dev/null c 1 3"); + open($cfgfile, ">", "$rootimg_dir/etc/fstab"); + print $cfgfile "devpts /dev/pts devpts gid=5,mode=620 0 0\n"; + print $cfgfile "tmpfs /dev/shm tmpfs defaults 0 0\n"; + print $cfgfile "proc /proc proc defaults 0 0\n"; + print $cfgfile "sysfs /sys sysfs defaults 0 0\n"; + if ($tmplimit) { + print $cfgfile "tmpfs /tmp tmpfs defaults,size=$tmplimit 0 2\n"; + print $cfgfile "tmpfs /var/tmp tmpfs defaults,size=$tmplimit 0 2\n"; + } else { + print $cfgfile "tmpfs /tmp tmpfs defaults,size=10m 0 2\n"; + print $cfgfile "tmpfs /var/tmp tmpfs defaults,size=10m 0 2\n"; + } + + my $rootfs_name = $profile . "_" . $arch; + print $cfgfile "$rootfs_name / tmpfs rw 0 1\n"; + + close($cfgfile); + + open($cfgfile, ">", "$rootimg_dir/etc/sysconfig/network"); + print $cfgfile "NETWORKING=yes\n"; + close($cfgfile); + + open($cfgfile, ">", "$rootimg_dir/etc/resolv.conf"); + print $cfgfile "#Dummy resolv.conf to make boot cleaner"; + close($cfgfile); + + # Create the ifcfg-x file for diskless node. But keep the ONBOOT=no + # to skip the break of nfs-based boot + if ($prinic) { + open($cfgfile, ">", "$rootimg_dir/etc/sysconfig/network/ifcfg-$prinic"); + print $cfgfile "ONBOOT=no\nBOOTPROTO=dhcp\nDEVICE=$prinic\nSTARTMODE=auto\n"; + close($cfgfile); + } + + foreach (split /,/, $othernics) { + next if (/^$/); + open($cfgfile, ">", "$rootimg_dir/etc/sysconfig/network/ifcfg-$_"); + print $cfgfile "ONBOOT=yes\nBOOTPROTO=dhcp\nDEVICE=$_\nSTARTMODE=auto\n"; + close($cfgfile); + } + + # securetty not needed on s390x + if ($arch ne "s390x") { + open($cfgfile, ">>", "$rootimg_dir/etc/securetty"); + print $cfgfile "ttyS0\n"; + print $cfgfile "ttyS1\n"; + print $cfgfile "console\n"; + close($cfgfile); + } + + my @passwd; + open($cfgfile, "<", "$rootimg_dir/etc/passwd"); + @passwd = <$cfgfile>; + close($cfgfile); + open($cfgfile, ">", "$rootimg_dir/etc/passwd"); + foreach (@passwd) { + if (/^root:/) { + s/^root:\*/root:x/; + } + print $cfgfile $_; + } + close($cfgfile); + foreach (<$rootimg_dir/etc/skel/.*>) { + next if (basename($_) eq '.' or basename($_) eq '..'); + copy $_, "$rootimg_dir/root/"; + } + + # gettyset is not found on s390x + if ($arch ne "s390x") { + open($cfgfile, ">", "$rootimg_dir/etc/init.d/gettyset"); + print $cfgfile "#!/bin/bash\n"; + print $cfgfile "### BEGIN INIT INFO\n"; + print $cfgfile "# Provides: gettyset\n"; + print $cfgfile "# Required-Start: sshd\n"; + print $cfgfile "# Required-Stop:\n"; + print $cfgfile "# Default-Start: 3\n"; + print $cfgfile "# Default-Stop: 0 1 2 6\n"; + print $cfgfile "# Short-Description: gettyset\n"; + print $cfgfile "# Description:\n"; + print $cfgfile "### END INIT INFO\n"; + print $cfgfile "VERS=`grep VERSION /etc/SuSE-release`\n"; + print $cfgfile "if [ -n \"\$VERS\" ]; then\n"; + print $cfgfile " VERNUM=`echo \$VERS|awk -F= \'{print \$2}\'|sed -e \'s/ //g\'`\n"; + print $cfgfile "fi\n"; + print $cfgfile "if [ \"\$VERNUM\" -gt 10 ]; then\n"; + print $cfgfile " exit\n"; + print $cfgfile "fi\n"; + print $cfgfile "\n"; + print $cfgfile "for i in `cat /proc/cmdline`; do\n"; + print $cfgfile ' KEY=`echo $i|cut -d= -f 1`' . "\n"; + print $cfgfile " if [ \"\$KEY\" == \"console\" -a \"\$i\" != \"console=tty0\" ]; then\n"; + print $cfgfile " VALUE=`echo \$i | cut -d= -f 2`\n"; + print $cfgfile " COTTY=`echo \$VALUE|cut -d, -f 1`\n"; + print $cfgfile " COSPEED=`echo \$VALUE|cut -d, -f 2|cut -dn -f 1`\n"; + print $cfgfile " if echo \$VALUE | grep n8r; then\n"; + print $cfgfile " FLOWFLAG=\"-h\"\n"; + print $cfgfile " fi\n"; + print $cfgfile " echo xco:2345:respawn:/sbin/agetty \$FLOWFLAG \$COTTY \$COSPEED xterm >> /etc/inittab\n"; + print $cfgfile " init q\n"; + print $cfgfile " fi\n"; + print $cfgfile "done\n"; + print $cfgfile "/etc/init.d/boot.localnet start\n"; + + close($cfgfile); + chmod(0755, "$rootimg_dir/etc/init.d/gettyset"); + } + + copy("$installroot/postscripts/xcatpostinit", "$rootimg_dir/etc/init.d/xcatpostinit"); + chmod(0755, "$rootimg_dir/etc/init.d/xcatpostinit"); + copy("$installroot/postscripts/xcatpostinit.service", "$rootimg_dir/usr/lib/systemd/system/xcatpostinit.service"); + + # + # set certain system services to start on boot, if the file exists in /etc/init.d as a script, + # use insserv to start it. If not, assume that the service is controlled by systemctl + # + # note: insserv is passed the -f option to ignore the dependency on sles10.4 + # + print "[genimage] setting services to start at boot time...\n"; + my @services; + push @services, qw/sshd network gettyset xcatpostinit/; + + foreach my $service (@services) { + my $cmd = "chroot $rootimg_dir "; + $cmd = $cmd . "systemctl enable $service.service"; + system("$cmd"); + } + + # + # Check if .depend.start file exists. For SLES12 and later OS, this does not apply + # + if (-r '$rootimg_dir/etc/init.d/.depend.start') { + my $rc = system("grep sshd $rootimg_dir/etc/init.d/.depend.start | grep TARGETS"); + if ($rc) { + system("sed -i '" . 's/^\(TARGETS = .*\)$/\1 sshd/' . "' $rootimg_dir/etc/init.d/.depend.start"); + system("ln -s ../sshd $rootimg_dir/etc/init.d/rc3.d/S20sshd"); + } + my $rc = system("grep gettyset $rootimg_dir/etc/init.d/.depend.start | grep TARGETS"); + if ($rc) { + system("sed -i '" . 's/^\(TARGETS = .*\)$/\1 gettyset/' . "' $rootimg_dir/etc/init.d/.depend.start"); + system("ln -s ../gettyset $rootimg_dir/etc/init.d/rc3.d/S60gettyset"); + } + } +} + + +my $driver_name; +my $real_path; + +sub get_path () +{ + if ($File::Find::name =~ /\/$driver_name/) { + $real_path = $File::Find::name; + } +} + +my @all_real_path; + +sub get_all_path () +{ + if ($File::Find::name =~ /\/$driver_name/) { + push @all_real_path, $File::Find::name; + } +} + +# Load driver disk and driver rpm to the initrd +# Get the driver disk or driver rpm from the osimage.driverupdatesrc +# The valid value: dud:/install/dud/dd.img,rpm:/install/rpm/d.rpm, if missing the tag: 'dud'/'rpm' +# the 'rpm' is default. +# +# If cannot find the driver disk from osimage.driverupdatesrc, will try to search driver disk +# from /install/driverdisk// +# +# For driver rpm, the driver list will be gotten from osimage.netdrivers. If not set, copy all the drivers from driver +# rpm to the initrd. +# +# Return the driver names by loading order + +sub load_dd() +{ + my @dd_list; + my @rpm_list; + my @driver_list; + + my $Injectalldriver; + my @rpm_drivers; + + # Parse the parameters to the the source of Driver update disk and Driver rpm, and driver list as well + if ($driverupdatesrc) { + my @srcs = split(',', $driverupdatesrc); + foreach my $src (@srcs) { + if ($src =~ /dud:(.*)/i) { + push @dd_list, $1; + } elsif ($src =~ /rpm:(.*)/i) { + push @rpm_list, $1; + } else { + push @rpm_list, $src; + } + } + } + if (!@dd_list) { + + # get Driver update disk from the default path if not specified in osimage + # check the Driver Update Disk images, it can be .img or .iso + if (-d "$installroot/driverdisk/$osver/$arch") { + @dd_list = `find $installroot/driverdisk/$osver/$arch -type f`; + } + } + + foreach (split /,/, $netdriver) { + if (/^allupdate$/) { + $Injectalldriver = 1; + next; + } + unless (/\.ko$/) { + s/$/.ko/; + } + push @driver_list, $_; + } + + chomp(@dd_list); + chomp(@rpm_list); + + unless (@dd_list || (@rpm_list && ($Injectalldriver || @driver_list))) { + return (); + } + + # Create the work space, it should be cleaned at end of genimage + my $dd_dir = mkdtemp("/tmp/ddtmpXXXXXXX"); + mkpath "$dd_dir/mnt"; + mkpath "$dd_dir/mods"; + + my @dd_drivers = (); #driver names + + # Load drivers from each Driver Disk + # For multiple dd, if want to make it has order, rename the dd with a number + # ahead of the name like 0_xx, 1_xx + foreach my $dd (sort(@dd_list)) { + my $rc = system("mount -o loop $dd $dd_dir/mnt"); + if ($rc) { + print "mount the Driver Disk $dd failed.\n"; + next; + } + + mkpath "$dd_dir/full"; + + # Copy out the drivers + opendir(DIR, "$dd_dir/mnt") || die "Cannot open dir $dd_dir/mnt"; + while (my $dir = readdir(DIR)) { + if ($dir =~ /^\./) { next; } + + # Every driver update disk can have multiple directories, each directory + # has the directory format like /linux/[distribution]/[architechture]-[version]/ + # If the directory name is numeric, then it will be used as order to load the + # the dirviers inside. + # For the directory name which is not numeric, copy them to directory 0. It will be + # loaled first. + if ($dir !~ /^\d*$/) { + mkpath "$dd_dir/full/0"; + system("cp -rf $dd_dir/mnt/$dir $dd_dir/full/0"); + } else { + system("cp -rf $dd_dir/mnt/$dir $dd_dir/full/"); + } + } + closedir(DIR); + + # Get all the kernel modules base on the order of directory name. + + # The structure of dd: /linux/[distribution]/[architechture]-[version]/ + + # The supported arch: i386, ia64, ppc, ppc64, s390, s390x sparc or x86_64. + my $darch = $arch; + if ($darch =~ /^x86$/) { + $darch = "i386"; + } + + # If the version is os version. If the os is "sles11.1", the possible os version + # could be "sles11.1", "11.1", "11", "sles11" + my @distro = ($osver); + my $distro1 = $osver; + $distro1 =~ s/[^\d]*//; + push @distro, $distro1; + my $distro2 = $distro1; + $distro2 =~ s/\..*//; + push @distro, $distro2; + my $distro3 = $osver; + $distro3 =~ s/\..*//; + push @distro, $distro3; + + opendir(FDIR, "$dd_dir/full") || die "Cannot open dir $dd_dir/full"; + my @fulldir = readdir(FDIR); + closedir(FDIR); + + # Create the directory for drivers from driver disk + if (!-d "$rootimg_dir/lib/modules/$kernelver/kernel/drivers/driverdisk") { + mkpath "$rootimg_dir/lib/modules/$kernelver/kernel/drivers/driverdisk"; + } + + # Copy the drivers to the root image and get the driver loading order + foreach my $dir (sort(@fulldir)) { + if ($dir =~ /^\./) { next; } + my $vdir; + foreach (@distro) { + if (-d "$dd_dir/full/$dir/linux/suse/$darch-$_") { + $vdir = "$dd_dir/full/$dir/linux/suse/$darch-$_"; + } + } + if (!$vdir) { next; } + + # Use the module_order if it has + if (-f "$vdir/modules/module.order") { + open(ORDER, "<", "$vdir/modules/module.order"); + while (my $file = ) { + chomp($file); + if (-f "$vdir/modules/$file") { + $driver_name = $file; + $real_path = ""; + find(\&get_path, <$rootimg_dir/lib/modules/$kernelver/*>); + if ($real_path eq "") { + system("cp $vdir/modules/$file $rootimg_dir/lib/modules/$kernelver/kernel/drivers/driverdisk"); + } else { + system("cp $vdir/modules/$file $real_path"); + } + + push @dd_drivers, $file; + } + } + } else { + opendir(MDIR, "$vdir/modules") || die "Cannot open dir $vdir/modules"; + while (my $file = readdir(MDIR)) { + if (-f "$vdir/modules/$file" && $file =~ /\.ko/) { + $driver_name = $file; + $real_path = ""; + find(\&get_path, <$rootimg_dir/lib/modules/$kernelver/*>); + if ($real_path eq "") { + system("cp $vdir/modules/$file $rootimg_dir/lib/modules/$kernelver/kernel/drivers/driverdisk"); + } else { + system("cp $vdir/modules/$file $real_path"); + } + + push @dd_drivers, $file; + } + } + } + } + + rmtree "$dd_dir/full"; + + my $rc = system("umount -f $dd_dir/mnt"); + if ($rc) { + print "umount the directory $dd_dir/mnt failed\n"; + exit 1; + } + } + + # Loading the drivers from rpm packages + if (@rpm_list && ($Injectalldriver || @driver_list)) { + + # Extract the files from rpm to the tmp dir + mkpath "$dd_dir/rpm"; + foreach my $rpm (@rpm_list) { + if (-r $rpm) { + if (system("cd $dd_dir/rpm; rpm2cpio $rpm | cpio -idum")) { + print "Error: Cannot extract the files from the rpm $rpm.\n"; + } + } else { + print "Error: Cannot read the rpm $rpm.\n"; + } + } + + # To skip the conflict of files that some rpm uses the xxx.ko.new as the name of the driver + # Change it back to xxx.ko here + $driver_name = "\*ko.new"; + @all_real_path = (); + find(\&get_all_path, <$dd_dir/rpm/*>); + foreach my $file (@all_real_path) { + my $newname = $file; + $newname =~ s/\.new$//; + if (system("mv -f $file $newname")) { + print "Error: Could not rename $file\n"; + + } + } + + # Copy the firmware to the rootimage + if (-d "$dd_dir/rpm/lib/firmware") { + system("cp -rf $dd_dir/rpm/lib/firmware $rootimg_dir/lib"); + } + + # if $ignorekernelchk is specified, copy all driver files to target kernel dir + if ($ignorekernelchk) { + my @kernelpath4vrpm = <$dd_dir/rpm/lib/modules/*>; + foreach my $path (@kernelpath4vrpm) { + if ($path eq "$dd_dir/rpm/lib/modules/$kernelver") { + next; + } + + unless (-d "$dd_dir/rpm/lib/modules/$kernelver") { + mkpath "$dd_dir/rpm/lib/modules/$kernelver"; + } + system("/bin/cp -rf $path/* $dd_dir/rpm/lib/modules/$kernelver"); + } + } + + # Copy the drivers to the rootimage + if (-d "$dd_dir/rpm/lib/modules/$kernelver") { + + #mkpath "$rootimg_dir/lib/modules/$kernelver/updates/"; + if (@driver_list) { + foreach my $driver (@driver_list) { + $driver_name = $driver; + $real_path = ""; + find(\&get_path, <$dd_dir/rpm/lib/modules/$kernelver/*>); + if ($real_path && $real_path =~ m!$dd_dir/rpm(/lib/modules/$kernelver/.*?)[^\/]*$!) { + + # remove the old one if existing + @all_real_path = (); + find(\&get_all_path, <$rootimg_dir/lib/modules/$kernelver/*>); + foreach (@all_real_path) { + if (-r $_) { + unlink($_); + } + } + + if (!-d "$rootimg_dir$1") { + mkpath "$rootimg_dir$1"; + } + system("cp -rf $real_path $rootimg_dir$1"); + push @rpm_drivers, $driver; + } else { + print "Warning: cannot find the driver $driver from the driver rpms\n"; + } + } + } elsif ($Injectalldriver) { + + # copy all the drviers to the rootimage + $driver_name = "\*\.ko"; + @all_real_path = (); + find(\&get_all_path, <$dd_dir/rpm/lib/modules/$kernelver/*>); + my @all_drivers = @all_real_path; + foreach my $new_driver (@all_drivers) { + if (basename($new_driver) =~ /\.ko$/) { + + # remove the old one if existing + $driver_name = basename($new_driver); + @all_real_path = (); + find(\&get_all_path, <$rootimg_dir/lib/modules/$kernelver/*>); + foreach my $old_driver (@all_real_path) { + if (-r $old_driver) { + unlink($old_driver); + } + } + push @rpm_drivers, basename($new_driver); + } + } + + system("cp -rf $dd_dir/rpm/lib/modules/$kernelver $rootimg_dir/lib/modules/"); + } + } else { + print "Warning: cannot find the kernel $kernelver from drvier rpms\n"; + } + + push @dd_drivers, @rpm_drivers; + } + + # Generate the dependency relationship + system("chroot '$rootimg_dir' depmod $kernelver"); + + # Clean the env + rmtree "$dd_dir"; + + return @dd_drivers; +} + +sub usage { + print 'Usage: genimage -o [-a ] -p -i -n [-r ] [-k ] [-g ] [-l rootlimitsize] [--permission ] [--interactive]' . "\n"; + print " --permission is used for statelite only\n"; + print "Examples:\n"; + print " genimage -i eth0 -n tg3 -o sles11 -p compute\n"; + print " genimage -i eth0 -r eth1,eth2 -n tg3,bnx2 -o sles11 -p compute --interactive\n"; + print " genimage -i eth0 -n tg3,bnx2 -o sles11 -p compute\n"; + print " genimage -i eth0 -n tg3,bnx2 -o sles11 -p compute --permission 777\n"; + return 0; +} + diff --git a/xCAT-server/share/xcat/netboot/sle/service.sle15.pkglist b/xCAT-server/share/xcat/netboot/sle/service.sle15.pkglist new file mode 100644 index 000000000..447e5a3ea --- /dev/null +++ b/xCAT-server/share/xcat/netboot/sle/service.sle15.pkglist @@ -0,0 +1,70 @@ +aaa_base +adaptec-firmware +apache2 +apache2-prefork +bash +bind +bind-utils +binutils +bc +btrfsprogs +bzip2 +cifs-utils +coreutils +cron +cryptsetup +curl +dhcp +dhcp-client +dhcp-relay +dhcp-server +dmraid +e2fsprogs +fcoe-utils +gpg2 +gzip +xz +kernel-default +keyutils +lvm2 +mdadm +multipath-tools +nfs-kernel-server +ntp +openssh +openssl +open-iscsi +open-lldp +pam +pam-modules +parted +perl-doc +perl-Expect +plymouth +plymouth-dracut +procps +psmisc +rpm +rsync +sysconfig +tar +timezone +udev +util-linux +util-linux-systemd +vim +vsftpd +wget +which +zypper + +#for database +unixODBC +perl-DBD-mysql +mariadb-client +libmysqlclient18 +# The following rpms are available on the SLES SDK +# You will need to locate and make these rpms available in your zypper +# repository for service node installs and uncomment the following lines: +#MyODBC-unixODBC +#perl-DBD-Pg diff --git a/xCAT-server/share/xcat/netboot/sle/service.sle15.postinstall b/xCAT-server/share/xcat/netboot/sle/service.sle15.postinstall new file mode 100755 index 000000000..201599be0 --- /dev/null +++ b/xCAT-server/share/xcat/netboot/sle/service.sle15.postinstall @@ -0,0 +1,68 @@ +#!/bin/sh +#-- Do not remove following line if you want to make use of CVS version tracking +#-- $Id: compute.postinstall,v 1.21 2008/09/04 12:05:45 sikorsky Exp $ +#-- jurij.sikorsky@t-systems.cz +#-- +#-- this script is run after all packages from $profile.pkglist are installed +#-- +#-- it gets these arguments: +#-- +#-- $1 = install root (chroot directory for profile) +#-- $2 = OS version +#-- $3 = architecture +#-- $4 = profile name +#-- $5 = work dir (where genimage is located) +#-- +#-- +installroot=$1 +osver=$2 +arch=$3 +profile=$4 +workdir=$5 + +#-- Example how /etc/fstab can be automatically generated during image generation: +cp $installroot/etc/fstab $installroot/etc/fstab.prev +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 + + +cat <>$installroot/etc/hosts +`getent hosts $HOSTNAME` +END + +#Prevent DHCP from starting up until xcatd has had a chance to configure it: +chroot $installroot chkconfig dhcpd off +chroot $installroot chkconfig dhcrelay off + +#turn on some services +chroot $installroot chkconfig dbus on +chroot $installroot chkconfig boot.localnet on +chroot $installroot chkconfig haldaemon on +chroot $installroot chkconfig network on +chroot $installroot chkconfig syslog on +chroot $installroot chkconfig apache2 on + +#export /install as read-only +mkdir -p /install +echo '/install *(ro,no_root_squash,sync,fsid=13)' > $installroot/etc/exports + +#uncomment out the cons line in etc/inittab +#sed -i 's/^\#\(\s\)*cons/cons/' $installroot/etc/inittab + +TMP_inittab=`sed 's/\(#\)\(cons:12345.*\)$/\2/' $installroot/etc/inittab` +echo "$TMP_inittab" > $installroot/etc/inittab + + +#-- Example of booted image versioning +#-- We want to know, with what configuration (version of the image) each node was booted. +#-- Hence, we keep image definition files and postscripts in CVS. During image generation we create file /etc/IMGVERSION and fill it with CVS "$Id$" of files with image definition (.pkglist, .exlist, .repolist, .postinstall). Then, during boot, each "CVS enabled" postscript (see /install/postscripts/cvs_template.sh and /install/postscripts/cvs_template.pl) adds one line to /etc/IMGVERSION. Then you can determine in any time what image you are running and what postscipts in which versions were run. +#cat /dev/null > $installroot/etc/IMGVERSION +#for ext in pkglist exlist postinstall repolist; do +# [ -r $workdir/$profile.$ext ] && cat $workdir/$profile.$ext | grep -E '^[[:space:]]*#.*[[:space:]]\$Id' >> $installroot/etc/IMGVERSION +#done diff --git a/xCAT-server/share/xcat/netboot/sle/service.sle15.x86_64.otherpkgs.pkglist b/xCAT-server/share/xcat/netboot/sle/service.sle15.x86_64.otherpkgs.pkglist new file mode 100644 index 000000000..7fe170d23 --- /dev/null +++ b/xCAT-server/share/xcat/netboot/sle/service.sle15.x86_64.otherpkgs.pkglist @@ -0,0 +1,3 @@ +-perl-doc +xcat/xcat-core/xCATsn +xcat/xcat-dep/sles12/x86_64/conserver-xcat diff --git a/xCAT/postscripts/xcatpostinit.service b/xCAT/postscripts/xcatpostinit.service new file mode 100755 index 000000000..4f1f57e4d --- /dev/null +++ b/xCAT/postscripts/xcatpostinit.service @@ -0,0 +1,12 @@ +[Unit] +Description=xcat service on compute node, the framework to run postbootscript and update node status +After=network.target rsyslog.service + +[Service] +Type=oneshot +ExecStart=/opt/xcat/xcatpostinit start +ExecStop=/opt/xcat/xcatpostinit stop +RemainAfterExit=yes + +[Install] +WantedBy=multi-user.target From d1ed2cf041fb0db513ab0a243f39f9b1b5d084e6 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Sat, 11 Aug 2018 13:17:44 -0400 Subject: [PATCH 002/139] Move xcatpostinit to /opt/xcat systemd was confused by the /etc/init.d entry it shouldn't use --- xCAT-server/share/xcat/netboot/sle/genimage | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/xCAT-server/share/xcat/netboot/sle/genimage b/xCAT-server/share/xcat/netboot/sle/genimage index baf3746f6..7f9f3f05f 100755 --- a/xCAT-server/share/xcat/netboot/sle/genimage +++ b/xCAT-server/share/xcat/netboot/sle/genimage @@ -2058,8 +2058,9 @@ sub generic_post { # This function is meant to leave the image in a state approx chmod(0755, "$rootimg_dir/etc/init.d/gettyset"); } - copy("$installroot/postscripts/xcatpostinit", "$rootimg_dir/etc/init.d/xcatpostinit"); - chmod(0755, "$rootimg_dir/etc/init.d/xcatpostinit"); + system("mkdir -p $rootimg_dir/opt/xcat"); + copy("$installroot/postscripts/xcatpostinit", "$rootimg_dir/opt/xcat/xcatpostinit"); + chmod(0755, "$rootimg_dir/opt/xcat/xcatpostinit"); copy("$installroot/postscripts/xcatpostinit.service", "$rootimg_dir/usr/lib/systemd/system/xcatpostinit.service"); # From a3743ea12b72933c2e2a8d2179334106f87bf372 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Sat, 11 Aug 2018 19:42:46 -0400 Subject: [PATCH 003/139] Turn on hostname from dhcp request in SLE15 stateless --- xCAT-server/share/xcat/netboot/sle/genimage | 3 +++ 1 file changed, 3 insertions(+) diff --git a/xCAT-server/share/xcat/netboot/sle/genimage b/xCAT-server/share/xcat/netboot/sle/genimage index 7f9f3f05f..5df177836 100755 --- a/xCAT-server/share/xcat/netboot/sle/genimage +++ b/xCAT-server/share/xcat/netboot/sle/genimage @@ -1948,6 +1948,9 @@ sub generic_post { # This function is meant to leave the image in a state approx if (-e "$rootimg_dir/etc/sysconfig/clock") { system("sed -i 's!\\(HWCLOCK=\\).*!\\1\"--localtime\"!' $rootimg_dir/etc/sysconfig/clock"); } + if (-e "$rootimg_dir/etc/sysconfig/network/dhcp") { + system("sed -i 's!^DHCLIENT_SET_HOSTNAME=\\\"no\\\"!DHCLIENT_SET_HOSTNAME=\\\"yes\\\"!' $rootimg_dir/etc/sysconfig/network/dhcp"); + } unlink("$rootimg_dir/dev/null"); system("mknod $rootimg_dir/dev/null c 1 3"); From 8a93d6360870cd9d5de9896a2ea7814f7d80e6bd Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Sat, 11 Aug 2018 19:51:20 -0400 Subject: [PATCH 004/139] Have SLE15 bring up bootnic normally in stateless --- .../xcat/netboot/sle/dracut_033/xcat-prepivot.sh | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/xCAT-server/share/xcat/netboot/sle/dracut_033/xcat-prepivot.sh b/xCAT-server/share/xcat/netboot/sle/dracut_033/xcat-prepivot.sh index b5114ef43..039990ab4 100755 --- a/xCAT-server/share/xcat/netboot/sle/dracut_033/xcat-prepivot.sh +++ b/xCAT-server/share/xcat/netboot/sle/dracut_033/xcat-prepivot.sh @@ -134,15 +134,11 @@ function getdevfrommac() { done } -for lf in /tmp/dhclient.*.lease; do - netif=${lf#*.} - netif=${netif%.*} - cp $lf "$NEWROOT/var/lib/dhclient/dhclient-$netif.leases" -done - -if [ -f $NEWROOT/etc/hostname ]; then - echo `hostname -s` > $NEWROOT/etc/hostname -fi +bootif=$(ls /tmp/net.*.conf|sed -e s/.*net\.// -e s/\.conf//) +cat < $NEWROOT/etc/sysconfig/network/ifcfg-$bootif +BOOTPROTO='dhcp' +STARTMODE='auto' +EOF if [ ! -z "$ifname" ]; then MACX=${ifname#*:} From fc0fcd6a5e487399527919d3d6ec1193d2679cd0 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Sat, 11 Aug 2018 20:51:30 -0400 Subject: [PATCH 005/139] Actually set up ifcfg correctly in SLE15 xcatroot is actually responsible, not prepivot.sh --- .../share/xcat/netboot/sle/dracut_033/xcatroot | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/xCAT-server/share/xcat/netboot/sle/dracut_033/xcatroot b/xCAT-server/share/xcat/netboot/sle/dracut_033/xcatroot index a6839b69f..ba8bb019a 100755 --- a/xCAT-server/share/xcat/netboot/sle/dracut_033/xcatroot +++ b/xCAT-server/share/xcat/netboot/sle/dracut_033/xcatroot @@ -292,12 +292,11 @@ function getdevfrommac() { if [ -z $STATEMNT ]; then - for lf in /tmp/dhclient.*.lease; do - netif=${lf#*.} - netif=${netif%.*} - cp $lf "$NEWROOT/var/lib/dhclient/dhclient-$netif.leases" - [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "saving $NEWROOT/var/lib/dhclient/dhclient-$netif.leases" - done + bootif=$(ls /tmp/net.*.conf|sed -e s/.*net\.// -e s/\.conf//) + cat < $NEWROOT/etc/sysconfig/network/ifcfg-$bootif +BOOTPROTO='dhcp' +STARTMODE='auto' +EOF if [ ! -z "$ifname" ]; then MACX=${ifname#*:} From 3554eb8544a5c3f53d6b2e9a61a88367b2bd1739 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Sat, 11 Aug 2018 23:46:30 -0400 Subject: [PATCH 006/139] Have compute stateless for SLE 15 be HPC edition --- xCAT-server/share/xcat/netboot/sle/compute.sle15.x86_64.pkglist | 1 + 1 file changed, 1 insertion(+) diff --git a/xCAT-server/share/xcat/netboot/sle/compute.sle15.x86_64.pkglist b/xCAT-server/share/xcat/netboot/sle/compute.sle15.x86_64.pkglist index d0b4c3a0e..cd5830aaf 100644 --- a/xCAT-server/share/xcat/netboot/sle/compute.sle15.x86_64.pkglist +++ b/xCAT-server/share/xcat/netboot/sle/compute.sle15.x86_64.pkglist @@ -42,3 +42,4 @@ kernel-default kernel-firmware adaptec-firmware xz +SLE_HPC-release From b23d6d661554269eed4139a3d69c370e46a7dcff Mon Sep 17 00:00:00 2001 From: adorsey-NOAA Date: Thu, 18 Jul 2019 17:56:05 -0400 Subject: [PATCH 007/139] Automatically find first unlocked user slot Instead of relying on hard coded offsets, query each slot's status with ```ipmitool channel getaccess``` and use the first slot that is unlocked. This fixes an issue on certain Cray x86 nodes that have arbitrary locked IPMI user slots. --- xCAT-genesis-scripts/usr/bin/bmcsetup | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/xCAT-genesis-scripts/usr/bin/bmcsetup b/xCAT-genesis-scripts/usr/bin/bmcsetup index fa5955adb..2bf6386aa 100755 --- a/xCAT-genesis-scripts/usr/bin/bmcsetup +++ b/xCAT-genesis-scripts/usr/bin/bmcsetup @@ -429,6 +429,14 @@ for user in $BMCUS; do USERSLOT=$((`ipmitool raw 6 0x44 1 1|awk '{print $3}'` + 1)) fi if [ "$USERSLOT" == 0 -o -z "$LOCKEDUSERS" ]; then USERSLOT=2; fi + # automatically find first unlocked user slot + for slot in {1..16}; do + USERLOCKED=`ipmitool channel getaccess $LANCHAN $slot | grep Fixed | awk '{print $4}'` + if [ "$USERLOCKED" == "No" ]; then + USERSLOT=$slot + break + fi + done if [ "$ISITE" = 1 ]; then allowcred.awk & CREDPID=$! From 99e452e5b346481c1dc2906c1ebedd74a0c6522c Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Tue, 5 Nov 2019 11:09:38 -0500 Subject: [PATCH 008/139] Update 2.15.x.csv --- docs/source/overview/_files/2.15.x.csv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/overview/_files/2.15.x.csv b/docs/source/overview/_files/2.15.x.csv index a2b0eba0f..c95f9d27d 100644 --- a/docs/source/overview/_files/2.15.x.csv +++ b/docs/source/overview/_files/2.15.x.csv @@ -1,2 +1,2 @@ Version,Release Date,New OS Supported,Release Notes -2.15.0,2019-07-31,,`2.15.0 Release Notes `_ +2.15.0,2019-11-??,,`2.15.0 Release Notes `_ From d303380054526edce12e23e5258ece0e7bbb34f9 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Tue, 5 Nov 2019 15:16:32 -0500 Subject: [PATCH 009/139] Display packages and version before go-xcat install --- xCAT-server/share/xcat/tools/go-xcat | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/xCAT-server/share/xcat/tools/go-xcat b/xCAT-server/share/xcat/tools/go-xcat index ce35926e1..bc8acfcc1 100755 --- a/xCAT-server/share/xcat/tools/go-xcat +++ b/xCAT-server/share/xcat/tools/go-xcat @@ -2,7 +2,7 @@ # # go-xcat - Install xCAT automatically. # -# Version 1.0.44 +# Version 1.0.45 # # Copyright (C) 2016 - 2019 International Business Machines # Eclipse Public License, Version 1.0 (EPL-1.0) @@ -27,6 +27,8 @@ # - Added conserver-xcat to uninstall list # 2019-10-23 Mark Gurevich # - Display a list of packages that could not be uninstalled +# 2019-11-05 Mark Gurevich +# - Display a list of packages that will be installed before "Continue?" # function usage() @@ -2156,6 +2158,7 @@ case "${GO_XCAT_ACTION}" in ;; "install"|"update") GO_XCAT_INSTALLER="${GO_XCAT_ACTION}_xcat" + list_xcat_packages ask_to_continue "${GO_XCAT_YES[0]}" "xCAT is going to be ${GO_XCAT_ACTION/%e/}ed." # Use `-y' here. Since the STDOUT is redirected. # `yum' does not display the prompt message properly when From a5fa42bb859d1a87cb989ac0ac7d7c24323742fc Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Thu, 7 Nov 2019 10:35:02 -0500 Subject: [PATCH 010/139] Fix repodata files permission in xcat-dep --- builddep.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/builddep.sh b/builddep.sh index 75235fa99..9cfde7ab8 100755 --- a/builddep.sh +++ b/builddep.sh @@ -268,8 +268,8 @@ chgrp -R -h $SYSGRP * chmod -R g+w * # Change permission on all repodata files to be readable by all -chmod a+r */*/repodata/*.gz -chmod a+r */*/repodata/*.bz2 +chmod a+rx */*/repodata +chmod a+r */*/repodata/* TARBALL_WORKING_DIR="${XCATCOREDIR}/${DESTDIR}" echo "===> Building the tarball at: ${TARBALL_WORKING_DIR} ..." From ee026089c397ba6c931cdbb40c0e2db5e79c5b43 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Thu, 7 Nov 2019 16:18:43 -0500 Subject: [PATCH 011/139] Fix broken doc links --- .../advanced/hierarchy/configure_dhcp.rst | 5 +- .../hierarchy/define_service_node.rst | 178 +++++++++--------- .../performance_tuning/httpd_tuning.rst | 8 +- .../restapi/restapi_usage/restapi_usage.rst | 5 +- .../developers/guides/docs/doc_guidelines.rst | 4 +- .../common/deployment/cfg_partition.rst | 2 +- .../common/deployment/enable_kdump.rst | 23 ++- .../diskful/customize_image/cfg_partition.rst | 10 +- 8 files changed, 113 insertions(+), 122 deletions(-) diff --git a/docs/source/advanced/hierarchy/configure_dhcp.rst b/docs/source/advanced/hierarchy/configure_dhcp.rst index 06fe9e258..bd61f2450 100644 --- a/docs/source/advanced/hierarchy/configure_dhcp.rst +++ b/docs/source/advanced/hierarchy/configure_dhcp.rst @@ -3,10 +3,9 @@ Configure DHCP Add the relevant networks into the DHCP configuration, refer to: :ref:`Setup-dhcp` -Add the defined nodes into the DHCP configuration, refer to: -`XCAT_pLinux_Clusters/#configure-dhcp `_ +Add the defined nodes into the DHCP configuration, refer to :doc:`Manually define nodes ` -In the large cluster, the size of dhcp lease file "/var/lib/dhcpd/dhcpd.leases" on the DHCP server will grow over time. At around 100MB in size, the DHCP server will take a long time to respond to DHCP requests from clients and cause DHCP timeouts: :: +In the large cluster, the size of dhcp lease file ``/var/lib/dhcpd/dhcpd.leases`` on the DHCP server will grow over time. At around 100MB in size, the DHCP server will take a long time to respond to DHCP requests from clients and cause DHCP timeouts: :: ... Mar 2 01:59:10 c656ems2 dhcpd: DHCPDISCOVER from 00:0a:f7:73:7d:d0 via eth0 diff --git a/docs/source/advanced/hierarchy/define_service_node.rst b/docs/source/advanced/hierarchy/define_service_node.rst index 81e6c8557..3c2d8ec1f 100644 --- a/docs/source/advanced/hierarchy/define_service_node.rst +++ b/docs/source/advanced/hierarchy/define_service_node.rst @@ -11,41 +11,41 @@ be adding the information to the database that will tell xCAT which service nodes (SN) will service which compute nodes (CN). For this example, we have two service nodes: **sn1** and **sn2**. We will call -our Management Node: **mn1**. Note: service nodes are, by convention, in a +our Management Node: **mn1**. Service nodes are, by convention, in a group called **service**. Some of the commands in this document will use the group **service** to update all service nodes. -Note: a Service Node's service node is the Management Node; so a service node -must have a direct connection to the management node. The compute nodes do not -have to be directly attached to the Management Node, only to their service -node. This will all have to be defined in your networks table. +.. note:: a Service Node's service node is the Management Node; so a service node + must have a direct connection to the management node. The compute nodes do not + have to be directly attached to the Management Node, only to their service + node. This will all have to be defined in your networks table. Add Service Nodes to the nodelist Table --------------------------------------- Define your service nodes (if not defined already), and by convention we put -them in a **service** group. We usually have a group compute for our compute +them in a **service** group. We usually have a group **compute** for our compute nodes, to distinguish between the two types of nodes. (If you want to use your -own group name for service nodes, rather than service, you need to change some -defaults in the xCAT db that use the group name service. For example, in the -postscripts table there is by default a group entry for service, with the +own group name for service nodes, rather than **service**, you need to change some +defaults in the xCAT db that use the group name **service**. For example, in the +postscripts table there is by default a group entry for **service**, with the appropriate postscripts to run when installing a service node. Also, the default ``kickstart/autoyast`` template, pkglist, etc that will be used have -files names based on the profile name service.) :: +files names based on the profile name **service**.) :: mkdef sn1,sn2 groups=service,ipmi,all Add OS and Hardware Attributes to Service Nodes ----------------------------------------------- -When you ran copycds, it creates several osimage definitions, including some +When you ran ``copycds``, it creates several osimage definitions, including some appropriate for SNs. Display the list of osimages and choose one with -"service" in the name: :: +**service** in the name: :: lsdef -t osimage For this example, let's assume you chose the stateful osimage definition for -rhels 7: rhels7-x86_64-install-service . If you want to modify any of the +rhels 7: ``rhels7-x86_64-install-service`` . If you want to modify any of the osimage attributes (e.g. ``kickstart/autoyast`` template, pkglist, etc), make a copy of the osimage definition and also copy to ``/install/custom`` any files it points to that you are modifying. @@ -60,19 +60,19 @@ Now set some of the common attributes for the SNs at the group level: :: primarynic=mac \ provmethod=rhels7-x86_64-install-service -Add Service Nodes to the servicenode Table +Add Service Nodes to the ``servicenode`` Table ------------------------------------------ -An entry must be created in the servicenode table for each service node or the -service group. This table describes all the services you would like xcat to +An entry must be created in the ``servicenode`` table for each service node or the +**service** group. This table describes all the services you would like xcat to setup on the service nodes. (Even if you don't want xCAT to set up any -services - unlikely - you must define the service nodes in the servicenode +services - unlikely - you must define the service nodes in the ``servicenode`` table with at least one attribute set (you can set it to 0), otherwise it will not be recognized as a service node.) -When the xcatd daemon is started or restarted on the service node, it will +When the ``xcatd`` daemon is started or restarted on the service node, it will make sure all of the requested services are configured and started. (To -temporarily avoid this when restarting xcatd, use "service xcatd reload" +temporarily avoid this when restarting ``xcatd``, use ``service xcatd reload`` instead.) To set up the minimum recommended services on the service nodes: :: @@ -82,23 +82,21 @@ To set up the minimum recommended services on the service nodes: :: setupnameserver=1 \ setupconserver=1 -.. TODO - See the ``setup*`` attributes in the :doc:`node manpage ` for the services available. (The HTTP server is also started when setupnfs is set.) -If you are using the setupntp postscript on the compute nodes, you should also -set setupntp=1. For clusters with subnetted management networks (i.e. the +If you are using the ``setupntp`` postscript on the compute nodes, you should also +set ``setupntp=1``. For clusters with subnetted management networks (i.e. the network between the SN and its compute nodes is separate from the network -between the MN and the SNs) you might want to also set setupipforward=1. +between the MN and the SNs) you might want to also set ``setupipforward=1``. .. _add_service_node_postscripts_label: Add Service Node Postscripts ---------------------------- -By default, xCAT defines the service node group to have the "servicenode" +By default, xCAT defines the **service** node group to have the ``servicenode`` postscript run when the SNs are installed or diskless booted. This -postscript sets up the xcatd credentials and installs the xCAT software on +postscript sets up the ``xcatd`` credentials and installs the xCAT software on the service nodes. If you have your own postscript that you want run on the SN during deployment of the SN, put it in ``/install/postscripts`` on the MN and add it to the service node postscripts or postbootscripts. For example: :: @@ -113,7 +111,7 @@ Notes: * Make sure that the servicenode postscript is set to run before the otherpkgs postscript or you will see errors during the service node deployment. - * The -p flag automatically adds the specified postscript at the end of the + * The ``-p`` flag automatically adds the specified postscript at the end of the comma-separated list of postscripts (or postbootscripts). If you are running additional software on the service nodes that need **ODBC** @@ -125,43 +123,42 @@ the xCAT supplied postbootscript called "odbcsetup". :: Assigning Nodes to their Service Nodes -------------------------------------- -The node attributes **servicenode** and **xcatmaster** define which SN -services this particular node. The servicenode attribute for a compute node -defines which SN the MN should send a command to (e.g. xdsh), and should be +The node attributes ``servicenode`` and ``xcatmaster`` define which SN +services this particular node. The ``servicenode`` attribute for a compute node +defines which SN the MN should send a command to (e.g. ``xdsh``), and should be set to the hostname or IP address of the service node that the management -node contacts it by. The xcatmaster attribute of the compute node defines +node contacts it by. The ``xcatmaster`` attribute of the compute node defines which SN the compute node should boot from, and should be set to the hostname or IP address of the service node that the compute node contacts it -by. Unless you are using service node pools, you must set the xcatmaster +by. Unless you are using service node pools, you must set the ``xcatmaster`` attribute for a node when using service nodes, even if it contains the same -value as the node's servicenode attribute. +value as the node's ``servicenode`` attribute. Host name resolution must have been setup in advance, with ``/etc/hosts``, DNS or dhcp to ensure that the names put in this table can be resolved on the Management Node, Service nodes, and the compute nodes. It is easiest to have a node group of the compute nodes for each service node. For example, if all the -nodes in node group compute1 are serviced by sn1 and all the nodes in node -group compute2 are serviced by sn2: +nodes in node group **compute1** are serviced by sn1 and all the nodes in node +group **compute2** are serviced by sn2: :: chdef -t group compute1 servicenode=sn1 xcatmaster=sn1-c chdef -t group compute2 servicenode=sn2 xcatmaster=sn2-c -Note: in this example, sn1 and sn2 are the node names of the service nodes -(and therefore the hostnames associated with the NICs that the MN talks to). -The hostnames sn1-c and sn2-c are associated with the SN NICs that communicate -with their compute nodes. +.. note:: In this example, sn1 and sn2 are the node names of the service nodes + (and therefore the hostnames associated with the NICs that the MN talks to). + The hostnames sn1-c and sn2-c are associated with the SN NICs that communicate + with their compute nodes. -Note: if not set, the attribute tftpserver's default value is xcatmaster, -but in some releases of xCAT it has not defaulted correctly, so it is safer -to set the tftpserver to the value of xcatmaster. +.. note:: If not set, the attribute tftpserver's default value is ``xcatmaster``, + but in some releases of xCAT it has not defaulted correctly, so it is safer + to set the tftpserver to the value of ``xcatmaster``. These attributes will allow you to specify which service node should run the conserver (console) and monserver (monitoring) daemon for the nodes in the group specified in the command. In this example, we are having each node's -primary SN also act as its conserver and monserver (the most typical setup). -:: +primary SN also act as its conserver and monserver (the most typical setup). :: chdef -t group compute1 conserver=sn1 monserver=sn1,sn1-c chdef -t group compute2 conserver=sn2 monserver=sn2,sn2-c @@ -176,22 +173,22 @@ for work-load balancing on the service nodes. But note that the selection of which SN will service which compute node is made at compute node boot time. After that, the selection of the SN for this compute node is fixed until the compute node is rebooted or the compute node is explicitly moved to another SN -using the `snmove `_ command. +using the :doc:`snmove ` command. To use Service Node pools, you need to architect your network such that all of the compute nodes and service nodes in a particular pool are on the same flat network. If you don't want the management node to respond to manage some of the compute nodes, it shouldn't be on that same flat network. The -site, dhcpinterfaces attribute should be set such that the SNs' DHCP daemon +``site`` table, ``dhcpinterfaces`` attribute should be set such that the SNs' DHCP daemon only listens on the NIC that faces the compute nodes, not the NIC that faces the MN. This avoids some timing issues when the SNs are being deployed (so that they don't respond to each other before they are completely ready). You -also need to make sure the `networks `_ table +also need to make sure the :doc:`networks ` table accurately reflects the physical network structure. To define a list of service nodes that support a set of compute nodes, set the -servicenode attribute to a comma-delimited list of the service nodes. When -running an xCAT command like xdsh or updatenode for compute nodes, the list +``servicenode`` attribute to a comma-delimited list of the service nodes. When +running an xCAT command like ``xdsh`` or ``updatenode`` for compute nodes, the list will be processed left to right, picking the first service node on the list to run the command. If that service node is not available, then the next service node on the list will be chosen until the command is successful. Errors will @@ -201,10 +198,10 @@ service nodes as we do below. When using service node pools, the intent is to have the service node that responds first to the compute node's DHCP request during boot also be the -xcatmaster, the tftpserver, and the NFS/http server for that node. Therefore, -the xcatmaster and nfsserver attributes for nodes should not be set. When -nodeset is run for the compute nodes, the service node interface on the -network to the compute nodes should be defined and active, so that nodeset +``xcatmaster``, the ``tftpserver``, and the NFS/http server for that node. Therefore, +the ``xcatmaster`` and ``nfsserver`` attributes for nodes should not be set. When +``nodeset`` is run for the compute nodes, the service node interface on the +network to the compute nodes should be defined and active, so that ``nodeset`` will default those attribute values to the "node ip facing" interface on that service node. @@ -213,30 +210,29 @@ For example: :: chdef -t node compute1 servicenode=sn1,sn2 xcatmaster="" nfsserver="" chdef -t node compute2 servicenode=sn2,sn1 xcatmaster="" nfsserver="" -You need to set the sharedtftp site attribute to 0 so that the SNs will not -automatically mount the ``/tftpboot`` directory from the management node: -:: +You need to set the ``sharedtftp`` site attribute to ``0`` so that the SNs will not +automatically mount the ``/tftpboot`` directory from the management node: :: chdef -t site clustersite sharedtftp=0 -For stateful (diskful) installs, you will need to use a local ``/install`` directory on each service node. The ``/install/autoinst/node`` files generated by nodeset will contain values specific to that service node for correctly installing the nodes. :: +For stateful (diskful) installs, you will need to use a local ``/install`` directory on each service node. The ``/install/autoinst/node`` files generated by ``nodeset`` will contain values specific to that service node for correctly installing the nodes. :: chdef -t site clustersite installloc="" -With this setting, you will need to remember to rsync your ``/install`` +With this setting, you will need to remember to ``rsync`` your ``/install`` directory from the xCAT management node to the service nodes anytime you change your ``/install/postscripts``, custom osimage files, os repositories, or other directories. It is best to exclude the ``/install/autoinst`` directory -from this rsync. +from this ``rsync``. :: rsync -auv --exclude 'autoinst' /install sn1:/ -Note: If your service nodes are stateless and site.sharedtftp=0, if you reboot -any service node when using servicenode pools, any data written to the local -``/tftpboot`` directory of that SN is lost. You will need to run nodeset for -all of the compute nodes serviced by that SN again. +.. note:: If your service nodes are stateless and ``site.sharedtftp=0``, if you reboot + any service node when using servicenode pools, any data written to the local + ``/tftpboot`` directory of that SN is lost. You will need to run ``nodeset`` for + all of the compute nodes serviced by that SN again. For additional information about service node pool related settings in the networks table, see ref: networks table, see :ref:`setup_networks_table_label`. @@ -246,13 +242,13 @@ Conserver and Monserver and Pools The support of conserver and monserver with Service Node Pools is still not supported. You must explicitly assign these functions to a service node using -the nodehm.conserver and noderes.monserver attribute as above. +the ``nodehm.conserver`` and ``noderes.monserver`` attribute as above. Setup Site Table ---------------- If you are not using the NFS-based statelite method of booting your compute -nodes, set the installloc attribute to ``/install``. This instructs the +nodes, set the ``installloc`` attribute to ``/install``. This instructs the service node to mount ``/install`` from the management node. (If you don't do this, you have to manually sync ``/install`` between the management node and the service nodes.) :: @@ -261,25 +257,25 @@ the service nodes.) :: For IPMI controlled nodes, if you want the out-of-band IPMI operations to be done directly from the management node (instead of being sent to the -appropriate service node), set site.ipmidispatch=n. +appropriate service node), set ``site.ipmidispatch=n``. If you want to throttle the rate at which nodes are booted up, you can set the following site attributes: -* syspowerinterval -* syspowermaxnodes -* powerinterval (system p only) +* ``syspowerinterval`` +* ``syspowermaxnodes`` +* ``powerinterval`` (system p only) -See the `site table man page `_ for details. +See the :doc:`site table man page ` for details. .. _setup_networks_table_label: Setup networks Table -------------------- -All networks in the cluster must be defined in the networks table. When xCAT -is installed, it runs makenetworks, which creates an entry in the networks +All networks in the cluster must be defined in the ``networks`` table. When xCAT +is installed, it runs ``makenetworks``, which creates an entry in the ``networks`` table for each of the networks the management node is on. You need to add entries for each network the service nodes use to communicate to the compute nodes. @@ -288,28 +284,27 @@ For example: :: mkdef -t network net1 net=10.5.1.0 mask=255.255.255.224 gateway=10.5.1.1 -If you want to set the nodes' xcatmaster as the default gateway for the nodes, -the gateway attribute can be set to keyword "". In this case, xCAT -code will automatically substitute the IP address of the node's xcatmaster for -the keyword. Here is an example: -:: +If you want to set the nodes' ``xcatmaster`` as the default gateway for the nodes, +the ``gateway`` attribute can be set to keyword ````. In this case, xCAT +code will automatically substitute the IP address of the node's ``xcatmaster`` for +the keyword. Here is an example: :: mkdef -t network net1 net=10.5.1.0 mask=255.255.255.224 gateway= -The ipforward attribute should be enabled on all the xcatmaster nodes that -will be acting as default gateways. You can set ipforward to 1 in the -servicenode table or add the line "net.ipv4.ip_forward = 1" in file -``/etc/sysctl.conf`` and then run "sysctl -p /etc/sysctl.conf" manually to +The ``ipforward`` attribute should be enabled on all the ``xcatmaster`` nodes that +will be acting as default gateways. You can set ``ipforward`` to ``1`` in the +``servicenode`` table or add the line ``net.ipv4.ip_forward = 1`` in file +``/etc/sysctl.conf`` and then run ``sysctl -p /etc/sysctl.conf`` manually to enable the ipforwarding. -Note:If using service node pools, the networks table dhcpserver attribute can -be set to any single service node in your pool. The networks tftpserver, and -nameserver attributes should be left blank. +.. note:: If using service node pools, the ``networks`` table ``dhcpserver`` attribute can + be set to any single service node in your pool. The networks ``tftpserver``, and + ``nameserver`` attributes should be left blank. Verify the Tables -------------------- -To verify that the tables are set correctly, run lsdef on the service nodes, +To verify that the tables are set correctly, run ``lsdef`` on the service nodes, compute1, compute2: :: lsdef service,compute1,compute2 @@ -318,22 +313,21 @@ Add additional adapters configuration script (optional) ------------------------------------------------------------ It is possible to have additional adapter interfaces automatically configured -when the nodes are booted. XCAT provides sample configuration scripts for +when the nodes are booted. xCAT provides sample configuration scripts for ethernet, IB, and HFI adapters. These scripts can be used as-is or they can be modified to suit your particular environment. The ethernet sample is ``/install/postscript/configeth``. When you have the configuration script that -you want you can add it to the "postscripts" attribute as mentioned above. Make +you want you can add it to the ``postscripts`` attribute as mentioned above. Make sure your script is in the ``/install/postscripts`` directory and that it is executable. -Note: For system p servers, if you plan to have your service node perform the -hardware control functions for its compute nodes, it is necessary that the SN -ethernet network adapters connected to the HW service VLAN be configured. +.. note:: For system p servers, if you plan to have your service node perform the + hardware control functions for its compute nodes, it is necessary that the SN + ethernet network adapters connected to the HW service VLAN be configured. Configuring Secondary Adapters ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -To configure secondary adapters, see `Configuring_Secondary_Adapters -`_ +To configure secondary adapters, see :doc:`Configure Additional Network Interfaces ` diff --git a/docs/source/advanced/performance_tuning/httpd_tuning.rst b/docs/source/advanced/performance_tuning/httpd_tuning.rst index 867fdb036..adb7f5f5a 100644 --- a/docs/source/advanced/performance_tuning/httpd_tuning.rst +++ b/docs/source/advanced/performance_tuning/httpd_tuning.rst @@ -6,9 +6,9 @@ In xCAT, the Operation System provisioning over network is heavily relying on th #. Tuning MaxRequestWorkers directive -By default, httpd is configured to use ``prefork`` module for **MPM**, which has a limit of 256 simultaneous requests. If any slow httpd response issue was hit during OS provisioning, you can increase **MaxRequestWorkers** directive for greater performance. +By default, httpd is configured to use ``prefork`` module for **MPM**, which has a limit of 256 simultaneous requests. If slow httpd response observed during OS provisioning, you can increase **MaxRequestWorkers** directive for better performance. -For example, to avoid some nodes provisioning failure when rebooting all nodes in a large hierarchy stateless cluster ( one service node is serving 270 compute nodes ). It is suggested to increased the value from 256 to 1000. +For example, to avoid some nodes provisioning failure when rebooting all nodes in a large hierarchy stateless cluster ( one service node is serving 270 compute nodes ), increase the value from 256 to 1000. On Red Hat, change (or add) these directives in :: @@ -24,9 +24,9 @@ For example, to avoid some nodes provisioning failure when rebooting all nodes i #. Having httpd Cache the Files It Is Serving -Note: this information was contributed by Jonathan Dye and is provided here as an example. The details may have to be changed for distro or apache version. +.. note:: this information was contributed by Jonathan Dye and is provided here as an example. The details may have to be changed for distro or apache version. -This is simplest if you set noderes.nfsserver to a separate apache server, and then you can configure it to reverse proxy and cache. For some reason mod_mem_cache doesn't seem to behave as expected, so you can use mod_disk_cache to achieve a similar result: make a tmpfs on the apache server and configure its mountpoint to be the directory that CacheRoot points to. Also tell it to ignore /install/autoinst since the caching settings are really aggressive. Do a recursive wget to warm the cache and watch the tmpfs fill up. Then do a bunch of kickstart installs. Before this, the apache server on the xcat management node may have been a bottleneck during kickstart installs. After this change, it no longer should be. +This is simplest if you set ``noderes.nfsserver`` to a separate apache server, and then you can configure it to reverse proxy and cache. For some reason ``mod_mem_cache`` doesn't seem to behave as expected, so you can use ``mod_disk_cache`` to achieve a similar result: make a ``tmpfs`` on the apache server and configure its mountpoint to be the directory that ``CacheRoot`` points to. Also tell it to ignore ``/install/autoinst`` since the caching settings are really aggressive. Do a recursive ``wget`` to warm the cache and watch the ``tmpfs`` fill up. Then do a bunch of kickstart installs. Before this, the apache server on the xcat management node may have been a bottleneck during kickstart installs. After this change, it no longer should be. Here is the apache config file: :: diff --git a/docs/source/advanced/restapi/restapi_usage/restapi_usage.rst b/docs/source/advanced/restapi/restapi_usage/restapi_usage.rst index ecca3b8e8..58d4f13f2 100644 --- a/docs/source/advanced/restapi/restapi_usage/restapi_usage.rst +++ b/docs/source/advanced/restapi/restapi_usage/restapi_usage.rst @@ -217,9 +217,9 @@ It can be used as an example script to access and control xCAT resources. From t ./xcatws-test.sh -u root -p cluster -h -t ./xcatws-test.sh -u root -p cluster -h -c -t -But for exploration and experimentation, you can make API calls from your browser or by using the **curl** command. +But for exploration and experimentation, you can make API calls from your browser or by using the ``curl`` command. -To make an API call from your browser, use the desired URL from this document. To simplify the test step, all the examples for the resources use 'curl -k' for unsecure http connection and use the 'username+password' to authenticate the user. :: +To make an API call from your browser, use the desired URL from this document. To simplify the test step, all the examples for the resources use ``curl -k`` for unsecure http connection and use the 'username+password' to authenticate the user. :: curl -X GET -k 'https://myserver/xcatws/nodes?userName=xxx&userPW=xxx&pretty=1' @@ -276,5 +276,4 @@ References * General JSON: http://www.json.org/ * JSON wrapping: http://search.cpan.org/~makamaka/JSON-2.27/lib/JSON.pm * Apache CGI: http://httpd.apache.org/docs/2.2/howto/cgi.html - * Perl CGI: http://perldoc.perl.org/CGI.html diff --git a/docs/source/developers/guides/docs/doc_guidelines.rst b/docs/source/developers/guides/docs/doc_guidelines.rst index ce121d4f5..1c07bdf39 100644 --- a/docs/source/developers/guides/docs/doc_guidelines.rst +++ b/docs/source/developers/guides/docs/doc_guidelines.rst @@ -137,9 +137,9 @@ Add links to refer other web page is a very common way in writing document, it' * **Add an External Link** - Link to an external web page: `google `_: :: + Link to an external web page: `google `_: :: - `google `_ + `google `_ .. diff --git a/docs/source/guides/admin-guides/manage_clusters/common/deployment/cfg_partition.rst b/docs/source/guides/admin-guides/manage_clusters/common/deployment/cfg_partition.rst index 9f3ad3ec8..cc170bd82 100644 --- a/docs/source/guides/admin-guides/manage_clusters/common/deployment/cfg_partition.rst +++ b/docs/source/guides/admin-guides/manage_clusters/common/deployment/cfg_partition.rst @@ -38,7 +38,7 @@ The partition file must follow the partitioning syntax of the respective install * Use yast2 autoyast in GUI or CLI mode to customize the installation options and create autoyast file * Use yast2 clone_system to create autoyast configuration file /root/autoinst.xml to clone an existing system - * Ubuntu: `Preseed documentation `_ + * Ubuntu: `Preseed documentation `_ * For detailed information see the files ``partman-auto-recipe.txt`` and ``partman-auto-raid-recipe.txt`` included in the debian-installer package. Both files are also available from the debian-installer source repository. diff --git a/docs/source/guides/admin-guides/manage_clusters/common/deployment/enable_kdump.rst b/docs/source/guides/admin-guides/manage_clusters/common/deployment/enable_kdump.rst index 17b8ea5cb..cc639b4b0 100644 --- a/docs/source/guides/admin-guides/manage_clusters/common/deployment/enable_kdump.rst +++ b/docs/source/guides/admin-guides/manage_clusters/common/deployment/enable_kdump.rst @@ -4,7 +4,7 @@ Enable kdump Over Ethernet Overview -------- -kdump is an feature of the Linux kernel that allows the system to be booted from the context of another kernel. This second kernel reserves a small amount of memory and its only purpose is to capture the core dump in the event of a kernel crash. The ability to analyze the core dump helps to determine causes of system failures. +``kdump`` is an feature of the Linux kernel that allows the system to be booted from the context of another kernel. This second kernel reserves a small amount of memory and its only purpose is to capture the core dump in the event of a kernel crash. The ability to analyze the core dump helps to determine causes of system failures. xCAT Interface @@ -22,7 +22,7 @@ The following attributes of an osimage should be modified to enable ``kdump``: Configure the ``pkglist`` file ------------------------------ -The ``pkglist`` for the osimage needs to include the appropriate RPMs. The following list of RPMs are provided as a sample, always refer to the Operating System specific documentataion to ensure the required packages are there for ``kdump`` support. +The ``pkglist`` for the osimage needs to include the appropriate RPMs. The following list of RPMs are provided as a sample, always refer to the Operating System specific documentation to ensure the required packages are there for ``kdump`` support. * **[RHELS]** :: @@ -53,7 +53,7 @@ Run ``packimage`` to update the diskless image with the changes. The ``postinstall`` file ------------------------ -The kdump will create a new initrd which used in the dumping stage. The ``/tmp`` or ``/var/tmp`` directory will be used as the temporary directory. These 2 directory only are allocated 10M space by default. You need to enlarge it to 200M. Modify the postinstall file to increase ``/tmp`` space. +The ``kdump`` will create a new initrd which is used in the dumping stage. The ``/tmp`` or ``/var/tmp`` directory will be used as the temporary directory. These two directories are only allocated 10M space by default. You need to enlarge it to 200M. Modify the postinstall file to increase ``/tmp`` space. * **[RHELS]** :: @@ -70,7 +70,7 @@ The kdump will create a new initrd which used in the dumping stage. The ``/tmp`` The ``dump`` attribute ---------------------- -To support kernel dumps, the ``dump`` attribute **must** be set on the osimage definition. If not set, kdump service will not be enabled. The ``dump`` attribute defines the NFS remote path where the crash information is to be stored. +To support kernel dumps, the ``dump`` attribute **must** be set in the osimage definition. If not set, ``kdump`` service will not be enabled. The ``dump`` attribute defines the NFS remote path where the crash information is to be stored. Use the ``chdef`` command to set a value of the ``dump`` attribute: :: @@ -80,7 +80,7 @@ If the NFS server is the Service Node or Management Node, the server can be left chdef -t osimage dump=nfs:/// -**Note:** Only NFS is currently supported as a storage location. Make sure the NFS remote path(``nfs:///``) is exported and it is read-writeable to the node where kdump service is enabled. +.. note:: Only NFS is currently supported as a storage location. Make sure the NFS remote path (``nfs:///``) is exported and it is read-writeable on the node where ``kdump`` service is enabled. The ``crashkernelsize`` attribute @@ -102,18 +102,18 @@ For setting specific sizes, use the following example: chdef -t osimage crashkernelsize=@32M -**Notes**: the value of the ``crashkernelsize`` depends on the total physical memory size on the machine. For more about size, refer to `Appedix`_ +.. note:: The value of the ``crashkernelsize`` depends on the total physical memory size on the machine. For more about size, refer to `Appedix`_ -If kdump start error like this: :: +If ``kdump`` start displays error like this: :: Your running kernel is using more than 70% of the amount of space you reserved for kdump, you should consider increasing your crashkernel -The ``crashkernelsize`` is not large enough, you should change the ``crashkernelsize`` larger until the error message disappear. +The ``crashkernelsize`` is not large enough, you should increase the ``crashkernelsize`` until the error message disappears. The ``enablekdump`` postscript ------------------------------ -xCAT provides a postscript ``enablekdump`` that can be added to the Nodes to automatically start the ``kdump`` service when the node boots. Add to the nodes using the following command: :: +xCAT provides a postscript ``enablekdump`` that can be added to the node definition to automatically start the ``kdump`` service when the node boots. :: chdef -t node -p postscripts=enablekdump @@ -147,13 +147,13 @@ Once the system has returned from recovering the crash, you can analyze the kern #. Locate the recent vmcore dump file. -#. Locate the kernel file for the crash server. The kernel is under ``/tftpboot/xcat/netboot////kernel`` on the managenent node. +#. Locate the kernel file for the crash server. The kernel is under ``/tftpboot/xcat/netboot////kernel`` on the management node. #. Once you have located a vmcore dump file and kernel file, call ``crash``: :: crash -**Note:** If ``crash`` cannot find any files, make sure you have the ``kernel-debuginfo`` package installed. +.. note:: If ``crash`` cannot find any files, make sure you have the ``kernel-debuginfo`` package installed. Appedix ------- @@ -170,4 +170,3 @@ Appedix * http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/5/html/Deployment_Guide/s1-kdump-crash.htmlRHELdocument - * http://www.novell.com/support/kb/doc.php?id=3374462SLESdocument diff --git a/docs/source/guides/admin-guides/manage_clusters/ppc64le/diskful/customize_image/cfg_partition.rst b/docs/source/guides/admin-guides/manage_clusters/ppc64le/diskful/customize_image/cfg_partition.rst index b4aeccd6b..f8a6f5b30 100644 --- a/docs/source/guides/admin-guides/manage_clusters/ppc64le/diskful/customize_image/cfg_partition.rst +++ b/docs/source/guides/admin-guides/manage_clusters/ppc64le/diskful/customize_image/cfg_partition.rst @@ -31,7 +31,7 @@ Partitioning disk file(For Ubuntu only) .. include:: ../../../common/deployment/cfg_partition.rst :start-after: BEGIN_Partition_Disk_File_ubuntu_only :end-before: END_Partition_Disk_File_ubuntu_only - + Additional preseed configuration file(For Ubuntu only) `````````````````````````````````````````````````````` .. include:: ../../../common/deployment/cfg_partition.rst @@ -64,14 +64,14 @@ Associate partition script with osimage :start-after: BEGIN_Partition_Definition_Script_Associate_partition_script_with_osimage_common :end-before: END_Partition_Definition_Script_Associate_partition_script_with_osimage_common -Partitioning disk script(For Ubuntu only) -````````````````````````````````````````` +Partitioning disk script (For Ubuntu only) +`````````````````````````````````````````` .. include:: ../../../common/deployment/cfg_partition.rst :start-after: BEGIN_Partition_Disk_Script_ubuntu_only :end-before: END_Partition_Disk_Script_ubuntu_only -Additional preseed configuration script(For Ubuntu only) -```````````````````````````````````````````````````````` +Additional preseed configuration script (For Ubuntu only) +````````````````````````````````````````````````````````` .. include:: ../../../common/deployment/cfg_partition.rst :start-after: BEGIN_Additional_preseed_configuration_script_ubuntu_only :end-before: END_Additional_preseed_configuration_script_ubuntu_only From 28a917b25c9d6af32039844036b044e7bccc5188 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 8 Nov 2019 08:25:32 -0500 Subject: [PATCH 012/139] Port Generic CentOS check from Lenovo tree This will do a more generic check if a discid is not found. --- xCAT-server/lib/xcat/plugins/anaconda.pm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xCAT-server/lib/xcat/plugins/anaconda.pm b/xCAT-server/lib/xcat/plugins/anaconda.pm index ccaabae36..24546a08d 100644 --- a/xCAT-server/lib/xcat/plugins/anaconda.pm +++ b/xCAT-server/lib/xcat/plugins/anaconda.pm @@ -2064,6 +2064,8 @@ sub copycd { $distname = $xCAT::data::discinfo::distnames{$did}; } + } elsif ($desc and $desc =~ /CentOS Linux (.*)/) { + $distname = "centos" . $1; } unless ($dno) { From 9853a321f2537c85826810867d85dfe826ce24fe Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Mon, 11 Nov 2019 09:44:13 -0500 Subject: [PATCH 013/139] Update 2.15.x.csv --- docs/source/overview/_files/2.15.x.csv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/overview/_files/2.15.x.csv b/docs/source/overview/_files/2.15.x.csv index c95f9d27d..57a983188 100644 --- a/docs/source/overview/_files/2.15.x.csv +++ b/docs/source/overview/_files/2.15.x.csv @@ -1,2 +1,2 @@ Version,Release Date,New OS Supported,Release Notes -2.15.0,2019-11-??,,`2.15.0 Release Notes `_ +2.15.0,2019-11-11,,`2.15.0 Release Notes `_ From 8db0ee3554c2bd89bae42f335ec91a575b6d150b Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Mon, 11 Nov 2019 09:45:02 -0500 Subject: [PATCH 014/139] Update 2.15.x.csv --- docs/source/overview/_files/2.15.x.csv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/overview/_files/2.15.x.csv b/docs/source/overview/_files/2.15.x.csv index 57a983188..d38f9a413 100644 --- a/docs/source/overview/_files/2.15.x.csv +++ b/docs/source/overview/_files/2.15.x.csv @@ -1,2 +1,2 @@ Version,Release Date,New OS Supported,Release Notes -2.15.0,2019-11-11,,`2.15.0 Release Notes `_ +2.15.0,2019-11-11,RHEL 8.0,`2.15.0 Release Notes `_ From 51a229be3519d97cdac55d577543d833489b1bac Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Mon, 11 Nov 2019 11:05:21 -0500 Subject: [PATCH 015/139] Update Version --- Version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Version b/Version index e3d069645..3b1fc7950 100644 --- a/Version +++ b/Version @@ -1 +1 @@ -2.15 +2.15.1 From 45afc4f58d0de4c369d9f0db1c47ff175749b46f Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Mon, 11 Nov 2019 11:07:44 -0500 Subject: [PATCH 016/139] Update conf.py --- docs/source/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 715fa4035..0a3d8b2c3 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -59,7 +59,7 @@ author = u'IBM Corporation' # The short X.Y version. version = '2' # The full version, including alpha/beta/rc tags. -release = '2.15.0' +release = '2.15.1' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. From 78e9d825eecd2f0c817ac75f57fa0c84e2c2c2db Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Tue, 12 Nov 2019 10:39:48 -0500 Subject: [PATCH 017/139] linux_diskless_kdump testcase enhancement --- xCAT-test/autotest/testcase/kdump/linux_diskless_kdump | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/xCAT-test/autotest/testcase/kdump/linux_diskless_kdump b/xCAT-test/autotest/testcase/kdump/linux_diskless_kdump index 3ef555b2d..50ccf16f4 100644 --- a/xCAT-test/autotest/testcase/kdump/linux_diskless_kdump +++ b/xCAT-test/autotest/testcase/kdump/linux_diskless_kdump @@ -72,7 +72,10 @@ check:output=~\d\d:\d\d:\d\d cmd:xdsh $$CN "echo 'echo 1 > /proc/sys/kernel/sysrq; echo c > /proc/sysrq-trigger' > /tmp/kdump.trigger" cmd:xdsh $$CN "chmod 755 /tmp/kdump.trigger" -cmd:xdsh $$CN "rpm -q at" +# at package should have been installed during provisioning. +# If it is still missing, install it with "yum install" +cmd:a=`xdsh $$CN rpm -q at`;if [[ $a =~ "package at is not installed" ]]; then xdsh $$CN yum install -y at; fi + cmd:xdsh $$CN "service atd start" check:rc==0 From 6ebee05df54b8207338b12257a8c8112c3672071 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Tue, 12 Nov 2019 15:20:00 -0500 Subject: [PATCH 018/139] OpenBMC Thermal Mode {Perl] --- .../admin-guides/references/man1/rspconfig.1.rst | 10 ++++++++++ perl-xCAT/xCAT/Usage.pm | 2 ++ xCAT-client/pods/man1/rspconfig.1.pod | 8 ++++++++ xCAT-server/lib/xcat/plugins/openbmc.pm | 15 +++++++++++++++ 4 files changed, 35 insertions(+) diff --git a/docs/source/guides/admin-guides/references/man1/rspconfig.1.rst b/docs/source/guides/admin-guides/references/man1/rspconfig.1.rst index d85e1eb50..a783d13aa 100644 --- a/docs/source/guides/admin-guides/references/man1/rspconfig.1.rst +++ b/docs/source/guides/admin-guides/references/man1/rspconfig.1.rst @@ -83,6 +83,10 @@ OpenBMC specific: \ **rspconfig**\ \ *noderange*\ \ **sshcfg**\ +\ **rspconfig**\ \ *noderange*\ \ **thermalmode**\ + +\ **rspconfig**\ \ *noderange*\ \ **thermalmode={default|custom|heavy_io|max_base_fan_floor}**\ + \ **rspconfig**\ \ *noderange*\ \ **timesyncmethod**\ \ **rspconfig**\ \ *noderange*\ \ **timesyncmethod={manual|ntp}**\ @@ -521,6 +525,12 @@ OPTIONS +\ **thermalmode**\ + + Display or set the thermal mode of the system to a setting, depending on your system, adapter, and cable type. After a factory reset of the system, the thermal mode setting is lost and must be reapplied. To choose the correct setting for your system, see http://blaze.aus.stglabs.ibm.com/kc20A-cur/POWER9/p9ei3/p9ei3_thermal_mode.htm [OpenBMC] + + + \ **timesyncmethod**\ Set the method for time synchronization on the BMC. [OpenBMC] diff --git a/perl-xCAT/xCAT/Usage.pm b/perl-xCAT/xCAT/Usage.pm index d40c13600..3b3b60d06 100755 --- a/perl-xCAT/xCAT/Usage.pm +++ b/perl-xCAT/xCAT/Usage.pm @@ -193,6 +193,8 @@ my %usage = ( rspconfig timesyncmethod={ntp|manual} rspconfig bootmode rspconfig bootmode={safe|regular|setup} + rspconfig thermalmode + rspconfig thermalmode={default|custom|heavy_io|max_base_fan_floor} rspconfig autoreboot rspconfig autoreboot={0|1} ", diff --git a/xCAT-client/pods/man1/rspconfig.1.pod b/xCAT-client/pods/man1/rspconfig.1.pod index b4cd8b4d3..c9c632d42 100644 --- a/xCAT-client/pods/man1/rspconfig.1.pod +++ b/xCAT-client/pods/man1/rspconfig.1.pod @@ -60,6 +60,10 @@ B I B B I B +B I B + +B I B + B I B B I B @@ -402,6 +406,10 @@ B<-d> will download a single dump or all generated dumps from the BMC to /var/lo =back +=item B + +Display or set the thermal mode of the system to a setting, depending on your system, adapter, and cable type. After a factory reset of the system, the thermal mode setting is lost and must be reapplied. To choose the correct setting for your system, see http://blaze.aus.stglabs.ibm.com/kc20A-cur/POWER9/p9ei3/p9ei3_thermal_mode.htm [OpenBMC] + =item B Set the method for time synchronization on the BMC. [OpenBMC] diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index d406cbed9..70afac5df 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -676,6 +676,21 @@ my %api_config_info = ( manual => "xyz.openbmc_project.Time.Synchronization.Method.Manual", }, }, + RSPCONFIG_THERMAL_MODE => { + command => "rspconfig", + url => "/control/thermal/0", + attr_url => "Current", + display_name => "BMC ThermalMode", + instruct_msg => "", + type => "attribute", + subcommand => "thermalmode", + attr_value => { + default => "DEFAULT", + custom => "CUSTOM", + heavy_io => "HEAVY_IO", + max_base_fan_floor => "MAX_BASE_FAN_FLOOR", + }, + }, ); $::RESPONSE_OK = "200 OK"; From ee62a970b473b5cf7ecb08c0aefd7328d5c23d69 Mon Sep 17 00:00:00 2001 From: cxhong Date: Tue, 12 Nov 2019 16:31:49 -0500 Subject: [PATCH 019/139] Modify pkglist to clean up genimage warning messages --- xCAT-server/share/xcat/netboot/centos/dracut_047 | 1 + .../share/xcat/netboot/rh/compute.rhels8.ppc64le.pkglist | 1 + xCAT-server/share/xcat/netboot/rh/compute.rhels8.x86_64.pkglist | 1 + xCAT-server/share/xcat/netboot/rh/genimage | 2 +- .../share/xcat/netboot/rh/service.rhels8.ppc64le.pkglist | 1 + xCAT-server/share/xcat/netboot/rh/service.rhels8.x86_64.pkglist | 1 + 6 files changed, 6 insertions(+), 1 deletion(-) create mode 120000 xCAT-server/share/xcat/netboot/centos/dracut_047 diff --git a/xCAT-server/share/xcat/netboot/centos/dracut_047 b/xCAT-server/share/xcat/netboot/centos/dracut_047 new file mode 120000 index 000000000..fe26fce05 --- /dev/null +++ b/xCAT-server/share/xcat/netboot/centos/dracut_047 @@ -0,0 +1 @@ +../rh/dracut_047 \ No newline at end of file diff --git a/xCAT-server/share/xcat/netboot/rh/compute.rhels8.ppc64le.pkglist b/xCAT-server/share/xcat/netboot/rh/compute.rhels8.ppc64le.pkglist index 7c33f0d7b..3777e6445 100644 --- a/xCAT-server/share/xcat/netboot/rh/compute.rhels8.ppc64le.pkglist +++ b/xCAT-server/share/xcat/netboot/rh/compute.rhels8.ppc64le.pkglist @@ -11,3 +11,4 @@ wget python3 tar bzip2 +bc diff --git a/xCAT-server/share/xcat/netboot/rh/compute.rhels8.x86_64.pkglist b/xCAT-server/share/xcat/netboot/rh/compute.rhels8.x86_64.pkglist index 7c33f0d7b..3777e6445 100644 --- a/xCAT-server/share/xcat/netboot/rh/compute.rhels8.x86_64.pkglist +++ b/xCAT-server/share/xcat/netboot/rh/compute.rhels8.x86_64.pkglist @@ -11,3 +11,4 @@ wget python3 tar bzip2 +bc diff --git a/xCAT-server/share/xcat/netboot/rh/genimage b/xCAT-server/share/xcat/netboot/rh/genimage index 42abf3e30..68be043da 100755 --- a/xCAT-server/share/xcat/netboot/rh/genimage +++ b/xCAT-server/share/xcat/netboot/rh/genimage @@ -717,7 +717,7 @@ if (@new_order) { @ndrivers = (@new_order, @ndrivers); } -if (-f "$rootimg_dir/lib/modules/$kernelver/kernel/drivers/net/ethernet/mellanox/mlx4/mlx4_en.ko") { +if (-d "$rootimg_dir/lib/modules/$kernelver/kernel/drivers/net/ethernet/mellanox/mlx4") { for (@ndrivers) { s/mlx_en/mlx4_en/; } diff --git a/xCAT-server/share/xcat/netboot/rh/service.rhels8.ppc64le.pkglist b/xCAT-server/share/xcat/netboot/rh/service.rhels8.ppc64le.pkglist index e15993e89..4544f99e2 100644 --- a/xCAT-server/share/xcat/netboot/rh/service.rhels8.ppc64le.pkglist +++ b/xCAT-server/share/xcat/netboot/rh/service.rhels8.ppc64le.pkglist @@ -13,3 +13,4 @@ perl-DBD-Pg python3 tar bzip2 +bc diff --git a/xCAT-server/share/xcat/netboot/rh/service.rhels8.x86_64.pkglist b/xCAT-server/share/xcat/netboot/rh/service.rhels8.x86_64.pkglist index e15993e89..4544f99e2 100644 --- a/xCAT-server/share/xcat/netboot/rh/service.rhels8.x86_64.pkglist +++ b/xCAT-server/share/xcat/netboot/rh/service.rhels8.x86_64.pkglist @@ -13,3 +13,4 @@ perl-DBD-Pg python3 tar bzip2 +bc From 42915fefe05667c6ec70b88750b102564dfcd0f7 Mon Sep 17 00:00:00 2001 From: cxhong Date: Wed, 13 Nov 2019 09:24:57 -0500 Subject: [PATCH 020/139] Use option type=A for nslookup --- xCAT-probe/lib/perl/probe_utils.pm | 2 +- xCAT-probe/subcmds/xcatmn | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/xCAT-probe/lib/perl/probe_utils.pm b/xCAT-probe/lib/perl/probe_utils.pm index 71e3ae8d6..6fbf59cd5 100644 --- a/xCAT-probe/lib/perl/probe_utils.pm +++ b/xCAT-probe/lib/perl/probe_utils.pm @@ -448,7 +448,7 @@ sub is_dns_ready { my $hostname = shift; my $domain = shift; - my $output = `nslookup $mnip $serverip 2>&1`; + my $output = `nslookup -type=A $mnip $serverip 2>&1`; if ($?) { return 0; diff --git a/xCAT-probe/subcmds/xcatmn b/xCAT-probe/subcmds/xcatmn index 262a2c86e..f2f6ed1da 100755 --- a/xCAT-probe/subcmds/xcatmn +++ b/xCAT-probe/subcmds/xcatmn @@ -1006,7 +1006,7 @@ sub check_dns_service { } else { # if there is no sn, nslookup mnip - my $nslkp = `nslookup $serverip $serverip 2>&1`; + my $nslkp = `nslookup -type=A $serverip $serverip 2>&1`; chomp($nslkp); my $tmp = grep { $_ =~ "Server:[\t\s]*$serverip" } split(/\n/, $nslkp); if (!$tmp) { From 12db3ad425c2ecb9883c4b3d70e76d3763f6223f Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Wed, 13 Nov 2019 09:45:53 -0500 Subject: [PATCH 021/139] Update URL for external link --- docs/source/guides/admin-guides/references/man1/rspconfig.1.rst | 2 +- xCAT-client/pods/man1/rspconfig.1.pod | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/guides/admin-guides/references/man1/rspconfig.1.rst b/docs/source/guides/admin-guides/references/man1/rspconfig.1.rst index a783d13aa..70deaa8c0 100644 --- a/docs/source/guides/admin-guides/references/man1/rspconfig.1.rst +++ b/docs/source/guides/admin-guides/references/man1/rspconfig.1.rst @@ -527,7 +527,7 @@ OPTIONS \ **thermalmode**\ - Display or set the thermal mode of the system to a setting, depending on your system, adapter, and cable type. After a factory reset of the system, the thermal mode setting is lost and must be reapplied. To choose the correct setting for your system, see http://blaze.aus.stglabs.ibm.com/kc20A-cur/POWER9/p9ei3/p9ei3_thermal_mode.htm [OpenBMC] + Display or set the thermal mode of the system to a setting, depending on your system, adapter, and cable type. After a factory reset of the system, the thermal mode setting is lost and must be reapplied. To choose the correct setting for your system, see https://www.ibm.com/support/knowledgecenter/POWER9/p9ei3/p9ei3_thermal_mode.htm [OpenBMC] diff --git a/xCAT-client/pods/man1/rspconfig.1.pod b/xCAT-client/pods/man1/rspconfig.1.pod index c9c632d42..0087291bf 100644 --- a/xCAT-client/pods/man1/rspconfig.1.pod +++ b/xCAT-client/pods/man1/rspconfig.1.pod @@ -408,7 +408,7 @@ B<-d> will download a single dump or all generated dumps from the BMC to /var/lo =item B -Display or set the thermal mode of the system to a setting, depending on your system, adapter, and cable type. After a factory reset of the system, the thermal mode setting is lost and must be reapplied. To choose the correct setting for your system, see http://blaze.aus.stglabs.ibm.com/kc20A-cur/POWER9/p9ei3/p9ei3_thermal_mode.htm [OpenBMC] +Display or set the thermal mode of the system to a setting, depending on your system, adapter, and cable type. After a factory reset of the system, the thermal mode setting is lost and must be reapplied. To choose the correct setting for your system, see https://www.ibm.com/support/knowledgecenter/POWER9/p9ei3/p9ei3_thermal_mode.htm [OpenBMC] =item B From d571ea1c128619750609d74ee606713b7b307c0c Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Wed, 13 Nov 2019 10:44:50 -0500 Subject: [PATCH 022/139] OpenBMC Thermal Mode [Python] --- .../lib/python/agent/hwctl/openbmc_client.py | 12 ++++++++++++ .../lib/python/agent/xcatagent/openbmc.py | 3 ++- xCAT-server/lib/xcat/plugins/openbmc2.pm | 3 ++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/xCAT-openbmc-py/lib/python/agent/hwctl/openbmc_client.py b/xCAT-openbmc-py/lib/python/agent/hwctl/openbmc_client.py index 2ce1a547e..e1e92a3fe 100644 --- a/xCAT-openbmc-py/lib/python/agent/hwctl/openbmc_client.py +++ b/xCAT-openbmc-py/lib/python/agent/hwctl/openbmc_client.py @@ -234,6 +234,18 @@ RSPCONFIG_APIS = { 'setup': "xyz.openbmc_project.Control.Boot.Mode.Modes.Setup", }, }, + 'thermalmode': { + 'baseurl': "/control/thermal/0", + 'set_url': "/attr/Current", + 'get_url': "/attr/Current", + 'display_name':"BMC ThermalMode", + 'attr_values': { + 'default': "DEFAULT", + 'custom': "CUSTOM", + 'heavy_io': "HEAVY_IO", + 'max_base_fan_floor': "MAX_BASE_FAN_FLOOR", + }, + }, 'timesyncmethod': { 'baseurl': '/time/sync_method', 'get_url': '', diff --git a/xCAT-openbmc-py/lib/python/agent/xcatagent/openbmc.py b/xCAT-openbmc-py/lib/python/agent/xcatagent/openbmc.py index de8df2484..c01884876 100644 --- a/xCAT-openbmc-py/lib/python/agent/xcatagent/openbmc.py +++ b/xCAT-openbmc-py/lib/python/agent/xcatagent/openbmc.py @@ -53,7 +53,7 @@ all_nodes_result = {} # global variables of rbeacon BEACON_OPTIONS = ('on', 'off', 'stat') -RSPCONFIG_GET_OPTIONS = ['ip','ipsrc','netmask','gateway','vlan','ntpservers','hostname','bootmode','autoreboot','powersupplyredundancy','powerrestorepolicy', 'timesyncmethod'] +RSPCONFIG_GET_OPTIONS = ['ip','ipsrc','netmask','gateway','vlan','ntpservers','hostname','bootmode','thermalmode','autoreboot','powersupplyredundancy','powerrestorepolicy', 'timesyncmethod'] RSPCONFIG_SET_OPTIONS = { 'ip':'.*', @@ -66,6 +66,7 @@ RSPCONFIG_SET_OPTIONS = { 'powersupplyredundancy':"^enabled$|^disabled$", 'powerrestorepolicy':"^always_on$|^always_off$|^restore$", 'bootmode':"^regular$|^safe$|^setup$", + 'thermalmode':"^default$|^custom$|^heavy_io$|^max_base_fan_floor$", 'admin_passwd':'.*,.*', 'timesyncmethod':'^ntp$|^manual$', } diff --git a/xCAT-server/lib/xcat/plugins/openbmc2.pm b/xCAT-server/lib/xcat/plugins/openbmc2.pm index 4a73fdcfb..f48817a26 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc2.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc2.pm @@ -160,12 +160,13 @@ sub process_request { xCAT::AGENT::wait_agent($pid, $callback); } -my @rsp_common_options = qw/autoreboot bootmode powersupplyredundancy powerrestorepolicy timesyncmethod +my @rsp_common_options = qw/autoreboot bootmode thermalmode powersupplyredundancy powerrestorepolicy timesyncmethod ip netmask gateway hostname vlan ntpservers/; my @rspconfig_set_options = (@rsp_common_options, qw/admin_passwd/); my %rsp_set_valid_values = ( autoreboot => "0|1", bootmode => "regular|safe|setup", + thermalmode => "default|custom|heavy_io|max_base_fan_floor", powersupplyredundancy => "disabled|enabled", powerrestorepolicy => "always_off|always_on|restore", timesyncmethod => "manual|ntp", From 42548895b303697286d46fb31935fc1b1e3ffa2d Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Wed, 13 Nov 2019 16:44:58 -0500 Subject: [PATCH 023/139] Add OpenBMC thermal mode testcases --- .../autotest/testcase/UT_openbmc/rinv_cases0 | 8 +-- .../testcase/UT_openbmc/rspconfig_cases0 | 50 +++++++++++++------ 2 files changed, 38 insertions(+), 20 deletions(-) diff --git a/xCAT-test/autotest/testcase/UT_openbmc/rinv_cases0 b/xCAT-test/autotest/testcase/UT_openbmc/rinv_cases0 index 44bc46855..eac07774f 100644 --- a/xCAT-test/autotest/testcase/UT_openbmc/rinv_cases0 +++ b/xCAT-test/autotest/testcase/UT_openbmc/rinv_cases0 @@ -12,10 +12,10 @@ hcp:openbmc label:cn_bmc_ready,hctrl_openbmc cmd: rinv $$CN firm | tee /tmp/xcattest.rinv_check_active_fw_count.output check:rc==0 -cmd: grep -i ibm /tmp/xcattest.rinv_check_active_fw_count.output | grep -i 'HOST Firmware Product' | grep -i 'Active)\*' | wc -l +cmd: grep -i 'Active)\*' /tmp/xcattest.rinv_check_active_fw_count.output | grep -i 'HOST Firmware Product' | wc -l check:rc==0 check:output=~1 -cmd: grep -i ibm /tmp/xcattest.rinv_check_active_fw_count.output | grep -i 'BMC Firmware Product'|grep -i 'Active)\*' | wc -l +cmd: grep -i 'Active)\*' /tmp/xcattest.rinv_check_active_fw_count.output | grep -i 'BMC Firmware Product' | wc -l check:rc==0 check:output=~1 cmd : rm -rf /tmp/xcattest.rinv_check_active_fw_count.output @@ -28,10 +28,10 @@ hcp:openbmc label:cn_bmc_ready,hctrl_openbmc cmd: rinv $$CN firm -V | tee /tmp/xcattest.rinv_check_active_fw_count_verbose.output check:rc==0 -cmd: grep -i ibm /tmp/xcattest.rinv_check_active_fw_count_verbose.output| grep -i 'HOST Firmware Product' | grep -i 'Active)\*' | wc -l +cmd: grep -i 'Active)\*' /tmp/xcattest.rinv_check_active_fw_count_verbose.output| grep -i 'HOST Firmware Product' | wc -l check:rc==0 check:output=~1 -cmd: grep -i ibm /tmp/xcattest.rinv_check_active_fw_count_verbose.output | grep -i 'BMC Firmware Product'|grep -i 'Active)\*' | wc -l +cmd: grep -i 'Active)\*' /tmp/xcattest.rinv_check_active_fw_count_verbose.output | grep -i 'BMC Firmware Product' | wc -l check:rc==0 check:output=~1 cmd : rm -rf /tmp/xcattest.rinv_check_active_fw_count_verbose.output diff --git a/xCAT-test/autotest/testcase/UT_openbmc/rspconfig_cases0 b/xCAT-test/autotest/testcase/UT_openbmc/rspconfig_cases0 index 9f7fc6ef1..695a6d7e7 100644 --- a/xCAT-test/autotest/testcase/UT_openbmc/rspconfig_cases0 +++ b/xCAT-test/autotest/testcase/UT_openbmc/rspconfig_cases0 @@ -1,4 +1,4 @@ -start:rspconfig_record_firmware_level +start:openbmc_rspconfig_record_firmware_level description: Record the firmware level for the start of each testcase to display in the output hcp:openbmc label:cn_bmc_ready,hctrl_openbmc @@ -6,7 +6,7 @@ cmd: rinv $$CN firm check:rc==0 end -start:rspconfig_get_all_network +start:openbmc_rspconfig_get_all_network description: Check that we can get all the network related attributes from the BMC os:Linux hcp:openbmc @@ -20,7 +20,7 @@ check:output=~$$CN: BMC Hostname: check:output=~$$CN: BMC VLAN ID: end -start:rspconfig_get_all_error +start:openbmc_rspconfig_get_all_error description: Check the parsing code for rspconfig (error cases) hcp: openbmc label:cn_bmc_ready,hctrl_openbmc @@ -29,7 +29,7 @@ check:rc==1 check:output=~Error: (\[.*?\]: )?Unsupported command end -start:rspconfig_get_set_error +start:openbmc_rspconfig_get_set_error description: Check the parsing code for rspconfig (error cases) - Cannot get/set in same line hcp: openbmc label:cn_bmc_ready,hctrl_openbmc @@ -38,7 +38,7 @@ check:rc==1 check:output=~Error: (\[.*?\]: )?Can not set and query OpenBMC information at the same time end -start:rspconfig_get_and_set_hostname +start:openbmc_rspconfig_get_and_set_hostname description: Test setting and getting hostname on the BMC os:Linux hcp:openbmc @@ -74,7 +74,7 @@ check:output=~$$CN: BMC Hostname: check:rc==0 end -start:rspconfig_admin_passwd_error +start:openbmc_rspconfig_admin_passwd_error description: Check the error handling for changing of BMC password hcp: openbmc label:cn_bmc_ready,hctrl_openbmc @@ -86,7 +86,7 @@ check:rc==1 check:output=~Current BMC password is incorrect, cannot set the new password. end -start:rspconfig_admin_passwd +start:openbmc_rspconfig_admin_passwd description: Check the setting of BMC password to the same value hcp: openbmc label:cn_bmc_ready,hctrl_openbmc @@ -95,7 +95,7 @@ check:rc==0 check:output=~$$CN: BMC Setting Password end -start:rspconfig_autoreboot +start:openbmc_rspconfig_autoreboot description: Check the getting and setting of autoreboot attribute hcp: openbmc label:cn_bmc_ready,hctrl_openbmc @@ -116,7 +116,7 @@ check:rc==1 check:output=~$$CN: Error: Invalid value '2' for 'autoreboot', Valid values: 0,1 end -start:rspconfig_bootmode +start:openbmc_rspconfig_bootmode description: Check the getting and setting of bootmode attribute hcp: openbmc label:cn_bmc_ready,hctrl_openbmc @@ -134,7 +134,7 @@ check:rc==1 check:output=~$$CN: Error: Invalid value 'abc' for 'bootmode', Valid values: regular,safe,setup end -start:rspconfig_dump +start:openbmc_rspconfig_dump description: Check dump generation, download and removal hcp: openbmc label:cn_bmc_ready,hctrl_openbmc @@ -150,12 +150,12 @@ check:output=~Downloading dump cmd: ls -l /var/log/xcat/dump/*$$CN* check:rc==0 #Remove last generated dump -cmd: rspconfig mid05tor12cn03 dump -l | tail -1 | cut -d ' ' -f2 | tr -d "[]" | xargs -i{} rspconfig $$CN dump -c {} +cmd: rspconfig $$CN dump -l | tail -1 | cut -d ' ' -f2 | tr -d "[]" | xargs -i{} rspconfig $$CN dump -c {} check:rc==0 check:output=clear end -start:rspconfig_ntpservers +start:openbmc_rspconfig_ntpservers description: Check the getting and setting of ntpservers attribute hcp: openbmc label:cn_bmc_ready,hctrl_openbmc @@ -170,7 +170,7 @@ check:rc==0 check:output=~$$CN: BMC NTP Servers: None end -start:rspconfig_powerrestorepolicy +start:openbmc_rspconfig_powerrestorepolicy description: Check the getting and setting of powerrestorepolicy attribute hcp: openbmc label:cn_bmc_ready,hctrl_openbmc @@ -197,7 +197,7 @@ check:rc==1 check:output=~$$CN: Error: Invalid value 'abc' for 'powerrestorepolicy', Valid values: always_off,always_on,restore end -start:rspconfig_powersupplyredundancy +start:openbmc_rspconfig_powersupplyredundancy description: Check the getting and setting of powersupplyredundancy attribute hcp: openbmc label:cn_bmc_ready,hctrl_openbmc @@ -209,7 +209,7 @@ check:rc==0 check:output=~$$CN: BMC PowerSupplyRedundancy: Disabled end -start:rspconfig_sshcfg +start:openbmc_rspconfig_sshcfg description: Check the copying of ssh keys to the BMC hcp: openbmc label:cn_bmc_ready,hctrl_openbmc @@ -218,7 +218,7 @@ check:rc==0 check:output=~$$CN: ssh keys copied to end -start:rspconfig_timesyncmethod +start:openbmc_rspconfig_timesyncmethod description: Check the getting and setting of timesyncmethod attribute hcp: openbmc label:cn_bmc_ready,hctrl_openbmc @@ -235,3 +235,21 @@ cmd: rspconfig $$CN timesyncmethod=abc check:rc==1 check:output=~$$CN: Error: Invalid value 'abc' for 'timesyncmethod', Valid values: manual,ntp end + +start:openbmc_rspconfig_thermalmode +description: Check the getting and setting of thermalmode attribute +hcp: openbmc +label:cn_bmc_ready,hctrl_openbmc +cmd: rspconfig $$CN thermalmode=heavy_io +check:rc==0 +check:output=~$$CN: BMC Setting BMC ThermalMode +cmd: rspconfig $$CN thermalmode +check:rc==0 +check:output=~$$CN: BMC BootMode: HEAVY_IO +cmd: rspconfig $$CN thermalmode=default +check:rc==0 +check:output=~$$CN: BMC Setting BMC ThermalMode +cmd: rspconfig $$CN thermalmode=abc +check:rc==1 +check:output=~$$CN: Error: Invalid value 'abc' for 'thermalmode', Valid values: default,custom,heavy_io,max_base_fan_floor +end From c5c5ee3023d41830c2dca92ddd4b21dbb3adde9b Mon Sep 17 00:00:00 2001 From: cxhong Date: Tue, 19 Nov 2019 15:48:09 -0500 Subject: [PATCH 024/139] Support SLE15 diskfull installation --- .../share/xcat/install/scripts/post.sle | 21 +++++++++++++++++++ .../install/scripts/{pre.sle15 => pre.sle} | 0 .../share/xcat/install/sle/compute.pkglist | 1 + .../{sles => sle}/compute.sle15.pkglist | 0 .../install/{sles => sle}/compute.sle15.tmpl | 4 ++-- .../share/xcat/install/sle/compute.tmpl | 1 + 6 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 xCAT-server/share/xcat/install/scripts/post.sle rename xCAT-server/share/xcat/install/scripts/{pre.sle15 => pre.sle} (100%) create mode 120000 xCAT-server/share/xcat/install/sle/compute.pkglist rename xCAT-server/share/xcat/install/{sles => sle}/compute.sle15.pkglist (100%) rename xCAT-server/share/xcat/install/{sles => sle}/compute.sle15.tmpl (96%) create mode 120000 xCAT-server/share/xcat/install/sle/compute.tmpl diff --git a/xCAT-server/share/xcat/install/scripts/post.sle b/xCAT-server/share/xcat/install/scripts/post.sle new file mode 100644 index 000000000..2eba0eae3 --- /dev/null +++ b/xCAT-server/share/xcat/install/scripts/post.sle @@ -0,0 +1,21 @@ + + + + diff --git a/xCAT-server/share/xcat/install/scripts/pre.sle15 b/xCAT-server/share/xcat/install/scripts/pre.sle similarity index 100% rename from xCAT-server/share/xcat/install/scripts/pre.sle15 rename to xCAT-server/share/xcat/install/scripts/pre.sle diff --git a/xCAT-server/share/xcat/install/sle/compute.pkglist b/xCAT-server/share/xcat/install/sle/compute.pkglist new file mode 120000 index 000000000..0e114f64f --- /dev/null +++ b/xCAT-server/share/xcat/install/sle/compute.pkglist @@ -0,0 +1 @@ +compute.sle15.pkglist \ No newline at end of file diff --git a/xCAT-server/share/xcat/install/sles/compute.sle15.pkglist b/xCAT-server/share/xcat/install/sle/compute.sle15.pkglist similarity index 100% rename from xCAT-server/share/xcat/install/sles/compute.sle15.pkglist rename to xCAT-server/share/xcat/install/sle/compute.sle15.pkglist diff --git a/xCAT-server/share/xcat/install/sles/compute.sle15.tmpl b/xCAT-server/share/xcat/install/sle/compute.sle15.tmpl similarity index 96% rename from xCAT-server/share/xcat/install/sles/compute.sle15.tmpl rename to xCAT-server/share/xcat/install/sle/compute.sle15.tmpl index d2ff50e93..b5254111d 100644 --- a/xCAT-server/share/xcat/install/sles/compute.sle15.tmpl +++ b/xCAT-server/share/xcat/install/sle/compute.sle15.tmpl @@ -90,9 +90,9 @@ - #INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/pre.sle15# + #INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/pre.sle# #INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/chroot.sles# - #INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/post.sles11# + #INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/post.sle# diff --git a/xCAT-server/share/xcat/install/sle/compute.tmpl b/xCAT-server/share/xcat/install/sle/compute.tmpl new file mode 120000 index 000000000..357788ec3 --- /dev/null +++ b/xCAT-server/share/xcat/install/sle/compute.tmpl @@ -0,0 +1 @@ +compute.sle15.tmpl \ No newline at end of file From f709e80cc3872c3cb8c1c7718bd4e8e8c4d66ad5 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Tue, 19 Nov 2019 16:01:03 -0500 Subject: [PATCH 025/139] New regression bundle for kits --- xCAT-test/autotest/bundle/rhels_kits.bundle | 42 +++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 xCAT-test/autotest/bundle/rhels_kits.bundle diff --git a/xCAT-test/autotest/bundle/rhels_kits.bundle b/xCAT-test/autotest/bundle/rhels_kits.bundle new file mode 100644 index 000000000..6874edb06 --- /dev/null +++ b/xCAT-test/autotest/bundle/rhels_kits.bundle @@ -0,0 +1,42 @@ +addkit_v +addkit_h +addkit_kit +addkit_i +addkit_multikit +addkit_p +addkitcomp_v +addkitcomp_h +addkitcomp_i +addkitcomp_f +buildkit_v +buildkit_h +buildkit_create +buildkit_create_l +buildkit_cleanrepo_all +buildkit_buildtar +chkkitcomp_v +chkkitcomp_h +chkkitcomp_V +lskit_v +lskit_h +lskit_F +lskit_K +lskit_R +lskit_C +lskitcomp_v +lskitcomp_h +lskitcomp_C +lskitcomp_S +lskitdeployparam_v +lskitdeployparam_h +lskitdeployparam_no_param +lskitdeployparam_k_1 +lskitdeployparam_c_1 +rmkit_v +rmkit_h +rmkit_t_no +rmkit_t_yes +rmkit_f +rmkit_V +rmkitcomp_v +rmkitcomp_h From f22f47f50d3fbb12f656264c098685921d0a5517 Mon Sep 17 00:00:00 2001 From: c-kern <58042466+c-kern@users.noreply.github.com> Date: Thu, 21 Nov 2019 16:57:45 +0100 Subject: [PATCH 026/139] fixed three typos replaced three "golden-cilent" with "golden-client" --- docs/source/advanced/sysclone/sysclone.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/source/advanced/sysclone/sysclone.rst b/docs/source/advanced/sysclone/sysclone.rst index 7e1fbebbe..2d77ff3c9 100644 --- a/docs/source/advanced/sysclone/sysclone.rst +++ b/docs/source/advanced/sysclone/sysclone.rst @@ -107,19 +107,19 @@ To support clone, add 'otherpkglist' and 'otherpkgdir' attributes to the image d chdef -t osimage -o otherpkglist=/opt/xcat/share/xcat/install/rh/sysclone.rhels6.x86_64.otherpkgs.pkglist chdef -t osimage -o -p otherpkgdir=/install/post/otherpkgs/CentOS6.3/x86_64 - updatenode -S + updatenode -S * **[SLES11.3 and x86_64]**:: chdef -t osimage -o otherpkglist=/opt/xcat/share/xcat/install/sles/sysclone.sles11.x86_64.otherpkgs.pkglist chdef -t osimage -o -p otherpkgdir=/install/post/otherpkgs/SLES11.3/x86_64 - updatenode -S + updatenode -S * **[RH6.3 and ppc64]**:: chdef -t osimage -o otherpkglist=/opt/xcat/share/xcat/install/rh/sysclone.rhels6.ppc64.otherpkgs.pkglist chdef -t osimage -o -p otherpkgdir=/install/post/otherpkgs/rhels6.3/ppc64 - updatenode -S + updatenode -S *[Note]: If you install systemimager RPMs on CentOS 6.5 node by above steps, you maybe hit a failure. This is a known issue with CentOS6.5. Refer to known issue section for help.* From 4703244376e4954fcaa4bee4afcd473240abb970 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Thu, 21 Nov 2019 10:50:36 -0500 Subject: [PATCH 027/139] Remove /install/autoinst config files as part of nodepurge --- .../admin-guides/references/man1/nodepurge.1.rst | 16 +++++----------- xCAT-client/pods/man1/nodepurge.1.pod | 16 +++++----------- xCAT-server/lib/xcat/plugins/profilednodes.pm | 16 +++++++++++++++- 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/docs/source/guides/admin-guides/references/man1/nodepurge.1.rst b/docs/source/guides/admin-guides/references/man1/nodepurge.1.rst index 847eb6c7b..a8d256927 100644 --- a/docs/source/guides/admin-guides/references/man1/nodepurge.1.rst +++ b/docs/source/guides/admin-guides/references/man1/nodepurge.1.rst @@ -31,7 +31,7 @@ DESCRIPTION The \ **nodepurge**\ automatically removes all nodes from the database and any related configurations used by the node. -After the nodes are removed, the configuration files related to these nodes are automatically updated, including the following files: /etc/hosts, DNS, DHCP. Any kits that are used by the nodes are triggered to automatically update kit configuration and services. +After the nodes are removed, the configuration files related to these nodes are automatically updated, including the following files: \ */etc/hosts*\ , DNS, DHCP. Any kits that are used by the nodes are triggered to automatically update kit configuration and services. Any related configuration files from \ */install/autoinst*\ are also removed. ******* @@ -39,17 +39,11 @@ OPTIONS ******* -\ **-h|-**\ **-help**\ +\ **-h|-**\ **-help**\ Display usage message. -Display usage message. +\ **-v|-**\ **-version**\ Command Version -\ **-v|-**\ **-version**\ - -Command Version - -\ *noderange*\ - -The nodes to be removed. +\ *noderange*\ The nodes to be removed. ************ @@ -67,7 +61,7 @@ EXAMPLES ******** -To remove nodes compute-000 and compute-001, use the following command: +To remove nodes compute-000 and compute-001: .. code-block:: perl diff --git a/xCAT-client/pods/man1/nodepurge.1.pod b/xCAT-client/pods/man1/nodepurge.1.pod index 714f164f2..c71ceb2c4 100644 --- a/xCAT-client/pods/man1/nodepurge.1.pod +++ b/xCAT-client/pods/man1/nodepurge.1.pod @@ -12,21 +12,15 @@ B I The B automatically removes all nodes from the database and any related configurations used by the node. -After the nodes are removed, the configuration files related to these nodes are automatically updated, including the following files: /etc/hosts, DNS, DHCP. Any kits that are used by the nodes are triggered to automatically update kit configuration and services. +After the nodes are removed, the configuration files related to these nodes are automatically updated, including the following files: I, DNS, DHCP. Any kits that are used by the nodes are triggered to automatically update kit configuration and services. Any related configuration files from I are also removed. =head1 OPTIONS -B<-h|--help> +B<-h|--help> Display usage message. -Display usage message. +B<-v|--version> Command Version -B<-v|--version> - -Command Version - -I - -The nodes to be removed. +I The nodes to be removed. =head1 RETURN VALUE @@ -36,7 +30,7 @@ The nodes to be removed. =head1 EXAMPLES -To remove nodes compute-000 and compute-001, use the following command: +To remove nodes compute-000 and compute-001: nodepurge compute-000,compute-001 diff --git a/xCAT-server/lib/xcat/plugins/profilednodes.pm b/xCAT-server/lib/xcat/plugins/profilednodes.pm index b3708cf9f..38c49c51d 100644 --- a/xCAT-server/lib/xcat/plugins/profilednodes.pm +++ b/xCAT-server/lib/xcat/plugins/profilednodes.pm @@ -687,7 +687,7 @@ sub nodepurge { Usage: \tnodepurge \tnodepurge [-h|--help] -\tnodepurge {-v|--version}"; +\tnodepurge [-v|--version]"; my $ret = validate_args($helpmsg); if (!$ret) { @@ -735,6 +735,20 @@ Usage: $warnstr .= "Details: $retstrref->[1]"; } } + # For each node in the noderange remove its configureation files in $config_dir, if file exists + setrsp_progress("Removing configuration files..."); + my $config_dir = "/install/autoinst/"; + foreach my $one_node (@$nodes) { + if ( -e "$config_dir/$one_node") { + unlink "$config_dir/$one_node"; + } + if ( -e "$config_dir/$one_node.post") { + unlink "$config_dir/$one_node.post"; + } + if ( -e "$config_dir/$one_node.pre") { + unlink "$config_dir/$one_node.pre"; + } + } setrsp_progress("Removed all nodes."); setrsp_success($nodes, $warnstr); } From 373eef1f79a764a4e0e299b21e8912435a1f58b8 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Thu, 21 Nov 2019 14:43:54 -0500 Subject: [PATCH 028/139] nodepurge testcases --- xCAT-test/autotest/testcase/nodepurge/cases0 | 59 ++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 xCAT-test/autotest/testcase/nodepurge/cases0 diff --git a/xCAT-test/autotest/testcase/nodepurge/cases0 b/xCAT-test/autotest/testcase/nodepurge/cases0 new file mode 100644 index 000000000..c26f63271 --- /dev/null +++ b/xCAT-test/autotest/testcase/nodepurge/cases0 @@ -0,0 +1,59 @@ +start:nodepurge_noderange +description:nodepurge testnode1,testnode2 +label:mn_only,ci_test,db +cmd:mkdef -t node -o testnode1 arch=ppc64le cons=ipmi groups=pbmc mgt=ipmi ip=10.1.1.200 mac=e6:d4:d2:3a:ad:01 monserver=10.1.1.1 nameservers=10.1.1.1 nodetype=ppc,osi profile=compute tftpserver=10.1.1.1 xcatmaster=10.1.1.1 +check:rc==0 +cmd:mkdef -t node -o testnode2 arch=ppc64le cons=ipmi groups=pbmc mgt=ipmi ip=10.1.1.201 mac=e6:d4:d2:3a:ad:02 monserver=10.1.1.1 nameservers=10.1.1.1 nodetype=ppc,osi profile=compute tftpserver=10.1.1.1 xcatmaster=10.1.1.1 +check:rc==0 +cmd:lsdef -t node testnode1,testnode2 +check:output=~testnode1 +check:output=~testnode2 +cmd:makehosts testnode1,testnode2 +check:rc==0 +cmd:nodeset testnode1,testnode2 osimage=rhels7.7-ppc64le-install-compute +check:rc==0 +cmd:nodepurge testnode1,testnode2 +check:rc==0 +cmd:lsdef -t node testnode1,testnode2 +check:output=~Could not find an object named 'testnode1' of type 'node'. +check:output=~Could not find an object named 'testnode2' of type 'node'. +cmd:ls /install/autoinst/testnode1* +check:output=~No such file or directory +cmd:ls /install/autoinst/testnode2* +check:output=~No such file or directory +cmd:ping testnode1 +check:output=~Name or service not known +cmd:ping testnode2 +check:output=~Name or service not known +end + +start:nodepurge_h +description:nodepurge -h +label:mn_only,ci_test,db +cmd:nodepurge -h +check:output=~Usage +cmd:nodepurge --help +check:output=~Usage +end + +start:nodepurge_null +description:nodepurge +label:mn_only,ci_test,db +cmd:nodepurge +check:output=~Usage +end + +start:nodepurge_err_node +description:nodepurge err +label:mn_only,ci_test,db +cmd:rmdef -t node testnode +cmd:nodepurge testnode +check:rc!=0 +check:output=~Invalid nodes and/or groups in noderange: testnode +end + + + + + + From e4dc9a1d0a8ae6c7c114fba0a4e209a5a0091acb Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Thu, 21 Nov 2019 14:48:00 -0500 Subject: [PATCH 029/139] Add testcase to daily bundles --- xCAT-test/autotest/bundle/MN_basic.bundle | 4 ++++ xCAT-test/autotest/bundle/rhels_ppc_daily.bundle | 4 ++++ xCAT-test/autotest/bundle/rhels_ppcle_daily.bundle | 4 ++++ xCAT-test/autotest/bundle/rhels_x86_daily.bundle | 4 ++++ xCAT-test/autotest/bundle/sles_ppc_daily.bundle | 4 ++++ xCAT-test/autotest/bundle/sles_ppcle_daily.bundle | 4 ++++ xCAT-test/autotest/bundle/sles_x86_daily.bundle | 4 ++++ xCAT-test/autotest/bundle/ubuntu_ppcle_daily.bundle | 4 ++++ xCAT-test/autotest/bundle/ubuntu_x86_daily.bundle | 4 ++++ 9 files changed, 36 insertions(+) diff --git a/xCAT-test/autotest/bundle/MN_basic.bundle b/xCAT-test/autotest/bundle/MN_basic.bundle index de3e09758..fb7574d4d 100644 --- a/xCAT-test/autotest/bundle/MN_basic.bundle +++ b/xCAT-test/autotest/bundle/MN_basic.bundle @@ -171,6 +171,10 @@ noderm_err_node noderm_h noderm_noderange noderm_null +nodepurge_err_node +nodepurge_h +nodepurge_noderange +nodepurge_null nodestat_err_node restorexCAT_h restorexCATdb_a_p_V diff --git a/xCAT-test/autotest/bundle/rhels_ppc_daily.bundle b/xCAT-test/autotest/bundle/rhels_ppc_daily.bundle index 39cd43183..0d9eed54a 100644 --- a/xCAT-test/autotest/bundle/rhels_ppc_daily.bundle +++ b/xCAT-test/autotest/bundle/rhels_ppc_daily.bundle @@ -212,6 +212,10 @@ noderm_err_node noderm_h noderm_noderange noderm_null +nodepurge_err_node +nodepurge_h +nodepurge_noderange +nodepurge_null tabdump_servicenode nodeset_check_warninginfo nodeset_errorcommand diff --git a/xCAT-test/autotest/bundle/rhels_ppcle_daily.bundle b/xCAT-test/autotest/bundle/rhels_ppcle_daily.bundle index 9184066d4..9fa8d73e0 100644 --- a/xCAT-test/autotest/bundle/rhels_ppcle_daily.bundle +++ b/xCAT-test/autotest/bundle/rhels_ppcle_daily.bundle @@ -205,6 +205,10 @@ noderm_err_node noderm_h noderm_noderange noderm_null +nodepurge_err_node +nodepurge_h +nodepurge_noderange +nodepurge_null nodeset_check_warninginfo nodeset_disjointdhcps_petitboot nodeset_errorcommand diff --git a/xCAT-test/autotest/bundle/rhels_x86_daily.bundle b/xCAT-test/autotest/bundle/rhels_x86_daily.bundle index 8da4e59e6..cd43395ed 100644 --- a/xCAT-test/autotest/bundle/rhels_x86_daily.bundle +++ b/xCAT-test/autotest/bundle/rhels_x86_daily.bundle @@ -205,6 +205,10 @@ noderm_err_node noderm_h noderm_noderange noderm_null +nodepurge_err_node +nodepurge_h +nodepurge_noderange +nodepurge_null nodeset_check_warninginfo nodeset_errorcommand nodeset_xnba diff --git a/xCAT-test/autotest/bundle/sles_ppc_daily.bundle b/xCAT-test/autotest/bundle/sles_ppc_daily.bundle index aacf5b76c..fcb5b2d5c 100644 --- a/xCAT-test/autotest/bundle/sles_ppc_daily.bundle +++ b/xCAT-test/autotest/bundle/sles_ppc_daily.bundle @@ -170,6 +170,10 @@ noderm_err_node noderm_h noderm_noderange noderm_null +nodepurge_err_node +nodepurge_h +nodepurge_noderange +nodepurge_null nodeset_check_warninginfo nodeset_errorcommand nodeset_grub2 diff --git a/xCAT-test/autotest/bundle/sles_ppcle_daily.bundle b/xCAT-test/autotest/bundle/sles_ppcle_daily.bundle index 1e8ed265d..57793ad92 100644 --- a/xCAT-test/autotest/bundle/sles_ppcle_daily.bundle +++ b/xCAT-test/autotest/bundle/sles_ppcle_daily.bundle @@ -155,6 +155,10 @@ noderm_err_node noderm_h noderm_noderange noderm_null +nodepurge_err_node +nodepurge_h +nodepurge_noderange +nodepurge_null nodeset_check_warninginfo nodeset_disjointdhcps_petitboot nodeset_errorcommand diff --git a/xCAT-test/autotest/bundle/sles_x86_daily.bundle b/xCAT-test/autotest/bundle/sles_x86_daily.bundle index fb00734d3..94d0afa29 100644 --- a/xCAT-test/autotest/bundle/sles_x86_daily.bundle +++ b/xCAT-test/autotest/bundle/sles_x86_daily.bundle @@ -155,6 +155,10 @@ noderm_err_node noderm_h noderm_noderange noderm_null +nodepurge_err_node +nodepurge_h +nodepurge_noderange +nodepurge_null nodeset_check_warninginfo nodeset_errorcommand nodeset_noderange diff --git a/xCAT-test/autotest/bundle/ubuntu_ppcle_daily.bundle b/xCAT-test/autotest/bundle/ubuntu_ppcle_daily.bundle index f9dff496b..5da3ac5fe 100644 --- a/xCAT-test/autotest/bundle/ubuntu_ppcle_daily.bundle +++ b/xCAT-test/autotest/bundle/ubuntu_ppcle_daily.bundle @@ -125,6 +125,10 @@ noderm_err_node noderm_h noderm_noderange noderm_null +nodepurge_err_node +nodepurge_h +nodepurge_noderange +nodepurge_null nodeset_errorcommand nodeset_check_warninginfo nodeset_grub2 diff --git a/xCAT-test/autotest/bundle/ubuntu_x86_daily.bundle b/xCAT-test/autotest/bundle/ubuntu_x86_daily.bundle index 280fb0f6e..46ff09f19 100644 --- a/xCAT-test/autotest/bundle/ubuntu_x86_daily.bundle +++ b/xCAT-test/autotest/bundle/ubuntu_x86_daily.bundle @@ -125,6 +125,10 @@ noderm_err_node noderm_h noderm_noderange noderm_null +nodepurge_err_node +nodepurge_h +nodepurge_noderange +nodepurge_null nodeset_errorcommand nodeset_check_warninginfo nodeset_noderange From b555a6b2c25b8cab227104ced7dd598ef69de042 Mon Sep 17 00:00:00 2001 From: c-kern <58042466+c-kern@users.noreply.github.com> Date: Thu, 21 Nov 2019 20:52:42 +0100 Subject: [PATCH 030/139] ... and the fourth typo of the same kind There were four "golden cilent". Fixed three of them before. Missed the last one. Here it comes. --- docs/source/advanced/sysclone/sysclone.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/advanced/sysclone/sysclone.rst b/docs/source/advanced/sysclone/sysclone.rst index 2d77ff3c9..1510aa5d8 100644 --- a/docs/source/advanced/sysclone/sysclone.rst +++ b/docs/source/advanced/sysclone/sysclone.rst @@ -101,7 +101,7 @@ To support clone, add 'otherpkglist' and 'otherpkgdir' attributes to the image d chdef -t osimage -o otherpkglist=/opt/xcat/share/xcat/install/rh/sysclone.rhels6.x86_64.otherpkgs.pkglist chdef -t osimage -o -p otherpkgdir=/install/post/otherpkgs/rhels6.4/x86_64 - updatenode -S + updatenode -S * **[CentOS6.3 and x86_64]**:: From 89f94a46be217120fa87d12a55ea2d866e4ae0b8 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Thu, 21 Nov 2019 17:01:16 -0500 Subject: [PATCH 031/139] Add os and netboot attributes --- xCAT-test/autotest/testcase/nodepurge/cases0 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xCAT-test/autotest/testcase/nodepurge/cases0 b/xCAT-test/autotest/testcase/nodepurge/cases0 index c26f63271..d13a79f62 100644 --- a/xCAT-test/autotest/testcase/nodepurge/cases0 +++ b/xCAT-test/autotest/testcase/nodepurge/cases0 @@ -1,9 +1,9 @@ start:nodepurge_noderange description:nodepurge testnode1,testnode2 label:mn_only,ci_test,db -cmd:mkdef -t node -o testnode1 arch=ppc64le cons=ipmi groups=pbmc mgt=ipmi ip=10.1.1.200 mac=e6:d4:d2:3a:ad:01 monserver=10.1.1.1 nameservers=10.1.1.1 nodetype=ppc,osi profile=compute tftpserver=10.1.1.1 xcatmaster=10.1.1.1 +cmd:mkdef -t node -o testnode1 arch=ppc64le cons=ipmi groups=pbmc mgt=ipmi ip=10.1.1.200 mac=e6:d4:d2:3a:ad:01 monserver=10.1.1.1 nameservers=10.1.1.1 nodetype=ppc,osi profile=compute tftpserver=10.1.1.1 xcatmaster=10.1.1.1 os=rhels7.7 netboot=petitboot check:rc==0 -cmd:mkdef -t node -o testnode2 arch=ppc64le cons=ipmi groups=pbmc mgt=ipmi ip=10.1.1.201 mac=e6:d4:d2:3a:ad:02 monserver=10.1.1.1 nameservers=10.1.1.1 nodetype=ppc,osi profile=compute tftpserver=10.1.1.1 xcatmaster=10.1.1.1 +cmd:mkdef -t node -o testnode2 arch=ppc64le cons=ipmi groups=pbmc mgt=ipmi ip=10.1.1.201 mac=e6:d4:d2:3a:ad:02 monserver=10.1.1.1 nameservers=10.1.1.1 nodetype=ppc,osi profile=compute tftpserver=10.1.1.1 xcatmaster=10.1.1.1 os=rhels7.7 netboot=petitboot check:rc==0 cmd:lsdef -t node testnode1,testnode2 check:output=~testnode1 From c5bdca0708d2ee1af09db80098b1e6b1d509c673 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Fri, 22 Nov 2019 09:19:39 -0500 Subject: [PATCH 032/139] Do not run nodepurge test during TravisCI --- xCAT-test/autotest/bundle/MN_basic.bundle | 1 - xCAT-test/autotest/testcase/nodepurge/cases0 | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/xCAT-test/autotest/bundle/MN_basic.bundle b/xCAT-test/autotest/bundle/MN_basic.bundle index fb7574d4d..5eb686d73 100644 --- a/xCAT-test/autotest/bundle/MN_basic.bundle +++ b/xCAT-test/autotest/bundle/MN_basic.bundle @@ -173,7 +173,6 @@ noderm_noderange noderm_null nodepurge_err_node nodepurge_h -nodepurge_noderange nodepurge_null nodestat_err_node restorexCAT_h diff --git a/xCAT-test/autotest/testcase/nodepurge/cases0 b/xCAT-test/autotest/testcase/nodepurge/cases0 index d13a79f62..2109d0521 100644 --- a/xCAT-test/autotest/testcase/nodepurge/cases0 +++ b/xCAT-test/autotest/testcase/nodepurge/cases0 @@ -1,6 +1,6 @@ start:nodepurge_noderange description:nodepurge testnode1,testnode2 -label:mn_only,ci_test,db +label:mn_only,db cmd:mkdef -t node -o testnode1 arch=ppc64le cons=ipmi groups=pbmc mgt=ipmi ip=10.1.1.200 mac=e6:d4:d2:3a:ad:01 monserver=10.1.1.1 nameservers=10.1.1.1 nodetype=ppc,osi profile=compute tftpserver=10.1.1.1 xcatmaster=10.1.1.1 os=rhels7.7 netboot=petitboot check:rc==0 cmd:mkdef -t node -o testnode2 arch=ppc64le cons=ipmi groups=pbmc mgt=ipmi ip=10.1.1.201 mac=e6:d4:d2:3a:ad:02 monserver=10.1.1.1 nameservers=10.1.1.1 nodetype=ppc,osi profile=compute tftpserver=10.1.1.1 xcatmaster=10.1.1.1 os=rhels7.7 netboot=petitboot From 6f3c1a3b6583b134f8d1f715f531e550b6338253 Mon Sep 17 00:00:00 2001 From: cxhong Date: Fri, 22 Nov 2019 14:32:55 -0500 Subject: [PATCH 033/139] Add support to provision SLE15 diskfull/diskless compute nodes --- .../share/xcat/install/sle/compute.pkglist | 1 - .../share/xcat/install/sle/compute.tmpl | 1 - .../{sle => sles}/compute.sle15.pkglist | 0 .../install/{sle => sles}/compute.sle15.tmpl | 0 .../xcat/install/sles/service.sle15.pkglist | 22 + .../service.sle15.ppc64le.otherpkgs.pkglist | 2 + .../xcat/install/sles/service.sle15.tmpl | 91 + .../service.sle15.x86_64.otherpkgs.pkglist | 2 + .../share/xcat/netboot/sle/dracut_033/check | 3 - .../netboot/sle/dracut_033/install.netboot | 9 - .../netboot/sle/dracut_033/install.statelite | 8 - .../xcat/netboot/sle/dracut_033/installkernel | 2 - .../dracut_033/patch/syslog/module-setup.sh | 41 - .../dracut_033/patch/syslog/rsyslogd-start.sh | 51 - .../patch/syslog/syslog-genrules.sh | 97 - .../netboot/sle/dracut_033/xcat-cmdline.sh | 4 - .../netboot/sle/dracut_033/xcat-premount.sh | 18 - .../netboot/sle/dracut_033/xcat-prepivot.sh | 173 -- .../xcat/netboot/sle/dracut_033/xcatroot | 341 --- xCAT-server/share/xcat/netboot/sle/genimage | 2441 ----------------- xCAT-server/share/xcat/netboot/sle/geninitrd | 2437 ---------------- .../compute.sle15.exlist} | 0 .../xcat/netboot/sles/compute.sle15.pkglist | 48 + .../compute.sle15.postinstall} | 0 .../compute.sle15.x86_64.pkglist | 4 + .../netboot/sles/dracut_033/install.netboot | 2 +- .../netboot/sles/dracut_033/install.statelite | 2 +- xCAT-server/share/xcat/netboot/sles/genimage | 10 +- .../service.sle15.otherpkgs.pkglist} | 0 .../{sle => sles}/service.sle15.pkglist | 0 .../{sle => sles}/service.sle15.postinstall | 0 .../service.sle15.x86_64.otherpkgs.pkglist | 3 + 32 files changed, 182 insertions(+), 5631 deletions(-) delete mode 120000 xCAT-server/share/xcat/install/sle/compute.pkglist delete mode 120000 xCAT-server/share/xcat/install/sle/compute.tmpl rename xCAT-server/share/xcat/install/{sle => sles}/compute.sle15.pkglist (100%) rename xCAT-server/share/xcat/install/{sle => sles}/compute.sle15.tmpl (100%) create mode 100644 xCAT-server/share/xcat/install/sles/service.sle15.pkglist create mode 100644 xCAT-server/share/xcat/install/sles/service.sle15.ppc64le.otherpkgs.pkglist create mode 100644 xCAT-server/share/xcat/install/sles/service.sle15.tmpl create mode 100644 xCAT-server/share/xcat/install/sles/service.sle15.x86_64.otherpkgs.pkglist delete mode 100755 xCAT-server/share/xcat/netboot/sle/dracut_033/check delete mode 100755 xCAT-server/share/xcat/netboot/sle/dracut_033/install.netboot delete mode 100755 xCAT-server/share/xcat/netboot/sle/dracut_033/install.statelite delete mode 100755 xCAT-server/share/xcat/netboot/sle/dracut_033/installkernel delete mode 100755 xCAT-server/share/xcat/netboot/sle/dracut_033/patch/syslog/module-setup.sh delete mode 100755 xCAT-server/share/xcat/netboot/sle/dracut_033/patch/syslog/rsyslogd-start.sh delete mode 100755 xCAT-server/share/xcat/netboot/sle/dracut_033/patch/syslog/syslog-genrules.sh delete mode 100644 xCAT-server/share/xcat/netboot/sle/dracut_033/xcat-cmdline.sh delete mode 100644 xCAT-server/share/xcat/netboot/sle/dracut_033/xcat-premount.sh delete mode 100755 xCAT-server/share/xcat/netboot/sle/dracut_033/xcat-prepivot.sh delete mode 100755 xCAT-server/share/xcat/netboot/sle/dracut_033/xcatroot delete mode 100755 xCAT-server/share/xcat/netboot/sle/genimage delete mode 100755 xCAT-server/share/xcat/netboot/sle/geninitrd rename xCAT-server/share/xcat/netboot/{sle/compute.sle15.x86_64.exlist => sles/compute.sle15.exlist} (100%) create mode 100644 xCAT-server/share/xcat/netboot/sles/compute.sle15.pkglist rename xCAT-server/share/xcat/netboot/{sle/compute.sle15.x86_64.postinstall => sles/compute.sle15.postinstall} (100%) rename xCAT-server/share/xcat/netboot/{sle => sles}/compute.sle15.x86_64.pkglist (92%) rename xCAT-server/share/xcat/netboot/{sle/service.sle15.x86_64.otherpkgs.pkglist => sles/service.sle15.otherpkgs.pkglist} (100%) rename xCAT-server/share/xcat/netboot/{sle => sles}/service.sle15.pkglist (100%) rename xCAT-server/share/xcat/netboot/{sle => sles}/service.sle15.postinstall (100%) create mode 100644 xCAT-server/share/xcat/netboot/sles/service.sle15.x86_64.otherpkgs.pkglist diff --git a/xCAT-server/share/xcat/install/sle/compute.pkglist b/xCAT-server/share/xcat/install/sle/compute.pkglist deleted file mode 120000 index 0e114f64f..000000000 --- a/xCAT-server/share/xcat/install/sle/compute.pkglist +++ /dev/null @@ -1 +0,0 @@ -compute.sle15.pkglist \ No newline at end of file diff --git a/xCAT-server/share/xcat/install/sle/compute.tmpl b/xCAT-server/share/xcat/install/sle/compute.tmpl deleted file mode 120000 index 357788ec3..000000000 --- a/xCAT-server/share/xcat/install/sle/compute.tmpl +++ /dev/null @@ -1 +0,0 @@ -compute.sle15.tmpl \ No newline at end of file diff --git a/xCAT-server/share/xcat/install/sle/compute.sle15.pkglist b/xCAT-server/share/xcat/install/sles/compute.sle15.pkglist similarity index 100% rename from xCAT-server/share/xcat/install/sle/compute.sle15.pkglist rename to xCAT-server/share/xcat/install/sles/compute.sle15.pkglist diff --git a/xCAT-server/share/xcat/install/sle/compute.sle15.tmpl b/xCAT-server/share/xcat/install/sles/compute.sle15.tmpl similarity index 100% rename from xCAT-server/share/xcat/install/sle/compute.sle15.tmpl rename to xCAT-server/share/xcat/install/sles/compute.sle15.tmpl diff --git a/xCAT-server/share/xcat/install/sles/service.sle15.pkglist b/xCAT-server/share/xcat/install/sles/service.sle15.pkglist new file mode 100644 index 000000000..23c37900d --- /dev/null +++ b/xCAT-server/share/xcat/install/sles/service.sle15.pkglist @@ -0,0 +1,22 @@ +@base +@x11 +openssl +ntp +rsync +nmap +perl-DBI +vsftpd +perl-IO-Tty +perl-Expect +perl-SNMP +unixODBC +perl-Net-DNS +perl-DBD-mysql +mariadb-client +libmysqlclient18 +# The following rpms are available on the SLES SDK +# You will need to locate and make these rpms available in your zypper +# repository for service node installs and uncomment the following lines: +#MyODBC-unixODBC +#perl-DBD-Pg + diff --git a/xCAT-server/share/xcat/install/sles/service.sle15.ppc64le.otherpkgs.pkglist b/xCAT-server/share/xcat/install/sles/service.sle15.ppc64le.otherpkgs.pkglist new file mode 100644 index 000000000..096209962 --- /dev/null +++ b/xCAT-server/share/xcat/install/sles/service.sle15.ppc64le.otherpkgs.pkglist @@ -0,0 +1,2 @@ +xcat/xcat-core/xCATsn +xcat/xcat-dep/sles12/ppc64le/goconserver diff --git a/xCAT-server/share/xcat/install/sles/service.sle15.tmpl b/xCAT-server/share/xcat/install/sles/service.sle15.tmpl new file mode 100644 index 000000000..bf5a3764a --- /dev/null +++ b/xCAT-server/share/xcat/install/sles/service.sle15.tmpl @@ -0,0 +1,91 @@ + + + + + + true + true + #XCATVAR:PERSKCMDLINE# + false + false + mbr + + + + GMT + #TABLE:site:key=timezone:value# + + + english-us + + en_US + + false + false + false + true + + + non + + + true + true + true + + + + + + XCATPARTITIONHOOK + true + all + + + + + + #INCLUDE_DEFAULT_PTRNLIST_S# + + + #INCLUDE_DEFAULT_PKGLIST_S# + + + + + + + root + #CRYPT:passwd:key=system,username=root:password# + true + + + + + + + true + true + local + linux + + + + dhcp + eth0 + onboot + + + true + + false + + + + + #INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/pre.sles# + #INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/chroot.sles# + #INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/post.sles11# + + + diff --git a/xCAT-server/share/xcat/install/sles/service.sle15.x86_64.otherpkgs.pkglist b/xCAT-server/share/xcat/install/sles/service.sle15.x86_64.otherpkgs.pkglist new file mode 100644 index 000000000..a9d86fded --- /dev/null +++ b/xCAT-server/share/xcat/install/sles/service.sle15.x86_64.otherpkgs.pkglist @@ -0,0 +1,2 @@ +xcat/xcat-core/xCATsn +xcat/xcat-dep/sles12/x86_64/goconserver diff --git a/xCAT-server/share/xcat/netboot/sle/dracut_033/check b/xCAT-server/share/xcat/netboot/sle/dracut_033/check deleted file mode 100755 index d7cc89ce0..000000000 --- a/xCAT-server/share/xcat/netboot/sle/dracut_033/check +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -[ "$1" = "-d" ] && echo network -exit 0 diff --git a/xCAT-server/share/xcat/netboot/sle/dracut_033/install.netboot b/xCAT-server/share/xcat/netboot/sle/dracut_033/install.netboot deleted file mode 100755 index d82e9502c..000000000 --- a/xCAT-server/share/xcat/netboot/sle/dracut_033/install.netboot +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -echo $drivers -dracut_install wget tar cpio gzip modprobe touch echo cut wc xz -dracut_install grep ip 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/sle/dracut_033/install.statelite b/xCAT-server/share/xcat/netboot/sle/dracut_033/install.statelite deleted file mode 100755 index 1ef4a721a..000000000 --- a/xCAT-server/share/xcat/netboot/sle/dracut_033/install.statelite +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -echo $drivers -dracut_install wget cpio gzip modprobe wc touch echo cut -dracut_install grep ip 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/sle/dracut_033/installkernel b/xCAT-server/share/xcat/netboot/sle/dracut_033/installkernel deleted file mode 100755 index 7902ce5f7..000000000 --- a/xCAT-server/share/xcat/netboot/sle/dracut_033/installkernel +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -instmods nfs sunrpc diff --git a/xCAT-server/share/xcat/netboot/sle/dracut_033/patch/syslog/module-setup.sh b/xCAT-server/share/xcat/netboot/sle/dracut_033/patch/syslog/module-setup.sh deleted file mode 100755 index 386a3a40b..000000000 --- a/xCAT-server/share/xcat/netboot/sle/dracut_033/patch/syslog/module-setup.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh - -check() { - # do not add this module by default - return 255 -} - -depends() { - return 0 -} - -install() { - local _i - local _installs - if type -P rsyslogd >/dev/null; then - _installs="rsyslogd" - inst_libdir_file rsyslog/lmnet.so rsyslog/imklog.so rsyslog/imuxsock.so - elif type -P syslogd >/dev/null; then - _installs="syslogd" - elif type -P syslog-ng >/dev/null; then - _installs="syslog-ng" - else - derror "Could not find any syslog binary although the syslogmodule" \ - "is selected to be installed. Please check." - fi - if [ -n "$_installs" ]; then - inst_multiple cat $_installs - inst_hook cmdline 90 "$moddir/parse-syslog-opts.sh" - inst_hook pre-udev 61 "$moddir/syslog-genrules.sh" - inst_hook cleanup 99 "$moddir/syslog-cleanup.sh" - inst_simple "$moddir/rsyslogd-start.sh" /sbin/rsyslogd-start - inst_simple "$moddir/rsyslogd-stop.sh" /sbin/rsyslogd-stop - mkdir -m 0755 -p ${initdir}/etc/templates - inst_simple "${moddir}/rsyslog.conf" /etc/templates/rsyslog.conf - fi - dracut_install logger - dracut_need_initqueue -} - diff --git a/xCAT-server/share/xcat/netboot/sle/dracut_033/patch/syslog/rsyslogd-start.sh b/xCAT-server/share/xcat/netboot/sle/dracut_033/patch/syslog/rsyslogd-start.sh deleted file mode 100755 index 9589af436..000000000 --- a/xCAT-server/share/xcat/netboot/sle/dracut_033/patch/syslog/rsyslogd-start.sh +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/sh -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh - -# Triggered by udev and starts rsyslogd with bootparameters - -type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh - -rsyslog_config() { - local server=$1 - shift - local syslog_template=$1 - shift - local filters=$* - local filter= - local confline= - - cat $syslog_template - -# for filter in $filters; do -# echo "${filter} @${server}" -# done - - - if [ -n "$filters" ];then - confline="${filters}"; - else - confline="*.*" - fi - - if [ -n "$server" ];then - confline="$confline @${server}" - else - confline="$confline /var/log/messages" - fi - - echo "$confline" -# echo "*.* /tmp/syslog" -} - -[ -f /tmp/syslog.server ] && read server < /tmp/syslog.server -[ -f /tmp/syslog.filters ] && read filters < /tmp/syslog.filters -[ -z "$filters" ] && filters="kern.*" -[ -f /tmp/syslog.conf ] && read conf < /tmp/syslog.conf -[ -z "$conf" ] && conf="/etc/rsyslog.conf" && echo "$conf" > /tmp/syslog.conf - -template=/etc/templates/rsyslog.conf -if [ -n "$server" ]; then - rsyslog_config "$server" "$template" "$filters" > $conf - rsyslogd -i /var/run/syslogd.pid -fi diff --git a/xCAT-server/share/xcat/netboot/sle/dracut_033/patch/syslog/syslog-genrules.sh b/xCAT-server/share/xcat/netboot/sle/dracut_033/patch/syslog/syslog-genrules.sh deleted file mode 100755 index 09a58c574..000000000 --- a/xCAT-server/share/xcat/netboot/sle/dracut_033/patch/syslog/syslog-genrules.sh +++ /dev/null @@ -1,97 +0,0 @@ -#!/bin/sh -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh - -# Creates the syslog udev rules to be triggered when interface becomes online. -type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh - -detect_syslog() { - syslogtype="" - if [ -e /sbin/rsyslogd ]; then - syslogtype="rsyslogd" - elif [ -e /sbin/syslogd ]; then - syslogtype="syslogd" - elif [ /sbin/syslog-ng ]; then - syslogtype="syslog-ng" - else - warn "Could not find any syslog binary although the syslogmodule is selected to be installed. Please check." - fi - echo "$syslogtype" - [ -n "$syslogtype" ] -} - -#the initqueue.sh shipped does not support --online option and -#there are some problem when processing --onetime option -#implement a patched initqueue function here, named initqueue_enhanced -initqueue_enhanced() { - local onetime= - local qname= - local unique= - local name= - local env= - while [ $# -gt 0 ]; do - case "$1" in - --onetime) - onetime="yes";; - --settled) - qname="/settled";; - --finished) - qname="/finished";; - --timeout) - qname="/timeout";; - --online) - qname="/online";; - --unique) - unique="yes";; - --name) - name="$2";shift;; - --env) - env="$2"; shift;; - *) - break;; - esac - shift - done - - local job= - if [ -z "$unique" ]; then - job="${name}$$" - else - job="${name:-$1}" - job=${job##*/} - fi - - local exe= - exe=$1 - shift - - [ -x "$exe" ] || exe=$(command -v $exe) - if [ -z "$exe" ] ; then - echo "Invalid command" - return 1 - fi - - { - [ -n "$env" ] && echo "$env" - echo "$exe $@" - [ -n "$onetime" ] && echo "[ -e $hookdir/initqueue${qname}/${job}.sh ] && rm -f -- $hookdir/initqueue${qname}/${job}.sh" - } > "/tmp/$$-${job}.sh" - - mv -f "/tmp/$$-${job}.sh" "$hookdir/initqueue${qname}/${job}.sh" - [ -z "$qname" ] && >> $hookdir/initqueue/work - - return 0 -} - -[ -f /tmp/syslog.type ] && read syslogtype < /tmp/syslog.type -if [ -z "$syslogtype" ]; then - syslogtype=$(detect_syslog) - echo $syslogtype > /tmp/syslog.type -fi -if [ -e "/sbin/${syslogtype}-start" ]; then - #printf 'ACTION=="online", SUBSYSTEM=="net", RUN+="/sbin/initqueue --onetime /sbin/'${syslogtype}'-start $env{INTERFACE}"\n' > /etc/udev/rules.d/70-syslog.rules - #printf 'ATTR{operstate}!="down", SUBSYSTEM=="net", RUN+="/sbin/initqueue --onetime /sbin/'${syslogtype}'-start $env{INTERFACE}"\n' > /etc/udev/rules.d/70-syslog.rules - initqueue_enhanced --online --onetime /sbin/${syslogtype}-start -else - warn "syslog-genrules: Could not find binary to start syslog of type \"$syslogtype\". Syslog will not be started." -fi diff --git a/xCAT-server/share/xcat/netboot/sle/dracut_033/xcat-cmdline.sh b/xCAT-server/share/xcat/netboot/sle/dracut_033/xcat-cmdline.sh deleted file mode 100644 index 80d088557..000000000 --- a/xCAT-server/share/xcat/netboot/sle/dracut_033/xcat-cmdline.sh +++ /dev/null @@ -1,4 +0,0 @@ -root=1 -rootok=1 -netroot=xcat -echo '[ -e $NEWROOT/proc ]' > $hookdir/initqueue/finished/xcatroot.sh diff --git a/xCAT-server/share/xcat/netboot/sle/dracut_033/xcat-premount.sh b/xCAT-server/share/xcat/netboot/sle/dracut_033/xcat-premount.sh deleted file mode 100644 index 40c1dbbe5..000000000 --- a/xCAT-server/share/xcat/netboot/sle/dracut_033/xcat-premount.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/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/sle/dracut_033/xcat-prepivot.sh b/xCAT-server/share/xcat/netboot/sle/dracut_033/xcat-prepivot.sh deleted file mode 100755 index 039990ab4..000000000 --- a/xCAT-server/share/xcat/netboot/sle/dracut_033/xcat-prepivot.sh +++ /dev/null @@ -1,173 +0,0 @@ -#!/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 - -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 -} - -bootif=$(ls /tmp/net.*.conf|sed -e s/.*net\.// -e s/\.conf//) -cat < $NEWROOT/etc/sysconfig/network/ifcfg-$bootif -BOOTPROTO='dhcp' -STARTMODE='auto' -EOF - -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/ifcfg-$ETHX ]; then - touch $NEWROOT/etc/sysconfig/network/ifcfg-$ETHX - fi - echo "DEVICE=$ETHX" > $NEWROOT/etc/sysconfig/network/ifcfg-$ETHX - echo "BOOTPROTO=dhcp" >> $NEWROOT/etc/sysconfig/network/ifcfg-$ETHX - echo "HWADDR=$MACX" >> $NEWROOT/etc/sysconfig/network/ifcfg-$ETHX - echo "ONBOOT=yes" >> $NEWROOT/etc/sysconfig/network/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 - -# 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/sle/dracut_033/xcatroot b/xCAT-server/share/xcat/netboot/sle/dracut_033/xcatroot deleted file mode 100755 index ba8bb019a..000000000 --- a/xCAT-server/share/xcat/netboot/sle/dracut_033/xcatroot +++ /dev/null @@ -1,341 +0,0 @@ -#!/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 - -xcatdebugmode="$(getarg xcatdebugmode=)" - -[ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "running xcatroot...." - -[ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "MASTER=$MASTER XCATIPORT=$XCATIPORT" - -if [ $NODESTATUS -ne 0 ];then -[ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "nodestatus: netbooting,reporting..." -/tmp/updateflag $MASTER $XCATIPORT "installstatus netbooting" -fi - -if [ ! -z "$imgurl" ]; then - if [ xhttp = x${imgurl%%:*} ]; then - NFS=0 - FILENAME=${imgurl##*/} - while [ ! -r "$FILENAME" ]; do - [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "downloading $imgurl...." - echo Getting $imgurl... - if ! wget -nv $imgurl; then - [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "downloading $imgurl failed,retrying...." - 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.cpio.gz ] || [ -r /rootimg.cpio.xz ]; then - [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "rootimg downloaded,setting up RAM-root tmpfs...." - 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 - [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "Extracting root filesystem:" - echo -n "Extracting root filesystem:" - if [ -r /rootimg.cpio.gz ]; then - if [ -x /bin/cpio ]; then - gzip -cd /rootimg.cpio.gz |/bin/cpio -idum - else - gzip -cd /rootimg.cpio.gz |cpio -idum - fi - elif [ -r /rootimg.cpio.xz ]; then - if [ -x /bin/cpio ]; then - xz -cd /rootimg.cpio.xz |/bin/cpio -idum - else - xz -cd /rootimg.cpio.xz |cpio -idum - fi - fi - [ -x $NEWROOT/etc/init.d/localdisk ] && $NEWROOT/etc/init.d/localdisk - [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "Done...." - echo Done -elif [ -r /rootimg.tar.gz ] || [ -r /rootimg.tar.xz ]; then - [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "rootimg downloaded,setting up RAM-root tmpfs...." - 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 - [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "Extracting root filesystem:" - echo -n "Extracting root filesystem:" - if [ -r /rootimg.tar.gz ]; then - tar --selinux --xattrs-include='*' -zxf /rootimg.tar.gz - if [ $? -ne 0 ]; then - tar -zxf /rootimg.tar.gz - fi - elif [ -r /rootimg.tar.xz ]; then - tar --selinux --xattrs-include='*' -Jxf /rootimg.tar.xz - if [ $? -ne 0 ]; then - tar -Jxf /rootimg.tar.xz - fi - fi - $NEWROOT/etc/init.d/localdisk - [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "Done...." - 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 - [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "Failed to download image, panicing in 5..." - echo -n Failed to download image, panicing in 5... - for i in 4 3 2 1 0; do - /bin/sleep 1 - [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "$i..." - echo -n $i... - done - - [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "You're dead. rpower nodename reset to play again." - [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "* Did you packimage with -m cpio, -m squashfs, or -m nfs?" - [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "* If using -m squashfs did you include aufs.ko with geninitrd? e.g.: -n tg3,squashfs,aufs,loop" - [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "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" - 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 / - -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 - bootif=$(ls /tmp/net.*.conf|sed -e s/.*net\.// -e s/\.conf//) - cat < $NEWROOT/etc/sysconfig/network/ifcfg-$bootif -BOOTPROTO='dhcp' -STARTMODE='auto' -EOF - - 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/ifcfg-$ETHX ]; then - [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "creating $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX" - touch $NEWROOT/etc/sysconfig/network/ifcfg-$ETHX - fi - [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "writing $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX: DEVICE=$ETHX;BOOTPROTO=dhcp;HWADDR=$MACX;ONBOOT=yes" - echo "DEVICE=$ETHX" > $NEWROOT/etc/sysconfig/network/ifcfg-$ETHX - echo "BOOTPROTO=dhcp" >> $NEWROOT/etc/sysconfig/network/ifcfg-$ETHX - echo "HWADDR=$MACX" >> $NEWROOT/etc/sysconfig/network/ifcfg-$ETHX - echo "ONBOOT=yes" >> $NEWROOT/etc/sysconfig/network/ifcfg-$ETHX - fi -fi - -[ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "saving $NEWROOT/etc/resolv.conf" -cp /etc/resolv.conf "$NEWROOT/etc/" - -if [ -d "$NEWROOT/etc/sysconfig" -a ! -e "$NEWROOT/etc/sysconfig/selinux" ]; then - [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "disable selinux ..." - echo "SELINUX=disabled" >> "$NEWROOT/etc/sysconfig/selinux" -fi - -[ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "setting hostname..." -echo `hostname` > $NEWROOT/etc/hostname - -[ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "exiting xcatroot..." - -# 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/sle/genimage b/xCAT-server/share/xcat/netboot/sle/genimage deleted file mode 100755 index 5df177836..000000000 --- a/xCAT-server/share/xcat/netboot/sle/genimage +++ /dev/null @@ -1,2441 +0,0 @@ -#!/usr/bin/env perl -BEGIN -{ - $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat'; -} -use lib "$::XCATROOT/lib/perl"; - -use File::Basename; -use File::Path; -use File::Copy qw/copy cp mv move/; -use File::Find; -use Getopt::Long; -use Cwd qw(realpath); -use File::Temp qw/mkdtemp/; - -use FindBin; -use lib "$FindBin::Bin/../imgutils"; -use imgutils; - -#use strict; -Getopt::Long::Configure("bundling"); -Getopt::Long::Configure("pass_through"); - -my $dracutmode; #Indicate whether this is a dracut style initrd -my $dracutdir = "dracut"; # The default directory name of dracut -my $dracutver; -my $prinic; #TODO be flexible on node primary nic -my $othernics; #TODO be flexible on node primary nic -my $netdriver; -my @yumdirs; -my $arch; -my %libhash; -my @filestoadd; -my $profile; -my $osver; -my $pathtofiles = dirname($0); -my $fullpath = realpath($pathtofiles); -my $name = basename($0); -my $onlyinitrd = 0; - -#that this method of calling genimage is no longer used -if ($name =~ /geninitrd/) { - $onlyinitrd = 1; -} -my $rootlimit; -my $tmplimit; -my $installroot = "/install"; -my $kerneldir; -my $kernelver = ""; -my $basekernelver; -my $customdir = $fullpath; -$customdir =~ s/.*share\/xcat/$installroot\/custom/; -my $imagename; -my $pkglist; -my $srcdir; -my $destdir; -my $srcdir_otherpkgs; -my $otherpkglist; -my $postinstall_filename; -my $rootimg_dir; -my $mode; -my $permission; #the permission works only for statelite mode currently -my $krpmver; -my $tempfile; -my $prompt; -my $timezone; #the TIMEZONE of the stateless and statelite node -my $ignorekernelchk; -my $noupdate; - -sub xdie { - system("rm -rf /tmp/xcatinitrd.$$"); - die @_; -} - -#-- fetch current version form CVS (overwrite locally changed versions) -# if (opendir(CVS,"$pathtofiles/CVS")){ -# close CVS; -# my $cvsout = qx/cd $pathtofiles; cvs update -C 2>&1/; -# chomp $cvsout; -# if ( $cvsout ne "cvs update: Updating ." ) { -# print "Difference of local copy from CVS detected\n"; -# print $cvsout,"\n"; -# print "Trying to re-run $name\n"; -# print("$pathtofiles/$name ",join(" ",@ARGV),"\n"); -# exec("$pathtofiles/$name",@ARGV); -# } -# } - - -$SIG{INT} = $SIG{TERM} = sub { xdie "Interrupted" }; -GetOptions( - 'a=s' => \$arch, - 'p=s' => \$profile, - 'o=s' => \$osver, - 'n=s' => \$netdriver, - 'i=s' => \$prinic, - 'r=s' => \$othernics, - 'l=s' => \$rootlimit, - 't=s' => \$tmplimit, - 'k=s' => \$kernelver, - 'g=s' => \$krpmver, - 'permission=s' => \$permission, - 'kerneldir=s' => \$kerneldir, - 'timezone=s' => \$timezone, - 'tempfile=s' => \$tempfile, #internal flag - 'pkglist=s' => \$pkglist, #internal flag - 'srcdir=s' => \$srcdir, #internal flag - 'otherpkgdir=s' => \$srcdir_otherpkgs, #internal flag - 'otherpkglist=s' => \$otherpkglist, #internal flag - 'postinstall=s' => \$postinstall_filename, #internal flag - 'rootimgdir=s' => \$destdir, #internal flag - 'driverupdatesrc=s' => \$driverupdatesrc, #internal flag - 'interactive' => \$prompt, - 'onlyinitrd' => \$onlyinitrd, - 'ignorekernelchk' => \$ignorekernelchk, - 'noupdate' => \$noupdate, -); - -if (@ARGV > 0) { - $imagename = $ARGV[0]; -} - - -my %updates_os = (); # the hash for updating osimage table -my %updates = (); # the hash for updating linuximage table - - -$permission = "755" unless ($permission); -$updates{'permission'} = $permission if ($tempfile); - -unless ($arch) { - $arch = `uname -m`; - chomp($arch); - $arch = "x86" if ($arch =~ /i.86$/); -} - -$srcdir = "$installroot/$osver/$arch" unless ($srcdir); -$updates{'pkgdir'} = $srcdir if ($tempfile); - -#$srcdir = $srcdir . "/1"; - -$srcdir_otherpkgs = "$installroot/post/otherpkgs/$osver/$arch" unless ($srcdir_otherpkgs); -#$updates{'otherpkgdir'} = $srcdir_otherpkgs if ($tempfile); - -$destdir = "$installroot/netboot/$osver/$arch/$profile" unless ($destdir); -$updates{'rootimgdir'} = $destdir if ($tempfile); - -$rootimg_dir = "$destdir/rootimg"; - -if ($kernelver && (!$krpmver)) { - print "The -g flag for the rpm version of kernel packages needs to be specified when kernel version has been specified.\n"; - exit 1; -} -$kerneldir = "$installroot/kernels" unless ($kerneldir); # the default directory for 3rd-party kernel is "$installroot/kernels"; - -#$updates{'kerneldir'} = $kerneldir if ($tempfile); - -unless ($osver and $profile) { - usage(); - exit 1; -} -my @ndrivers; - -if ($netdriver) { - foreach (split /,/, $netdriver) { - if (/^allupdate$/) { - next; - } - unless (/\.ko$/) { - s/$/.ko/; - } - next if (/^$/); - - # Do not include qeth module here - # This module is included later on - unless ($_ =~ m/qeth/i) { - push @ndrivers, $_; - } - } - - if (($updates{'netdrivers'} ne $netdriver) and $tempfile) { - $updates{'netdrivers'} = $netdriver; - } -} - -# Add the default driver list -if ($arch eq 'x86' or $arch eq 'x86_64') { - push @ndrivers, qw/tg3 bnx2 bnx2x e1000 e1000e virtio_net virtio_balloon igb mlx4_en be2net/; -} elsif ($arch eq 'ppc64') { - push @ndrivers, qw/tg3 e1000 e1000e igb ibmveth ehea be2net/; -} elsif ($arch eq "s390x") { - push @ndrivers, qw/qdio ccwgroup qeth qeth_l2 qeth_l3/; -} - -foreach (@ndrivers) { - unless (/\.ko$/) { - s/$/.ko/; - } -} - -unless (grep /af_packet/, @ndrivers) { - unshift(@ndrivers, "af_packet.ko"); -} - -my $osver_host; -if (`grep VERSION /etc/os-release` =~ /VERSION = (\d+)/) { - $osver_host = $1; -} else { - $osver_host = 11; -} - -unless ($onlyinitrd) { - - # now, let's handle the extra packages - unless ($imagename) { - $otherpkglist = imgutils::get_profile_def_filename($osver, $profile, $arch, $customdir, "otherpkgs.pkglist"); - unless ($otherpkglist) { $otherpkglist = imgutils::get_profile_def_filename($osver, $profile, $arch, $pathtofiles, "otherpkgs.pkglist"); } - $updates{'otherpkglist'} = $otherpkglist if ($tempfile and $otherpkglist); - } - my %extra_hash = (); - %extra_hash = imgutils::get_package_names($otherpkglist) if ($otherpkglist); - - - # prepare the chroot environment for the root image - - mkpath "$rootimg_dir/etc"; - mkpath "$rootimg_dir/dev"; - - #system "mount -o bind /dev $rootimg_dir/dev"; - unless (-e "$rootimg_dir/dev/zero") { - system "mknod $rootimg_dir/dev/zero c 1 5"; - } - unless (-e "$rootimg_dir/dev/null") { - system "mknod $rootimg_dir/dev/null c 1 3"; #that's neccessary for SLES11 - } - - unless (-e "$rootimg_dir/dev/random") { - system "mknod $rootimg_dir/dev/random c 1 8"; #that's neccessary for SLES11 - } - unless (-e "$rootimg_dir/dev/urandom") { - system "mknod $rootimg_dir/dev/urandom c 1 9"; #that's neccessary for SLES11 - } - - for (my $i = 0 ; $i <= 12 ; $i++) - { - unless (-e "$rootimg_dir/dev/tty$i") { - system "mknod $rootimg_dir/dev/tty$i c 4 $i"; #that's neccessary for SLES11 - } - } - - open($fd, ">>", "$rootimg_dir/etc/fstab"); # TODO: is it necessary? - print $fd "#Dummy fstab for rpm postscripts to see\n"; - close($fd); - - my $non_interactive; - if (!$prompt) { $non_interactive = "--non-interactive --no-gpg-checks --gpg-auto-import-keys"; } - - if ($osver_host >= 11) { #zypper in SLES11 is different - - system("rm -rf $rootimg_dir/etc/zypp/repos.d/$osver-*.repo"); - my @pkgdirs = split(",", $srcdir); - my $dir; - my $i = 0; - - # To support multiple paths for osimage.pkgdir - foreach $dir (@pkgdirs) { - my $ddir = $dir; - if (-d "$dir/1") { - $ddir .= "/1"; - } - system("zypper -R $rootimg_dir $non_interactive ar file:$ddir $osver-$i"); - $i++; - if (-d "$dir/2") { - $ddir = $dir . "/2"; - system("zypper -R $rootimg_dir $non_interactive ar file:$ddir $osver-$i"); - $i++; - } - } - - #if(-e "$rootimg_dir/etc/zypp/repos.d/$osver.repo") { - # system("rm -rf $rootimg_dir/etc/zypp/repos.d/$osver.repo"); - #} - #system("zypper -R $rootimg_dir $non_interactive ar file:$srcdir $osver"); - #if(-e "$rootimg_dir/etc/zypp/repos.d/${osver}sdk.repo") { - # system("rm -rf $rootimg_dir/etc/zypp/repos.d/${osver}sdk.repo"); - #} - if (opendir(SRCDIR, "$installroot/$osver/$arch/")) { - while (my $tmpfile = readdir(SRCDIR)) { - if ($tmpfile =~ m/^sdk/) { - my $srcdir_sdk = "$installroot/$osver/$arch/${tmpfile}"; - if (-d "$srcdir_sdk") { - system("zypper -R $rootimg_dir $non_interactive ar file:$srcdir_sdk ${osver}${tmpfile}"); - } - } - } - } - } else { - $srcdir = $srcdir . "/1"; - system("zypper -R $rootimg_dir $non_interactive sa file:$srcdir"); - } - - # Add the rep for kernel packages - if ($kernelver) { - if (!-d $kerneldir) { - print "Cannot find the directory for the kernel at $kerneldir.\n"; - exit 1; - } - if ($osver_host >= 11) { - if (-e "$rootimg_dir/etc/zypp/repos.d/$kernelver.repo") { - system("rm -rf $rootimg_dir/etc/zypp/repos.d/$kernelver.repo"); - } - system("zypper -R $rootimg_dir $non_interactive ar file:$kerneldir $kernelver"); - } else { - system("zypper -R $rootimg_dir $non_interactive sa file:$kerneldir"); - } - } - - #remove the old repository for extra packages - if ($osver_host >= 11) { - my $result = `zypper -R $rootimg_dir $non_interactive lr |grep otherpkg|cut -f2 -d '|'|tr "\n" " "`; - if ($result =~ /\S/) { - system("zypper -R $rootimg_dir $non_interactive rr $result"); - } - } else { - my $result = `zypper -R $rootimg_dir $non_interactive sl |grep otherpkg|cut -f2 -d '|'|tr "\n" " "`; - if ($result =~ /\S/) { - system("zypper -R $rootimg_dir $non_interactive sd $result"); - } - } - - #add the new repository for extra packages - my %extrapkgnames; - if ($osver_host >= 11) { #SLES11 - if (-e "$rootimg_dir/etc/zypp/repos.d/otherpkg.repo") { - system("rm -rf $rootimg_dir/etc/zypp/repos.d/otherpkg.repo"); - } - } - my $index = 1; - my $pass; - foreach $pass (sort { $a <=> $b } (keys(%extra_hash))) { - foreach (keys(%{ $extra_hash{$pass} })) { - - if ($_ eq "INCLUDEBAD") { - print "Unable to open the following pkglist files:\n" . join("\n", @{ $extra_hash{$pass}{INCLUDEBAD} }); - exit 1; - } - - if (($_ eq "PRE_REMOVE") || ($_ eq "POST_REMOVE") || ($_ eq "ENVLIST")) { next; } - my $whole_path = "$srcdir_otherpkgs/$_"; - if (-r "$srcdir_otherpkgs/$_/repodata/repomd.xml") { - if ($osver_host >= 11) { - system("zypper -R $rootimg_dir $non_interactive ar file:$srcdir_otherpkgs/$_ otherpkg$index"); - } else { - system("zypper -R $rootimg_dir $non_interactive sa file:$srcdir_otherpkgs/$_"); - } - } else { - if ($osver_host >= 11) { - system("zypper -R $rootimg_dir $non_interactive ar -t Plaindir file:$srcdir_otherpkgs/$_ otherpkg$index"); - } else { - system("zypper -R $rootimg_dir $non_interactive sa -t Plaindir file:$srcdir_otherpkgs/$_"); - } - } - $index++; - - my $pa = $extra_hash{$pass}{$_}; - $extrapkgnames{$pass} .= " " . join(' ', @$pa); - } - } - - #-- add custom repositories to the image - #TODO: should we add the support to otherpkgs for this? we have too many list files and it seems only SLES supports this - # not sure, but it is convenient - my $repolist; - $repolist = imgutils::get_profile_def_filename($osver, $profile, $arch, $customdir, "repolist"); - unless ($repolist) { - $repolist = imgutils::get_profile_def_filename($osver, $profile, $arch, $pathtofiles, "repolist"); - } - - if (-r "$repolist") { - print "Reading custom repositories\n"; - open($repoconfig, "<", "$repolist"); - while (<$repoconfig>) { - chomp; - next if /^\s*#/; - my ($repotype, $repourl, $repoalias) = split m/\|/; - if ($osver_host >= 11) { - system("zypper -R $rootimg_dir $non_interactive ar $repourl $repoalias"); - } else { - system("zypper -R $rootimg_dir $non_interactive sa $repourl $repoalias"); - } - } - } - - # Refresh the zypper cache in case there is still old data out there - system("zypper -R $rootimg_dir $non_interactive refresh"); - - #my $yumcmd = "yum -y -c /tmp/genimage.$$.yum.conf --installroot=$rootimg_dir --disablerepo=* "; - #$yumcmd .= "install "; - #mkpath("$rootimg_dir/var/lib/yum"); - mkpath("$rootimg_dir/etc/"); - my $passwdfile; - open($passwdfile, ">", "$rootimg_dir/etc/passwd"); - print $passwdfile "root:x:0:0:root:/root:/bin/bash\n"; - my $yumcmd; - if ($osver_host < 11) { - $yumcmd = "zypper -R $rootimg_dir $non_interactive install "; - } else { - $yumcmd = "zypper -R $rootimg_dir $non_interactive install -l --no-recommends "; #add -l for SLES11 - } - - #install packages from pkglist file - my $pkgnames; - unless ($imagename) { - $pkglist = imgutils::get_profile_def_filename($osver, $profile, $arch, $customdir, "pkglist"); - unless ($pkglist) { $pkglist = imgutils::get_profile_def_filename($osver, $profile, $arch, $pathtofiles, "pkglist"); } - } - - if ($pkglist) { - $updates{'pkglist'} = $pkglist if ($tempfile); - } else { - print "Unable to find package list for $profile!"; - exit 1; - } - - my %pkg_hash = imgutils::get_package_names($pkglist); - my $index = 1; - foreach $pass (sort { $a <=> $b } (keys(%pkg_hash))) { - $pkgnames = ""; - $group_pkgnames = ""; - foreach (keys(%{ $pkg_hash{$pass} })) { - - if ($_ eq "INCLUDEBAD") { - print "Unable to open the following pkglist files:\n" . join("\n", @{ $pkg_hash{$pass}{INCLUDEBAD} }); - exit 1; - } - - if (($_ eq "PRE_REMOVE") || ($_ eq "POST_REMOVE") || ($_ eq "ENVLIST")) { next; } - my $pa = $pkg_hash{$pass}{$_}; - - # replace the kernel package with the name has the specific version - my @npa = (); - my @npa_group = (); - foreach my $p (@$pa) { - if ($p =~ /^kernel/ && $kernelver) { - - # get all files in $srcdir and $kerneldir - my @alldirs = ("$srcdir", "$kerneldir"); - my @allrpms = (); - foreach my $dir (@alldirs) { - my @files = `find $dir -name *.rpm`; - push @allrpms, @files; - } - my @kernelpkgs = (); - if ($p =~ /^kernel$/) { - @kernelpkgs = ("kernel-default", "kernel-default-base"); - } elsif ($p =~ /^kernel-ppc64$/) { - @kernelpkgs = ($p, $p . "-base"); - } else { - @kernelpkgs = ($p); - } - foreach my $kern (@kernelpkgs) { - my @rpm = grep /$kern-$krpmver/, @allrpms; - if (!@rpm) { - print "Cannot find the kernel package with the versioin $krpmver.\n"; - exit 1; - } - my $kernelname = "$kern-" . $krpmver; - push @npa, $kernelname; - } - } else { - if ($p =~ s/^@//) - { - push @npa_group, $p; - } - else - { - push @npa, $p; - } - } - } - if (@npa) { - $pkgnames .= " " . join(' ', @npa); - } - if (@npa_group) { - $group_pkgnames .= " " . join(' ', @npa_group); - } - } - my $envlist; - if (exists $pkg_hash{$pass}{ENVLIST}) { - $envlist = join(' ', @{ $pkg_hash{$pass}{ENVLIST} }); - } - if ($pkgnames) - { - print "$envlist $yumcmd $pkgnames\n"; - $rc = system("$envlist $yumcmd $pkgnames"); - $rc = $rc >> 8; - if (($rc) && ($rc != '104')) { - print "zypper invocation failed with rc: $rc\n"; - exit 1; - } - } - if ($group_pkgnames) - { - print "$envlist $yumcmd -t pattern $group_pkgnames\n"; - $rc = system("$envlist $yumcmd -t pattern $group_pkgnames"); - $rc = $rc >> 8; - if (($rc) && ($rc != '104')) { - print "zypper invocation failed with rc: $rc\n"; - exit 1; - } - } - } - - foreach $pass (sort { $a <=> $b } (keys(%extra_hash))) { - - my $index = 1; - - #remove the old repository for extra packages - if ($osver_host >= 11) { - my $result = `zypper -R $rootimg_dir $non_interactive lr |grep otherpkg|cut -f2 -d '|'|tr "\n" " "`; - if ($result =~ /\S/) { - system("zypper -R $rootimg_dir $non_interactive rr $result"); - } - } else { - my $result = `zypper -R $rootimg_dir $non_interactive sl |grep otherpkg|cut -f2 -d '|'|tr "\n" " "`; - if ($result =~ /\S/) { - system("zypper -R $rootimg_dir $non_interactive sd $result"); - } - } - - foreach (keys(%{ $extra_hash{$pass} })) { - if (($_ eq "PRE_REMOVE") || ($_ eq "POST_REMOVE") || ($_ eq "ENVLIST")) { next; } - if (-r "$srcdir_otherpkgs/$_/repodata/repomd.xml") { - if ($osver_host >= 11) { - system("zypper -R $rootimg_dir $non_interactive ar file:$srcdir_otherpkgs/$_ otherpkg$index"); - } else { - system("zypper -R $rootimg_dir $non_interactive sa file:$srcdir_otherpkgs/$_"); - } - } else { - if ($osver_host >= 11) { - system("zypper -R $rootimg_dir $non_interactive ar -t Plaindir file:$srcdir_otherpkgs/$_ otherpkg$index"); - } else { - system("zypper -R $rootimg_dir $non_interactive sa -t Plaindir file:$srcdir_otherpkgs/$_"); - } - } - $index++; - } - - # Refresh the zypper cache in case there is still old data out there - system("zypper -R $rootimg_dir $non_interactive refresh"); - - #remove the packages that are specified in the otherpkgs.list files with leading '-' - my $envlist; - if (exists $extra_hash{$pass}{ENVLIST}) { - $envlist = join(' ', @{ $extra_hash{$pass}{ENVLIST} }); - } - - my $yumcmd_remove = "zypper -R $rootimg_dir $non_interactive remove "; - if (exists($extra_hash{$pass}{'PRE_REMOVE'})) { - my $pa = $extra_hash{$pass}{'PRE_REMOVE'}; - my $rm_packges = join(' ', @$pa); - if ($rm_packges) { - print "$envlist $yumcmd_remove $rm_packges"; - $rc = system("$envlist $yumcmd_remove $rm_packges"); - } - } - - - #add extra packages in the list - if ($extrapkgnames{$pass}) { - print "$envlist $yumcmd $extrapkgnames{$pass}\n"; - $rc = system("$envlist $yumcmd $extrapkgnames{$pass}"); - $rc = $rc >> 8; - if (($rc) && ($rc != '104')) { - print "zypper invocation failed with rc: $rc\n"; - exit 1; - } - } - - #remove the packages that are specified in the otherpkgs.list files with leading '--' - if (exists($extra_hash{$pass}{'POST_REMOVE'})) { - my $pa = $extra_hash{$pass}{'POST_REMOVE'}; - my $rm_packges = join(' ', @$pa); - if ($rm_packges) { - print "$envlist $yumcmd_remove $rm_packges"; - $rc = system("$envlist $yumcmd_remove $rm_packges"); - } - } - - if (!$noupdate) { - - # run zypper update to update any installed rpms - # needed when running genimage again after updating software in repositories - my $yumcmd_update; - if ($osver_host >= 11) { - $yumcmd_update = "zypper -R $rootimg_dir $non_interactive update "; - } else { - $yumcmd_update = "zypper -R $rootimg_dir $non_interactive update "; - } - $rc = system("$yumcmd_update"); - } - } - - #remove the old repository for extra packages - if ($osver_host >= 11) { - my $result = `zypper -R $rootimg_dir $non_interactive lr |grep otherpkg|cut -f2 -d '|'|tr "\n" " "`; - if ($result =~ /\S/) { - system("zypper -R $rootimg_dir $non_interactive rr $result"); - } - } else { - my $result = `zypper -R $rootimg_dir $non_interactive sl |grep otherpkg|cut -f2 -d '|'|tr "\n" " "`; - if ($result =~ /\S/) { - system("zypper -R $rootimg_dir $non_interactive sd $result"); - } - } - - # ignore any return code - - postscripts(); #run 'postscripts' -} -unlink "/tmp/genimage.$$.yum.conf"; - -# added dracut mode -if ((-d "$rootimg_dir/usr/share/dracut") or (-d "$rootimg_dir/usr/lib/dracut")) { - $dracutmode = 1; - - # get dracut version - $dracutver = `chroot $rootimg_dir rpm -qi dracut | awk '/Version/{print \$3}' | awk -F. '{print \$1}'`; - chomp($dracutver); - if ($dracutver =~ /^\d\d\d$/) { - if ($dracutver >= "033") { - $dracutdir = "dracut_033"; - } else { - $dracutdir = "dracut"; # The default directory - } - } - print "Enter the dracut mode. Dracut version: $dracutver. Dracut directory: $dracutdir.\n"; -} - -# default to the first kernel found in the install image if nothing specified explicitly. -# A more accurate guess than whatever the image build server happens to be running -# If specified, that takes precedence. -# If image has one, that is used -# If all else fails, resort to uname -r like this script did before - -if (-e "$rootimg_dir/boot/vmlinux") { - $basekernelver = basename(readlink "$rootimg_dir/boot/vmlinux"); - if ($basekernelver eq "vmlinux") { - $basekernelver = ""; - } else { - $basekernelver =~ s/vmlinu.-//; - $basekernelver =~ s/image-//; - } -} - -unless ($basekernelver) { - my @KVERS = <$rootimg_dir/boot/vmlinu[xz]-*>; - - # The kernel name is different on s390x, e.g. image-2.6.32.9-0.5-default - @KVERS = <$rootimg_dir/boot/image-*> if $arch eq "s390x"; - foreach (@KVERS) { - s/vmlinu.-//; - s/image-//; - } - unless (scalar @KVERS) { - @KVERS = <$rootimg_dir/lib/modules/*>; - } - if (scalar @KVERS) { - foreach my $kver (@KVERS) { - unless ($kver =~ m/.gz$/) { - $basekernelver = basename($kver); - last; - } - } - } - - @KVERS = <$rootimg_dir/lib/modules/*> unless (scalar @KVERS); - $basekernelver = basename(pop @KVERS) if (scalar @KVERS); - $basekernelver = `uname -r` unless ($basekernelver); -} - -$kernelver = $basekernelver unless ($kernelver); -chomp $kernelver; - -#$updates{kernelver} = $kernelver if ($tempfile); - -# copy the kernel to $destdir -if (-e "$rootimg_dir/boot/vmlinux-$kernelver") { - copy("$rootimg_dir/boot/vmlinux-$kernelver", "$destdir/kernel"); -} elsif (-e "$rootimg_dir/boot/vmlinuz-$kernelver") { - copy("$rootimg_dir/boot/vmlinuz-$kernelver", "$destdir/kernel"); -} elsif (-e "$rootimg_dir/boot/image-$kernelver") { - copy("$rootimg_dir/boot/image-$kernelver", "$destdir/kernel"); -} else { - xdie "couldn't find the kernel file matched $kernelver in $rootimg_dir/boot !"; -} - -#-- run postinstall script -unless ($imagename) { - $postinstall_filename = imgutils::get_profile_def_filename($osver, $profile, $arch, $customdir, "postinstall"); - unless ($postinstall_filename) { - $postinstall_filename = imgutils::get_profile_def_filename($osver, $profile, $arch, $pathtofiles, "postinstall"); - } -} - -if ($postinstall_filename) { - - #print "postinstall_filename=$postinstall_filename\n"; - - #For Mellonax IB script. In diskless image, the uname -r not returning the rootimg level, - #because the "uname -r" only returns the version of the kernel in use - #create a temporary uname script. for every flag except for -r, it should just call the real - #uname with the same flags and return that info. - if (!(-e "$rootimg_dir/bin/orig_uname")) { - system("mv $rootimg_dir/bin/uname $rootimg_dir/bin/orig_uname"); - } - my $tmpuname; - open($tmpuname, ">", "$rootimg_dir/bin/uname"); - print $tmpuname <>$tempfile"); - if ($imagename) { - if (keys(%updates) > 0) { - print FILE "The output for table updates starts here\n"; - print FILE "table::linuximage\n"; - print FILE "imagename::$imagename\n"; - my @a = %updates; - print FILE join('::', @a) . "\n"; - print FILE "The output for table updates ends here\n"; - } - } else { - $updates_os{'profile'} = $profile; - $updates_os{'imagetype'} = 'linux'; - $updates_os{'provmethod'} = 'netboot'; - $updates_os{'osname'} = 'Linux'; - $updates_os{'osvers'} = $osver; - $updates_os{'osdistroname'} = 'sle'; # not used currently - $updates_os{'osarch'} = $arch; - - # update the imagename for stateless - print FILE "The output for table updates starts here\n"; - print FILE "table::osimage\n"; - print FILE "imagename::$osver-$arch-netboot-$profile\n"; - my @a = %updates_os; - print FILE join('::', @a) . "\n"; - print FILE "The output for table updates ends here\n"; - - print FILE "The output for table updates starts here\n"; - print FILE "table::linuximage\n"; - print FILE "imagename::$osver-$arch-netboot-$profile\n"; - my @a = %updates; - print FILE join('::', @a) . "\n"; - print FILE "The output for table updates ends here\n"; - - # update the imagename for statelite - $updates_os{'provmethod'} = 'statelite'; - print FILE "The output for table updates starts here\n"; - print FILE "table::osimage\n"; - print FILE "imagename::$osver-$arch-statelite-$profile\n"; - my @a = %updates_os; - print FILE join('::', @a) . "\n"; - print FILE "The output for table updates ends here\n"; - - print FILE "The output for table updates starts here\n"; - print FILE "table::linuximage\n"; - print FILE "imagename::$osver-$arch-statelite-$profile\n"; - my @a = %updates; - print FILE join('::', @a) . "\n"; - print FILE "The output for table updates ends here\n"; - } - close FILE; -} - -#END - - - -mkpath "$rootimg_dir/.statelite"; # create place for NFS mounts; -mkpath "$rootimg_dir/.sllocal/localmnt"; # create place for localdisk mount -mkpath "$rootimg_dir/.sllocal/log"; # create place for localdisk log - -mkpath "$rootimg_dir/root/.ssh"; # create place for NFS mounts for ssh; #TODO is necessary? - -# this script will get the directories; -# TODO: it seems it is re-copied in liteimg.pm -unless (-r "$pathtofiles/../add-on/statelite/rc.statelite") { - print "Can't find $pathtofiles/../add-on/statelite/rc.statelite!\n"; - exit; -} -system("cp $pathtofiles/../add-on/statelite/rc.statelite $rootimg_dir/etc/init.d/statelite"); -system("cp $pathtofiles/../add-on/statelite/rc.localdisk $rootimg_dir/etc/init.d/localdisk"); - -# added dracutmode -unless ($dracutmode) { #in dracut mode, we delegate all this activity - unless (-l "$rootimg_dir/var/lib/dhclient") { - mkpath "$rootimg_dir/var/lib/dhclient/"; - system("touch $rootimg_dir/var/lib/dhclient/dhclient-$prinic.leases"); - } - - unless (-l "$rootimg_dir/var/lib/dhcp") { - mkpath "$rootimg_dir/var/lib/dhcp/"; - system("touch $rootimg_dir/var/lib/dhcp/dhclient-$prinic.leases"); - } -} - - -# the dhcp client information stores in the directory "/var/lib/dhcpcd/" -unless (-l "$rootimg_dir/var/lib/dhcpcd") { - mkpath "$rootimg_dir/var/lib/dhcpcd/"; - system("touch $rootimg_dir/var/lib/dhcpcd/dhcpcd-$prinic.info"); -} - -#keyctl moved to /bin for newer release -system("cd $rootimg_dir/usr/bin/; ln -s ../../bin/keyctl $rootimg_dir/usr/bin/keyctl"); - -# which is different from the Redhat family - -# some rpms mounts the imageroot/proc on the /proc, need to release it, -# otherwise got kernal panic when installing -# sometimes, the proc fs is not mounted, so one warning/error message will display, -# and I add one check point here. -my $MFD; -open MFD, "/proc/mounts"; -my @lines = ; -close MFD; - -my $ret = grep m{$rootimg_dir/proc}, @lines; -if ($ret > 0) { - system("umount -l $rootimg_dir/proc"); -} - -# Load driver update disk, and copy them to the root image -my @dd_drivers = &load_dd(); - -# Push the drivers into the @ndrivers base on the order -my @new_order = (); -foreach my $dd (@dd_drivers) { - unless (grep { $_ eq $dd } @ndrivers) { - push @new_order, $dd; - } - print "Added driver $dd from driver update disk or driver rpm\n"; -} - -if (@new_order) { - @ndrivers = (@new_order, @ndrivers); -} - -# add drivers for local disk support -push @ndrivers, ("ext3.ko", "ext4.ko", "virtio_pci.ko", "virtio_blk.ko", "libata.ko", "scsi_mod.ko", "scsi_dh.ko", "ahci.ko", "megaraid_sas.ko", "sd_mod.ko"); - -if ($osver_host >= 12) { - push @ndrivers, ("ibmvscsi.ko"); -} else { # for sles11 or lower - push @ndrivers, ("ibmvscsic.ko", "ata_piix.ko", "pcieport.ko"); -} - -if (-f "$rootimg_dir/lib/modules/$kernelver/kernel/drivers/net/ethernet/mellanox/mlx4/mlx4_en.ko") { - for (@ndrivers) { - s/mlx_en/mlx4_en/; - } -} - -open($moddeps, "<", "$rootimg_dir/lib/modules/$kernelver/modules.dep"); -my @moddeps = <$moddeps>; -my @checkdeps = @ndrivers; -while (scalar @checkdeps) { - my $driver = pop @checkdeps; - my @lines = grep /\/$driver:/, @moddeps; - foreach (@lines) { - chomp; - s/.*://; - s/^\s*//; - my @deps = split /\s+/, $_; - if ($driver =~ /libcrc32c.ko/) { - push @deps, 'crc32c.ko'; - } - my $dep; - foreach $dep (@deps) { - $dep =~ s/.*\///; - unless (grep { $_ eq $dep } @ndrivers) { #only add if not added - print "Added $dep as an autodetected dependency\n"; - } - unshift(@checkdeps, $dep); #recursively check dependencies - unshift(@ndrivers, $dep); - } - } -} -close($moddeps); - -#remove the duplicated drivers -my @fulldrivers; -foreach my $dn (@ndrivers) { - unless (grep { $_ eq $dn } @fulldrivers) { - push @fulldrivers, $dn; - } -} -@ndrivers = @fulldrivers; - -# before mkinitrd, run depmod to generate the modules.dep -system("chroot $rootimg_dir depmod $kernelver"); - -if ($dracutmode) { - mkinitrd_dracut("stateless"); - mkinitrd_dracut("statelite"); -} else { - my @drivers; # backup of @ndrivers - push @drivers, @ndrivers; - mkinitrd("statelite"); - @ndrivers = (); - push @ndrivers, @drivers; - mkinitrd("stateless"); -} -print "It is safe to ignore message 'Failed to connect to bus: No such file or directory' that may have appeared above one or more times.\n"; - -sub getlibs { - my $file = shift; - my $liblist = `chroot $rootimg_dir ldd $file`; - if ($liblist =~ /not a dynamic executable/) { - return; - } - my @libs = split /\n/, $liblist; - my @return; - foreach (@libs) { - unless (/=>/) { - (my $wjnk, my $lib, my $jnk) = split /\s+/, $_, 3; - $lib =~ s/^\///; - $libhash{$lib} = 1; - next; - } - (my $temp1, my $temp2) = split />/, $_, 2; - (my $whitespace, $temp1, $temp2) = split /\s+/, $temp2, 4; - unless ($temp1 =~ /\//) { - next; - } - $temp1 =~ s/^\///; - $libhash{$temp1} = 1; - } -} - -#added dracut -sub mkinitrd_dracut { - my ($mode) = @_; # the mode is for statelite or stateless - - my $dracutmoduledir = "$rootimg_dir/usr/share/dracut/modules.d/"; - if ((!-d $dracutmoduledir) and (-d "$rootimg_dir/usr/lib/dracut/modules.d/")) - { - $dracutmoduledir = "$rootimg_dir/usr/lib/dracut/modules.d/"; - } - - if ($dracutver >= "033") { - - my $perm = (stat("$fullpath/$dracutdir/patch/syslog/module-setup.sh"))[2]; - cp("$fullpath/$dracutdir/patch/syslog/module-setup.sh", $dracutmoduledir . "98syslog/"); - chmod($perm & 07777, $dracutmoduledir . "98syslog/" . "module-setup.sh"); - - $perm = (stat("$fullpath/$dracutdir/patch/syslog/rsyslogd-start.sh"))[2]; - cp("$fullpath/$dracutdir/patch/syslog/rsyslogd-start.sh", $dracutmoduledir . "98syslog/"); - chmod($perm & 07777, $dracutmoduledir . "98syslog/" . "rsyslogd-start.sh"); - - $perm = (stat("$fullpath/$dracutdir/patch/syslog/syslog-genrules.sh"))[2]; - cp("$fullpath/$dracutdir/patch/syslog/syslog-genrules.sh", $dracutmoduledir . "98syslog/"); - chmod($perm & 07777, $dracutmoduledir . "98syslog/" . "syslog-genrules.sh"); - - } - - my $dracutmpath = $dracutmoduledir . "97xcat/"; - mkpath($dracutmpath); - - my $perm = (stat("$fullpath/$dracutdir/check"))[2]; - cp("$fullpath/$dracutdir/check", $dracutmpath); - chmod($perm & 07777, "$dracutmpath/check"); - - foreach (@ndrivers) { s/\.ko$//; } - - # Add drivers to support local disk - push @ndrivers, "ext3"; - push @ndrivers, "ext4"; - - #remove the duplicated drivers - my @fulldrivers; - foreach my $dn (@ndrivers) { - unless (grep { $_ eq $dn } @fulldrivers) { - push @fulldrivers, $dn; - } - } - @ndrivers = @fulldrivers; - - my $add_drivers = join(' ', @ndrivers); - print "Try to load drivers: $add_drivers to initrd.\n"; - my $DRACUTCONF; - - if ($mode eq "statelite") { - - # for statelite - cp("$fullpath/$dracutdir/install.statelite", "$dracutmpath/install"); - $perm = (stat("$fullpath/$dracutdir/install.statelite"))[2]; - chmod($perm & 07777, "$dracutmpath/install"); - - cp("$installroot/postscripts/updateflag.awk", "$dracutmpath/xcat-updateflag"); - $perm = (stat("$installroot/postscripts/updateflag.awk"))[2]; - chmod($perm & 07777, "$dracutmpath/xcat-updateflag"); - - cp("$fullpath/$dracutdir/xcat-prepivot.sh", $dracutmpath); - $perm = (stat("$fullpath/$dracutdir/xcat-prepivot.sh"))[2]; - chmod($perm & 07777, "$dracutmpath/xcat-prepivot.sh"); - - cp("$fullpath/$dracutdir/xcat-premount.sh", $dracutmpath); - $perm = (stat("$fullpath/$dracutdir/xcat-premount.sh"))[2]; - chmod($perm & 07777, "$dracutmpath/xcat-premount.sh"); - - #update etc/dracut.conf - open($DRACUTCONF, '>', "$rootimg_dir/etc/dracut.conf"); - if (-d glob($dracutmoduledir . "[0-9]*fadump")) { - print $DRACUTCONF qq{dracutmodules+="xcat nfs base network kernel-modules lvm fadump"\n}; - } - else { - print $DRACUTCONF qq{dracutmodules+="xcat nfs base network kernel-modules lvm"\n}; - } - print $DRACUTCONF qq{add_drivers+="$add_drivers"\n}; - print $DRACUTCONF qq{filesystems+="nfs"\n}; - close $DRACUTCONF; - } elsif ($mode eq "stateless") { - cp("$fullpath/$dracutdir/install.netboot", "$dracutmpath/install"); - $perm = (stat("$fullpath/$dracutdir/install.netboot"))[2]; - chmod($perm & 07777, "$dracutmpath/install"); - - cp("$fullpath/$dracutdir/xcat-cmdline.sh", "$dracutmpath/"); - $perm = (stat("$fullpath/$dracutdir/xcat-cmdline.sh"))[2]; - chmod($perm & 07777, "$dracutmpath/xcat-cmdline.sh"); - - cp("$installroot/postscripts/updateflag.awk", "$dracutmpath/xcat-updateflag"); - $perm = (stat("$installroot/postscripts/updateflag.awk"))[2]; - chmod($perm & 07777, "$dracutmpath/xcat-updateflag"); - if ($prinic) { - my $optspec; - open($optspec, '>>', "$dracutmpath/xcat-cmdline.sh"); - print $optspec "PRINIC=$prinic\n"; - close $optspec; - } - - cp("$fullpath/$dracutdir/xcatroot", "$dracutmpath/"); - $perm = (stat("$fullpath/$dracutdir/xcatroot"))[2]; - chmod($perm & 07777, "$dracutmpath/xcatroot"); - - cp("$fullpath/$dracutdir/installkernel", "$dracutmpath/"); - $perm = (stat("$fullpath/$dracutdir/installkernel"))[2]; - chmod($perm & 07777, "$dracutmpath/installkernel"); - - # update etc/dracut.conf - open($DRACUTCONF, '>', "$rootimg_dir/etc/dracut.conf"); - if (-d glob($dracutmoduledir . "[0-9]*fadump")) { - print $DRACUTCONF qq{dracutmodules+="xcat nfs base network kernel-modules lvm fadump syslog"\n}; - } - else { - print $DRACUTCONF qq{dracutmodules+="xcat nfs base network kernel-modules lvm syslog"\n}; - } - print $DRACUTCONF qq{add_drivers+="$add_drivers"\n}; - close $DRACUTCONF; - } else { - xdie "the mode: $mode is not supported by genimage"; - } - - my $additional_options = undef; - if ($rootlimit) - { - open(my $ETC_CMDLINE, ">", "$rootimg_dir/tmp/cmdline"); - print $ETC_CMDLINE qq{rootlimit=$rootlimit\n}; - close $ETC_CMDLINE; - $additional_options = qq{--include /tmp/cmdline /etc/cmdline}; - } - - # force the dracut run in non-hostonly mode for dracut higher than version 033 - if ($dracutver > "033") { - $additional_options .= " -N"; - } - - #if "pigz" is available in the rootimg, use "pigz" instead of "gzip" - my $compress = qx(chroot $rootimg_dir bash -c "type -p pigz"|tr -d "\n"); - if ($compress) { - - #take the online cpu numerber as the pigz processes number - my $processnum = qx(lscpu -p=cpu --online|grep -v '#'|wc -l|tr -d "\n"); - $additional_options .= " --compress \"$compress -p $processnum \""; - } - - print "\nchroot $rootimg_dir dracut $additional_options -f /tmp/initrd.$$.gz $kernelver\n"; - !system("chroot $rootimg_dir dracut $additional_options -f /tmp/initrd.$$.gz $kernelver") - or die("Error: failed to generate the initial ramdisk for $mode.\n"); - print "the initial ramdisk for $mode is generated successfully.\n"; - move("$rootimg_dir/tmp/initrd.$$.gz", "$destdir/initrd-$mode.gz"); -} - - -sub mkinitrd { - my ($mode) = @_; # statelite or stateless - - if ($mode eq "statelite") { - - # additional modules needed on s390x - push @ndrivers, qw{qdio.ko ccwgroup.ko qeth.ko qeth_l2.ko qeth_l3.ko} if ($arch eq "s390x"); - - # for nfs - my @modlist = qw{sunrpc.ko lockd.ko nfs_acl.ko fscache.ko auth_rpcgss.ko exportfs.ko nfsd.ko nfs.ko}; - unshift(@ndrivers, @modlist); - } - - mkpath("/tmp/xcatinitrd.$$/bin"); - symlink("bin", "/tmp/xcatinitrd.$$/sbin"); - mkpath("/tmp/xcatinitrd.$$/usr/bin"); - mkpath("/tmp/xcatinitrd.$$/usr/sbin"); - mkpath("/tmp/xcatinitrd.$$/usr/lib"); - mkpath("/tmp/xcatinitrd.$$/usr/lib64"); - mkpath("/tmp/xcatinitrd.$$/lib/firmware"); - mkpath("/tmp/xcatinitrd.$$/tmp"); - mkpath("/tmp/xcatinitrd.$$/var/run"); - mkpath("/tmp/xcatinitrd.$$/lib64/firmware"); - mkpath("/tmp/xcatinitrd.$$/lib/power6"); #SLES10 - mkpath("/tmp/xcatinitrd.$$/lib/power7"); #SLES10 - mkpath("/tmp/xcatinitrd.$$/lib/mkinitrd/bin"); - mkpath("/tmp/xcatinitrd.$$/proc"); - mkpath("/tmp/xcatinitrd.$$/sys"); - mkpath("/tmp/xcatinitrd.$$/dev/mapper"); - mkpath("/tmp/xcatinitrd.$$/sysroot"); - mkpath("/tmp/xcatinitrd.$$/etc/ld.so.conf.d"); - mkpath("/tmp/xcatinitrd.$$/var/lib/dhcpcd"); - my $inifile; - open($inifile, ">", "/tmp/xcatinitrd.$$/init"); - print $inifile "#!/bin/bash\n"; - - # copied from genimage for rh - # add some functions - print $inifile < <\\ \\____/ | \\ | - /__/\\_ \\\\______ /\\____|__ /____| - \\/ \\/ \\/ -' - echo -e "\$RESET" -} - - -EOS1 - - print $inifile "mount -t proc /proc /proc\n"; - print $inifile "mount -t sysfs /sys /sys\n"; - print $inifile "mount -o mode=0755 -t tmpfs /dev /dev\n"; - print $inifile "mkdir /dev/pts\n"; - print $inifile "mount -t devpts -o gid=5,mode=620 /dev/pts /dev/pts\n"; - print $inifile "mkdir /dev/shm\n"; - print $inifile "mkdir /dev/mapper\n"; - - print $inifile "mknod /dev/random c 1 8\n"; - print $inifile "mknod /dev/urandom c 1 9\n"; - print $inifile "mknod /dev/null c 1 3\n"; - print $inifile "mknod /dev/zero c 1 5\n"; - print $inifile "mknod /dev/systty c 4 0\n"; - print $inifile "mknod /dev/tty c 5 0\n"; - print $inifile "mknod /dev/console c 5 1\n"; - print $inifile "mknod /dev/ptmx c 5 2\n"; - print $inifile "mknod /dev/rtc c 10 135\n"; - print $inifile "mknod /dev/tty0 c 4 0\n"; - print $inifile "mknod /dev/tty1 c 4 1\n"; - print $inifile "mknod /dev/tty2 c 4 2\n"; - print $inifile "mknod /dev/tty3 c 4 3\n"; - print $inifile "mknod /dev/tty4 c 4 4\n"; - print $inifile "mknod /dev/tty5 c 4 5\n"; - print $inifile "mknod /dev/tty6 c 4 6\n"; - print $inifile "mknod /dev/tty7 c 4 7\n"; - print $inifile "mknod /dev/tty8 c 4 8\n"; - print $inifile "mknod /dev/tty9 c 4 9\n"; - print $inifile "mknod /dev/tty10 c 4 10\n"; - print $inifile "mknod /dev/tty11 c 4 11\n"; - print $inifile "mknod /dev/tty12 c 4 12\n"; - print $inifile "mknod /dev/ttyS0 c 4 64\n"; - print $inifile "mknod /dev/ttyS1 c 4 65\n"; - print $inifile "mknod /dev/ttyS2 c 4 66\n"; - print $inifile "mknod /dev/ttyS3 c 4 67\n"; - - # Install modules before starting udev - # because networking modules (qeth/qeth_l2/qeth_l3) are needed - foreach (@ndrivers) { - print $inifile "insmod /lib/$_\n"; - } - - # Start udev - print $inifile < /dev/null && export DEBUG=1\n"; - } - - print $inifile < /tmp/ifcfg-\$IFACE - -ip addr add dev lo 127.0.0.1/8 -ip link set lo up - - -XCATMASTER=`echo \$XCATSERVER|awk -F: '{print \$1}'` - -if [ -z \$XCATIPORT ]; then - XCATIPORT="3002" -fi - -if [ \$NODESTATUS != 'n' ]; then - /tmp/updateflag \$XCATMASTER \$XCATIPORT "installstatus netbooting" -fi - -cd / -for i in `cat /proc/cmdline`; do - KEY=`echo \$i |awk -F= '{print \$1}'` - if [ "\$KEY" == 'imgurl' ]; then - VALUE=`echo \$i |awk -F= '{print \$2}'` - if [ "http" == "`echo \$VALUE|awk -F: '{print \$1}'`" ]; then - #NOTE needs FT retry code to scale - #NOTE: should prob have max count - FILENAME=`echo \$VALUE|awk -F/ '{print \$NF}'` - while [ ! -r "\$FILENAME" ]; do - echo Getting \$VALUE... - if ! wget \$VALUE; then - sleep 5 #should be random, exponential for scale - rm -f \$FILENAME - fi - done - fi - elif [[ "\$KEY" == NFSROOT ]]; then # for NFSROOT - NFSROOT=1 - VALUE=`echo \$i |awk -F= '{print \$2}'` - SERVER=`echo \$VALUE|awk -F: '{print \$1}'` - ROOTDIR=`echo \$VALUE|awk -F/ '{for(i=2;i<=NF;i++) printf "/%s",\$i}'` - elif [ "\$KEY" == 'STATEMNT' ]; then - STATELITE=1 - VALUE=`echo \$i |awk -F= '{print \$2}'` - # VALUE may be null - if [ ! -z \$VALUE ]; then - SNAPSHOTSERVER=`echo \$VALUE|awk -F: '{print \$1}'` - SNAPSHOTROOT=`echo \$VALUE|awk -F/ '{for(i=2;i<=NF;i++) printf "/%s",\$i}'` - # may be that there is not server and just a directory. - if [ -z \$SNAPSHOTROOT ]; then - SNAPSHOTROOT=\$SNAPSHOTSERVER - SNAPSHOTSERVER= - fi - fi - elif [ "\$KEY" == 'NODE' ]; then - NODENAME=`echo \$i |awk -F= '{print \$2}'` - fi -done - -# show xCAT logo -fancydisplay - -# Statelite code is here -if [ "\$STATELITE" = "1" ]; then - echo Setting up Statelite - mknod /dev/loop0 b 7 0 - mkdir -p \$NEWROOT - MAXTRIES=15 - ITER=0 - ME=`hostname` - if [ ! -z "$NODENAME" ]; then - ME=$NODENAME - fi - if [ "\$NFSROOT" = "1" ]; then - while ! mount.nfs \${SERVER}:\${ROOTDIR}/rootimg \$NEWROOT -r -n -o nolock,rsize=32768,tcp,nfsvers=3,timeo=14; do - ITER=\$(expr \$ITER + 1) - if [ "\$ITER" = "\$MAXTRIES" ]; then - echo "You're dead. rpower \$ME boot to play again." - echo "Possible problems: -1. This initrd wan't created for the statelite node? -2. IS DNS set up? Maybe that's why I can't mount \${SERVER}. -3. The nfs modules aren't set right in this initial ramdisk?" - shell - exit - fi - echo -e "\${RED}Couldn't mount \$SERVER:\$ROOTDIR on \$NEWROOT \$RESET" - RS=\$(expr \$RANDOM % 30) - echo -e "Trying again in \$RS seconds" - sleep \$RS - done - else - # for statelite mode on top of the ramdisk -EOMS - - print $inifile "if [ -r /rootimg-statelite.gz ]; then \n"; - print $inifile "echo Setting up RAM-root tmpfs.\n"; - if ($rootlimit) { - print $inifile " mount -o size=$rootlimit,mode=755 -t tmpfs rootfs \$NEWROOT \n"; - } else { - print $inifile " mount -o mode=755 -t tmpfs rootfs \$NEWROOT \n"; - } - - print $inifile </dev/null && shell - mount -t tmpfs rw -o mode=$permission \$NEWROOT/\$RWDIR - mkdir -p \$NEWROOT/\$RWDIR/tmpfs - - #mount the /root/.ssh, it needs more strict permission in order for ssh work - #if [ ! -e "\$NEWROOT/root/.ssh" ] - #then - # mkdir -p \$NEWROOT/root/.ssh - #fi - #mount -t tmpfs -o mode=755 ssh \$NEWROOT/root/.ssh - - # mount the SNAPSHOT directory here for persistent use. - if [ ! -z \$SNAPSHOTSERVER ] - then - mkdir -p \$NEWROOT/\$RWDIR/persistent - MAXTRIES=5 - ITER=0 - while ! mount \$SNAPSHOTSERVER:\$SNAPSHOTROOT \$NEWROOT/\$RWDIR/persistent -o nolock,\$XCATMNTOPTS - do - ITER=\$(expr \$ITER + 1) - if [ "\$ITER" == "\$MAXTRIES" ] - then - echo "You're 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." - shell - exit - fi - echo -e "\${RED}Hmmm... Can't mount \$SNAPSHOTSERVER:\$SNAPSHOTROOT. \${NORMAL} \$XCATMNTOPTS" - RS=`expr \$RANDOM % 20` - echo -e "Trying again in \$RS seconds" - sleep \$RS - done - - # create directory which is named after my node name - mkdir -p \$NEWROOT/\$RWDIR/persistent/\$ME - ITER=0 - # umount current persistent mount - while ! umount -l \$NEWROOT/\$RWDIR/persistent; do - ITER=\$(( ITER + 1 )) - if [ "\$ITER" == "\$MAXTRIES" ]; then - echo "Your are dead, rpower \$ME boot to play again." - echo "Cannot umount \$NEWROOT/\$RWDIR/persistent." - /bin/sh - exit - fi - RS= \$(( \$RANDOM % 20 )) - echo "Trying again in \$RS seconds..." - sleep \$RS - done - - # mount persistent to server:/rootpath/nodename - ITER=0 - while ! mount \$SNAPSHOTSERVER:/\$SNAPSHOTROOT/\$ME \$NEWROOT/\$RWDIR/persistent -o nolock,\$XCATMNTOPTS; do - ITER=\$(( ITER + 1 )) - if [ "\$ITER" == "\$MAXTRIES" ]; then - echo "Your are dead, rpower \$ME boot to play again." - echo "Possible problems: cannot mount to \$SNAPSHOTSERVER:/\$SNAPSHOTROOT/\$ME." - /bin/sh - exit - fi - RS= \$(( \$RANDOM % 20 )) - echo "Trying again in \$RS seconds..." - sleep \$RS - done - fi - - grep '\\(shell\\)' /proc/cmdline >/dev/null && shell - - # have to preserve the initial DHCP request. So we link it. - # SLES uses different file to store DHCP info - if [ ! -d \$NEWROOT/\$RWDIR/tmpfs/var/lib/dhcpcd ] - then - mkdir -p \$NEWROOT/\$RWDIR/tmpfs/var/lib/dhcpcd - fi - cp -fp /var/lib/dhcpcd/dhcpcd-\$IFACE.info \${NEWROOT}/\${RWDIR}/tmpfs/var/lib/dhcpcd/dhcpcd-\$IFACE.info - - [ -e /etc/ntp.conf ] && mkdir -p \$NEWROOT/\$RWDIR/tmpfs/etc && cp /etc/ntp.conf \$NEWROOT/\$RWDIR/tmpfs/etc/ - - [ -e /etc/resolv.conf ] && mkdir -p \$NEWROOT/\$RWDIR/tmpfs/etc && cp /etc/resolv.conf \$NEWROOT/\$RWDIR/tmpfs/etc/ - - # now that everything is mounted, lets do this - # hmmm, apparently I'm checking this twice... so I'd better - # be really sure the file is there. - while [ ! -e \$NEWROOT/etc/init.d/statelite ] - do - echo "\$NEWROOT/etc/init.d/statelite does not exist in image!" - shell - done - - # try to configure the local disk - \$NEWROOT/etc/init.d/localdisk - - # do all the mounts: - \$NEWROOT/etc/init.d/statelite -EOMS - - # udevd needed by s390x for networking - # but for other type of machine, udevd will affect the start of devices which detected - # after the chroot, so kill it before the switching root - if ($arch ne "s390x") { - print $inifile "\n killall -9 udevd\n"; - } - - print $inifile < /dev/null && shell - - echo 0x100 > /proc/sys/kernel/real-root-dev - export keep_old_ip=yes - export fastboot=yes - export READONLY=yes - grep '\\(shell\\)' /proc/cmdline >/dev/null && shell - mount -n --bind /dev /sysroot/dev - umount /sys - umount /proc - - # sles use the standard utility to chroot - if ! exec /usr/bin/chroot \$NEWROOT /sbin/init - then - echo "" - echo -e "\${RED}Couldn't chroot. Something must be wrong with NFS root image.\${RESET}" - shell - fi - exit -fi -# end NFSROOT/Statelite code - -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 /sysroot - mkdir -p /sysroot/ro - mkdir -p /sysroot/rw - mount --move /ro /sysroot/ro - mount --move /rw /sysroot/rw -EOMS - print $inifile "elif [ -r /rootimg.cpio.gz ] || [ -r /rootimg.cpio.xz ]; then\n"; - print $inifile "echo Setting up RAM-root tmpfs.\n"; - if ($rootlimit) { - print $inifile " mount -o size=$rootlimit,mode=755 -t tmpfs rootfs \$NEWROOT\n"; - } else { - print $inifile " mount -o mode=755 -t tmpfs rootfs \$NEWROOT\n"; - } - print $inifile " cd /sysroot\n"; - print $inifile " echo -n \"Extracting root filesystem:\"\n"; - print $inifile " if [ -r /rootimg.cpio.gz ]; then\n"; - print $inifile " if [ -x /bin/cpio ]; then\n"; - print $inifile " zcat /rootimg.cpio.gz |/bin/cpio -idum\n"; - print $inifile " else\n"; - print $inifile " zcat /rootimg.cpio.gz |cpio -idum\n"; - print $inifile " fi\n"; - print $inifile " elif [ -r /rootimg.cpio.xz ]; then\n"; - print $inifile " if [ -x /bin/cpio ]; then\n"; - print $inifile " xz -cd /rootimg.cpio.xz |/bin/cpio -idum\n"; - print $inifile " else\n"; - print $inifile " xz -cd /rootimg.cpio.xz |cpio -idum\n"; - print $inifile " fi\n"; - print $inifile " fi\n"; - print $inifile " echo Done\n"; - print $inifile "elif [ -r /rootimg.tar.gz ] || [ -r /rootimg.tar.xz ]; then\n"; - print $inifile " echo Setting up RAM-root tmpfs.\n"; - - if ($rootlimit) { - print $inifile " mount -o \"size=$rootlimit,mode=755\" -t tmpfs rootfs \$NEWROOT\n"; - } else { - print $inifile " mount -o mode=755 -t tmpfs rootfs \$NEWROOT\n"; - } - print $inifile " cd \$NEWROOT\n"; - print $inifile " echo -n \"Extracting root filesystem:\"\n"; - print $inifile " if [ -r /rootimg.tar.gz ]; then\n"; - print $inifile " tar --selinux --xattrs-include='*' -zxf /rootimg.tar.gz\n"; - print $inifile " if [ \$? -ne 0 ]; then\n"; - print $inifile " tar -zxf /rootimg.tar.gz\n"; - print $inifile " fi\n"; - print $inifile " elif [ -r /rootimg.tar.xz ]; then\n"; - print $inifile " tar --selinux --xattrs-include='*' -Jxf /rootimg.tar.xz\n"; - print $inifile " if [ \$? -ne 0 ]; then\n"; - print $inifile " tar -Jxf /rootimg.tar.xz\n"; - print $inifile " fi\n"; - print $inifile " fi\n"; - print $inifile " echo Done\n"; - print $inifile "else\n"; - print $inifile " echo -n Failed to download image, panicing in 5...\n"; - print $inifile " for i in 4 3 2 1 0; do\n"; - print $inifile " /bin/sleep 1\n"; - print $inifile " echo -n \$i...\n"; - print $inifile " done\n"; - print $inifile " echo\n"; - print $inifile <" . "/tmp/xcatinitrd.$$/bin/netstart"); - print $inifile "#!/bin/bash \n"; - if ($osver_host == 10) { - print $inifile "dhcpcd \${1}\n"; - } else { # for sles11 or higher - # -p is used to keep the network connection during the shutdown. Used for nfs-based statelite shutdown - print $inifile "dhcpcd \${1} -p\n"; - } - - #-- Bring other NICs up in /bin/netstart in initrd for NIC failover - foreach (split /,/, $othernics) { - if (/^$/) { next; } - print $inifile "dhcpcd $_\n"; - } - - print $inifile <> /etc/HOSTNAME -END - - close($inifile); - - #if "nonodestatus" specified,do not update the nodestatus - system("mkdir -p /tmp/xcatinitrd.$$/tmp/"); - cp("$installroot/postscripts/updateflag.awk","/tmp/xcatinitrd.$$/tmp/updateflag"); - $perm = (stat("$installroot/postscripts/updateflag.awk"))[2]; - chmod($perm & 07777, "/tmp/xcatinitrd.$$/tmp/updateflag"); - - chmod(0755, "/tmp/xcatinitrd.$$/init"); - chmod(0755, "/tmp/xcatinitrd.$$/bin/netstart"); - - @filestoadd = (); - foreach (@ndrivers) { - if (-f "$customdir/$_") { - push @filestoadd, [ $_, "lib/$_" ]; - } elsif (-f "$pathtofiles/$_") { - push @filestoadd, [ $_, "lib/$_" ]; - } - } - if ($mode eq "statelite") { - foreach ("sbin/ifconfig", "usr/bin/clear", "usr/bin/touch", "usr/bin/cut", "usr/bin/rm", "bin/hostname", "usr/bin/egrep", "bin/ln", "bin/ls", "usr/bin/dirname", "usr/bin/expr", "usr/bin/chroot", "usr/bin/grep", "bin/cpio", "bin/sleep", "bin/mount", "bin/umount", "sbin/dhcpcd", "bin/bash", "sbin/insmod", "bin/mkdir", "bin/mknod", "sbin/ip", "bin/cat", "usr/bin/awk", "usr/bin/wget", "bin/cp", "usr/bin/cpio", "usr/bin/zcat", "usr/bin/gzip", "lib/mkinitrd/bin/run-init", "usr/bin/uniq", "usr/bin/sed", "usr/bin/wc", "bin/sed", "sbin/udevd", "usr/bin/readlink", "usr/sbin/parted", "sbin/mke2fs", "sbin/mkswap", "sbin/swapon", "bin/chmod", "usr/bin/bc", "usr/bin/xz", "usr/bin/gzip", "bin/tar") { - getlibs($_); - push @filestoadd, $_; - } - if ($osver_host >= 11) { - foreach ("sbin/mount.nfs", "sbin/umount.nfs", "sbin/udevadm") { - getlibs($_); - push @filestoadd, $_; - } - } - - } else { - foreach ("sbin/ifconfig", "usr/bin/clear", "usr/bin/touch", "usr/bin/grep", "usr/bin/egrep", "bin/cpio", "bin/sleep", "bin/mount", "sbin/dhcpcd", "bin/bash", "sbin/insmod", "bin/mkdir", "bin/mknod", "sbin/ip", "bin/cat", "usr/bin/awk", "usr/bin/wget", "bin/cp", "usr/bin/cpio", "usr/bin/zcat", "usr/bin/gzip", "lib/mkinitrd/bin/run-init", "usr/bin/uniq", "usr/bin/sed", "sbin/udevd", "usr/bin/readlink", "usr/bin/expr", "usr/sbin/parted", "sbin/mke2fs", "sbin/mkswap", "sbin/swapon", "bin/chmod", "usr/bin/bc", "usr/bin/xz", "usr/bin/gzip", "bin/tar") { - getlibs($_); - push @filestoadd, $_; - } - if ($osver_host >= 11) { - getlibs("sbin/udevadm"); - push @filestoadd, "sbin/udevadm"; - } - } - - if ($arch =~ /64/) { - push @filestoadd, "lib64/libnss_dns.so.2"; - push @filestoadd, "lib64/libnss_files.so.2"; - } - else { - push @filestoadd, "lib/libnss_dns.so.2"; - push @filestoadd, "lib/libnss_files.so.2"; - } - - # cross-platfrom support on power6&7 etc - # ldd can't handle such one scenario: mn is power6, the target platform is power7 - if ($arch =~ /ppc64/) { - system("cp -a -r $rootimg_dir/lib64/* /tmp/xcatinitrd.$$/lib64/"); - } - - - push @filestoadd, keys %libhash; - - find(\&isnetdriver, <$rootimg_dir/lib/modules/$kernelver/*>); - my $pathonrootimage = "$rootimg_dir/tmpfiles"; - my $pathinrootimage = "/tmpfiles"; - mkpath($pathonrootimage); - foreach (@filestoadd) { - if (ref($_)) { - - #print "$_->[0], $_->[1]\n"; - my $srcfile = $_->[0]; - system("chroot $rootimg_dir cp $srcfile $pathinrootimage"); - my $srcpath = "$pathonrootimage/" . basename($_->[0]); - if (-f "$customdir/" . $_->[0]) { - $srcpath = "$customdir/" . $_->[0]; - } elsif (-f "$pathtofiles/" . $_->[0]) { - $srcpath = "$pathtofiles/" . $_->[0]; - } - mkpath(dirname("/tmp/xcatinitrd.$$/" . $_->[1])); - copy($srcpath, "/tmp/xcatinitrd.$$/" . $_->[1]); - chmod 0755, "/tmp/xcatinitrd.$$/" . $_->[1]; - } else { - - #print "$_\n"; - system("chroot $rootimg_dir cp $_ $pathinrootimage"); - my $srcpath = "$pathonrootimage/" . basename($_); - if (-f "$customdir/$_") { - $srcpath = "$customdir/$_"; - } elsif (-f "$pathtofiles/$_") { - $srcpath = "$pathtofiles/$_"; - } - mkpath(dirname("/tmp/xcatinitrd.$$/$_")); - copy("$srcpath", "/tmp/xcatinitrd.$$/$_"); - chmod 0755, "/tmp/xcatinitrd.$$/" . $_; - } - } - rmtree($pathonrootimage); - - #copy conf files needed by nfs mount in sles11.2 - if ($osver_host >= 11) - { - system("cp -r $rootimg_dir/etc/protocols /tmp/xcatinitrd.$$/etc/"); - system("cp -r $rootimg_dir/etc/netconfig /tmp/xcatinitrd.$$/etc/"); - } - - - # Copy udev libraries - system("mkdir -p /tmp/xcatinitrd.$$/etc/udev"); - system("mkdir -p /tmp/xcatinitrd.$$/lib/firmware"); - system("cp -r $rootimg_dir/etc/udev/* /tmp/xcatinitrd.$$/etc/udev"); - system("cp -r $rootimg_dir/bin/uname /tmp/xcatinitrd.$$/bin/"); - if (-d "$rootimg_dir/lib/firmware/") { - system("cp -r $rootimg_dir/lib/firmware/* /tmp/xcatinitrd.$$/lib/firmware"); - } - system("cp -r $rootimg_dir/usr/bin/killall /tmp/xcatinitrd.$$/usr/bin"); - - # Copy rules for network adapter - #my $name = `cat /etc/sysconfig/network/ifcfg-$prinic | grep NAME`; - #my $nic = ''; - #if ($name =~ m/(\d+\.\d+\.\d+)/g) { - # $nic = $&; - #} - - # Somehow checking for *$nic.rules does not work - #if ( -f "/etc/udev/rules.d/*$nic.rules" ) { - # system("cp -r /etc/udev/rules.d/*$nic.rules /tmp/xcatinitrd.$$/etc/udev/rules.d"); - #} - #if ( -f "/etc/udev/rules.d/*persistent-net.rules" ) { - # system("cp -r /etc/udev/rules.d/*persistent-net.rules /tmp/xcatinitrd.$$/etc/udev/rules.d"); - #} - - system("mkdir -p /tmp/xcatinitrd.$$/lib/udev"); - system("cp -r $rootimg_dir/lib/udev/* /tmp/xcatinitrd.$$/lib/udev"); - - #copy("$rootimg_dir/lib/modules/*d","/tmp/xcatinitrd.$$/$_"); - system("cd /tmp/xcatinitrd.$$/bin/; ln -sf bash sh"); #neccessary for SLES11 - if ($mode eq "statelite") { - system("cd /tmp/xcatinitrd.$$;find .|cpio -H newc -o|gzip -9 -c - > $destdir/initrd-statelite.gz"); - print "The initial ramdisk for statelite has been generated successfully!\n"; - } else { - system("cd /tmp/xcatinitrd.$$;find .|cpio -H newc -o|gzip -9 -c - > $destdir/initrd-stateless.gz"); - print "The initial ramdisk for stateless has been generated successfully!\n"; - } - system("rm -rf /tmp/xcatinitrd.$$"); - -} - -sub isyumdir { - if ($File::Find::name =~ /\/repodata$/) { - my $location = $File::Find::name; - $location =~ s/\/repodata$//; - push @yumdirs, $location; - } -} - -sub isnetdriver { - foreach (@ndrivers) { - if ($File::Find::name =~ /\/$_/) { - my $filetoadd = $File::Find::name; - $filetoadd =~ s!$rootimg_dir!!; - push @filestoadd, [ $filetoadd, "lib/$_" ]; - print "Added driver $_ to initrd\n"; - } - } -} - - - - - - - -sub postscripts { # TODO: customized postscripts - generic_post(); - unless (-d "$rootimg_dir/opt/xcat/") { - mkdir "$rootimg_dir/opt/xcat/"; - } - copy("$installroot/postscripts/xcatdsklspost", "$rootimg_dir/opt/xcat/"); #TODO: it is not used in stateless - chmod '0755', "$rootimg_dir/opt/xcat/xcatdsklspost"; -} - -sub generic_post { # This function is meant to leave the image in a state approximating a normal install - my $cfgfile; - - #modify /etc/sysconfig/clock in the image:HWCLOCK="--local", TIMEZONE=site:timezone - if ($timezone) { - if (-e "$rootimg_dir/etc/sysconfig/clock") { - system("sed -i '" . 's!\(TIMEZONE=\).*!\1' . "\"$timezone\"!" . "' $rootimg_dir/etc/sysconfig/clock"); - } - system("chroot $rootimg_dir zic -l $timezone"); - } - - if (-e "$rootimg_dir/etc/sysconfig/clock") { - system("sed -i 's!\\(HWCLOCK=\\).*!\\1\"--localtime\"!' $rootimg_dir/etc/sysconfig/clock"); - } - if (-e "$rootimg_dir/etc/sysconfig/network/dhcp") { - system("sed -i 's!^DHCLIENT_SET_HOSTNAME=\\\"no\\\"!DHCLIENT_SET_HOSTNAME=\\\"yes\\\"!' $rootimg_dir/etc/sysconfig/network/dhcp"); - } - - unlink("$rootimg_dir/dev/null"); - system("mknod $rootimg_dir/dev/null c 1 3"); - open($cfgfile, ">", "$rootimg_dir/etc/fstab"); - print $cfgfile "devpts /dev/pts devpts gid=5,mode=620 0 0\n"; - print $cfgfile "tmpfs /dev/shm tmpfs defaults 0 0\n"; - print $cfgfile "proc /proc proc defaults 0 0\n"; - print $cfgfile "sysfs /sys sysfs defaults 0 0\n"; - if ($tmplimit) { - print $cfgfile "tmpfs /tmp tmpfs defaults,size=$tmplimit 0 2\n"; - print $cfgfile "tmpfs /var/tmp tmpfs defaults,size=$tmplimit 0 2\n"; - } else { - print $cfgfile "tmpfs /tmp tmpfs defaults,size=10m 0 2\n"; - print $cfgfile "tmpfs /var/tmp tmpfs defaults,size=10m 0 2\n"; - } - - my $rootfs_name = $profile . "_" . $arch; - print $cfgfile "$rootfs_name / tmpfs rw 0 1\n"; - - close($cfgfile); - - open($cfgfile, ">", "$rootimg_dir/etc/sysconfig/network"); - print $cfgfile "NETWORKING=yes\n"; - close($cfgfile); - - open($cfgfile, ">", "$rootimg_dir/etc/resolv.conf"); - print $cfgfile "#Dummy resolv.conf to make boot cleaner"; - close($cfgfile); - - # Create the ifcfg-x file for diskless node. But keep the ONBOOT=no - # to skip the break of nfs-based boot - if ($prinic) { - open($cfgfile, ">", "$rootimg_dir/etc/sysconfig/network/ifcfg-$prinic"); - print $cfgfile "ONBOOT=no\nBOOTPROTO=dhcp\nDEVICE=$prinic\nSTARTMODE=auto\n"; - close($cfgfile); - } - - foreach (split /,/, $othernics) { - next if (/^$/); - open($cfgfile, ">", "$rootimg_dir/etc/sysconfig/network/ifcfg-$_"); - print $cfgfile "ONBOOT=yes\nBOOTPROTO=dhcp\nDEVICE=$_\nSTARTMODE=auto\n"; - close($cfgfile); - } - - # securetty not needed on s390x - if ($arch ne "s390x") { - open($cfgfile, ">>", "$rootimg_dir/etc/securetty"); - print $cfgfile "ttyS0\n"; - print $cfgfile "ttyS1\n"; - print $cfgfile "console\n"; - close($cfgfile); - } - - my @passwd; - open($cfgfile, "<", "$rootimg_dir/etc/passwd"); - @passwd = <$cfgfile>; - close($cfgfile); - open($cfgfile, ">", "$rootimg_dir/etc/passwd"); - foreach (@passwd) { - if (/^root:/) { - s/^root:\*/root:x/; - } - print $cfgfile $_; - } - close($cfgfile); - foreach (<$rootimg_dir/etc/skel/.*>) { - next if (basename($_) eq '.' or basename($_) eq '..'); - copy $_, "$rootimg_dir/root/"; - } - - # gettyset is not found on s390x - if ($arch ne "s390x") { - open($cfgfile, ">", "$rootimg_dir/etc/init.d/gettyset"); - print $cfgfile "#!/bin/bash\n"; - print $cfgfile "### BEGIN INIT INFO\n"; - print $cfgfile "# Provides: gettyset\n"; - print $cfgfile "# Required-Start: sshd\n"; - print $cfgfile "# Required-Stop:\n"; - print $cfgfile "# Default-Start: 3\n"; - print $cfgfile "# Default-Stop: 0 1 2 6\n"; - print $cfgfile "# Short-Description: gettyset\n"; - print $cfgfile "# Description:\n"; - print $cfgfile "### END INIT INFO\n"; - print $cfgfile "VERS=`grep VERSION /etc/SuSE-release`\n"; - print $cfgfile "if [ -n \"\$VERS\" ]; then\n"; - print $cfgfile " VERNUM=`echo \$VERS|awk -F= \'{print \$2}\'|sed -e \'s/ //g\'`\n"; - print $cfgfile "fi\n"; - print $cfgfile "if [ \"\$VERNUM\" -gt 10 ]; then\n"; - print $cfgfile " exit\n"; - print $cfgfile "fi\n"; - print $cfgfile "\n"; - print $cfgfile "for i in `cat /proc/cmdline`; do\n"; - print $cfgfile ' KEY=`echo $i|cut -d= -f 1`' . "\n"; - print $cfgfile " if [ \"\$KEY\" == \"console\" -a \"\$i\" != \"console=tty0\" ]; then\n"; - print $cfgfile " VALUE=`echo \$i | cut -d= -f 2`\n"; - print $cfgfile " COTTY=`echo \$VALUE|cut -d, -f 1`\n"; - print $cfgfile " COSPEED=`echo \$VALUE|cut -d, -f 2|cut -dn -f 1`\n"; - print $cfgfile " if echo \$VALUE | grep n8r; then\n"; - print $cfgfile " FLOWFLAG=\"-h\"\n"; - print $cfgfile " fi\n"; - print $cfgfile " echo xco:2345:respawn:/sbin/agetty \$FLOWFLAG \$COTTY \$COSPEED xterm >> /etc/inittab\n"; - print $cfgfile " init q\n"; - print $cfgfile " fi\n"; - print $cfgfile "done\n"; - print $cfgfile "/etc/init.d/boot.localnet start\n"; - - close($cfgfile); - chmod(0755, "$rootimg_dir/etc/init.d/gettyset"); - } - - system("mkdir -p $rootimg_dir/opt/xcat"); - copy("$installroot/postscripts/xcatpostinit", "$rootimg_dir/opt/xcat/xcatpostinit"); - chmod(0755, "$rootimg_dir/opt/xcat/xcatpostinit"); - copy("$installroot/postscripts/xcatpostinit.service", "$rootimg_dir/usr/lib/systemd/system/xcatpostinit.service"); - - # - # set certain system services to start on boot, if the file exists in /etc/init.d as a script, - # use insserv to start it. If not, assume that the service is controlled by systemctl - # - # note: insserv is passed the -f option to ignore the dependency on sles10.4 - # - print "[genimage] setting services to start at boot time...\n"; - my @services; - push @services, qw/sshd network gettyset xcatpostinit/; - - foreach my $service (@services) { - my $cmd = "chroot $rootimg_dir "; - $cmd = $cmd . "systemctl enable $service.service"; - system("$cmd"); - } - - # - # Check if .depend.start file exists. For SLES12 and later OS, this does not apply - # - if (-r '$rootimg_dir/etc/init.d/.depend.start') { - my $rc = system("grep sshd $rootimg_dir/etc/init.d/.depend.start | grep TARGETS"); - if ($rc) { - system("sed -i '" . 's/^\(TARGETS = .*\)$/\1 sshd/' . "' $rootimg_dir/etc/init.d/.depend.start"); - system("ln -s ../sshd $rootimg_dir/etc/init.d/rc3.d/S20sshd"); - } - my $rc = system("grep gettyset $rootimg_dir/etc/init.d/.depend.start | grep TARGETS"); - if ($rc) { - system("sed -i '" . 's/^\(TARGETS = .*\)$/\1 gettyset/' . "' $rootimg_dir/etc/init.d/.depend.start"); - system("ln -s ../gettyset $rootimg_dir/etc/init.d/rc3.d/S60gettyset"); - } - } -} - - -my $driver_name; -my $real_path; - -sub get_path () -{ - if ($File::Find::name =~ /\/$driver_name/) { - $real_path = $File::Find::name; - } -} - -my @all_real_path; - -sub get_all_path () -{ - if ($File::Find::name =~ /\/$driver_name/) { - push @all_real_path, $File::Find::name; - } -} - -# Load driver disk and driver rpm to the initrd -# Get the driver disk or driver rpm from the osimage.driverupdatesrc -# The valid value: dud:/install/dud/dd.img,rpm:/install/rpm/d.rpm, if missing the tag: 'dud'/'rpm' -# the 'rpm' is default. -# -# If cannot find the driver disk from osimage.driverupdatesrc, will try to search driver disk -# from /install/driverdisk// -# -# For driver rpm, the driver list will be gotten from osimage.netdrivers. If not set, copy all the drivers from driver -# rpm to the initrd. -# -# Return the driver names by loading order - -sub load_dd() -{ - my @dd_list; - my @rpm_list; - my @driver_list; - - my $Injectalldriver; - my @rpm_drivers; - - # Parse the parameters to the the source of Driver update disk and Driver rpm, and driver list as well - if ($driverupdatesrc) { - my @srcs = split(',', $driverupdatesrc); - foreach my $src (@srcs) { - if ($src =~ /dud:(.*)/i) { - push @dd_list, $1; - } elsif ($src =~ /rpm:(.*)/i) { - push @rpm_list, $1; - } else { - push @rpm_list, $src; - } - } - } - if (!@dd_list) { - - # get Driver update disk from the default path if not specified in osimage - # check the Driver Update Disk images, it can be .img or .iso - if (-d "$installroot/driverdisk/$osver/$arch") { - @dd_list = `find $installroot/driverdisk/$osver/$arch -type f`; - } - } - - foreach (split /,/, $netdriver) { - if (/^allupdate$/) { - $Injectalldriver = 1; - next; - } - unless (/\.ko$/) { - s/$/.ko/; - } - push @driver_list, $_; - } - - chomp(@dd_list); - chomp(@rpm_list); - - unless (@dd_list || (@rpm_list && ($Injectalldriver || @driver_list))) { - return (); - } - - # Create the work space, it should be cleaned at end of genimage - my $dd_dir = mkdtemp("/tmp/ddtmpXXXXXXX"); - mkpath "$dd_dir/mnt"; - mkpath "$dd_dir/mods"; - - my @dd_drivers = (); #driver names - - # Load drivers from each Driver Disk - # For multiple dd, if want to make it has order, rename the dd with a number - # ahead of the name like 0_xx, 1_xx - foreach my $dd (sort(@dd_list)) { - my $rc = system("mount -o loop $dd $dd_dir/mnt"); - if ($rc) { - print "mount the Driver Disk $dd failed.\n"; - next; - } - - mkpath "$dd_dir/full"; - - # Copy out the drivers - opendir(DIR, "$dd_dir/mnt") || die "Cannot open dir $dd_dir/mnt"; - while (my $dir = readdir(DIR)) { - if ($dir =~ /^\./) { next; } - - # Every driver update disk can have multiple directories, each directory - # has the directory format like /linux/[distribution]/[architechture]-[version]/ - # If the directory name is numeric, then it will be used as order to load the - # the dirviers inside. - # For the directory name which is not numeric, copy them to directory 0. It will be - # loaled first. - if ($dir !~ /^\d*$/) { - mkpath "$dd_dir/full/0"; - system("cp -rf $dd_dir/mnt/$dir $dd_dir/full/0"); - } else { - system("cp -rf $dd_dir/mnt/$dir $dd_dir/full/"); - } - } - closedir(DIR); - - # Get all the kernel modules base on the order of directory name. - - # The structure of dd: /linux/[distribution]/[architechture]-[version]/ - - # The supported arch: i386, ia64, ppc, ppc64, s390, s390x sparc or x86_64. - my $darch = $arch; - if ($darch =~ /^x86$/) { - $darch = "i386"; - } - - # If the version is os version. If the os is "sles11.1", the possible os version - # could be "sles11.1", "11.1", "11", "sles11" - my @distro = ($osver); - my $distro1 = $osver; - $distro1 =~ s/[^\d]*//; - push @distro, $distro1; - my $distro2 = $distro1; - $distro2 =~ s/\..*//; - push @distro, $distro2; - my $distro3 = $osver; - $distro3 =~ s/\..*//; - push @distro, $distro3; - - opendir(FDIR, "$dd_dir/full") || die "Cannot open dir $dd_dir/full"; - my @fulldir = readdir(FDIR); - closedir(FDIR); - - # Create the directory for drivers from driver disk - if (!-d "$rootimg_dir/lib/modules/$kernelver/kernel/drivers/driverdisk") { - mkpath "$rootimg_dir/lib/modules/$kernelver/kernel/drivers/driverdisk"; - } - - # Copy the drivers to the root image and get the driver loading order - foreach my $dir (sort(@fulldir)) { - if ($dir =~ /^\./) { next; } - my $vdir; - foreach (@distro) { - if (-d "$dd_dir/full/$dir/linux/suse/$darch-$_") { - $vdir = "$dd_dir/full/$dir/linux/suse/$darch-$_"; - } - } - if (!$vdir) { next; } - - # Use the module_order if it has - if (-f "$vdir/modules/module.order") { - open(ORDER, "<", "$vdir/modules/module.order"); - while (my $file = ) { - chomp($file); - if (-f "$vdir/modules/$file") { - $driver_name = $file; - $real_path = ""; - find(\&get_path, <$rootimg_dir/lib/modules/$kernelver/*>); - if ($real_path eq "") { - system("cp $vdir/modules/$file $rootimg_dir/lib/modules/$kernelver/kernel/drivers/driverdisk"); - } else { - system("cp $vdir/modules/$file $real_path"); - } - - push @dd_drivers, $file; - } - } - } else { - opendir(MDIR, "$vdir/modules") || die "Cannot open dir $vdir/modules"; - while (my $file = readdir(MDIR)) { - if (-f "$vdir/modules/$file" && $file =~ /\.ko/) { - $driver_name = $file; - $real_path = ""; - find(\&get_path, <$rootimg_dir/lib/modules/$kernelver/*>); - if ($real_path eq "") { - system("cp $vdir/modules/$file $rootimg_dir/lib/modules/$kernelver/kernel/drivers/driverdisk"); - } else { - system("cp $vdir/modules/$file $real_path"); - } - - push @dd_drivers, $file; - } - } - } - } - - rmtree "$dd_dir/full"; - - my $rc = system("umount -f $dd_dir/mnt"); - if ($rc) { - print "umount the directory $dd_dir/mnt failed\n"; - exit 1; - } - } - - # Loading the drivers from rpm packages - if (@rpm_list && ($Injectalldriver || @driver_list)) { - - # Extract the files from rpm to the tmp dir - mkpath "$dd_dir/rpm"; - foreach my $rpm (@rpm_list) { - if (-r $rpm) { - if (system("cd $dd_dir/rpm; rpm2cpio $rpm | cpio -idum")) { - print "Error: Cannot extract the files from the rpm $rpm.\n"; - } - } else { - print "Error: Cannot read the rpm $rpm.\n"; - } - } - - # To skip the conflict of files that some rpm uses the xxx.ko.new as the name of the driver - # Change it back to xxx.ko here - $driver_name = "\*ko.new"; - @all_real_path = (); - find(\&get_all_path, <$dd_dir/rpm/*>); - foreach my $file (@all_real_path) { - my $newname = $file; - $newname =~ s/\.new$//; - if (system("mv -f $file $newname")) { - print "Error: Could not rename $file\n"; - - } - } - - # Copy the firmware to the rootimage - if (-d "$dd_dir/rpm/lib/firmware") { - system("cp -rf $dd_dir/rpm/lib/firmware $rootimg_dir/lib"); - } - - # if $ignorekernelchk is specified, copy all driver files to target kernel dir - if ($ignorekernelchk) { - my @kernelpath4vrpm = <$dd_dir/rpm/lib/modules/*>; - foreach my $path (@kernelpath4vrpm) { - if ($path eq "$dd_dir/rpm/lib/modules/$kernelver") { - next; - } - - unless (-d "$dd_dir/rpm/lib/modules/$kernelver") { - mkpath "$dd_dir/rpm/lib/modules/$kernelver"; - } - system("/bin/cp -rf $path/* $dd_dir/rpm/lib/modules/$kernelver"); - } - } - - # Copy the drivers to the rootimage - if (-d "$dd_dir/rpm/lib/modules/$kernelver") { - - #mkpath "$rootimg_dir/lib/modules/$kernelver/updates/"; - if (@driver_list) { - foreach my $driver (@driver_list) { - $driver_name = $driver; - $real_path = ""; - find(\&get_path, <$dd_dir/rpm/lib/modules/$kernelver/*>); - if ($real_path && $real_path =~ m!$dd_dir/rpm(/lib/modules/$kernelver/.*?)[^\/]*$!) { - - # remove the old one if existing - @all_real_path = (); - find(\&get_all_path, <$rootimg_dir/lib/modules/$kernelver/*>); - foreach (@all_real_path) { - if (-r $_) { - unlink($_); - } - } - - if (!-d "$rootimg_dir$1") { - mkpath "$rootimg_dir$1"; - } - system("cp -rf $real_path $rootimg_dir$1"); - push @rpm_drivers, $driver; - } else { - print "Warning: cannot find the driver $driver from the driver rpms\n"; - } - } - } elsif ($Injectalldriver) { - - # copy all the drviers to the rootimage - $driver_name = "\*\.ko"; - @all_real_path = (); - find(\&get_all_path, <$dd_dir/rpm/lib/modules/$kernelver/*>); - my @all_drivers = @all_real_path; - foreach my $new_driver (@all_drivers) { - if (basename($new_driver) =~ /\.ko$/) { - - # remove the old one if existing - $driver_name = basename($new_driver); - @all_real_path = (); - find(\&get_all_path, <$rootimg_dir/lib/modules/$kernelver/*>); - foreach my $old_driver (@all_real_path) { - if (-r $old_driver) { - unlink($old_driver); - } - } - push @rpm_drivers, basename($new_driver); - } - } - - system("cp -rf $dd_dir/rpm/lib/modules/$kernelver $rootimg_dir/lib/modules/"); - } - } else { - print "Warning: cannot find the kernel $kernelver from drvier rpms\n"; - } - - push @dd_drivers, @rpm_drivers; - } - - # Generate the dependency relationship - system("chroot '$rootimg_dir' depmod $kernelver"); - - # Clean the env - rmtree "$dd_dir"; - - return @dd_drivers; -} - -sub usage { - print 'Usage: genimage -o [-a ] -p -i -n [-r ] [-k ] [-g ] [-l rootlimitsize] [--permission ] [--interactive]' . "\n"; - print " --permission is used for statelite only\n"; - print "Examples:\n"; - print " genimage -i eth0 -n tg3 -o sles11 -p compute\n"; - print " genimage -i eth0 -r eth1,eth2 -n tg3,bnx2 -o sles11 -p compute --interactive\n"; - print " genimage -i eth0 -n tg3,bnx2 -o sles11 -p compute\n"; - print " genimage -i eth0 -n tg3,bnx2 -o sles11 -p compute --permission 777\n"; - return 0; -} - diff --git a/xCAT-server/share/xcat/netboot/sle/geninitrd b/xCAT-server/share/xcat/netboot/sle/geninitrd deleted file mode 100755 index baf3746f6..000000000 --- a/xCAT-server/share/xcat/netboot/sle/geninitrd +++ /dev/null @@ -1,2437 +0,0 @@ -#!/usr/bin/env perl -BEGIN -{ - $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat'; -} -use lib "$::XCATROOT/lib/perl"; - -use File::Basename; -use File::Path; -use File::Copy qw/copy cp mv move/; -use File::Find; -use Getopt::Long; -use Cwd qw(realpath); -use File::Temp qw/mkdtemp/; - -use FindBin; -use lib "$FindBin::Bin/../imgutils"; -use imgutils; - -#use strict; -Getopt::Long::Configure("bundling"); -Getopt::Long::Configure("pass_through"); - -my $dracutmode; #Indicate whether this is a dracut style initrd -my $dracutdir = "dracut"; # The default directory name of dracut -my $dracutver; -my $prinic; #TODO be flexible on node primary nic -my $othernics; #TODO be flexible on node primary nic -my $netdriver; -my @yumdirs; -my $arch; -my %libhash; -my @filestoadd; -my $profile; -my $osver; -my $pathtofiles = dirname($0); -my $fullpath = realpath($pathtofiles); -my $name = basename($0); -my $onlyinitrd = 0; - -#that this method of calling genimage is no longer used -if ($name =~ /geninitrd/) { - $onlyinitrd = 1; -} -my $rootlimit; -my $tmplimit; -my $installroot = "/install"; -my $kerneldir; -my $kernelver = ""; -my $basekernelver; -my $customdir = $fullpath; -$customdir =~ s/.*share\/xcat/$installroot\/custom/; -my $imagename; -my $pkglist; -my $srcdir; -my $destdir; -my $srcdir_otherpkgs; -my $otherpkglist; -my $postinstall_filename; -my $rootimg_dir; -my $mode; -my $permission; #the permission works only for statelite mode currently -my $krpmver; -my $tempfile; -my $prompt; -my $timezone; #the TIMEZONE of the stateless and statelite node -my $ignorekernelchk; -my $noupdate; - -sub xdie { - system("rm -rf /tmp/xcatinitrd.$$"); - die @_; -} - -#-- fetch current version form CVS (overwrite locally changed versions) -# if (opendir(CVS,"$pathtofiles/CVS")){ -# close CVS; -# my $cvsout = qx/cd $pathtofiles; cvs update -C 2>&1/; -# chomp $cvsout; -# if ( $cvsout ne "cvs update: Updating ." ) { -# print "Difference of local copy from CVS detected\n"; -# print $cvsout,"\n"; -# print "Trying to re-run $name\n"; -# print("$pathtofiles/$name ",join(" ",@ARGV),"\n"); -# exec("$pathtofiles/$name",@ARGV); -# } -# } - - -$SIG{INT} = $SIG{TERM} = sub { xdie "Interrupted" }; -GetOptions( - 'a=s' => \$arch, - 'p=s' => \$profile, - 'o=s' => \$osver, - 'n=s' => \$netdriver, - 'i=s' => \$prinic, - 'r=s' => \$othernics, - 'l=s' => \$rootlimit, - 't=s' => \$tmplimit, - 'k=s' => \$kernelver, - 'g=s' => \$krpmver, - 'permission=s' => \$permission, - 'kerneldir=s' => \$kerneldir, - 'timezone=s' => \$timezone, - 'tempfile=s' => \$tempfile, #internal flag - 'pkglist=s' => \$pkglist, #internal flag - 'srcdir=s' => \$srcdir, #internal flag - 'otherpkgdir=s' => \$srcdir_otherpkgs, #internal flag - 'otherpkglist=s' => \$otherpkglist, #internal flag - 'postinstall=s' => \$postinstall_filename, #internal flag - 'rootimgdir=s' => \$destdir, #internal flag - 'driverupdatesrc=s' => \$driverupdatesrc, #internal flag - 'interactive' => \$prompt, - 'onlyinitrd' => \$onlyinitrd, - 'ignorekernelchk' => \$ignorekernelchk, - 'noupdate' => \$noupdate, -); - -if (@ARGV > 0) { - $imagename = $ARGV[0]; -} - - -my %updates_os = (); # the hash for updating osimage table -my %updates = (); # the hash for updating linuximage table - - -$permission = "755" unless ($permission); -$updates{'permission'} = $permission if ($tempfile); - -unless ($arch) { - $arch = `uname -m`; - chomp($arch); - $arch = "x86" if ($arch =~ /i.86$/); -} - -$srcdir = "$installroot/$osver/$arch" unless ($srcdir); -$updates{'pkgdir'} = $srcdir if ($tempfile); - -#$srcdir = $srcdir . "/1"; - -$srcdir_otherpkgs = "$installroot/post/otherpkgs/$osver/$arch" unless ($srcdir_otherpkgs); -#$updates{'otherpkgdir'} = $srcdir_otherpkgs if ($tempfile); - -$destdir = "$installroot/netboot/$osver/$arch/$profile" unless ($destdir); -$updates{'rootimgdir'} = $destdir if ($tempfile); - -$rootimg_dir = "$destdir/rootimg"; - -if ($kernelver && (!$krpmver)) { - print "The -g flag for the rpm version of kernel packages needs to be specified when kernel version has been specified.\n"; - exit 1; -} -$kerneldir = "$installroot/kernels" unless ($kerneldir); # the default directory for 3rd-party kernel is "$installroot/kernels"; - -#$updates{'kerneldir'} = $kerneldir if ($tempfile); - -unless ($osver and $profile) { - usage(); - exit 1; -} -my @ndrivers; - -if ($netdriver) { - foreach (split /,/, $netdriver) { - if (/^allupdate$/) { - next; - } - unless (/\.ko$/) { - s/$/.ko/; - } - next if (/^$/); - - # Do not include qeth module here - # This module is included later on - unless ($_ =~ m/qeth/i) { - push @ndrivers, $_; - } - } - - if (($updates{'netdrivers'} ne $netdriver) and $tempfile) { - $updates{'netdrivers'} = $netdriver; - } -} - -# Add the default driver list -if ($arch eq 'x86' or $arch eq 'x86_64') { - push @ndrivers, qw/tg3 bnx2 bnx2x e1000 e1000e virtio_net virtio_balloon igb mlx4_en be2net/; -} elsif ($arch eq 'ppc64') { - push @ndrivers, qw/tg3 e1000 e1000e igb ibmveth ehea be2net/; -} elsif ($arch eq "s390x") { - push @ndrivers, qw/qdio ccwgroup qeth qeth_l2 qeth_l3/; -} - -foreach (@ndrivers) { - unless (/\.ko$/) { - s/$/.ko/; - } -} - -unless (grep /af_packet/, @ndrivers) { - unshift(@ndrivers, "af_packet.ko"); -} - -my $osver_host; -if (`grep VERSION /etc/os-release` =~ /VERSION = (\d+)/) { - $osver_host = $1; -} else { - $osver_host = 11; -} - -unless ($onlyinitrd) { - - # now, let's handle the extra packages - unless ($imagename) { - $otherpkglist = imgutils::get_profile_def_filename($osver, $profile, $arch, $customdir, "otherpkgs.pkglist"); - unless ($otherpkglist) { $otherpkglist = imgutils::get_profile_def_filename($osver, $profile, $arch, $pathtofiles, "otherpkgs.pkglist"); } - $updates{'otherpkglist'} = $otherpkglist if ($tempfile and $otherpkglist); - } - my %extra_hash = (); - %extra_hash = imgutils::get_package_names($otherpkglist) if ($otherpkglist); - - - # prepare the chroot environment for the root image - - mkpath "$rootimg_dir/etc"; - mkpath "$rootimg_dir/dev"; - - #system "mount -o bind /dev $rootimg_dir/dev"; - unless (-e "$rootimg_dir/dev/zero") { - system "mknod $rootimg_dir/dev/zero c 1 5"; - } - unless (-e "$rootimg_dir/dev/null") { - system "mknod $rootimg_dir/dev/null c 1 3"; #that's neccessary for SLES11 - } - - unless (-e "$rootimg_dir/dev/random") { - system "mknod $rootimg_dir/dev/random c 1 8"; #that's neccessary for SLES11 - } - unless (-e "$rootimg_dir/dev/urandom") { - system "mknod $rootimg_dir/dev/urandom c 1 9"; #that's neccessary for SLES11 - } - - for (my $i = 0 ; $i <= 12 ; $i++) - { - unless (-e "$rootimg_dir/dev/tty$i") { - system "mknod $rootimg_dir/dev/tty$i c 4 $i"; #that's neccessary for SLES11 - } - } - - open($fd, ">>", "$rootimg_dir/etc/fstab"); # TODO: is it necessary? - print $fd "#Dummy fstab for rpm postscripts to see\n"; - close($fd); - - my $non_interactive; - if (!$prompt) { $non_interactive = "--non-interactive --no-gpg-checks --gpg-auto-import-keys"; } - - if ($osver_host >= 11) { #zypper in SLES11 is different - - system("rm -rf $rootimg_dir/etc/zypp/repos.d/$osver-*.repo"); - my @pkgdirs = split(",", $srcdir); - my $dir; - my $i = 0; - - # To support multiple paths for osimage.pkgdir - foreach $dir (@pkgdirs) { - my $ddir = $dir; - if (-d "$dir/1") { - $ddir .= "/1"; - } - system("zypper -R $rootimg_dir $non_interactive ar file:$ddir $osver-$i"); - $i++; - if (-d "$dir/2") { - $ddir = $dir . "/2"; - system("zypper -R $rootimg_dir $non_interactive ar file:$ddir $osver-$i"); - $i++; - } - } - - #if(-e "$rootimg_dir/etc/zypp/repos.d/$osver.repo") { - # system("rm -rf $rootimg_dir/etc/zypp/repos.d/$osver.repo"); - #} - #system("zypper -R $rootimg_dir $non_interactive ar file:$srcdir $osver"); - #if(-e "$rootimg_dir/etc/zypp/repos.d/${osver}sdk.repo") { - # system("rm -rf $rootimg_dir/etc/zypp/repos.d/${osver}sdk.repo"); - #} - if (opendir(SRCDIR, "$installroot/$osver/$arch/")) { - while (my $tmpfile = readdir(SRCDIR)) { - if ($tmpfile =~ m/^sdk/) { - my $srcdir_sdk = "$installroot/$osver/$arch/${tmpfile}"; - if (-d "$srcdir_sdk") { - system("zypper -R $rootimg_dir $non_interactive ar file:$srcdir_sdk ${osver}${tmpfile}"); - } - } - } - } - } else { - $srcdir = $srcdir . "/1"; - system("zypper -R $rootimg_dir $non_interactive sa file:$srcdir"); - } - - # Add the rep for kernel packages - if ($kernelver) { - if (!-d $kerneldir) { - print "Cannot find the directory for the kernel at $kerneldir.\n"; - exit 1; - } - if ($osver_host >= 11) { - if (-e "$rootimg_dir/etc/zypp/repos.d/$kernelver.repo") { - system("rm -rf $rootimg_dir/etc/zypp/repos.d/$kernelver.repo"); - } - system("zypper -R $rootimg_dir $non_interactive ar file:$kerneldir $kernelver"); - } else { - system("zypper -R $rootimg_dir $non_interactive sa file:$kerneldir"); - } - } - - #remove the old repository for extra packages - if ($osver_host >= 11) { - my $result = `zypper -R $rootimg_dir $non_interactive lr |grep otherpkg|cut -f2 -d '|'|tr "\n" " "`; - if ($result =~ /\S/) { - system("zypper -R $rootimg_dir $non_interactive rr $result"); - } - } else { - my $result = `zypper -R $rootimg_dir $non_interactive sl |grep otherpkg|cut -f2 -d '|'|tr "\n" " "`; - if ($result =~ /\S/) { - system("zypper -R $rootimg_dir $non_interactive sd $result"); - } - } - - #add the new repository for extra packages - my %extrapkgnames; - if ($osver_host >= 11) { #SLES11 - if (-e "$rootimg_dir/etc/zypp/repos.d/otherpkg.repo") { - system("rm -rf $rootimg_dir/etc/zypp/repos.d/otherpkg.repo"); - } - } - my $index = 1; - my $pass; - foreach $pass (sort { $a <=> $b } (keys(%extra_hash))) { - foreach (keys(%{ $extra_hash{$pass} })) { - - if ($_ eq "INCLUDEBAD") { - print "Unable to open the following pkglist files:\n" . join("\n", @{ $extra_hash{$pass}{INCLUDEBAD} }); - exit 1; - } - - if (($_ eq "PRE_REMOVE") || ($_ eq "POST_REMOVE") || ($_ eq "ENVLIST")) { next; } - my $whole_path = "$srcdir_otherpkgs/$_"; - if (-r "$srcdir_otherpkgs/$_/repodata/repomd.xml") { - if ($osver_host >= 11) { - system("zypper -R $rootimg_dir $non_interactive ar file:$srcdir_otherpkgs/$_ otherpkg$index"); - } else { - system("zypper -R $rootimg_dir $non_interactive sa file:$srcdir_otherpkgs/$_"); - } - } else { - if ($osver_host >= 11) { - system("zypper -R $rootimg_dir $non_interactive ar -t Plaindir file:$srcdir_otherpkgs/$_ otherpkg$index"); - } else { - system("zypper -R $rootimg_dir $non_interactive sa -t Plaindir file:$srcdir_otherpkgs/$_"); - } - } - $index++; - - my $pa = $extra_hash{$pass}{$_}; - $extrapkgnames{$pass} .= " " . join(' ', @$pa); - } - } - - #-- add custom repositories to the image - #TODO: should we add the support to otherpkgs for this? we have too many list files and it seems only SLES supports this - # not sure, but it is convenient - my $repolist; - $repolist = imgutils::get_profile_def_filename($osver, $profile, $arch, $customdir, "repolist"); - unless ($repolist) { - $repolist = imgutils::get_profile_def_filename($osver, $profile, $arch, $pathtofiles, "repolist"); - } - - if (-r "$repolist") { - print "Reading custom repositories\n"; - open($repoconfig, "<", "$repolist"); - while (<$repoconfig>) { - chomp; - next if /^\s*#/; - my ($repotype, $repourl, $repoalias) = split m/\|/; - if ($osver_host >= 11) { - system("zypper -R $rootimg_dir $non_interactive ar $repourl $repoalias"); - } else { - system("zypper -R $rootimg_dir $non_interactive sa $repourl $repoalias"); - } - } - } - - # Refresh the zypper cache in case there is still old data out there - system("zypper -R $rootimg_dir $non_interactive refresh"); - - #my $yumcmd = "yum -y -c /tmp/genimage.$$.yum.conf --installroot=$rootimg_dir --disablerepo=* "; - #$yumcmd .= "install "; - #mkpath("$rootimg_dir/var/lib/yum"); - mkpath("$rootimg_dir/etc/"); - my $passwdfile; - open($passwdfile, ">", "$rootimg_dir/etc/passwd"); - print $passwdfile "root:x:0:0:root:/root:/bin/bash\n"; - my $yumcmd; - if ($osver_host < 11) { - $yumcmd = "zypper -R $rootimg_dir $non_interactive install "; - } else { - $yumcmd = "zypper -R $rootimg_dir $non_interactive install -l --no-recommends "; #add -l for SLES11 - } - - #install packages from pkglist file - my $pkgnames; - unless ($imagename) { - $pkglist = imgutils::get_profile_def_filename($osver, $profile, $arch, $customdir, "pkglist"); - unless ($pkglist) { $pkglist = imgutils::get_profile_def_filename($osver, $profile, $arch, $pathtofiles, "pkglist"); } - } - - if ($pkglist) { - $updates{'pkglist'} = $pkglist if ($tempfile); - } else { - print "Unable to find package list for $profile!"; - exit 1; - } - - my %pkg_hash = imgutils::get_package_names($pkglist); - my $index = 1; - foreach $pass (sort { $a <=> $b } (keys(%pkg_hash))) { - $pkgnames = ""; - $group_pkgnames = ""; - foreach (keys(%{ $pkg_hash{$pass} })) { - - if ($_ eq "INCLUDEBAD") { - print "Unable to open the following pkglist files:\n" . join("\n", @{ $pkg_hash{$pass}{INCLUDEBAD} }); - exit 1; - } - - if (($_ eq "PRE_REMOVE") || ($_ eq "POST_REMOVE") || ($_ eq "ENVLIST")) { next; } - my $pa = $pkg_hash{$pass}{$_}; - - # replace the kernel package with the name has the specific version - my @npa = (); - my @npa_group = (); - foreach my $p (@$pa) { - if ($p =~ /^kernel/ && $kernelver) { - - # get all files in $srcdir and $kerneldir - my @alldirs = ("$srcdir", "$kerneldir"); - my @allrpms = (); - foreach my $dir (@alldirs) { - my @files = `find $dir -name *.rpm`; - push @allrpms, @files; - } - my @kernelpkgs = (); - if ($p =~ /^kernel$/) { - @kernelpkgs = ("kernel-default", "kernel-default-base"); - } elsif ($p =~ /^kernel-ppc64$/) { - @kernelpkgs = ($p, $p . "-base"); - } else { - @kernelpkgs = ($p); - } - foreach my $kern (@kernelpkgs) { - my @rpm = grep /$kern-$krpmver/, @allrpms; - if (!@rpm) { - print "Cannot find the kernel package with the versioin $krpmver.\n"; - exit 1; - } - my $kernelname = "$kern-" . $krpmver; - push @npa, $kernelname; - } - } else { - if ($p =~ s/^@//) - { - push @npa_group, $p; - } - else - { - push @npa, $p; - } - } - } - if (@npa) { - $pkgnames .= " " . join(' ', @npa); - } - if (@npa_group) { - $group_pkgnames .= " " . join(' ', @npa_group); - } - } - my $envlist; - if (exists $pkg_hash{$pass}{ENVLIST}) { - $envlist = join(' ', @{ $pkg_hash{$pass}{ENVLIST} }); - } - if ($pkgnames) - { - print "$envlist $yumcmd $pkgnames\n"; - $rc = system("$envlist $yumcmd $pkgnames"); - $rc = $rc >> 8; - if (($rc) && ($rc != '104')) { - print "zypper invocation failed with rc: $rc\n"; - exit 1; - } - } - if ($group_pkgnames) - { - print "$envlist $yumcmd -t pattern $group_pkgnames\n"; - $rc = system("$envlist $yumcmd -t pattern $group_pkgnames"); - $rc = $rc >> 8; - if (($rc) && ($rc != '104')) { - print "zypper invocation failed with rc: $rc\n"; - exit 1; - } - } - } - - foreach $pass (sort { $a <=> $b } (keys(%extra_hash))) { - - my $index = 1; - - #remove the old repository for extra packages - if ($osver_host >= 11) { - my $result = `zypper -R $rootimg_dir $non_interactive lr |grep otherpkg|cut -f2 -d '|'|tr "\n" " "`; - if ($result =~ /\S/) { - system("zypper -R $rootimg_dir $non_interactive rr $result"); - } - } else { - my $result = `zypper -R $rootimg_dir $non_interactive sl |grep otherpkg|cut -f2 -d '|'|tr "\n" " "`; - if ($result =~ /\S/) { - system("zypper -R $rootimg_dir $non_interactive sd $result"); - } - } - - foreach (keys(%{ $extra_hash{$pass} })) { - if (($_ eq "PRE_REMOVE") || ($_ eq "POST_REMOVE") || ($_ eq "ENVLIST")) { next; } - if (-r "$srcdir_otherpkgs/$_/repodata/repomd.xml") { - if ($osver_host >= 11) { - system("zypper -R $rootimg_dir $non_interactive ar file:$srcdir_otherpkgs/$_ otherpkg$index"); - } else { - system("zypper -R $rootimg_dir $non_interactive sa file:$srcdir_otherpkgs/$_"); - } - } else { - if ($osver_host >= 11) { - system("zypper -R $rootimg_dir $non_interactive ar -t Plaindir file:$srcdir_otherpkgs/$_ otherpkg$index"); - } else { - system("zypper -R $rootimg_dir $non_interactive sa -t Plaindir file:$srcdir_otherpkgs/$_"); - } - } - $index++; - } - - # Refresh the zypper cache in case there is still old data out there - system("zypper -R $rootimg_dir $non_interactive refresh"); - - #remove the packages that are specified in the otherpkgs.list files with leading '-' - my $envlist; - if (exists $extra_hash{$pass}{ENVLIST}) { - $envlist = join(' ', @{ $extra_hash{$pass}{ENVLIST} }); - } - - my $yumcmd_remove = "zypper -R $rootimg_dir $non_interactive remove "; - if (exists($extra_hash{$pass}{'PRE_REMOVE'})) { - my $pa = $extra_hash{$pass}{'PRE_REMOVE'}; - my $rm_packges = join(' ', @$pa); - if ($rm_packges) { - print "$envlist $yumcmd_remove $rm_packges"; - $rc = system("$envlist $yumcmd_remove $rm_packges"); - } - } - - - #add extra packages in the list - if ($extrapkgnames{$pass}) { - print "$envlist $yumcmd $extrapkgnames{$pass}\n"; - $rc = system("$envlist $yumcmd $extrapkgnames{$pass}"); - $rc = $rc >> 8; - if (($rc) && ($rc != '104')) { - print "zypper invocation failed with rc: $rc\n"; - exit 1; - } - } - - #remove the packages that are specified in the otherpkgs.list files with leading '--' - if (exists($extra_hash{$pass}{'POST_REMOVE'})) { - my $pa = $extra_hash{$pass}{'POST_REMOVE'}; - my $rm_packges = join(' ', @$pa); - if ($rm_packges) { - print "$envlist $yumcmd_remove $rm_packges"; - $rc = system("$envlist $yumcmd_remove $rm_packges"); - } - } - - if (!$noupdate) { - - # run zypper update to update any installed rpms - # needed when running genimage again after updating software in repositories - my $yumcmd_update; - if ($osver_host >= 11) { - $yumcmd_update = "zypper -R $rootimg_dir $non_interactive update "; - } else { - $yumcmd_update = "zypper -R $rootimg_dir $non_interactive update "; - } - $rc = system("$yumcmd_update"); - } - } - - #remove the old repository for extra packages - if ($osver_host >= 11) { - my $result = `zypper -R $rootimg_dir $non_interactive lr |grep otherpkg|cut -f2 -d '|'|tr "\n" " "`; - if ($result =~ /\S/) { - system("zypper -R $rootimg_dir $non_interactive rr $result"); - } - } else { - my $result = `zypper -R $rootimg_dir $non_interactive sl |grep otherpkg|cut -f2 -d '|'|tr "\n" " "`; - if ($result =~ /\S/) { - system("zypper -R $rootimg_dir $non_interactive sd $result"); - } - } - - # ignore any return code - - postscripts(); #run 'postscripts' -} -unlink "/tmp/genimage.$$.yum.conf"; - -# added dracut mode -if ((-d "$rootimg_dir/usr/share/dracut") or (-d "$rootimg_dir/usr/lib/dracut")) { - $dracutmode = 1; - - # get dracut version - $dracutver = `chroot $rootimg_dir rpm -qi dracut | awk '/Version/{print \$3}' | awk -F. '{print \$1}'`; - chomp($dracutver); - if ($dracutver =~ /^\d\d\d$/) { - if ($dracutver >= "033") { - $dracutdir = "dracut_033"; - } else { - $dracutdir = "dracut"; # The default directory - } - } - print "Enter the dracut mode. Dracut version: $dracutver. Dracut directory: $dracutdir.\n"; -} - -# default to the first kernel found in the install image if nothing specified explicitly. -# A more accurate guess than whatever the image build server happens to be running -# If specified, that takes precedence. -# If image has one, that is used -# If all else fails, resort to uname -r like this script did before - -if (-e "$rootimg_dir/boot/vmlinux") { - $basekernelver = basename(readlink "$rootimg_dir/boot/vmlinux"); - if ($basekernelver eq "vmlinux") { - $basekernelver = ""; - } else { - $basekernelver =~ s/vmlinu.-//; - $basekernelver =~ s/image-//; - } -} - -unless ($basekernelver) { - my @KVERS = <$rootimg_dir/boot/vmlinu[xz]-*>; - - # The kernel name is different on s390x, e.g. image-2.6.32.9-0.5-default - @KVERS = <$rootimg_dir/boot/image-*> if $arch eq "s390x"; - foreach (@KVERS) { - s/vmlinu.-//; - s/image-//; - } - unless (scalar @KVERS) { - @KVERS = <$rootimg_dir/lib/modules/*>; - } - if (scalar @KVERS) { - foreach my $kver (@KVERS) { - unless ($kver =~ m/.gz$/) { - $basekernelver = basename($kver); - last; - } - } - } - - @KVERS = <$rootimg_dir/lib/modules/*> unless (scalar @KVERS); - $basekernelver = basename(pop @KVERS) if (scalar @KVERS); - $basekernelver = `uname -r` unless ($basekernelver); -} - -$kernelver = $basekernelver unless ($kernelver); -chomp $kernelver; - -#$updates{kernelver} = $kernelver if ($tempfile); - -# copy the kernel to $destdir -if (-e "$rootimg_dir/boot/vmlinux-$kernelver") { - copy("$rootimg_dir/boot/vmlinux-$kernelver", "$destdir/kernel"); -} elsif (-e "$rootimg_dir/boot/vmlinuz-$kernelver") { - copy("$rootimg_dir/boot/vmlinuz-$kernelver", "$destdir/kernel"); -} elsif (-e "$rootimg_dir/boot/image-$kernelver") { - copy("$rootimg_dir/boot/image-$kernelver", "$destdir/kernel"); -} else { - xdie "couldn't find the kernel file matched $kernelver in $rootimg_dir/boot !"; -} - -#-- run postinstall script -unless ($imagename) { - $postinstall_filename = imgutils::get_profile_def_filename($osver, $profile, $arch, $customdir, "postinstall"); - unless ($postinstall_filename) { - $postinstall_filename = imgutils::get_profile_def_filename($osver, $profile, $arch, $pathtofiles, "postinstall"); - } -} - -if ($postinstall_filename) { - - #print "postinstall_filename=$postinstall_filename\n"; - - #For Mellonax IB script. In diskless image, the uname -r not returning the rootimg level, - #because the "uname -r" only returns the version of the kernel in use - #create a temporary uname script. for every flag except for -r, it should just call the real - #uname with the same flags and return that info. - if (!(-e "$rootimg_dir/bin/orig_uname")) { - system("mv $rootimg_dir/bin/uname $rootimg_dir/bin/orig_uname"); - } - my $tmpuname; - open($tmpuname, ">", "$rootimg_dir/bin/uname"); - print $tmpuname <>$tempfile"); - if ($imagename) { - if (keys(%updates) > 0) { - print FILE "The output for table updates starts here\n"; - print FILE "table::linuximage\n"; - print FILE "imagename::$imagename\n"; - my @a = %updates; - print FILE join('::', @a) . "\n"; - print FILE "The output for table updates ends here\n"; - } - } else { - $updates_os{'profile'} = $profile; - $updates_os{'imagetype'} = 'linux'; - $updates_os{'provmethod'} = 'netboot'; - $updates_os{'osname'} = 'Linux'; - $updates_os{'osvers'} = $osver; - $updates_os{'osdistroname'} = 'sle'; # not used currently - $updates_os{'osarch'} = $arch; - - # update the imagename for stateless - print FILE "The output for table updates starts here\n"; - print FILE "table::osimage\n"; - print FILE "imagename::$osver-$arch-netboot-$profile\n"; - my @a = %updates_os; - print FILE join('::', @a) . "\n"; - print FILE "The output for table updates ends here\n"; - - print FILE "The output for table updates starts here\n"; - print FILE "table::linuximage\n"; - print FILE "imagename::$osver-$arch-netboot-$profile\n"; - my @a = %updates; - print FILE join('::', @a) . "\n"; - print FILE "The output for table updates ends here\n"; - - # update the imagename for statelite - $updates_os{'provmethod'} = 'statelite'; - print FILE "The output for table updates starts here\n"; - print FILE "table::osimage\n"; - print FILE "imagename::$osver-$arch-statelite-$profile\n"; - my @a = %updates_os; - print FILE join('::', @a) . "\n"; - print FILE "The output for table updates ends here\n"; - - print FILE "The output for table updates starts here\n"; - print FILE "table::linuximage\n"; - print FILE "imagename::$osver-$arch-statelite-$profile\n"; - my @a = %updates; - print FILE join('::', @a) . "\n"; - print FILE "The output for table updates ends here\n"; - } - close FILE; -} - -#END - - - -mkpath "$rootimg_dir/.statelite"; # create place for NFS mounts; -mkpath "$rootimg_dir/.sllocal/localmnt"; # create place for localdisk mount -mkpath "$rootimg_dir/.sllocal/log"; # create place for localdisk log - -mkpath "$rootimg_dir/root/.ssh"; # create place for NFS mounts for ssh; #TODO is necessary? - -# this script will get the directories; -# TODO: it seems it is re-copied in liteimg.pm -unless (-r "$pathtofiles/../add-on/statelite/rc.statelite") { - print "Can't find $pathtofiles/../add-on/statelite/rc.statelite!\n"; - exit; -} -system("cp $pathtofiles/../add-on/statelite/rc.statelite $rootimg_dir/etc/init.d/statelite"); -system("cp $pathtofiles/../add-on/statelite/rc.localdisk $rootimg_dir/etc/init.d/localdisk"); - -# added dracutmode -unless ($dracutmode) { #in dracut mode, we delegate all this activity - unless (-l "$rootimg_dir/var/lib/dhclient") { - mkpath "$rootimg_dir/var/lib/dhclient/"; - system("touch $rootimg_dir/var/lib/dhclient/dhclient-$prinic.leases"); - } - - unless (-l "$rootimg_dir/var/lib/dhcp") { - mkpath "$rootimg_dir/var/lib/dhcp/"; - system("touch $rootimg_dir/var/lib/dhcp/dhclient-$prinic.leases"); - } -} - - -# the dhcp client information stores in the directory "/var/lib/dhcpcd/" -unless (-l "$rootimg_dir/var/lib/dhcpcd") { - mkpath "$rootimg_dir/var/lib/dhcpcd/"; - system("touch $rootimg_dir/var/lib/dhcpcd/dhcpcd-$prinic.info"); -} - -#keyctl moved to /bin for newer release -system("cd $rootimg_dir/usr/bin/; ln -s ../../bin/keyctl $rootimg_dir/usr/bin/keyctl"); - -# which is different from the Redhat family - -# some rpms mounts the imageroot/proc on the /proc, need to release it, -# otherwise got kernal panic when installing -# sometimes, the proc fs is not mounted, so one warning/error message will display, -# and I add one check point here. -my $MFD; -open MFD, "/proc/mounts"; -my @lines = ; -close MFD; - -my $ret = grep m{$rootimg_dir/proc}, @lines; -if ($ret > 0) { - system("umount -l $rootimg_dir/proc"); -} - -# Load driver update disk, and copy them to the root image -my @dd_drivers = &load_dd(); - -# Push the drivers into the @ndrivers base on the order -my @new_order = (); -foreach my $dd (@dd_drivers) { - unless (grep { $_ eq $dd } @ndrivers) { - push @new_order, $dd; - } - print "Added driver $dd from driver update disk or driver rpm\n"; -} - -if (@new_order) { - @ndrivers = (@new_order, @ndrivers); -} - -# add drivers for local disk support -push @ndrivers, ("ext3.ko", "ext4.ko", "virtio_pci.ko", "virtio_blk.ko", "libata.ko", "scsi_mod.ko", "scsi_dh.ko", "ahci.ko", "megaraid_sas.ko", "sd_mod.ko"); - -if ($osver_host >= 12) { - push @ndrivers, ("ibmvscsi.ko"); -} else { # for sles11 or lower - push @ndrivers, ("ibmvscsic.ko", "ata_piix.ko", "pcieport.ko"); -} - -if (-f "$rootimg_dir/lib/modules/$kernelver/kernel/drivers/net/ethernet/mellanox/mlx4/mlx4_en.ko") { - for (@ndrivers) { - s/mlx_en/mlx4_en/; - } -} - -open($moddeps, "<", "$rootimg_dir/lib/modules/$kernelver/modules.dep"); -my @moddeps = <$moddeps>; -my @checkdeps = @ndrivers; -while (scalar @checkdeps) { - my $driver = pop @checkdeps; - my @lines = grep /\/$driver:/, @moddeps; - foreach (@lines) { - chomp; - s/.*://; - s/^\s*//; - my @deps = split /\s+/, $_; - if ($driver =~ /libcrc32c.ko/) { - push @deps, 'crc32c.ko'; - } - my $dep; - foreach $dep (@deps) { - $dep =~ s/.*\///; - unless (grep { $_ eq $dep } @ndrivers) { #only add if not added - print "Added $dep as an autodetected dependency\n"; - } - unshift(@checkdeps, $dep); #recursively check dependencies - unshift(@ndrivers, $dep); - } - } -} -close($moddeps); - -#remove the duplicated drivers -my @fulldrivers; -foreach my $dn (@ndrivers) { - unless (grep { $_ eq $dn } @fulldrivers) { - push @fulldrivers, $dn; - } -} -@ndrivers = @fulldrivers; - -# before mkinitrd, run depmod to generate the modules.dep -system("chroot $rootimg_dir depmod $kernelver"); - -if ($dracutmode) { - mkinitrd_dracut("stateless"); - mkinitrd_dracut("statelite"); -} else { - my @drivers; # backup of @ndrivers - push @drivers, @ndrivers; - mkinitrd("statelite"); - @ndrivers = (); - push @ndrivers, @drivers; - mkinitrd("stateless"); -} -print "It is safe to ignore message 'Failed to connect to bus: No such file or directory' that may have appeared above one or more times.\n"; - -sub getlibs { - my $file = shift; - my $liblist = `chroot $rootimg_dir ldd $file`; - if ($liblist =~ /not a dynamic executable/) { - return; - } - my @libs = split /\n/, $liblist; - my @return; - foreach (@libs) { - unless (/=>/) { - (my $wjnk, my $lib, my $jnk) = split /\s+/, $_, 3; - $lib =~ s/^\///; - $libhash{$lib} = 1; - next; - } - (my $temp1, my $temp2) = split />/, $_, 2; - (my $whitespace, $temp1, $temp2) = split /\s+/, $temp2, 4; - unless ($temp1 =~ /\//) { - next; - } - $temp1 =~ s/^\///; - $libhash{$temp1} = 1; - } -} - -#added dracut -sub mkinitrd_dracut { - my ($mode) = @_; # the mode is for statelite or stateless - - my $dracutmoduledir = "$rootimg_dir/usr/share/dracut/modules.d/"; - if ((!-d $dracutmoduledir) and (-d "$rootimg_dir/usr/lib/dracut/modules.d/")) - { - $dracutmoduledir = "$rootimg_dir/usr/lib/dracut/modules.d/"; - } - - if ($dracutver >= "033") { - - my $perm = (stat("$fullpath/$dracutdir/patch/syslog/module-setup.sh"))[2]; - cp("$fullpath/$dracutdir/patch/syslog/module-setup.sh", $dracutmoduledir . "98syslog/"); - chmod($perm & 07777, $dracutmoduledir . "98syslog/" . "module-setup.sh"); - - $perm = (stat("$fullpath/$dracutdir/patch/syslog/rsyslogd-start.sh"))[2]; - cp("$fullpath/$dracutdir/patch/syslog/rsyslogd-start.sh", $dracutmoduledir . "98syslog/"); - chmod($perm & 07777, $dracutmoduledir . "98syslog/" . "rsyslogd-start.sh"); - - $perm = (stat("$fullpath/$dracutdir/patch/syslog/syslog-genrules.sh"))[2]; - cp("$fullpath/$dracutdir/patch/syslog/syslog-genrules.sh", $dracutmoduledir . "98syslog/"); - chmod($perm & 07777, $dracutmoduledir . "98syslog/" . "syslog-genrules.sh"); - - } - - my $dracutmpath = $dracutmoduledir . "97xcat/"; - mkpath($dracutmpath); - - my $perm = (stat("$fullpath/$dracutdir/check"))[2]; - cp("$fullpath/$dracutdir/check", $dracutmpath); - chmod($perm & 07777, "$dracutmpath/check"); - - foreach (@ndrivers) { s/\.ko$//; } - - # Add drivers to support local disk - push @ndrivers, "ext3"; - push @ndrivers, "ext4"; - - #remove the duplicated drivers - my @fulldrivers; - foreach my $dn (@ndrivers) { - unless (grep { $_ eq $dn } @fulldrivers) { - push @fulldrivers, $dn; - } - } - @ndrivers = @fulldrivers; - - my $add_drivers = join(' ', @ndrivers); - print "Try to load drivers: $add_drivers to initrd.\n"; - my $DRACUTCONF; - - if ($mode eq "statelite") { - - # for statelite - cp("$fullpath/$dracutdir/install.statelite", "$dracutmpath/install"); - $perm = (stat("$fullpath/$dracutdir/install.statelite"))[2]; - chmod($perm & 07777, "$dracutmpath/install"); - - cp("$installroot/postscripts/updateflag.awk", "$dracutmpath/xcat-updateflag"); - $perm = (stat("$installroot/postscripts/updateflag.awk"))[2]; - chmod($perm & 07777, "$dracutmpath/xcat-updateflag"); - - cp("$fullpath/$dracutdir/xcat-prepivot.sh", $dracutmpath); - $perm = (stat("$fullpath/$dracutdir/xcat-prepivot.sh"))[2]; - chmod($perm & 07777, "$dracutmpath/xcat-prepivot.sh"); - - cp("$fullpath/$dracutdir/xcat-premount.sh", $dracutmpath); - $perm = (stat("$fullpath/$dracutdir/xcat-premount.sh"))[2]; - chmod($perm & 07777, "$dracutmpath/xcat-premount.sh"); - - #update etc/dracut.conf - open($DRACUTCONF, '>', "$rootimg_dir/etc/dracut.conf"); - if (-d glob($dracutmoduledir . "[0-9]*fadump")) { - print $DRACUTCONF qq{dracutmodules+="xcat nfs base network kernel-modules lvm fadump"\n}; - } - else { - print $DRACUTCONF qq{dracutmodules+="xcat nfs base network kernel-modules lvm"\n}; - } - print $DRACUTCONF qq{add_drivers+="$add_drivers"\n}; - print $DRACUTCONF qq{filesystems+="nfs"\n}; - close $DRACUTCONF; - } elsif ($mode eq "stateless") { - cp("$fullpath/$dracutdir/install.netboot", "$dracutmpath/install"); - $perm = (stat("$fullpath/$dracutdir/install.netboot"))[2]; - chmod($perm & 07777, "$dracutmpath/install"); - - cp("$fullpath/$dracutdir/xcat-cmdline.sh", "$dracutmpath/"); - $perm = (stat("$fullpath/$dracutdir/xcat-cmdline.sh"))[2]; - chmod($perm & 07777, "$dracutmpath/xcat-cmdline.sh"); - - cp("$installroot/postscripts/updateflag.awk", "$dracutmpath/xcat-updateflag"); - $perm = (stat("$installroot/postscripts/updateflag.awk"))[2]; - chmod($perm & 07777, "$dracutmpath/xcat-updateflag"); - if ($prinic) { - my $optspec; - open($optspec, '>>', "$dracutmpath/xcat-cmdline.sh"); - print $optspec "PRINIC=$prinic\n"; - close $optspec; - } - - cp("$fullpath/$dracutdir/xcatroot", "$dracutmpath/"); - $perm = (stat("$fullpath/$dracutdir/xcatroot"))[2]; - chmod($perm & 07777, "$dracutmpath/xcatroot"); - - cp("$fullpath/$dracutdir/installkernel", "$dracutmpath/"); - $perm = (stat("$fullpath/$dracutdir/installkernel"))[2]; - chmod($perm & 07777, "$dracutmpath/installkernel"); - - # update etc/dracut.conf - open($DRACUTCONF, '>', "$rootimg_dir/etc/dracut.conf"); - if (-d glob($dracutmoduledir . "[0-9]*fadump")) { - print $DRACUTCONF qq{dracutmodules+="xcat nfs base network kernel-modules lvm fadump syslog"\n}; - } - else { - print $DRACUTCONF qq{dracutmodules+="xcat nfs base network kernel-modules lvm syslog"\n}; - } - print $DRACUTCONF qq{add_drivers+="$add_drivers"\n}; - close $DRACUTCONF; - } else { - xdie "the mode: $mode is not supported by genimage"; - } - - my $additional_options = undef; - if ($rootlimit) - { - open(my $ETC_CMDLINE, ">", "$rootimg_dir/tmp/cmdline"); - print $ETC_CMDLINE qq{rootlimit=$rootlimit\n}; - close $ETC_CMDLINE; - $additional_options = qq{--include /tmp/cmdline /etc/cmdline}; - } - - # force the dracut run in non-hostonly mode for dracut higher than version 033 - if ($dracutver > "033") { - $additional_options .= " -N"; - } - - #if "pigz" is available in the rootimg, use "pigz" instead of "gzip" - my $compress = qx(chroot $rootimg_dir bash -c "type -p pigz"|tr -d "\n"); - if ($compress) { - - #take the online cpu numerber as the pigz processes number - my $processnum = qx(lscpu -p=cpu --online|grep -v '#'|wc -l|tr -d "\n"); - $additional_options .= " --compress \"$compress -p $processnum \""; - } - - print "\nchroot $rootimg_dir dracut $additional_options -f /tmp/initrd.$$.gz $kernelver\n"; - !system("chroot $rootimg_dir dracut $additional_options -f /tmp/initrd.$$.gz $kernelver") - or die("Error: failed to generate the initial ramdisk for $mode.\n"); - print "the initial ramdisk for $mode is generated successfully.\n"; - move("$rootimg_dir/tmp/initrd.$$.gz", "$destdir/initrd-$mode.gz"); -} - - -sub mkinitrd { - my ($mode) = @_; # statelite or stateless - - if ($mode eq "statelite") { - - # additional modules needed on s390x - push @ndrivers, qw{qdio.ko ccwgroup.ko qeth.ko qeth_l2.ko qeth_l3.ko} if ($arch eq "s390x"); - - # for nfs - my @modlist = qw{sunrpc.ko lockd.ko nfs_acl.ko fscache.ko auth_rpcgss.ko exportfs.ko nfsd.ko nfs.ko}; - unshift(@ndrivers, @modlist); - } - - mkpath("/tmp/xcatinitrd.$$/bin"); - symlink("bin", "/tmp/xcatinitrd.$$/sbin"); - mkpath("/tmp/xcatinitrd.$$/usr/bin"); - mkpath("/tmp/xcatinitrd.$$/usr/sbin"); - mkpath("/tmp/xcatinitrd.$$/usr/lib"); - mkpath("/tmp/xcatinitrd.$$/usr/lib64"); - mkpath("/tmp/xcatinitrd.$$/lib/firmware"); - mkpath("/tmp/xcatinitrd.$$/tmp"); - mkpath("/tmp/xcatinitrd.$$/var/run"); - mkpath("/tmp/xcatinitrd.$$/lib64/firmware"); - mkpath("/tmp/xcatinitrd.$$/lib/power6"); #SLES10 - mkpath("/tmp/xcatinitrd.$$/lib/power7"); #SLES10 - mkpath("/tmp/xcatinitrd.$$/lib/mkinitrd/bin"); - mkpath("/tmp/xcatinitrd.$$/proc"); - mkpath("/tmp/xcatinitrd.$$/sys"); - mkpath("/tmp/xcatinitrd.$$/dev/mapper"); - mkpath("/tmp/xcatinitrd.$$/sysroot"); - mkpath("/tmp/xcatinitrd.$$/etc/ld.so.conf.d"); - mkpath("/tmp/xcatinitrd.$$/var/lib/dhcpcd"); - my $inifile; - open($inifile, ">", "/tmp/xcatinitrd.$$/init"); - print $inifile "#!/bin/bash\n"; - - # copied from genimage for rh - # add some functions - print $inifile < <\\ \\____/ | \\ | - /__/\\_ \\\\______ /\\____|__ /____| - \\/ \\/ \\/ -' - echo -e "\$RESET" -} - - -EOS1 - - print $inifile "mount -t proc /proc /proc\n"; - print $inifile "mount -t sysfs /sys /sys\n"; - print $inifile "mount -o mode=0755 -t tmpfs /dev /dev\n"; - print $inifile "mkdir /dev/pts\n"; - print $inifile "mount -t devpts -o gid=5,mode=620 /dev/pts /dev/pts\n"; - print $inifile "mkdir /dev/shm\n"; - print $inifile "mkdir /dev/mapper\n"; - - print $inifile "mknod /dev/random c 1 8\n"; - print $inifile "mknod /dev/urandom c 1 9\n"; - print $inifile "mknod /dev/null c 1 3\n"; - print $inifile "mknod /dev/zero c 1 5\n"; - print $inifile "mknod /dev/systty c 4 0\n"; - print $inifile "mknod /dev/tty c 5 0\n"; - print $inifile "mknod /dev/console c 5 1\n"; - print $inifile "mknod /dev/ptmx c 5 2\n"; - print $inifile "mknod /dev/rtc c 10 135\n"; - print $inifile "mknod /dev/tty0 c 4 0\n"; - print $inifile "mknod /dev/tty1 c 4 1\n"; - print $inifile "mknod /dev/tty2 c 4 2\n"; - print $inifile "mknod /dev/tty3 c 4 3\n"; - print $inifile "mknod /dev/tty4 c 4 4\n"; - print $inifile "mknod /dev/tty5 c 4 5\n"; - print $inifile "mknod /dev/tty6 c 4 6\n"; - print $inifile "mknod /dev/tty7 c 4 7\n"; - print $inifile "mknod /dev/tty8 c 4 8\n"; - print $inifile "mknod /dev/tty9 c 4 9\n"; - print $inifile "mknod /dev/tty10 c 4 10\n"; - print $inifile "mknod /dev/tty11 c 4 11\n"; - print $inifile "mknod /dev/tty12 c 4 12\n"; - print $inifile "mknod /dev/ttyS0 c 4 64\n"; - print $inifile "mknod /dev/ttyS1 c 4 65\n"; - print $inifile "mknod /dev/ttyS2 c 4 66\n"; - print $inifile "mknod /dev/ttyS3 c 4 67\n"; - - # Install modules before starting udev - # because networking modules (qeth/qeth_l2/qeth_l3) are needed - foreach (@ndrivers) { - print $inifile "insmod /lib/$_\n"; - } - - # Start udev - print $inifile < /dev/null && export DEBUG=1\n"; - } - - print $inifile < /tmp/ifcfg-\$IFACE - -ip addr add dev lo 127.0.0.1/8 -ip link set lo up - - -XCATMASTER=`echo \$XCATSERVER|awk -F: '{print \$1}'` - -if [ -z \$XCATIPORT ]; then - XCATIPORT="3002" -fi - -if [ \$NODESTATUS != 'n' ]; then - /tmp/updateflag \$XCATMASTER \$XCATIPORT "installstatus netbooting" -fi - -cd / -for i in `cat /proc/cmdline`; do - KEY=`echo \$i |awk -F= '{print \$1}'` - if [ "\$KEY" == 'imgurl' ]; then - VALUE=`echo \$i |awk -F= '{print \$2}'` - if [ "http" == "`echo \$VALUE|awk -F: '{print \$1}'`" ]; then - #NOTE needs FT retry code to scale - #NOTE: should prob have max count - FILENAME=`echo \$VALUE|awk -F/ '{print \$NF}'` - while [ ! -r "\$FILENAME" ]; do - echo Getting \$VALUE... - if ! wget \$VALUE; then - sleep 5 #should be random, exponential for scale - rm -f \$FILENAME - fi - done - fi - elif [[ "\$KEY" == NFSROOT ]]; then # for NFSROOT - NFSROOT=1 - VALUE=`echo \$i |awk -F= '{print \$2}'` - SERVER=`echo \$VALUE|awk -F: '{print \$1}'` - ROOTDIR=`echo \$VALUE|awk -F/ '{for(i=2;i<=NF;i++) printf "/%s",\$i}'` - elif [ "\$KEY" == 'STATEMNT' ]; then - STATELITE=1 - VALUE=`echo \$i |awk -F= '{print \$2}'` - # VALUE may be null - if [ ! -z \$VALUE ]; then - SNAPSHOTSERVER=`echo \$VALUE|awk -F: '{print \$1}'` - SNAPSHOTROOT=`echo \$VALUE|awk -F/ '{for(i=2;i<=NF;i++) printf "/%s",\$i}'` - # may be that there is not server and just a directory. - if [ -z \$SNAPSHOTROOT ]; then - SNAPSHOTROOT=\$SNAPSHOTSERVER - SNAPSHOTSERVER= - fi - fi - elif [ "\$KEY" == 'NODE' ]; then - NODENAME=`echo \$i |awk -F= '{print \$2}'` - fi -done - -# show xCAT logo -fancydisplay - -# Statelite code is here -if [ "\$STATELITE" = "1" ]; then - echo Setting up Statelite - mknod /dev/loop0 b 7 0 - mkdir -p \$NEWROOT - MAXTRIES=15 - ITER=0 - ME=`hostname` - if [ ! -z "$NODENAME" ]; then - ME=$NODENAME - fi - if [ "\$NFSROOT" = "1" ]; then - while ! mount.nfs \${SERVER}:\${ROOTDIR}/rootimg \$NEWROOT -r -n -o nolock,rsize=32768,tcp,nfsvers=3,timeo=14; do - ITER=\$(expr \$ITER + 1) - if [ "\$ITER" = "\$MAXTRIES" ]; then - echo "You're dead. rpower \$ME boot to play again." - echo "Possible problems: -1. This initrd wan't created for the statelite node? -2. IS DNS set up? Maybe that's why I can't mount \${SERVER}. -3. The nfs modules aren't set right in this initial ramdisk?" - shell - exit - fi - echo -e "\${RED}Couldn't mount \$SERVER:\$ROOTDIR on \$NEWROOT \$RESET" - RS=\$(expr \$RANDOM % 30) - echo -e "Trying again in \$RS seconds" - sleep \$RS - done - else - # for statelite mode on top of the ramdisk -EOMS - - print $inifile "if [ -r /rootimg-statelite.gz ]; then \n"; - print $inifile "echo Setting up RAM-root tmpfs.\n"; - if ($rootlimit) { - print $inifile " mount -o size=$rootlimit,mode=755 -t tmpfs rootfs \$NEWROOT \n"; - } else { - print $inifile " mount -o mode=755 -t tmpfs rootfs \$NEWROOT \n"; - } - - print $inifile </dev/null && shell - mount -t tmpfs rw -o mode=$permission \$NEWROOT/\$RWDIR - mkdir -p \$NEWROOT/\$RWDIR/tmpfs - - #mount the /root/.ssh, it needs more strict permission in order for ssh work - #if [ ! -e "\$NEWROOT/root/.ssh" ] - #then - # mkdir -p \$NEWROOT/root/.ssh - #fi - #mount -t tmpfs -o mode=755 ssh \$NEWROOT/root/.ssh - - # mount the SNAPSHOT directory here for persistent use. - if [ ! -z \$SNAPSHOTSERVER ] - then - mkdir -p \$NEWROOT/\$RWDIR/persistent - MAXTRIES=5 - ITER=0 - while ! mount \$SNAPSHOTSERVER:\$SNAPSHOTROOT \$NEWROOT/\$RWDIR/persistent -o nolock,\$XCATMNTOPTS - do - ITER=\$(expr \$ITER + 1) - if [ "\$ITER" == "\$MAXTRIES" ] - then - echo "You're 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." - shell - exit - fi - echo -e "\${RED}Hmmm... Can't mount \$SNAPSHOTSERVER:\$SNAPSHOTROOT. \${NORMAL} \$XCATMNTOPTS" - RS=`expr \$RANDOM % 20` - echo -e "Trying again in \$RS seconds" - sleep \$RS - done - - # create directory which is named after my node name - mkdir -p \$NEWROOT/\$RWDIR/persistent/\$ME - ITER=0 - # umount current persistent mount - while ! umount -l \$NEWROOT/\$RWDIR/persistent; do - ITER=\$(( ITER + 1 )) - if [ "\$ITER" == "\$MAXTRIES" ]; then - echo "Your are dead, rpower \$ME boot to play again." - echo "Cannot umount \$NEWROOT/\$RWDIR/persistent." - /bin/sh - exit - fi - RS= \$(( \$RANDOM % 20 )) - echo "Trying again in \$RS seconds..." - sleep \$RS - done - - # mount persistent to server:/rootpath/nodename - ITER=0 - while ! mount \$SNAPSHOTSERVER:/\$SNAPSHOTROOT/\$ME \$NEWROOT/\$RWDIR/persistent -o nolock,\$XCATMNTOPTS; do - ITER=\$(( ITER + 1 )) - if [ "\$ITER" == "\$MAXTRIES" ]; then - echo "Your are dead, rpower \$ME boot to play again." - echo "Possible problems: cannot mount to \$SNAPSHOTSERVER:/\$SNAPSHOTROOT/\$ME." - /bin/sh - exit - fi - RS= \$(( \$RANDOM % 20 )) - echo "Trying again in \$RS seconds..." - sleep \$RS - done - fi - - grep '\\(shell\\)' /proc/cmdline >/dev/null && shell - - # have to preserve the initial DHCP request. So we link it. - # SLES uses different file to store DHCP info - if [ ! -d \$NEWROOT/\$RWDIR/tmpfs/var/lib/dhcpcd ] - then - mkdir -p \$NEWROOT/\$RWDIR/tmpfs/var/lib/dhcpcd - fi - cp -fp /var/lib/dhcpcd/dhcpcd-\$IFACE.info \${NEWROOT}/\${RWDIR}/tmpfs/var/lib/dhcpcd/dhcpcd-\$IFACE.info - - [ -e /etc/ntp.conf ] && mkdir -p \$NEWROOT/\$RWDIR/tmpfs/etc && cp /etc/ntp.conf \$NEWROOT/\$RWDIR/tmpfs/etc/ - - [ -e /etc/resolv.conf ] && mkdir -p \$NEWROOT/\$RWDIR/tmpfs/etc && cp /etc/resolv.conf \$NEWROOT/\$RWDIR/tmpfs/etc/ - - # now that everything is mounted, lets do this - # hmmm, apparently I'm checking this twice... so I'd better - # be really sure the file is there. - while [ ! -e \$NEWROOT/etc/init.d/statelite ] - do - echo "\$NEWROOT/etc/init.d/statelite does not exist in image!" - shell - done - - # try to configure the local disk - \$NEWROOT/etc/init.d/localdisk - - # do all the mounts: - \$NEWROOT/etc/init.d/statelite -EOMS - - # udevd needed by s390x for networking - # but for other type of machine, udevd will affect the start of devices which detected - # after the chroot, so kill it before the switching root - if ($arch ne "s390x") { - print $inifile "\n killall -9 udevd\n"; - } - - print $inifile < /dev/null && shell - - echo 0x100 > /proc/sys/kernel/real-root-dev - export keep_old_ip=yes - export fastboot=yes - export READONLY=yes - grep '\\(shell\\)' /proc/cmdline >/dev/null && shell - mount -n --bind /dev /sysroot/dev - umount /sys - umount /proc - - # sles use the standard utility to chroot - if ! exec /usr/bin/chroot \$NEWROOT /sbin/init - then - echo "" - echo -e "\${RED}Couldn't chroot. Something must be wrong with NFS root image.\${RESET}" - shell - fi - exit -fi -# end NFSROOT/Statelite code - -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 /sysroot - mkdir -p /sysroot/ro - mkdir -p /sysroot/rw - mount --move /ro /sysroot/ro - mount --move /rw /sysroot/rw -EOMS - print $inifile "elif [ -r /rootimg.cpio.gz ] || [ -r /rootimg.cpio.xz ]; then\n"; - print $inifile "echo Setting up RAM-root tmpfs.\n"; - if ($rootlimit) { - print $inifile " mount -o size=$rootlimit,mode=755 -t tmpfs rootfs \$NEWROOT\n"; - } else { - print $inifile " mount -o mode=755 -t tmpfs rootfs \$NEWROOT\n"; - } - print $inifile " cd /sysroot\n"; - print $inifile " echo -n \"Extracting root filesystem:\"\n"; - print $inifile " if [ -r /rootimg.cpio.gz ]; then\n"; - print $inifile " if [ -x /bin/cpio ]; then\n"; - print $inifile " zcat /rootimg.cpio.gz |/bin/cpio -idum\n"; - print $inifile " else\n"; - print $inifile " zcat /rootimg.cpio.gz |cpio -idum\n"; - print $inifile " fi\n"; - print $inifile " elif [ -r /rootimg.cpio.xz ]; then\n"; - print $inifile " if [ -x /bin/cpio ]; then\n"; - print $inifile " xz -cd /rootimg.cpio.xz |/bin/cpio -idum\n"; - print $inifile " else\n"; - print $inifile " xz -cd /rootimg.cpio.xz |cpio -idum\n"; - print $inifile " fi\n"; - print $inifile " fi\n"; - print $inifile " echo Done\n"; - print $inifile "elif [ -r /rootimg.tar.gz ] || [ -r /rootimg.tar.xz ]; then\n"; - print $inifile " echo Setting up RAM-root tmpfs.\n"; - - if ($rootlimit) { - print $inifile " mount -o \"size=$rootlimit,mode=755\" -t tmpfs rootfs \$NEWROOT\n"; - } else { - print $inifile " mount -o mode=755 -t tmpfs rootfs \$NEWROOT\n"; - } - print $inifile " cd \$NEWROOT\n"; - print $inifile " echo -n \"Extracting root filesystem:\"\n"; - print $inifile " if [ -r /rootimg.tar.gz ]; then\n"; - print $inifile " tar --selinux --xattrs-include='*' -zxf /rootimg.tar.gz\n"; - print $inifile " if [ \$? -ne 0 ]; then\n"; - print $inifile " tar -zxf /rootimg.tar.gz\n"; - print $inifile " fi\n"; - print $inifile " elif [ -r /rootimg.tar.xz ]; then\n"; - print $inifile " tar --selinux --xattrs-include='*' -Jxf /rootimg.tar.xz\n"; - print $inifile " if [ \$? -ne 0 ]; then\n"; - print $inifile " tar -Jxf /rootimg.tar.xz\n"; - print $inifile " fi\n"; - print $inifile " fi\n"; - print $inifile " echo Done\n"; - print $inifile "else\n"; - print $inifile " echo -n Failed to download image, panicing in 5...\n"; - print $inifile " for i in 4 3 2 1 0; do\n"; - print $inifile " /bin/sleep 1\n"; - print $inifile " echo -n \$i...\n"; - print $inifile " done\n"; - print $inifile " echo\n"; - print $inifile <" . "/tmp/xcatinitrd.$$/bin/netstart"); - print $inifile "#!/bin/bash \n"; - if ($osver_host == 10) { - print $inifile "dhcpcd \${1}\n"; - } else { # for sles11 or higher - # -p is used to keep the network connection during the shutdown. Used for nfs-based statelite shutdown - print $inifile "dhcpcd \${1} -p\n"; - } - - #-- Bring other NICs up in /bin/netstart in initrd for NIC failover - foreach (split /,/, $othernics) { - if (/^$/) { next; } - print $inifile "dhcpcd $_\n"; - } - - print $inifile <> /etc/HOSTNAME -END - - close($inifile); - - #if "nonodestatus" specified,do not update the nodestatus - system("mkdir -p /tmp/xcatinitrd.$$/tmp/"); - cp("$installroot/postscripts/updateflag.awk","/tmp/xcatinitrd.$$/tmp/updateflag"); - $perm = (stat("$installroot/postscripts/updateflag.awk"))[2]; - chmod($perm & 07777, "/tmp/xcatinitrd.$$/tmp/updateflag"); - - chmod(0755, "/tmp/xcatinitrd.$$/init"); - chmod(0755, "/tmp/xcatinitrd.$$/bin/netstart"); - - @filestoadd = (); - foreach (@ndrivers) { - if (-f "$customdir/$_") { - push @filestoadd, [ $_, "lib/$_" ]; - } elsif (-f "$pathtofiles/$_") { - push @filestoadd, [ $_, "lib/$_" ]; - } - } - if ($mode eq "statelite") { - foreach ("sbin/ifconfig", "usr/bin/clear", "usr/bin/touch", "usr/bin/cut", "usr/bin/rm", "bin/hostname", "usr/bin/egrep", "bin/ln", "bin/ls", "usr/bin/dirname", "usr/bin/expr", "usr/bin/chroot", "usr/bin/grep", "bin/cpio", "bin/sleep", "bin/mount", "bin/umount", "sbin/dhcpcd", "bin/bash", "sbin/insmod", "bin/mkdir", "bin/mknod", "sbin/ip", "bin/cat", "usr/bin/awk", "usr/bin/wget", "bin/cp", "usr/bin/cpio", "usr/bin/zcat", "usr/bin/gzip", "lib/mkinitrd/bin/run-init", "usr/bin/uniq", "usr/bin/sed", "usr/bin/wc", "bin/sed", "sbin/udevd", "usr/bin/readlink", "usr/sbin/parted", "sbin/mke2fs", "sbin/mkswap", "sbin/swapon", "bin/chmod", "usr/bin/bc", "usr/bin/xz", "usr/bin/gzip", "bin/tar") { - getlibs($_); - push @filestoadd, $_; - } - if ($osver_host >= 11) { - foreach ("sbin/mount.nfs", "sbin/umount.nfs", "sbin/udevadm") { - getlibs($_); - push @filestoadd, $_; - } - } - - } else { - foreach ("sbin/ifconfig", "usr/bin/clear", "usr/bin/touch", "usr/bin/grep", "usr/bin/egrep", "bin/cpio", "bin/sleep", "bin/mount", "sbin/dhcpcd", "bin/bash", "sbin/insmod", "bin/mkdir", "bin/mknod", "sbin/ip", "bin/cat", "usr/bin/awk", "usr/bin/wget", "bin/cp", "usr/bin/cpio", "usr/bin/zcat", "usr/bin/gzip", "lib/mkinitrd/bin/run-init", "usr/bin/uniq", "usr/bin/sed", "sbin/udevd", "usr/bin/readlink", "usr/bin/expr", "usr/sbin/parted", "sbin/mke2fs", "sbin/mkswap", "sbin/swapon", "bin/chmod", "usr/bin/bc", "usr/bin/xz", "usr/bin/gzip", "bin/tar") { - getlibs($_); - push @filestoadd, $_; - } - if ($osver_host >= 11) { - getlibs("sbin/udevadm"); - push @filestoadd, "sbin/udevadm"; - } - } - - if ($arch =~ /64/) { - push @filestoadd, "lib64/libnss_dns.so.2"; - push @filestoadd, "lib64/libnss_files.so.2"; - } - else { - push @filestoadd, "lib/libnss_dns.so.2"; - push @filestoadd, "lib/libnss_files.so.2"; - } - - # cross-platfrom support on power6&7 etc - # ldd can't handle such one scenario: mn is power6, the target platform is power7 - if ($arch =~ /ppc64/) { - system("cp -a -r $rootimg_dir/lib64/* /tmp/xcatinitrd.$$/lib64/"); - } - - - push @filestoadd, keys %libhash; - - find(\&isnetdriver, <$rootimg_dir/lib/modules/$kernelver/*>); - my $pathonrootimage = "$rootimg_dir/tmpfiles"; - my $pathinrootimage = "/tmpfiles"; - mkpath($pathonrootimage); - foreach (@filestoadd) { - if (ref($_)) { - - #print "$_->[0], $_->[1]\n"; - my $srcfile = $_->[0]; - system("chroot $rootimg_dir cp $srcfile $pathinrootimage"); - my $srcpath = "$pathonrootimage/" . basename($_->[0]); - if (-f "$customdir/" . $_->[0]) { - $srcpath = "$customdir/" . $_->[0]; - } elsif (-f "$pathtofiles/" . $_->[0]) { - $srcpath = "$pathtofiles/" . $_->[0]; - } - mkpath(dirname("/tmp/xcatinitrd.$$/" . $_->[1])); - copy($srcpath, "/tmp/xcatinitrd.$$/" . $_->[1]); - chmod 0755, "/tmp/xcatinitrd.$$/" . $_->[1]; - } else { - - #print "$_\n"; - system("chroot $rootimg_dir cp $_ $pathinrootimage"); - my $srcpath = "$pathonrootimage/" . basename($_); - if (-f "$customdir/$_") { - $srcpath = "$customdir/$_"; - } elsif (-f "$pathtofiles/$_") { - $srcpath = "$pathtofiles/$_"; - } - mkpath(dirname("/tmp/xcatinitrd.$$/$_")); - copy("$srcpath", "/tmp/xcatinitrd.$$/$_"); - chmod 0755, "/tmp/xcatinitrd.$$/" . $_; - } - } - rmtree($pathonrootimage); - - #copy conf files needed by nfs mount in sles11.2 - if ($osver_host >= 11) - { - system("cp -r $rootimg_dir/etc/protocols /tmp/xcatinitrd.$$/etc/"); - system("cp -r $rootimg_dir/etc/netconfig /tmp/xcatinitrd.$$/etc/"); - } - - - # Copy udev libraries - system("mkdir -p /tmp/xcatinitrd.$$/etc/udev"); - system("mkdir -p /tmp/xcatinitrd.$$/lib/firmware"); - system("cp -r $rootimg_dir/etc/udev/* /tmp/xcatinitrd.$$/etc/udev"); - system("cp -r $rootimg_dir/bin/uname /tmp/xcatinitrd.$$/bin/"); - if (-d "$rootimg_dir/lib/firmware/") { - system("cp -r $rootimg_dir/lib/firmware/* /tmp/xcatinitrd.$$/lib/firmware"); - } - system("cp -r $rootimg_dir/usr/bin/killall /tmp/xcatinitrd.$$/usr/bin"); - - # Copy rules for network adapter - #my $name = `cat /etc/sysconfig/network/ifcfg-$prinic | grep NAME`; - #my $nic = ''; - #if ($name =~ m/(\d+\.\d+\.\d+)/g) { - # $nic = $&; - #} - - # Somehow checking for *$nic.rules does not work - #if ( -f "/etc/udev/rules.d/*$nic.rules" ) { - # system("cp -r /etc/udev/rules.d/*$nic.rules /tmp/xcatinitrd.$$/etc/udev/rules.d"); - #} - #if ( -f "/etc/udev/rules.d/*persistent-net.rules" ) { - # system("cp -r /etc/udev/rules.d/*persistent-net.rules /tmp/xcatinitrd.$$/etc/udev/rules.d"); - #} - - system("mkdir -p /tmp/xcatinitrd.$$/lib/udev"); - system("cp -r $rootimg_dir/lib/udev/* /tmp/xcatinitrd.$$/lib/udev"); - - #copy("$rootimg_dir/lib/modules/*d","/tmp/xcatinitrd.$$/$_"); - system("cd /tmp/xcatinitrd.$$/bin/; ln -sf bash sh"); #neccessary for SLES11 - if ($mode eq "statelite") { - system("cd /tmp/xcatinitrd.$$;find .|cpio -H newc -o|gzip -9 -c - > $destdir/initrd-statelite.gz"); - print "The initial ramdisk for statelite has been generated successfully!\n"; - } else { - system("cd /tmp/xcatinitrd.$$;find .|cpio -H newc -o|gzip -9 -c - > $destdir/initrd-stateless.gz"); - print "The initial ramdisk for stateless has been generated successfully!\n"; - } - system("rm -rf /tmp/xcatinitrd.$$"); - -} - -sub isyumdir { - if ($File::Find::name =~ /\/repodata$/) { - my $location = $File::Find::name; - $location =~ s/\/repodata$//; - push @yumdirs, $location; - } -} - -sub isnetdriver { - foreach (@ndrivers) { - if ($File::Find::name =~ /\/$_/) { - my $filetoadd = $File::Find::name; - $filetoadd =~ s!$rootimg_dir!!; - push @filestoadd, [ $filetoadd, "lib/$_" ]; - print "Added driver $_ to initrd\n"; - } - } -} - - - - - - - -sub postscripts { # TODO: customized postscripts - generic_post(); - unless (-d "$rootimg_dir/opt/xcat/") { - mkdir "$rootimg_dir/opt/xcat/"; - } - copy("$installroot/postscripts/xcatdsklspost", "$rootimg_dir/opt/xcat/"); #TODO: it is not used in stateless - chmod '0755', "$rootimg_dir/opt/xcat/xcatdsklspost"; -} - -sub generic_post { # This function is meant to leave the image in a state approximating a normal install - my $cfgfile; - - #modify /etc/sysconfig/clock in the image:HWCLOCK="--local", TIMEZONE=site:timezone - if ($timezone) { - if (-e "$rootimg_dir/etc/sysconfig/clock") { - system("sed -i '" . 's!\(TIMEZONE=\).*!\1' . "\"$timezone\"!" . "' $rootimg_dir/etc/sysconfig/clock"); - } - system("chroot $rootimg_dir zic -l $timezone"); - } - - if (-e "$rootimg_dir/etc/sysconfig/clock") { - system("sed -i 's!\\(HWCLOCK=\\).*!\\1\"--localtime\"!' $rootimg_dir/etc/sysconfig/clock"); - } - - unlink("$rootimg_dir/dev/null"); - system("mknod $rootimg_dir/dev/null c 1 3"); - open($cfgfile, ">", "$rootimg_dir/etc/fstab"); - print $cfgfile "devpts /dev/pts devpts gid=5,mode=620 0 0\n"; - print $cfgfile "tmpfs /dev/shm tmpfs defaults 0 0\n"; - print $cfgfile "proc /proc proc defaults 0 0\n"; - print $cfgfile "sysfs /sys sysfs defaults 0 0\n"; - if ($tmplimit) { - print $cfgfile "tmpfs /tmp tmpfs defaults,size=$tmplimit 0 2\n"; - print $cfgfile "tmpfs /var/tmp tmpfs defaults,size=$tmplimit 0 2\n"; - } else { - print $cfgfile "tmpfs /tmp tmpfs defaults,size=10m 0 2\n"; - print $cfgfile "tmpfs /var/tmp tmpfs defaults,size=10m 0 2\n"; - } - - my $rootfs_name = $profile . "_" . $arch; - print $cfgfile "$rootfs_name / tmpfs rw 0 1\n"; - - close($cfgfile); - - open($cfgfile, ">", "$rootimg_dir/etc/sysconfig/network"); - print $cfgfile "NETWORKING=yes\n"; - close($cfgfile); - - open($cfgfile, ">", "$rootimg_dir/etc/resolv.conf"); - print $cfgfile "#Dummy resolv.conf to make boot cleaner"; - close($cfgfile); - - # Create the ifcfg-x file for diskless node. But keep the ONBOOT=no - # to skip the break of nfs-based boot - if ($prinic) { - open($cfgfile, ">", "$rootimg_dir/etc/sysconfig/network/ifcfg-$prinic"); - print $cfgfile "ONBOOT=no\nBOOTPROTO=dhcp\nDEVICE=$prinic\nSTARTMODE=auto\n"; - close($cfgfile); - } - - foreach (split /,/, $othernics) { - next if (/^$/); - open($cfgfile, ">", "$rootimg_dir/etc/sysconfig/network/ifcfg-$_"); - print $cfgfile "ONBOOT=yes\nBOOTPROTO=dhcp\nDEVICE=$_\nSTARTMODE=auto\n"; - close($cfgfile); - } - - # securetty not needed on s390x - if ($arch ne "s390x") { - open($cfgfile, ">>", "$rootimg_dir/etc/securetty"); - print $cfgfile "ttyS0\n"; - print $cfgfile "ttyS1\n"; - print $cfgfile "console\n"; - close($cfgfile); - } - - my @passwd; - open($cfgfile, "<", "$rootimg_dir/etc/passwd"); - @passwd = <$cfgfile>; - close($cfgfile); - open($cfgfile, ">", "$rootimg_dir/etc/passwd"); - foreach (@passwd) { - if (/^root:/) { - s/^root:\*/root:x/; - } - print $cfgfile $_; - } - close($cfgfile); - foreach (<$rootimg_dir/etc/skel/.*>) { - next if (basename($_) eq '.' or basename($_) eq '..'); - copy $_, "$rootimg_dir/root/"; - } - - # gettyset is not found on s390x - if ($arch ne "s390x") { - open($cfgfile, ">", "$rootimg_dir/etc/init.d/gettyset"); - print $cfgfile "#!/bin/bash\n"; - print $cfgfile "### BEGIN INIT INFO\n"; - print $cfgfile "# Provides: gettyset\n"; - print $cfgfile "# Required-Start: sshd\n"; - print $cfgfile "# Required-Stop:\n"; - print $cfgfile "# Default-Start: 3\n"; - print $cfgfile "# Default-Stop: 0 1 2 6\n"; - print $cfgfile "# Short-Description: gettyset\n"; - print $cfgfile "# Description:\n"; - print $cfgfile "### END INIT INFO\n"; - print $cfgfile "VERS=`grep VERSION /etc/SuSE-release`\n"; - print $cfgfile "if [ -n \"\$VERS\" ]; then\n"; - print $cfgfile " VERNUM=`echo \$VERS|awk -F= \'{print \$2}\'|sed -e \'s/ //g\'`\n"; - print $cfgfile "fi\n"; - print $cfgfile "if [ \"\$VERNUM\" -gt 10 ]; then\n"; - print $cfgfile " exit\n"; - print $cfgfile "fi\n"; - print $cfgfile "\n"; - print $cfgfile "for i in `cat /proc/cmdline`; do\n"; - print $cfgfile ' KEY=`echo $i|cut -d= -f 1`' . "\n"; - print $cfgfile " if [ \"\$KEY\" == \"console\" -a \"\$i\" != \"console=tty0\" ]; then\n"; - print $cfgfile " VALUE=`echo \$i | cut -d= -f 2`\n"; - print $cfgfile " COTTY=`echo \$VALUE|cut -d, -f 1`\n"; - print $cfgfile " COSPEED=`echo \$VALUE|cut -d, -f 2|cut -dn -f 1`\n"; - print $cfgfile " if echo \$VALUE | grep n8r; then\n"; - print $cfgfile " FLOWFLAG=\"-h\"\n"; - print $cfgfile " fi\n"; - print $cfgfile " echo xco:2345:respawn:/sbin/agetty \$FLOWFLAG \$COTTY \$COSPEED xterm >> /etc/inittab\n"; - print $cfgfile " init q\n"; - print $cfgfile " fi\n"; - print $cfgfile "done\n"; - print $cfgfile "/etc/init.d/boot.localnet start\n"; - - close($cfgfile); - chmod(0755, "$rootimg_dir/etc/init.d/gettyset"); - } - - copy("$installroot/postscripts/xcatpostinit", "$rootimg_dir/etc/init.d/xcatpostinit"); - chmod(0755, "$rootimg_dir/etc/init.d/xcatpostinit"); - copy("$installroot/postscripts/xcatpostinit.service", "$rootimg_dir/usr/lib/systemd/system/xcatpostinit.service"); - - # - # set certain system services to start on boot, if the file exists in /etc/init.d as a script, - # use insserv to start it. If not, assume that the service is controlled by systemctl - # - # note: insserv is passed the -f option to ignore the dependency on sles10.4 - # - print "[genimage] setting services to start at boot time...\n"; - my @services; - push @services, qw/sshd network gettyset xcatpostinit/; - - foreach my $service (@services) { - my $cmd = "chroot $rootimg_dir "; - $cmd = $cmd . "systemctl enable $service.service"; - system("$cmd"); - } - - # - # Check if .depend.start file exists. For SLES12 and later OS, this does not apply - # - if (-r '$rootimg_dir/etc/init.d/.depend.start') { - my $rc = system("grep sshd $rootimg_dir/etc/init.d/.depend.start | grep TARGETS"); - if ($rc) { - system("sed -i '" . 's/^\(TARGETS = .*\)$/\1 sshd/' . "' $rootimg_dir/etc/init.d/.depend.start"); - system("ln -s ../sshd $rootimg_dir/etc/init.d/rc3.d/S20sshd"); - } - my $rc = system("grep gettyset $rootimg_dir/etc/init.d/.depend.start | grep TARGETS"); - if ($rc) { - system("sed -i '" . 's/^\(TARGETS = .*\)$/\1 gettyset/' . "' $rootimg_dir/etc/init.d/.depend.start"); - system("ln -s ../gettyset $rootimg_dir/etc/init.d/rc3.d/S60gettyset"); - } - } -} - - -my $driver_name; -my $real_path; - -sub get_path () -{ - if ($File::Find::name =~ /\/$driver_name/) { - $real_path = $File::Find::name; - } -} - -my @all_real_path; - -sub get_all_path () -{ - if ($File::Find::name =~ /\/$driver_name/) { - push @all_real_path, $File::Find::name; - } -} - -# Load driver disk and driver rpm to the initrd -# Get the driver disk or driver rpm from the osimage.driverupdatesrc -# The valid value: dud:/install/dud/dd.img,rpm:/install/rpm/d.rpm, if missing the tag: 'dud'/'rpm' -# the 'rpm' is default. -# -# If cannot find the driver disk from osimage.driverupdatesrc, will try to search driver disk -# from /install/driverdisk// -# -# For driver rpm, the driver list will be gotten from osimage.netdrivers. If not set, copy all the drivers from driver -# rpm to the initrd. -# -# Return the driver names by loading order - -sub load_dd() -{ - my @dd_list; - my @rpm_list; - my @driver_list; - - my $Injectalldriver; - my @rpm_drivers; - - # Parse the parameters to the the source of Driver update disk and Driver rpm, and driver list as well - if ($driverupdatesrc) { - my @srcs = split(',', $driverupdatesrc); - foreach my $src (@srcs) { - if ($src =~ /dud:(.*)/i) { - push @dd_list, $1; - } elsif ($src =~ /rpm:(.*)/i) { - push @rpm_list, $1; - } else { - push @rpm_list, $src; - } - } - } - if (!@dd_list) { - - # get Driver update disk from the default path if not specified in osimage - # check the Driver Update Disk images, it can be .img or .iso - if (-d "$installroot/driverdisk/$osver/$arch") { - @dd_list = `find $installroot/driverdisk/$osver/$arch -type f`; - } - } - - foreach (split /,/, $netdriver) { - if (/^allupdate$/) { - $Injectalldriver = 1; - next; - } - unless (/\.ko$/) { - s/$/.ko/; - } - push @driver_list, $_; - } - - chomp(@dd_list); - chomp(@rpm_list); - - unless (@dd_list || (@rpm_list && ($Injectalldriver || @driver_list))) { - return (); - } - - # Create the work space, it should be cleaned at end of genimage - my $dd_dir = mkdtemp("/tmp/ddtmpXXXXXXX"); - mkpath "$dd_dir/mnt"; - mkpath "$dd_dir/mods"; - - my @dd_drivers = (); #driver names - - # Load drivers from each Driver Disk - # For multiple dd, if want to make it has order, rename the dd with a number - # ahead of the name like 0_xx, 1_xx - foreach my $dd (sort(@dd_list)) { - my $rc = system("mount -o loop $dd $dd_dir/mnt"); - if ($rc) { - print "mount the Driver Disk $dd failed.\n"; - next; - } - - mkpath "$dd_dir/full"; - - # Copy out the drivers - opendir(DIR, "$dd_dir/mnt") || die "Cannot open dir $dd_dir/mnt"; - while (my $dir = readdir(DIR)) { - if ($dir =~ /^\./) { next; } - - # Every driver update disk can have multiple directories, each directory - # has the directory format like /linux/[distribution]/[architechture]-[version]/ - # If the directory name is numeric, then it will be used as order to load the - # the dirviers inside. - # For the directory name which is not numeric, copy them to directory 0. It will be - # loaled first. - if ($dir !~ /^\d*$/) { - mkpath "$dd_dir/full/0"; - system("cp -rf $dd_dir/mnt/$dir $dd_dir/full/0"); - } else { - system("cp -rf $dd_dir/mnt/$dir $dd_dir/full/"); - } - } - closedir(DIR); - - # Get all the kernel modules base on the order of directory name. - - # The structure of dd: /linux/[distribution]/[architechture]-[version]/ - - # The supported arch: i386, ia64, ppc, ppc64, s390, s390x sparc or x86_64. - my $darch = $arch; - if ($darch =~ /^x86$/) { - $darch = "i386"; - } - - # If the version is os version. If the os is "sles11.1", the possible os version - # could be "sles11.1", "11.1", "11", "sles11" - my @distro = ($osver); - my $distro1 = $osver; - $distro1 =~ s/[^\d]*//; - push @distro, $distro1; - my $distro2 = $distro1; - $distro2 =~ s/\..*//; - push @distro, $distro2; - my $distro3 = $osver; - $distro3 =~ s/\..*//; - push @distro, $distro3; - - opendir(FDIR, "$dd_dir/full") || die "Cannot open dir $dd_dir/full"; - my @fulldir = readdir(FDIR); - closedir(FDIR); - - # Create the directory for drivers from driver disk - if (!-d "$rootimg_dir/lib/modules/$kernelver/kernel/drivers/driverdisk") { - mkpath "$rootimg_dir/lib/modules/$kernelver/kernel/drivers/driverdisk"; - } - - # Copy the drivers to the root image and get the driver loading order - foreach my $dir (sort(@fulldir)) { - if ($dir =~ /^\./) { next; } - my $vdir; - foreach (@distro) { - if (-d "$dd_dir/full/$dir/linux/suse/$darch-$_") { - $vdir = "$dd_dir/full/$dir/linux/suse/$darch-$_"; - } - } - if (!$vdir) { next; } - - # Use the module_order if it has - if (-f "$vdir/modules/module.order") { - open(ORDER, "<", "$vdir/modules/module.order"); - while (my $file = ) { - chomp($file); - if (-f "$vdir/modules/$file") { - $driver_name = $file; - $real_path = ""; - find(\&get_path, <$rootimg_dir/lib/modules/$kernelver/*>); - if ($real_path eq "") { - system("cp $vdir/modules/$file $rootimg_dir/lib/modules/$kernelver/kernel/drivers/driverdisk"); - } else { - system("cp $vdir/modules/$file $real_path"); - } - - push @dd_drivers, $file; - } - } - } else { - opendir(MDIR, "$vdir/modules") || die "Cannot open dir $vdir/modules"; - while (my $file = readdir(MDIR)) { - if (-f "$vdir/modules/$file" && $file =~ /\.ko/) { - $driver_name = $file; - $real_path = ""; - find(\&get_path, <$rootimg_dir/lib/modules/$kernelver/*>); - if ($real_path eq "") { - system("cp $vdir/modules/$file $rootimg_dir/lib/modules/$kernelver/kernel/drivers/driverdisk"); - } else { - system("cp $vdir/modules/$file $real_path"); - } - - push @dd_drivers, $file; - } - } - } - } - - rmtree "$dd_dir/full"; - - my $rc = system("umount -f $dd_dir/mnt"); - if ($rc) { - print "umount the directory $dd_dir/mnt failed\n"; - exit 1; - } - } - - # Loading the drivers from rpm packages - if (@rpm_list && ($Injectalldriver || @driver_list)) { - - # Extract the files from rpm to the tmp dir - mkpath "$dd_dir/rpm"; - foreach my $rpm (@rpm_list) { - if (-r $rpm) { - if (system("cd $dd_dir/rpm; rpm2cpio $rpm | cpio -idum")) { - print "Error: Cannot extract the files from the rpm $rpm.\n"; - } - } else { - print "Error: Cannot read the rpm $rpm.\n"; - } - } - - # To skip the conflict of files that some rpm uses the xxx.ko.new as the name of the driver - # Change it back to xxx.ko here - $driver_name = "\*ko.new"; - @all_real_path = (); - find(\&get_all_path, <$dd_dir/rpm/*>); - foreach my $file (@all_real_path) { - my $newname = $file; - $newname =~ s/\.new$//; - if (system("mv -f $file $newname")) { - print "Error: Could not rename $file\n"; - - } - } - - # Copy the firmware to the rootimage - if (-d "$dd_dir/rpm/lib/firmware") { - system("cp -rf $dd_dir/rpm/lib/firmware $rootimg_dir/lib"); - } - - # if $ignorekernelchk is specified, copy all driver files to target kernel dir - if ($ignorekernelchk) { - my @kernelpath4vrpm = <$dd_dir/rpm/lib/modules/*>; - foreach my $path (@kernelpath4vrpm) { - if ($path eq "$dd_dir/rpm/lib/modules/$kernelver") { - next; - } - - unless (-d "$dd_dir/rpm/lib/modules/$kernelver") { - mkpath "$dd_dir/rpm/lib/modules/$kernelver"; - } - system("/bin/cp -rf $path/* $dd_dir/rpm/lib/modules/$kernelver"); - } - } - - # Copy the drivers to the rootimage - if (-d "$dd_dir/rpm/lib/modules/$kernelver") { - - #mkpath "$rootimg_dir/lib/modules/$kernelver/updates/"; - if (@driver_list) { - foreach my $driver (@driver_list) { - $driver_name = $driver; - $real_path = ""; - find(\&get_path, <$dd_dir/rpm/lib/modules/$kernelver/*>); - if ($real_path && $real_path =~ m!$dd_dir/rpm(/lib/modules/$kernelver/.*?)[^\/]*$!) { - - # remove the old one if existing - @all_real_path = (); - find(\&get_all_path, <$rootimg_dir/lib/modules/$kernelver/*>); - foreach (@all_real_path) { - if (-r $_) { - unlink($_); - } - } - - if (!-d "$rootimg_dir$1") { - mkpath "$rootimg_dir$1"; - } - system("cp -rf $real_path $rootimg_dir$1"); - push @rpm_drivers, $driver; - } else { - print "Warning: cannot find the driver $driver from the driver rpms\n"; - } - } - } elsif ($Injectalldriver) { - - # copy all the drviers to the rootimage - $driver_name = "\*\.ko"; - @all_real_path = (); - find(\&get_all_path, <$dd_dir/rpm/lib/modules/$kernelver/*>); - my @all_drivers = @all_real_path; - foreach my $new_driver (@all_drivers) { - if (basename($new_driver) =~ /\.ko$/) { - - # remove the old one if existing - $driver_name = basename($new_driver); - @all_real_path = (); - find(\&get_all_path, <$rootimg_dir/lib/modules/$kernelver/*>); - foreach my $old_driver (@all_real_path) { - if (-r $old_driver) { - unlink($old_driver); - } - } - push @rpm_drivers, basename($new_driver); - } - } - - system("cp -rf $dd_dir/rpm/lib/modules/$kernelver $rootimg_dir/lib/modules/"); - } - } else { - print "Warning: cannot find the kernel $kernelver from drvier rpms\n"; - } - - push @dd_drivers, @rpm_drivers; - } - - # Generate the dependency relationship - system("chroot '$rootimg_dir' depmod $kernelver"); - - # Clean the env - rmtree "$dd_dir"; - - return @dd_drivers; -} - -sub usage { - print 'Usage: genimage -o [-a ] -p -i -n [-r ] [-k ] [-g ] [-l rootlimitsize] [--permission ] [--interactive]' . "\n"; - print " --permission is used for statelite only\n"; - print "Examples:\n"; - print " genimage -i eth0 -n tg3 -o sles11 -p compute\n"; - print " genimage -i eth0 -r eth1,eth2 -n tg3,bnx2 -o sles11 -p compute --interactive\n"; - print " genimage -i eth0 -n tg3,bnx2 -o sles11 -p compute\n"; - print " genimage -i eth0 -n tg3,bnx2 -o sles11 -p compute --permission 777\n"; - return 0; -} - diff --git a/xCAT-server/share/xcat/netboot/sle/compute.sle15.x86_64.exlist b/xCAT-server/share/xcat/netboot/sles/compute.sle15.exlist similarity index 100% rename from xCAT-server/share/xcat/netboot/sle/compute.sle15.x86_64.exlist rename to xCAT-server/share/xcat/netboot/sles/compute.sle15.exlist diff --git a/xCAT-server/share/xcat/netboot/sles/compute.sle15.pkglist b/xCAT-server/share/xcat/netboot/sles/compute.sle15.pkglist new file mode 100644 index 000000000..ead89aa5e --- /dev/null +++ b/xCAT-server/share/xcat/netboot/sles/compute.sle15.pkglist @@ -0,0 +1,48 @@ +aaa_base +coreutils +bash +dbus +wicked +device-mapper +dracut +nfs-kernel-server +keyutils +lvm2 +openssl +dhcp-client +openssh +procps +psmisc +wget +sysconfig +rsyslog +vim +rsync +timezone +bc +ntp +gzip +e2fsprogs +parted +binutils +tar +open-iscsi +curl +plymouth +btrfsprogs +cryptsetup +dmraid +mdadm +multipath-tools +gpg2 +which +cifs-utils +open-lldp +fcoe-utils +util-linux-systemd +plymouth-dracut +udev +kernel-default +kernel-firmware +adaptec-firmware +xz diff --git a/xCAT-server/share/xcat/netboot/sle/compute.sle15.x86_64.postinstall b/xCAT-server/share/xcat/netboot/sles/compute.sle15.postinstall similarity index 100% rename from xCAT-server/share/xcat/netboot/sle/compute.sle15.x86_64.postinstall rename to xCAT-server/share/xcat/netboot/sles/compute.sle15.postinstall diff --git a/xCAT-server/share/xcat/netboot/sle/compute.sle15.x86_64.pkglist b/xCAT-server/share/xcat/netboot/sles/compute.sle15.x86_64.pkglist similarity index 92% rename from xCAT-server/share/xcat/netboot/sle/compute.sle15.x86_64.pkglist rename to xCAT-server/share/xcat/netboot/sles/compute.sle15.x86_64.pkglist index cd5830aaf..93fbcf9b5 100644 --- a/xCAT-server/share/xcat/netboot/sle/compute.sle15.x86_64.pkglist +++ b/xCAT-server/share/xcat/netboot/sles/compute.sle15.x86_64.pkglist @@ -1,6 +1,10 @@ aaa_base coreutils bash +dbus +wicked +device-mapper +dracut nfs-kernel-server keyutils lvm2 diff --git a/xCAT-server/share/xcat/netboot/sles/dracut_033/install.netboot b/xCAT-server/share/xcat/netboot/sles/dracut_033/install.netboot index 79f85312e..d98aa6c54 100755 --- a/xCAT-server/share/xcat/netboot/sles/dracut_033/install.netboot +++ b/xCAT-server/share/xcat/netboot/sles/dracut_033/install.netboot @@ -1,7 +1,7 @@ #!/bin/sh echo $drivers dracut_install wget tar cpio gzip modprobe touch echo cut wc xz -dracut_install grep ifconfig hostname awk egrep grep dirname expr +dracut_install grep ifconfig ip hostname awk egrep grep dirname expr dracut_install mount.nfs dracut_install parted mke2fs bc mkswap swapon chmod inst "$moddir/xcat-updateflag" "/tmp/updateflag" diff --git a/xCAT-server/share/xcat/netboot/sles/dracut_033/install.statelite b/xCAT-server/share/xcat/netboot/sles/dracut_033/install.statelite index 2c00d3ec8..ccbdc49cf 100755 --- a/xCAT-server/share/xcat/netboot/sles/dracut_033/install.statelite +++ b/xCAT-server/share/xcat/netboot/sles/dracut_033/install.statelite @@ -1,7 +1,7 @@ #!/bin/sh echo $drivers dracut_install wget cpio gzip modprobe wc touch echo cut -dracut_install grep ifconfig hostname awk egrep grep dirname expr logger +dracut_install grep ifconfig ip hostname awk egrep grep dirname expr logger dracut_install parted mke2fs bc mkswap swapon chmod inst "$moddir/xcat-updateflag" "/tmp/updateflag" inst_hook pre-mount 5 "$moddir/xcat-premount.sh" diff --git a/xCAT-server/share/xcat/netboot/sles/genimage b/xCAT-server/share/xcat/netboot/sles/genimage index 5e241ea7d..c4ace26c9 100755 --- a/xCAT-server/share/xcat/netboot/sles/genimage +++ b/xCAT-server/share/xcat/netboot/sles/genimage @@ -264,11 +264,17 @@ unless ($onlyinitrd) { # To support multiple paths for osimage.pkgdir foreach $dir (@pkgdirs) { + my $ddir = $dir; if (-d "$dir/1") { - $dir .= "/1"; + $ddir .= "/1"; } - system("zypper -R $rootimg_dir $non_interactive ar file:$dir $osver-$i"); + system("zypper -R $rootimg_dir $non_interactive ar file:$ddir $osver-$i"); $i++; + if (-d "$dir/2") { + $ddir = $dir . "/2"; + system("zypper -R $rootimg_dir $non_interactive ar file:$ddir $osver-$i"); + $i++; + } } #if(-e "$rootimg_dir/etc/zypp/repos.d/$osver.repo") { diff --git a/xCAT-server/share/xcat/netboot/sle/service.sle15.x86_64.otherpkgs.pkglist b/xCAT-server/share/xcat/netboot/sles/service.sle15.otherpkgs.pkglist similarity index 100% rename from xCAT-server/share/xcat/netboot/sle/service.sle15.x86_64.otherpkgs.pkglist rename to xCAT-server/share/xcat/netboot/sles/service.sle15.otherpkgs.pkglist diff --git a/xCAT-server/share/xcat/netboot/sle/service.sle15.pkglist b/xCAT-server/share/xcat/netboot/sles/service.sle15.pkglist similarity index 100% rename from xCAT-server/share/xcat/netboot/sle/service.sle15.pkglist rename to xCAT-server/share/xcat/netboot/sles/service.sle15.pkglist diff --git a/xCAT-server/share/xcat/netboot/sle/service.sle15.postinstall b/xCAT-server/share/xcat/netboot/sles/service.sle15.postinstall similarity index 100% rename from xCAT-server/share/xcat/netboot/sle/service.sle15.postinstall rename to xCAT-server/share/xcat/netboot/sles/service.sle15.postinstall diff --git a/xCAT-server/share/xcat/netboot/sles/service.sle15.x86_64.otherpkgs.pkglist b/xCAT-server/share/xcat/netboot/sles/service.sle15.x86_64.otherpkgs.pkglist new file mode 100644 index 000000000..7fe170d23 --- /dev/null +++ b/xCAT-server/share/xcat/netboot/sles/service.sle15.x86_64.otherpkgs.pkglist @@ -0,0 +1,3 @@ +-perl-doc +xcat/xcat-core/xCATsn +xcat/xcat-dep/sles12/x86_64/conserver-xcat From 8c25187510ea3a03f77f0b8789d4701ff1f04df8 Mon Sep 17 00:00:00 2001 From: cxhong Date: Mon, 25 Nov 2019 11:23:55 -0500 Subject: [PATCH 034/139] nodepurge test cases failed on the regression --- xCAT-test/autotest/testcase/nodepurge/cases0 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/xCAT-test/autotest/testcase/nodepurge/cases0 b/xCAT-test/autotest/testcase/nodepurge/cases0 index 2109d0521..451fdc46b 100644 --- a/xCAT-test/autotest/testcase/nodepurge/cases0 +++ b/xCAT-test/autotest/testcase/nodepurge/cases0 @@ -1,16 +1,16 @@ start:nodepurge_noderange description:nodepurge testnode1,testnode2 label:mn_only,db -cmd:mkdef -t node -o testnode1 arch=ppc64le cons=ipmi groups=pbmc mgt=ipmi ip=10.1.1.200 mac=e6:d4:d2:3a:ad:01 monserver=10.1.1.1 nameservers=10.1.1.1 nodetype=ppc,osi profile=compute tftpserver=10.1.1.1 xcatmaster=10.1.1.1 os=rhels7.7 netboot=petitboot +cmd:mkdef -t node -o testnode1 arch=ppc64le cons=ipmi groups=pbmc mgt=ipmi ip=10.1.1.200 mac=e6:d4:d2:3a:ad:01 monserver=10.1.1.1 nameservers=10.1.1.1 nodetype=ppc,osi profile=compute tftpserver=10.1.1.1 xcatmaster=10.1.1.1 netboot=petitboot check:rc==0 -cmd:mkdef -t node -o testnode2 arch=ppc64le cons=ipmi groups=pbmc mgt=ipmi ip=10.1.1.201 mac=e6:d4:d2:3a:ad:02 monserver=10.1.1.1 nameservers=10.1.1.1 nodetype=ppc,osi profile=compute tftpserver=10.1.1.1 xcatmaster=10.1.1.1 os=rhels7.7 netboot=petitboot +cmd:mkdef -t node -o testnode2 arch=ppc64le cons=ipmi groups=pbmc mgt=ipmi ip=10.1.1.201 mac=e6:d4:d2:3a:ad:02 monserver=10.1.1.1 nameservers=10.1.1.1 nodetype=ppc,osi profile=compute tftpserver=10.1.1.1 xcatmaster=10.1.1.1 netboot=petitboot check:rc==0 cmd:lsdef -t node testnode1,testnode2 check:output=~testnode1 check:output=~testnode2 cmd:makehosts testnode1,testnode2 check:rc==0 -cmd:nodeset testnode1,testnode2 osimage=rhels7.7-ppc64le-install-compute +cmd:nodeset testnode1,testnode2 osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-compute check:rc==0 cmd:nodepurge testnode1,testnode2 check:rc==0 @@ -22,9 +22,9 @@ check:output=~No such file or directory cmd:ls /install/autoinst/testnode2* check:output=~No such file or directory cmd:ping testnode1 -check:output=~Name or service not known +check:rc!=0 cmd:ping testnode2 -check:output=~Name or service not known +check:rc!=0 end start:nodepurge_h From 35f91f454e1d87606fc1dfadb0171114168d1dc3 Mon Sep 17 00:00:00 2001 From: cxhong Date: Tue, 26 Nov 2019 15:04:00 -0500 Subject: [PATCH 035/139] Regression test failed on the nodeset_shell_incorrectmasterip --- xCAT-test/autotest/testcase/genesis/test.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/xCAT-test/autotest/testcase/genesis/test.sh b/xCAT-test/autotest/testcase/genesis/test.sh index bdd174318..fe605dac9 100755 --- a/xCAT-test/autotest/testcase/genesis/test.sh +++ b/xCAT-test/autotest/testcase/genesis/test.sh @@ -23,7 +23,7 @@ MASTER_PRIVATE_NETWORK="192_168_0_0-255_255_0_0" function check_destiny() { - cmd="chdef ${TESTNODE} arch=ppc64le cons=ipmi groups=all ip=${TESTNODE_IP} mac=4e:ee:ee:ee:ee:0e netboot=$NETBOOT"; + cmd="chdef ${TESTNODE} arch=ppc64le cons=ipmi groups=all ip=${TESTNODE_IP} mac=4e:ee:ee:ee:ee:0e netboot=$NETBOOT" tftpserver=$MASTER_PRIVATE_IP xcatmaster=$MASTER_PRIVATE_IP; runcmd $cmd; lsdef ${TESTNODE} @@ -44,7 +44,8 @@ function check_destiny() { cmd="makenetworks"; runcmd $cmd; ip addr show - makehosts ${TESTNODE} + cmd="makehosts ${TESTNODE}" + runcmd $cmd grep ${TESTNODE} /etc/hosts cmd="nodeset ${TESTNODE} shell"; runcmd $cmd; From ed6c7be7955f52b66f17ca106149c119cc2aa83f Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Mon, 2 Dec 2019 14:45:04 -0500 Subject: [PATCH 036/139] Update 2.15.x.csv --- docs/source/overview/_files/2.15.x.csv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/overview/_files/2.15.x.csv b/docs/source/overview/_files/2.15.x.csv index a2b0eba0f..d38f9a413 100644 --- a/docs/source/overview/_files/2.15.x.csv +++ b/docs/source/overview/_files/2.15.x.csv @@ -1,2 +1,2 @@ Version,Release Date,New OS Supported,Release Notes -2.15.0,2019-07-31,,`2.15.0 Release Notes `_ +2.15.0,2019-11-11,RHEL 8.0,`2.15.0 Release Notes `_ From 1febaa2d3ca67a928002bff8a28044e6a915815d Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Tue, 3 Dec 2019 13:27:29 -0500 Subject: [PATCH 037/139] Restart libssl1.1 without asking for regression Ubuntu pkg install2 --- xCAT-test/autotest/testcase/migration/ubuntu_migration1_vm | 1 + 1 file changed, 1 insertion(+) diff --git a/xCAT-test/autotest/testcase/migration/ubuntu_migration1_vm b/xCAT-test/autotest/testcase/migration/ubuntu_migration1_vm index 9e6bdeb2e..29b4af714 100644 --- a/xCAT-test/autotest/testcase/migration/ubuntu_migration1_vm +++ b/xCAT-test/autotest/testcase/migration/ubuntu_migration1_vm @@ -43,6 +43,7 @@ cmd:xdsh $$CN "apt-get clean all" check:rc==0 cmd:xdsh $$CN "apt-get update" check:rc==0 +cmd:xdsh $$CN "echo '* libraries/restart-without-asking boolean true' | debconf-set-selections" cmd:xdsh $$CN "apt-get -y install build-essential dpkg-dev dh-make debhelper fakeroot gnupg lintian pbuilder quilt reprepro libsoap-lite-perl libdbi-perl" check:rc==0 cmd:xdsh $$CN "rm -rf /oldxcat" From ad1fc5c69b262fe77b8fd146bebe325ed519db0f Mon Sep 17 00:00:00 2001 From: cxhong Date: Wed, 4 Dec 2019 11:00:20 -0500 Subject: [PATCH 038/139] Add support for provision SLE15 diskless compute --- .../xcat/netboot/sles/compute.sle15.pkglist | 2 +- .../netboot/sles/compute.sle15.x86_64.pkglist | 2 +- .../xcat/netboot/sles/dracut_033/xcatroot | 3 +++ xCAT-server/share/xcat/netboot/sles/genimage | 20 ++++++++++++++----- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/xCAT-server/share/xcat/netboot/sles/compute.sle15.pkglist b/xCAT-server/share/xcat/netboot/sles/compute.sle15.pkglist index ead89aa5e..f15625428 100644 --- a/xCAT-server/share/xcat/netboot/sles/compute.sle15.pkglist +++ b/xCAT-server/share/xcat/netboot/sles/compute.sle15.pkglist @@ -1,7 +1,7 @@ aaa_base coreutils bash -dbus +dbus-1 wicked device-mapper dracut diff --git a/xCAT-server/share/xcat/netboot/sles/compute.sle15.x86_64.pkglist b/xCAT-server/share/xcat/netboot/sles/compute.sle15.x86_64.pkglist index 93fbcf9b5..20881c2af 100644 --- a/xCAT-server/share/xcat/netboot/sles/compute.sle15.x86_64.pkglist +++ b/xCAT-server/share/xcat/netboot/sles/compute.sle15.x86_64.pkglist @@ -1,7 +1,7 @@ aaa_base coreutils bash -dbus +dbus-1 wicked device-mapper dracut diff --git a/xCAT-server/share/xcat/netboot/sles/dracut_033/xcatroot b/xCAT-server/share/xcat/netboot/sles/dracut_033/xcatroot index 7414e5b7d..a1f39ac71 100755 --- a/xCAT-server/share/xcat/netboot/sles/dracut_033/xcatroot +++ b/xCAT-server/share/xcat/netboot/sles/dracut_033/xcatroot @@ -336,6 +336,9 @@ fi [ "$xcatdebugmode" > "0" ] && logger -t $log_label -p debug "setting hostname..." echo `hostname` > $NEWROOT/etc/hostname +if [ ! -z $NODE ]; then + echo $NODE > $NEWROOT/etc/hostname +fi logger $SYSLOGHOST -t $log_label -p debug "Exiting xcatroot..." diff --git a/xCAT-server/share/xcat/netboot/sles/genimage b/xCAT-server/share/xcat/netboot/sles/genimage index c4ace26c9..5792b3c6c 100755 --- a/xCAT-server/share/xcat/netboot/sles/genimage +++ b/xCAT-server/share/xcat/netboot/sles/genimage @@ -185,7 +185,7 @@ if ($netdriver) { # Add the default driver list if ($arch eq 'x86' or $arch eq 'x86_64') { - push @ndrivers, qw/tg3 bnx2 bnx2x e1000 e1000e virtio_net virtio_balloon igb mlx_en be2net/; + push @ndrivers, qw/tg3 bnx2 bnx2x e1000 e1000e virtio_net virtio_balloon igb mlx4_en be2net/; } elsif ($arch eq 'ppc64') { push @ndrivers, qw/tg3 e1000 e1000e igb ibmveth ehea be2net/; } elsif ($arch eq "s390x") { @@ -203,7 +203,7 @@ unless (grep /af_packet/, @ndrivers) { } my $osver_host; -if (`grep VERSION /etc/SuSE-release` =~ /VERSION = (\d+)/) { +if (`grep VERSION /etc/os-release` =~ /VERSION = (\d+)/) { $osver_host = $1; } else { $osver_host = 11; @@ -397,6 +397,10 @@ unless ($onlyinitrd) { #my $yumcmd = "yum -y -c /tmp/genimage.$$.yum.conf --installroot=$rootimg_dir --disablerepo=* "; #$yumcmd .= "install "; #mkpath("$rootimg_dir/var/lib/yum"); + mkpath("$rootimg_dir/etc/"); + my $passwdfile; + open($passwdfile, ">", "$rootimg_dir/etc/passwd"); + print $passwdfile "root:x:0:0:root:/root:/bin/bash\n"; my $yumcmd; if ($osver_host < 11) { $yumcmd = "zypper -R $rootimg_dir $non_interactive install "; @@ -1944,6 +1948,10 @@ sub generic_post { # This function is meant to leave the image in a state approx system("sed -i 's!\\(HWCLOCK=\\).*!\\1\"--localtime\"!' $rootimg_dir/etc/sysconfig/clock"); } + if (-e "$rootimg_dir/etc/sysconfig/network/dhcp") { + system("sed -i 's!^DHCLIENT_SET_HOSTNAME=\\\"no\\\"!DHCLIENT_SET_HOSTNAME=\\\"yes\\\"!' $rootimg_dir/etc/sysconfig/network/dhcp"); + } + unlink("$rootimg_dir/dev/null"); system("mknod $rootimg_dir/dev/null c 1 3"); open($cfgfile, ">", "$rootimg_dir/etc/fstab"); @@ -2053,8 +2061,10 @@ sub generic_post { # This function is meant to leave the image in a state approx chmod(0755, "$rootimg_dir/etc/init.d/gettyset"); } - copy("$installroot/postscripts/xcatpostinit", "$rootimg_dir/etc/init.d/xcatpostinit"); - chmod(0755, "$rootimg_dir/etc/init.d/xcatpostinit"); + system("mkdir -p $rootimg_dir/opt/xcat"); + copy("$installroot/postscripts/xcatpostinit", "$rootimg_dir/opt/xcat/xcatpostinit"); + chmod(0755, "$rootimg_dir/opt/xcat/xcatpostinit"); + copy("$installroot/postscripts/xcatpostinit.service", "$rootimg_dir/usr/lib/systemd/system/xcatpostinit.service"); # # set certain system services to start on boot, if the file exists in /etc/init.d as a script, @@ -2073,7 +2083,7 @@ sub generic_post { # This function is meant to leave the image in a state approx system("$cmd"); } else { - $cmd = $cmd . "systemctl start $service.service"; + $cmd = $cmd . "systemctl enable $service.service"; system("$cmd"); } } From 98f111538b680dae4955ac27875e55a242b80eee Mon Sep 17 00:00:00 2001 From: Markus Hilger Date: Thu, 5 Dec 2019 12:07:24 +0100 Subject: [PATCH 039/139] Add KVM CPU mode to vm.othersettings (see issue #4182) Initial patch by @ajw1980 --- perl-xCAT/xCAT/Schema.pm | 2 +- xCAT-server/lib/xcat/plugins/kvm.pm | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/perl-xCAT/xCAT/Schema.pm b/perl-xCAT/xCAT/Schema.pm index c456a533f..0fbc23d1f 100755 --- a/perl-xCAT/xCAT/Schema.pm +++ b/perl-xCAT/xCAT/Schema.pm @@ -226,7 +226,7 @@ qq{ link,ro - The file is readonly, and will be placed in tmpfs on the booted no 'vncport' => 'Tracks the current VNC display port (currently not meant to be set', 'textconsole' => 'Tracks the Psuedo-TTY that maps to the serial port or console of a VM', 'powerstate' => "This flag is used by xCAT to track the last known power state of the VM.", -'othersettings' => "This allows specifying a semicolon delimited list of key->value pairs to include in a vmx file of VMware or KVM. For partitioning on normal power machines, this option is used to specify the hugepage and/or bsr information, the value is like:'hugepage:1,bsr=2'. For KVM cpu pinning, this option is used to specify the physical cpu set on the host, the value is like:\"vcpupin:'0-15,^8'\",Its syntax is a comma separated list and a special markup using '-' and '^' (ex. '0-4', '0-3,^2') can also be allowed, the '-' denotes the range and the '^' denotes exclusive. For KVM memory binding, the value is like:'membind:0', restrict a guest to allocate memory from the specified set of NUMA nodes. For PCI passthrough, the value is like:'devpassthrough:pci_0001_01_00_0,pci_0000_03_00_0', the value for PCI device format also can be like:'devpassthrough:0001:01:00.1', the PCI devices are assigned to a virtual machine, and the virtual machine can use this I/O exclusively, the devices list are a list of PCI device names delimited with comma, the PCI device names can be obtained by running B on the host.", +'othersettings' => "This allows specifying a semicolon delimited list of key->value pairs to include in a vmx file of VMware or KVM. For partitioning on normal power machines, this option is used to specify the hugepage and/or bsr information, the value is like:'hugepage:1,bsr=2'. For KVM cpu mode use either:'cpumode:host-passthrough' or 'cpumode:host-model'. This improves performance on x86 VMs significantly. For KVM cpu pinning, this option is used to specify the physical cpu set on the host, the value is like:\"vcpupin:'0-15,^8'\",Its syntax is a comma separated list and a special markup using '-' and '^' (ex. '0-4', '0-3,^2') can also be allowed, the '-' denotes the range and the '^' denotes exclusive. For KVM memory binding, the value is like:'membind:0', restrict a guest to allocate memory from the specified set of NUMA nodes. For PCI passthrough, the value is like:'devpassthrough:pci_0001_01_00_0,pci_0000_03_00_0', the value for PCI device format also can be like:'devpassthrough:0001:01:00.1', the PCI devices are assigned to a virtual machine, and the virtual machine can use this I/O exclusively, the devices list are a list of PCI device names delimited with comma, the PCI device names can be obtained by running B on the host.", 'guestostype' => "This allows administrator to specify an identifier for OS to pass through to virtualization stack. Normally this should be ignored as xCAT will translate from nodetype.os rather than requiring this field be used\n", 'beacon' => "This flag is used by xCAT to track the state of the identify LED with respect to the VM.", 'datacenter' => "Optionally specify a datacenter for the VM to exist in (only applicable to VMWare)", diff --git a/xCAT-server/lib/xcat/plugins/kvm.pm b/xCAT-server/lib/xcat/plugins/kvm.pm index 02fb6e385..8a75d39dc 100755 --- a/xCAT-server/lib/xcat/plugins/kvm.pm +++ b/xCAT-server/lib/xcat/plugins/kvm.pm @@ -730,6 +730,7 @@ sub build_xmldesc { my %cpupinhash; my @passthrudevices; my $memnumanodes; + my $cpumode; my $advsettings = undef; if (defined $confdata->{vm}->{$node}->[0]->{othersettings}) { $advsettings = $confdata->{vm}->{$node}->[0]->{othersettings}; @@ -740,6 +741,7 @@ sub build_xmldesc { #cpu pining: "vcpupin:" #pci passthrough: "devpassthrough:,..." #memory binding: "membind:" + #cpu mode: "cpumode:" if ($advsettings) { my @tmp_array = split ";", $advsettings; foreach (@tmp_array) { @@ -762,6 +764,9 @@ sub build_xmldesc { $memnumanodes = $1; } + if (/cpumode:(.*)/) { + $cpumode = $1; + } } } @@ -779,6 +784,12 @@ sub build_xmldesc { $xtree{vcpu}->{cpuset} =~ s/\"\'//g; } + if (defined $cpumode) { + if ($cpumode eq 'host-passthrough' or $cpumode eq 'host-model') { + $xtree{cpu}->{mode} = $cpumode; + } + } + #prepare the xml hash for pci passthrough my @prdevarray; foreach my $devname (@passthrudevices) { From 8ac03366a8a969b809c30a3df6a7096b0035686f Mon Sep 17 00:00:00 2001 From: cxhong Date: Thu, 5 Dec 2019 15:56:32 -0500 Subject: [PATCH 040/139] Remove perl-IO-Stty requirement from xCAT spec --- xCAT/xCAT.spec | 4 +++- xCATsn/xCATsn.spec | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/xCAT/xCAT.spec b/xCAT/xCAT.spec index f52bb3a90..93c0ff9cb 100644 --- a/xCAT/xCAT.spec +++ b/xCAT/xCAT.spec @@ -58,10 +58,12 @@ Requires: /usr/bin/ssh %if %nots390x Requires: /usr/sbin/in.tftpd Requires: xCAT-buildkit -# Stty is only needed for rcons on ppc64 nodes, but for mixed clusters require it on both x and p +# Stty is only needed for rcons on ppc64 nodes +%ifarch ppc64 Requires: perl-IO-Stty %endif %endif +%endif %ifos linux Requires: goconserver diff --git a/xCATsn/xCATsn.spec b/xCATsn/xCATsn.spec index 6e10a4756..31775b764 100644 --- a/xCATsn/xCATsn.spec +++ b/xCATsn/xCATsn.spec @@ -41,10 +41,12 @@ Requires: /usr/sbin/dhcpd Requires: /usr/bin/ssh %ifnarch s390x Requires: /usr/sbin/in.tftpd -# Stty is only needed for rcons on ppc64 nodes, but for mixed clusters require it on both x and p +# Stty is only needed for rcons on ppc64 nodes +%ifarch ppc64 Requires: perl-IO-Stty %endif %endif +%endif %ifos linux Requires: goconserver From b332f3baa35a32a590718ebb04905e16d29c2a7d Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Mon, 9 Dec 2019 11:24:33 -0500 Subject: [PATCH 041/139] Update man pages for vm.othersettings --- docs/source/guides/admin-guides/references/man5/vm.5.rst | 2 +- docs/source/guides/admin-guides/references/man7/group.7.rst | 4 ++-- docs/source/guides/admin-guides/references/man7/node.7.rst | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/source/guides/admin-guides/references/man5/vm.5.rst b/docs/source/guides/admin-guides/references/man5/vm.5.rst index 2c34af76a..9254b7ea7 100644 --- a/docs/source/guides/admin-guides/references/man5/vm.5.rst +++ b/docs/source/guides/admin-guides/references/man5/vm.5.rst @@ -191,7 +191,7 @@ vm Attributes: \ **othersettings**\ - This allows specifying a semicolon delimited list of key->value pairs to include in a vmx file of VMware or KVM. For partitioning on normal power machines, this option is used to specify the hugepage and/or bsr information, the value is like:'hugepage:1,bsr=2'. For KVM cpu pinning, this option is used to specify the physical cpu set on the host, the value is like:"vcpupin:'0-15,^8'",Its syntax is a comma separated list and a special markup using '-' and '^' (ex. '0-4', '0-3,^2') can also be allowed, the '-' denotes the range and the '^' denotes exclusive. For KVM memory binding, the value is like:'membind:0', restrict a guest to allocate memory from the specified set of NUMA nodes. For PCI passthrough, the value is like:'devpassthrough:pci_0001_01_00_0,pci_0000_03_00_0', the value for PCI device format also can be like:'devpassthrough:0001:01:00.1', the PCI devices are assigned to a virtual machine, and the virtual machine can use this I/O exclusively, the devices list are a list of PCI device names delimited with comma, the PCI device names can be obtained by running \ **virsh nodedev-list**\ on the host. + This allows specifying a semicolon delimited list of key->value pairs to include in a vmx file of VMware or KVM. For partitioning on normal power machines, this option is used to specify the hugepage and/or bsr information, the value is like:'hugepage:1,bsr=2'. For KVM cpu mode use either:'cpumode:host-passthrough' or 'cpumode:host-model'. This improves performance on x86 VMs significantly. For KVM cpu pinning, this option is used to specify the physical cpu set on the host, the value is like:"vcpupin:'0-15,^8'",Its syntax is a comma separated list and a special markup using '-' and '^' (ex. '0-4', '0-3,^2') can also be allowed, the '-' denotes the range and the '^' denotes exclusive. For KVM memory binding, the value is like:'membind:0', restrict a guest to allocate memory from the specified set of NUMA nodes. For PCI passthrough, the value is like:'devpassthrough:pci_0001_01_00_0,pci_0000_03_00_0', the value for PCI device format also can be like:'devpassthrough:0001:01:00.1', the PCI devices are assigned to a virtual machine, and the virtual machine can use this I/O exclusively, the devices list are a list of PCI device names delimited with comma, the PCI device names can be obtained by running \ **virsh nodedev-list**\ on the host. diff --git a/docs/source/guides/admin-guides/references/man7/group.7.rst b/docs/source/guides/admin-guides/references/man7/group.7.rst index 13ae364b2..98c2710d1 100644 --- a/docs/source/guides/admin-guides/references/man7/group.7.rst +++ b/docs/source/guides/admin-guides/references/man7/group.7.rst @@ -277,7 +277,7 @@ group Attributes: \ **dockerflag**\ (vm.othersettings) - This allows specifying a semicolon delimited list of key->value pairs to include in a vmx file of VMware or KVM. For partitioning on normal power machines, this option is used to specify the hugepage and/or bsr information, the value is like:'hugepage:1,bsr=2'. For KVM cpu pinning, this option is used to specify the physical cpu set on the host, the value is like:"vcpupin:'0-15,^8'",Its syntax is a comma separated list and a special markup using '-' and '^' (ex. '0-4', '0-3,^2') can also be allowed, the '-' denotes the range and the '^' denotes exclusive. For KVM memory binding, the value is like:'membind:0', restrict a guest to allocate memory from the specified set of NUMA nodes. For PCI passthrough, the value is like:'devpassthrough:pci_0001_01_00_0,pci_0000_03_00_0', the value for PCI device format also can be like:'devpassthrough:0001:01:00.1', the PCI devices are assigned to a virtual machine, and the virtual machine can use this I/O exclusively, the devices list are a list of PCI device names delimited with comma, the PCI device names can be obtained by running \ **virsh nodedev-list**\ on the host. + This allows specifying a semicolon delimited list of key->value pairs to include in a vmx file of VMware or KVM. For partitioning on normal power machines, this option is used to specify the hugepage and/or bsr information, the value is like:'hugepage:1,bsr=2'. For KVM cpu mode use either:'cpumode:host-passthrough' or 'cpumode:host-model'. This improves performance on x86 VMs significantly. For KVM cpu pinning, this option is used to specify the physical cpu set on the host, the value is like:"vcpupin:'0-15,^8'",Its syntax is a comma separated list and a special markup using '-' and '^' (ex. '0-4', '0-3,^2') can also be allowed, the '-' denotes the range and the '^' denotes exclusive. For KVM memory binding, the value is like:'membind:0', restrict a guest to allocate memory from the specified set of NUMA nodes. For PCI passthrough, the value is like:'devpassthrough:pci_0001_01_00_0,pci_0000_03_00_0', the value for PCI device format also can be like:'devpassthrough:0001:01:00.1', the PCI devices are assigned to a virtual machine, and the virtual machine can use this I/O exclusively, the devices list are a list of PCI device names delimited with comma, the PCI device names can be obtained by running \ **virsh nodedev-list**\ on the host. @@ -1328,7 +1328,7 @@ group Attributes: \ **vmothersetting**\ (vm.othersettings) - This allows specifying a semicolon delimited list of key->value pairs to include in a vmx file of VMware or KVM. For partitioning on normal power machines, this option is used to specify the hugepage and/or bsr information, the value is like:'hugepage:1,bsr=2'. For KVM cpu pinning, this option is used to specify the physical cpu set on the host, the value is like:"vcpupin:'0-15,^8'",Its syntax is a comma separated list and a special markup using '-' and '^' (ex. '0-4', '0-3,^2') can also be allowed, the '-' denotes the range and the '^' denotes exclusive. For KVM memory binding, the value is like:'membind:0', restrict a guest to allocate memory from the specified set of NUMA nodes. For PCI passthrough, the value is like:'devpassthrough:pci_0001_01_00_0,pci_0000_03_00_0', the value for PCI device format also can be like:'devpassthrough:0001:01:00.1', the PCI devices are assigned to a virtual machine, and the virtual machine can use this I/O exclusively, the devices list are a list of PCI device names delimited with comma, the PCI device names can be obtained by running \ **virsh nodedev-list**\ on the host. + This allows specifying a semicolon delimited list of key->value pairs to include in a vmx file of VMware or KVM. For partitioning on normal power machines, this option is used to specify the hugepage and/or bsr information, the value is like:'hugepage:1,bsr=2'. For KVM cpu mode use either:'cpumode:host-passthrough' or 'cpumode:host-model'. This improves performance on x86 VMs significantly. For KVM cpu pinning, this option is used to specify the physical cpu set on the host, the value is like:"vcpupin:'0-15,^8'",Its syntax is a comma separated list and a special markup using '-' and '^' (ex. '0-4', '0-3,^2') can also be allowed, the '-' denotes the range and the '^' denotes exclusive. For KVM memory binding, the value is like:'membind:0', restrict a guest to allocate memory from the specified set of NUMA nodes. For PCI passthrough, the value is like:'devpassthrough:pci_0001_01_00_0,pci_0000_03_00_0', the value for PCI device format also can be like:'devpassthrough:0001:01:00.1', the PCI devices are assigned to a virtual machine, and the virtual machine can use this I/O exclusively, the devices list are a list of PCI device names delimited with comma, the PCI device names can be obtained by running \ **virsh nodedev-list**\ on the host. diff --git a/docs/source/guides/admin-guides/references/man7/node.7.rst b/docs/source/guides/admin-guides/references/man7/node.7.rst index c8f61824d..d94e998b7 100644 --- a/docs/source/guides/admin-guides/references/man7/node.7.rst +++ b/docs/source/guides/admin-guides/references/man7/node.7.rst @@ -289,7 +289,7 @@ node Attributes: \ **dockerflag**\ (vm.othersettings) - This allows specifying a semicolon delimited list of key->value pairs to include in a vmx file of VMware or KVM. For partitioning on normal power machines, this option is used to specify the hugepage and/or bsr information, the value is like:'hugepage:1,bsr=2'. For KVM cpu pinning, this option is used to specify the physical cpu set on the host, the value is like:"vcpupin:'0-15,^8'",Its syntax is a comma separated list and a special markup using '-' and '^' (ex. '0-4', '0-3,^2') can also be allowed, the '-' denotes the range and the '^' denotes exclusive. For KVM memory binding, the value is like:'membind:0', restrict a guest to allocate memory from the specified set of NUMA nodes. For PCI passthrough, the value is like:'devpassthrough:pci_0001_01_00_0,pci_0000_03_00_0', the value for PCI device format also can be like:'devpassthrough:0001:01:00.1', the PCI devices are assigned to a virtual machine, and the virtual machine can use this I/O exclusively, the devices list are a list of PCI device names delimited with comma, the PCI device names can be obtained by running \ **virsh nodedev-list**\ on the host. + This allows specifying a semicolon delimited list of key->value pairs to include in a vmx file of VMware or KVM. For partitioning on normal power machines, this option is used to specify the hugepage and/or bsr information, the value is like:'hugepage:1,bsr=2'. For KVM cpu mode use either:'cpumode:host-passthrough' or 'cpumode:host-model'. This improves performance on x86 VMs significantly. For KVM cpu pinning, this option is used to specify the physical cpu set on the host, the value is like:"vcpupin:'0-15,^8'",Its syntax is a comma separated list and a special markup using '-' and '^' (ex. '0-4', '0-3,^2') can also be allowed, the '-' denotes the range and the '^' denotes exclusive. For KVM memory binding, the value is like:'membind:0', restrict a guest to allocate memory from the specified set of NUMA nodes. For PCI passthrough, the value is like:'devpassthrough:pci_0001_01_00_0,pci_0000_03_00_0', the value for PCI device format also can be like:'devpassthrough:0001:01:00.1', the PCI devices are assigned to a virtual machine, and the virtual machine can use this I/O exclusively, the devices list are a list of PCI device names delimited with comma, the PCI device names can be obtained by running \ **virsh nodedev-list**\ on the host. @@ -1364,7 +1364,7 @@ node Attributes: \ **vmothersetting**\ (vm.othersettings) - This allows specifying a semicolon delimited list of key->value pairs to include in a vmx file of VMware or KVM. For partitioning on normal power machines, this option is used to specify the hugepage and/or bsr information, the value is like:'hugepage:1,bsr=2'. For KVM cpu pinning, this option is used to specify the physical cpu set on the host, the value is like:"vcpupin:'0-15,^8'",Its syntax is a comma separated list and a special markup using '-' and '^' (ex. '0-4', '0-3,^2') can also be allowed, the '-' denotes the range and the '^' denotes exclusive. For KVM memory binding, the value is like:'membind:0', restrict a guest to allocate memory from the specified set of NUMA nodes. For PCI passthrough, the value is like:'devpassthrough:pci_0001_01_00_0,pci_0000_03_00_0', the value for PCI device format also can be like:'devpassthrough:0001:01:00.1', the PCI devices are assigned to a virtual machine, and the virtual machine can use this I/O exclusively, the devices list are a list of PCI device names delimited with comma, the PCI device names can be obtained by running \ **virsh nodedev-list**\ on the host. + This allows specifying a semicolon delimited list of key->value pairs to include in a vmx file of VMware or KVM. For partitioning on normal power machines, this option is used to specify the hugepage and/or bsr information, the value is like:'hugepage:1,bsr=2'. For KVM cpu mode use either:'cpumode:host-passthrough' or 'cpumode:host-model'. This improves performance on x86 VMs significantly. For KVM cpu pinning, this option is used to specify the physical cpu set on the host, the value is like:"vcpupin:'0-15,^8'",Its syntax is a comma separated list and a special markup using '-' and '^' (ex. '0-4', '0-3,^2') can also be allowed, the '-' denotes the range and the '^' denotes exclusive. For KVM memory binding, the value is like:'membind:0', restrict a guest to allocate memory from the specified set of NUMA nodes. For PCI passthrough, the value is like:'devpassthrough:pci_0001_01_00_0,pci_0000_03_00_0', the value for PCI device format also can be like:'devpassthrough:0001:01:00.1', the PCI devices are assigned to a virtual machine, and the virtual machine can use this I/O exclusively, the devices list are a list of PCI device names delimited with comma, the PCI device names can be obtained by running \ **virsh nodedev-list**\ on the host. From f97802ba7d87cdba89ddaa4dae040850d57be146 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Tue, 10 Dec 2019 13:34:33 -0500 Subject: [PATCH 042/139] Update return code for OpenBMC testcase --- .../autotest/testcase/UT_openbmc/reventlog_resolved_cases0 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-test/autotest/testcase/UT_openbmc/reventlog_resolved_cases0 b/xCAT-test/autotest/testcase/UT_openbmc/reventlog_resolved_cases0 index efbace4c8..f475d5a27 100644 --- a/xCAT-test/autotest/testcase/UT_openbmc/reventlog_resolved_cases0 +++ b/xCAT-test/autotest/testcase/UT_openbmc/reventlog_resolved_cases0 @@ -64,6 +64,6 @@ os:Linux hcp:openbmc label:cn_bmc_ready,hctrl_openbmc cmd:reventlog $$CN resolved=Led -check:rc==1 +check:rc==0 check:output=~Attempting to resolve the following log entries: Led... end From 929b9fe8043e8d990c8517cfdec356028651a0bb Mon Sep 17 00:00:00 2001 From: cxhong Date: Thu, 12 Dec 2019 08:34:59 -0500 Subject: [PATCH 043/139] Modify logrotate conf file to reduce log missing --- xCAT-server/share/xcat/conf/goconslogrotate | 2 ++ xCAT/etc/logrotate.d/xcat | 2 ++ 2 files changed, 4 insertions(+) diff --git a/xCAT-server/share/xcat/conf/goconslogrotate b/xCAT-server/share/xcat/conf/goconslogrotate index 2e5fd42ff..f972baa30 100644 --- a/xCAT-server/share/xcat/conf/goconslogrotate +++ b/xCAT-server/share/xcat/conf/goconslogrotate @@ -3,6 +3,8 @@ { missingok sharedscripts + copytruncate + delaycompress postrotate kill -HUP `systemctl show -p MainPID goconserver.service 2> /dev/null |awk -F= '{print $2}'` 2> /dev/null || true endscript diff --git a/xCAT/etc/logrotate.d/xcat b/xCAT/etc/logrotate.d/xcat index f820f55e7..407fb4024 100644 --- a/xCAT/etc/logrotate.d/xcat +++ b/xCAT/etc/logrotate.d/xcat @@ -1,6 +1,8 @@ /var/log/xcat/*.log { missingok sharedscripts + copytruncate + delaycompress postrotate test -f /var/run/rsyslogd.pid && kill -HUP `cat /var/run/rsyslogd.pid 2> /dev/null` 2> /dev/null || true test -f /var/run/syslogd.pid && kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true From b4c16006a22f07c02770e7c5fc85e74b08e6e349 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Tue, 17 Dec 2019 11:21:45 -0500 Subject: [PATCH 044/139] BMC password change script --- .../share/xcat/scripts/BMC_change_password.sh | 94 +++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100755 xCAT-server/share/xcat/scripts/BMC_change_password.sh diff --git a/xCAT-server/share/xcat/scripts/BMC_change_password.sh b/xCAT-server/share/xcat/scripts/BMC_change_password.sh new file mode 100755 index 000000000..d010cb46a --- /dev/null +++ b/xCAT-server/share/xcat/scripts/BMC_change_password.sh @@ -0,0 +1,94 @@ +#!/bin/sh + +########################################################################## +# This script does the following: +# - use nmap for the range given (ex: 172.11.139.3-5) to generate list of IP address +# - try to connect using REST api +# with root/0penBmc (Witherspoon) or +# ADMIN/ADMIN (Boston) to check if this is OpenBMC system +# - check the output of the REST login to see if password needs to be changed +# - use REST call to change to user provided password +# - report error is password does not meet PAM validation rules +# +# Usage: $0 -r -n +########################################################################## + + +if [ $# -le 3 ]; then + echo "Usage:" + echo " $0 -r -n " + exit +fi + +while getopts n:r:h: option +do + case "${option}" + in + r) RANGE=${OPTARG};; + n) NEW=${OPTARG};; + esac +done + +if ! [ -x "$(command -v nmap)" ]; then + echo 'Error: nmap is not installed.' >&2 + exit 1 +fi + +#Generate the list of IP addresses in the range that user provided +nmap -n -sn $RANGE -oG - | awk '/Up$/{print $2}' > /tmp/$$.ip.list + +WITHERSPOON_DEFAULT_USER="root" +WITHERSPOON_DEFAULT_PW="0penBmc" + +BOSTON_DEFAULT_USER="ADMIN" +BOSTON_DEFAULT_PW="ADMIN" + +CHANGE_PW_REQUIRED="The password provided for this account must be changed before access is granted" +PW_PAM_VALIDATION="password value failed PAM validation checks" +UNAUTHORIZED="Unauthorized" + +for name in `cat /tmp/$$.ip.list` +do + + ## Look for Witherspoon first + SYSTEM_TYPE="Witherspoon" + PasswordChangeNeeded=`curl -sD - --data '{"UserName":"'"$WITHERSPOON_DEFAULT_USER"'","Password":"'"$WITHERSPOON_DEFAULT_PW"'"}' -k -X POST https://$name/redfish/v1/SessionService/Sessions` + + if [[ "$PasswordChangeNeeded" =~ "$CHANGE_PW_REQUIRED" ]]; then + echo "$name: Password change needed for $SYSTEM_TYPE system" + PasswordChanged=`curl -u $WITHERSPOON_DEFAULT_USER:$WITHERSPOON_DEFAULT_PW --data '{"Password":"'"$NEW"'"}' -k -X PATCH https://$name/redfish/v1/AccountService/Accounts/$WITHERSPOON_DEFAULT_USER 2> /dev/null` + if [[ "$PasswordChanged" =~ "$PW_PAM_VALIDATION" ]]; then + echo "$name: Can not change password for $SYSTEM_TYPE system - $PW_PAM_VALIDATION" + elif [[ -z "$PasswordChanged" ]]; then + # If no output, password change was successful + echo "$name: Password for $SYSTEM_TYPE system changed" + else + # Some unexpected output changing the password - report error and show output + echo "$name: Unable to change password for $SYSTEM_TYPE system - $PasswordChanged" + fi + + continue + fi + + ## Look for Boston next + SYSTEM_TYPE="Boston" + PasswordChangeNeeded=`curl -sD - --data '{"UserName":"'"$BOSTON_DEFAULT_USER"'","Password":"'"$BOSTON_DEFAULT_PW"'"}' -k -X POST https://$name/redfish/v1/SessionService/Sessions` + if [[ "$PasswordChangeNeeded" =~ "$CHANGE_PW_REQUIRED" ]]; then + echo "$name: Password change needed for $SYSTEM_TYPE system" + PasswordChanged=`curl -u $BOSTON_DEFAULT_USER:$BOSTON_DEFAULT_PW --data '{"Password":"'"$NEW"'"}' -k -X PATCH https://$name/redfish/v1/AccountService/Accounts/2 2> /dev/null` + if [[ "$PasswordChanged" =~ "$PW_PAM_VALIDATION" ]]; then + echo "$name: Can not change password for $SYSTEM_TYPE system - $PW_PAM_VALIDATION" + elif [[ -z "$PasswordChanged" ]]; then + # If no output, password change was successful + echo "$name: Password for $SYSTEM_TYPE system changed" + else + # Some unexpected output changing the password - report error and show output + echo "$name: Unable to change password for $SYSTEM_TYPE system - $PasswordChanged" + fi + + continue + fi + +done + +rm /tmp/$$.ip.list From dc41af4e617320c820b791a36cafab88f05f7e43 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Wed, 18 Dec 2019 10:30:20 -0500 Subject: [PATCH 045/139] Update BMC_change_password.sh usage --- .../share/xcat/scripts/BMC_change_password.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/xCAT-server/share/xcat/scripts/BMC_change_password.sh b/xCAT-server/share/xcat/scripts/BMC_change_password.sh index d010cb46a..cedd35204 100755 --- a/xCAT-server/share/xcat/scripts/BMC_change_password.sh +++ b/xCAT-server/share/xcat/scripts/BMC_change_password.sh @@ -11,12 +11,25 @@ # - report error is password does not meet PAM validation rules # # Usage: $0 -r -n +# Note: If this script is being used in the process of discovering new BMCs, +# the new BMC password should be passed to bmcdiscover command +# using the [-p|--bmcpasswd] option. ########################################################################## if [ $# -le 3 ]; then + echo " +Change the default root or ADMIN password of the BMC to the one +specified by '-n' flag. Use the same password when discovering new +BMCs, by passing it with '[-p|--bmcpasswd]' option to 'bmcdiscover' command. +" echo "Usage:" echo " $0 -r -n " + echo "Examples:" + echo " Target one node:" + echo " $0 -r 172.11.139.1 -n 0penBmc123:" + echo " Target a range of nodes:" + echo " $0 -r 172.11.139.1-12 -n 0penBmc123:" exit fi From 30e1bfb9f70037f1fa8acbf593a6e1d8ed482d02 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Wed, 18 Dec 2019 14:09:22 -0500 Subject: [PATCH 046/139] Update message for BMC password change --- xCAT-server/share/xcat/scripts/BMC_change_password.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xCAT-server/share/xcat/scripts/BMC_change_password.sh b/xCAT-server/share/xcat/scripts/BMC_change_password.sh index cedd35204..96bc3df2a 100755 --- a/xCAT-server/share/xcat/scripts/BMC_change_password.sh +++ b/xCAT-server/share/xcat/scripts/BMC_change_password.sh @@ -74,7 +74,7 @@ do echo "$name: Can not change password for $SYSTEM_TYPE system - $PW_PAM_VALIDATION" elif [[ -z "$PasswordChanged" ]]; then # If no output, password change was successful - echo "$name: Password for $SYSTEM_TYPE system changed" + echo "$name: Password for $SYSTEM_TYPE system changed. It might take up to 5 minutes for the BMC to update." else # Some unexpected output changing the password - report error and show output echo "$name: Unable to change password for $SYSTEM_TYPE system - $PasswordChanged" @@ -93,7 +93,7 @@ do echo "$name: Can not change password for $SYSTEM_TYPE system - $PW_PAM_VALIDATION" elif [[ -z "$PasswordChanged" ]]; then # If no output, password change was successful - echo "$name: Password for $SYSTEM_TYPE system changed" + echo "$name: Password for $SYSTEM_TYPE system changed. It might take up to 5 minutes for the BMC to update." else # Some unexpected output changing the password - report error and show output echo "$name: Unable to change password for $SYSTEM_TYPE system - $PasswordChanged" From 7151ec74bc760e7ee4767d25dde24ae707f28e8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Obih=C3=B6rnchen?= Date: Wed, 18 Dec 2019 22:20:36 +0100 Subject: [PATCH 047/139] Add note about OpenBMC tool (fixes #5683) --- .../manage_clusters/ppc64le/management/advanced/reventlog.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/guides/admin-guides/manage_clusters/ppc64le/management/advanced/reventlog.rst b/docs/source/guides/admin-guides/manage_clusters/ppc64le/management/advanced/reventlog.rst index 4af7dd135..73543c6eb 100644 --- a/docs/source/guides/admin-guides/manage_clusters/ppc64le/management/advanced/reventlog.rst +++ b/docs/source/guides/admin-guides/manage_clusters/ppc64le/management/advanced/reventlog.rst @@ -3,7 +3,7 @@ See :doc:`reventlog manpage ` for more information. -The ``reventlog`` command can be used to display and clear event log information on the service processor, or Baseboard Management Controller (BMC), of a physical machine. +The ``reventlog`` command can be used to display and clear event log information on the service processor, or Baseboard Management Controller (BMC), of a physical machine. OpenBMC based servers need the `IBM OpenBMC tool `_ to obtain more detailed logging messages. For example, to display all event log entries for node ``cn5``: :: From 2d58c5b860bb9125fa4f04a735ea1fa1630dbb66 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Tue, 7 Jan 2020 10:39:05 -0500 Subject: [PATCH 048/139] Improve OpenBMC reventlog message for missing policyTable.json --- xCAT-openbmc-py/lib/python/agent/hwctl/openbmc_client.py | 3 ++- xCAT-server/lib/xcat/plugins/openbmc.pm | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/xCAT-openbmc-py/lib/python/agent/hwctl/openbmc_client.py b/xCAT-openbmc-py/lib/python/agent/hwctl/openbmc_client.py index e1e92a3fe..fe9640919 100644 --- a/xCAT-openbmc-py/lib/python/agent/hwctl/openbmc_client.py +++ b/xCAT-openbmc-py/lib/python/agent/hwctl/openbmc_client.py @@ -265,7 +265,8 @@ EVENTLOG_URLS = { } RAS_POLICY_TABLE = "/opt/ibm/ras/lib/policyTable.json" -RAS_POLICY_MSG = "Install the OpenBMC RAS package to obtain more detailed logging messages." +RAS_POLICY_TABLE_RPM_LOC = "https://www.ibm.com/support/customercare/sas/f/lopdiags/scaleOutLCdebugtool.html#OpenBMC" +RAS_POLICY_MSG = "Install the openbmctool rpm from " + RAS_POLICY_TABLE_RPM_LOC + " to obtain more detailed logging messages." RAS_NOT_FOUND_MSG = " Not found in policy table: " RESULT_OK = 'ok' diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index 70afac5df..a0cc90cf0 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -91,6 +91,7 @@ $::RSPCONFIG_CONFIGURED_API_KEY = -1; $::XCAT_LOG_DIR = "/var/log/xcat"; $::RAS_POLICY_TABLE = "/opt/ibm/ras/lib/policyTable.json"; +$::RAS_POLICY_TABLE_RPM_LOC = "https://www.ibm.com/support/customercare/sas/f/lopdiags/scaleOutLCdebugtool.html#OpenBMC"; $::XCAT_LOG_RFLASH_DIR = $::XCAT_LOG_DIR . "/rflash/"; $::XCAT_LOG_DUMP_DIR = $::XCAT_LOG_DIR . "/dump/"; @@ -1122,7 +1123,7 @@ rmdir \"/tmp/\$userid\" \n"; while (1) { unless ($wait_node_num) { if ($event_mapping and (ref($event_mapping) ne "HASH")) { - xCAT::SvrUtils::sendmsg("$event_mapping, install the OpenBMC RAS package to obtain more details logging messages.", $callback); + xCAT::SvrUtils::sendmsg("$event_mapping, install the openbmctool rpm from $::RAS_POLICY_TABLE_RPM_LOC to obtain more detailed logging messages.", $callback); } if ($next_status{LOGIN_RESPONSE} eq "RSPCONFIG_SSHCFG_REQUEST") { my $home = xCAT::Utils->getHomeDir("root"); From 82c03a47ea47049741e0529f32de044476266fef Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Tue, 7 Jan 2020 11:01:41 -0500 Subject: [PATCH 049/139] Use a different message utility to remove extra space after : --- xCAT-server/lib/xcat/plugins/openbmc.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index a0cc90cf0..55a69df29 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -1123,7 +1123,7 @@ rmdir \"/tmp/\$userid\" \n"; while (1) { unless ($wait_node_num) { if ($event_mapping and (ref($event_mapping) ne "HASH")) { - xCAT::SvrUtils::sendmsg("$event_mapping, install the openbmctool rpm from $::RAS_POLICY_TABLE_RPM_LOC to obtain more detailed logging messages.", $callback); + xCAT::MsgUtils->message("I", { data=> ["$event_mapping, install the openbmctool rpm from $::RAS_POLICY_TABLE_RPM_LOC to obtain more detailed logging messages."]}, $callback); } if ($next_status{LOGIN_RESPONSE} eq "RSPCONFIG_SSHCFG_REQUEST") { my $home = xCAT::Utils->getHomeDir("root"); From 020c404730177081cadfada256b5a046bafc4ce9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Obih=C3=B6rnchen?= Date: Tue, 7 Jan 2020 19:23:08 +0100 Subject: [PATCH 050/139] Update reventlog.rst --- .../manage_clusters/ppc64le/management/advanced/reventlog.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/guides/admin-guides/manage_clusters/ppc64le/management/advanced/reventlog.rst b/docs/source/guides/admin-guides/manage_clusters/ppc64le/management/advanced/reventlog.rst index 73543c6eb..310f94be0 100644 --- a/docs/source/guides/admin-guides/manage_clusters/ppc64le/management/advanced/reventlog.rst +++ b/docs/source/guides/admin-guides/manage_clusters/ppc64le/management/advanced/reventlog.rst @@ -3,7 +3,7 @@ See :doc:`reventlog manpage ` for more information. -The ``reventlog`` command can be used to display and clear event log information on the service processor, or Baseboard Management Controller (BMC), of a physical machine. OpenBMC based servers need the `IBM OpenBMC tool `_ to obtain more detailed logging messages. +The ``reventlog`` command can be used to display and clear event log information on the service processor, or Baseboard Management Controller (BMC), of a physical machine. OpenBMC based servers need the `IBM OpenBMC tool `_ to obtain more detailed logging messages. For example, to display all event log entries for node ``cn5``: :: From 773ef3323596f8b291d733ae59675f0da729c03d Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Tue, 7 Jan 2020 14:00:05 -0500 Subject: [PATCH 051/139] Default to all for OpenBMC reventlog verbose --- xCAT-server/lib/xcat/plugins/openbmc2.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-server/lib/xcat/plugins/openbmc2.pm b/xCAT-server/lib/xcat/plugins/openbmc2.pm index f48817a26..6bf4f8e28 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc2.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc2.pm @@ -448,7 +448,7 @@ sub refactor_args { } } if ($command eq "reventlog") { - if (!defined($extrargs->[0])) { + if ((!defined($extrargs->[0])) or ($extrargs->[0] =~ /^-V/)) { # If no parameters are passed, default to list all records $request->{arg} = ["list","all"]; } From b815a269efaa83ad93765a9562ed78bcae06a0ef Mon Sep 17 00:00:00 2001 From: cxhong Date: Wed, 8 Jan 2020 14:23:24 -0500 Subject: [PATCH 052/139] Change shabang for python on rhels8.1 --- xCAT-test/autotest/testcase/xcat_inventory/validatehelper | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-test/autotest/testcase/xcat_inventory/validatehelper b/xCAT-test/autotest/testcase/xcat_inventory/validatehelper index 2609acaa4..f903873df 100755 --- a/xCAT-test/autotest/testcase/xcat_inventory/validatehelper +++ b/xCAT-test/autotest/testcase/xcat_inventory/validatehelper @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python from __future__ import print_function import yaml From 3987e4b233d6c1d2cd9e538f886866520139945f Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Thu, 9 Jan 2020 13:56:33 -0500 Subject: [PATCH 053/139] bmcdiscover with bmc password expiration --- .../references/man1/bmcdiscover.1.rst | 18 ++++------ xCAT-client/pods/man1/bmcdiscover.1.pod | 17 ++++----- xCAT-server/lib/xcat/plugins/bmcdiscover.pm | 35 +++++++++++++++++-- 3 files changed, 46 insertions(+), 24 deletions(-) diff --git a/docs/source/guides/admin-guides/references/man1/bmcdiscover.1.rst b/docs/source/guides/admin-guides/references/man1/bmcdiscover.1.rst index 9a0962c41..dd303e369 100644 --- a/docs/source/guides/admin-guides/references/man1/bmcdiscover.1.rst +++ b/docs/source/guides/admin-guides/references/man1/bmcdiscover.1.rst @@ -23,7 +23,7 @@ SYNOPSIS \ **bmcdiscover**\ [\ **-v | -**\ **-version**\ ] -\ **bmcdiscover**\ [\ **-**\ **-sn**\ \ *SN_nodename*\ ] [\ **-s**\ \ *scan_method*\ ] [\ **-u**\ \ *bmc_user*\ ] [\ **-p**\ \ *bmc_passwd*\ ] [\ **-z**\ ] [\ **-w**\ ] \ **-**\ **-range**\ \ *ip_ranges*\ +\ **bmcdiscover**\ \ **-**\ **-range**\ \ *ip_ranges*\ [\ **-**\ **-sn**\ \ *SN_nodename*\ ] [\ **-s**\ \ *scan_method*\ ] [\ **-u**\ \ *bmc_user*\ ] [\ **-p**\ \ *bmc_passwd*\ ] [\ **-z**\ ] [\ **-w**\ ] *********** @@ -35,9 +35,9 @@ The \ **bmcdiscover**\ command will discover Baseboard Management Controllers ( The command uses \ **nmap**\ to scan active nodes over a specified IP range. The IP range format should be a format that is acceptable by \ **nmap**\ . -The \ **bmcdiscover**\ command can also obtain some information about the BMC. (Check username/password, IP address source, DHCP/static configuration) +\ **Note:**\ The scan method currently supported is \ **nmap**\ . -Note: The scan method currently support is \ **nmap**\ . +\ **Note:**\ Starting on January 1, 2020, some newly shipped systems will require the default BMC password to be changed before they can be managed by xCAT. \ **bmcdiscover**\ will not be able to discover such systems. Run \ */opt/xcat/share/xcat/scripts/BMC_change_password.sh*\ script to change the default password for BMCs in specified range, then rerun \ **bmcdiscover**\ with \ **-p "new bmc password"**\ flag to discover systems with the changed password. ******* @@ -48,13 +48,13 @@ OPTIONS \ **-**\ **-range**\ - Specify one or more IP ranges acceptable to \ **nmap**\ . IP range can be hostnames, IP addresses, networks, etc. A single IP address (10.1.2.3), several IPs with commas (10.1.2.3,10.1.2.10), Ip range with "-" (10.1.2.0-100) or an IP range (10.1.2.0/24) can be specified. If the range is very large, the \ **bmcdiscover**\ command may take a long time to return. + Specify one or more IP ranges acceptable to \ **nmap**\ . IP range can be hostnames, IP addresses, networks, etc. A single IP address (10.1.2.3), several IPs with commas (10.1.2.3,10.1.2.10), IP range with "-" (10.1.2.0-100) or an IP range (10.1.2.0/24) can be specified. If the range is very large, the \ **bmcdiscover**\ command may take a long time to return. \ **-**\ **-sn**\ - Specify one or more service nodes on which bmcdiscover will run. In hierarchical cluster, the MN may not be able to access the BMC of CN directly, but SN can. With this option, \ **bmcdiscover**\ will be dispatched to the specified SNs. Then, the nodename of the service node that \ **bmcdiscover**\ is running on will be set to the 'servicenode' attribute of the discovered BMC node. + Specify one or more service nodes on which \ **bmcdiscover**\ will run. In hierarchical cluster, the MN may not be able to access the BMC of CN directly, but SN can. In that case, \ **bmcdiscover**\ will be dispatched to the specified SNs. Then, the nodename of the service node that \ **bmcdiscover**\ is running on will be set to the 'servicenode' attribute of the discovered BMC node. @@ -76,12 +76,6 @@ OPTIONS -\ **-i|-**\ **-bmcip**\ - - BMC IP address. - - - \ **-u|-**\ **-bmcuser**\ BMC user name. @@ -122,7 +116,7 @@ EXAMPLES ******** -1. To get all responding BMCs from IP range "10.4.23.100-254" and 50.3.15.1-2": +1. To get all responding BMCs from IP range "10.4.23.100-254" and "50.3.15.1-2": .. code-block:: perl diff --git a/xCAT-client/pods/man1/bmcdiscover.1.pod b/xCAT-client/pods/man1/bmcdiscover.1.pod index 41bc9be1b..6523a77ab 100644 --- a/xCAT-client/pods/man1/bmcdiscover.1.pod +++ b/xCAT-client/pods/man1/bmcdiscover.1.pod @@ -8,7 +8,7 @@ B [B<-?>|B<-h>|B<--help>] B [B<-v>|B<--version>] -B [B<--sn> I] [B<-s> I] [B<-u> I] [B<-p> I] [B<-z>] [B<-w>] B<--range> I +B B<--range> I [B<--sn> I] [B<-s> I] [B<-u> I] [B<-p> I] [B<-z>] [B<-w>] =head1 DESCRIPTION @@ -17,9 +17,10 @@ The B command will discover Baseboard Management Controllers (BMCs) The command uses B to scan active nodes over a specified IP range. The IP range format should be a format that is acceptable by B. -The B command can also obtain some information about the BMC. (Check username/password, IP address source, DHCP/static configuration) +B The scan method currently supported is B. -Note: The scan method currently support is B. + +B Starting on January 1, 2020, some newly shipped systems will require the default BMC password to be changed before they can be managed by xCAT. B will not be able to discover such systems. Run I script to change the default password for BMCs in specified range, then rerun B with B<-p "new bmc password"> flag to discover systems with the changed password. =head1 OPTIONS @@ -27,11 +28,11 @@ Note: The scan method currently support is B. =item B<--range> -Specify one or more IP ranges acceptable to B. IP range can be hostnames, IP addresses, networks, etc. A single IP address (10.1.2.3), several IPs with commas (10.1.2.3,10.1.2.10), Ip range with "-" (10.1.2.0-100) or an IP range (10.1.2.0/24) can be specified. If the range is very large, the B command may take a long time to return. +Specify one or more IP ranges acceptable to B. IP range can be hostnames, IP addresses, networks, etc. A single IP address (10.1.2.3), several IPs with commas (10.1.2.3,10.1.2.10), IP range with "-" (10.1.2.0-100) or an IP range (10.1.2.0/24) can be specified. If the range is very large, the B command may take a long time to return. =item B<--sn> -Specify one or more service nodes on which bmcdiscover will run. In hierarchical cluster, the MN may not be able to access the BMC of CN directly, but SN can. With this option, B will be dispatched to the specified SNs. Then, the nodename of the service node that B is running on will be set to the 'servicenode' attribute of the discovered BMC node. +Specify one or more service nodes on which B will run. In hierarchical cluster, the MN may not be able to access the BMC of CN directly, but SN can. In that case, B will be dispatched to the specified SNs. Then, the nodename of the service node that B is running on will be set to the 'servicenode' attribute of the discovered BMC node. =item B<-s> @@ -45,10 +46,6 @@ List the data returned in xCAT stanza format Write to the xCAT database. -=item B<-i|--bmcip> - -BMC IP address. - =item B<-u|--bmcuser> BMC user name. @@ -76,7 +73,7 @@ Display version information =head1 EXAMPLES -1. To get all responding BMCs from IP range "10.4.23.100-254" and 50.3.15.1-2": +1. To get all responding BMCs from IP range "10.4.23.100-254" and "50.3.15.1-2": bmcdiscover -s nmap --range "10.4.23.100-254 50.3.15.1-2" diff --git a/xCAT-server/lib/xcat/plugins/bmcdiscover.pm b/xCAT-server/lib/xcat/plugins/bmcdiscover.pm index 8c979363b..64b701fe4 100644 --- a/xCAT-server/lib/xcat/plugins/bmcdiscover.pm +++ b/xCAT-server/lib/xcat/plugins/bmcdiscover.pm @@ -51,6 +51,10 @@ my $openbmc_pass; my $done_num = 0; $::P9_WITHERSPOON_MFG_ID = "42817"; $::P9_WITHERSPOON_PRODUCT_ID = "16975"; +$::CHANGE_PW_REQUIRED="The password provided for this account must be changed before access is granted"; +$::NO_SESSION="Unable to establish IPMI v2 / RMCP"; +$::CHANGE_PW_INSTRUCTIONS_1="Run script '/opt/xcat/share/xcat/scripts/BMC_change_password.sh' to change default password"; +$::CHANGE_PW_INSTRUCTIONS_2="Rerun 'bmcdiscover' command with '-p new_bmc_password' flag"; %::VPDHASH = (); my %node_in_list = (); @@ -748,9 +752,11 @@ sub scan_process { $bmcpassword = "-P $bmc_pass" if ($bmc_pass); my @mc_cmds = ("/opt/xcat/bin/ipmitool-xcat -I lanplus -H ${$live_ip}[$i] -P $openbmc_pass mc info -N 1 -R 1", - "/opt/xcat/bin/ipmitool-xcat -I lanplus -H ${$live_ip}[$i] $bmcusername $bmcpassword mc info -N 1 -R 1"); + "/opt/xcat/bin/ipmitool-xcat -I lanplus -H ${$live_ip}[$i] -U $openbmc_user -P $openbmc_pass mc info -N 1 -R 1", + "/opt/xcat/bin/ipmitool-xcat -I lanplus -H ${$live_ip}[$i] $bmcusername $bmcpassword mc info -N 1 -R 1"); my $mc_info; my $is_openbmc = 0; + my $is_ipmi = 0; foreach my $mc_cmd (@mc_cmds) { $mc_info = xCAT::Utils->runcmd($mc_cmd, -1); if ($::RUNCMD_RC != 0) { @@ -761,13 +767,38 @@ sub scan_process { if ($1 eq $::P9_WITHERSPOON_MFG_ID and $2 eq $::P9_WITHERSPOON_PRODUCT_ID) { bmcdiscovery_openbmc(${$live_ip}[$i], $opz, $opw, $request_command,$parent_fd); $is_openbmc = 1; + $is_ipmi = 0; + last; + } + else { + # System replied to mc info but not with $::P9_WITHERSPOON_MFG_ID and $::P9_WITHERSPOON_PRODUCT_ID, assume IPMI + $is_openbmc = 0; + $is_ipmi = 1; last; } } } - unless ($is_openbmc) { + + if ($is_ipmi) { bmcdiscovery_ipmi(${$live_ip}[$i], $opz, $opw, $request_command,$parent_fd); } + if (!$is_openbmc and !$is_ipmi) { + if ($mc_info =~ /$::NO_SESSION/) { + # Did not get usefull data from ipmi mc info, could be one of two possibilities: + # 1. Incorrect pw was used + # 2. New system installed after January 1, 2020 where default password needs to be changed + # + # Verify this is case 2, by attempting to establish a RedFish session + my $redfish_session_cmd = "curl -sD - --data '{\"UserName\":\"$openbmc_user\",\"Password\":\"$openbmc_pass\"}' -k -X POST https://${$live_ip}[$i]/redfish/v1/SessionService/Sessions"; + my $redfish_session_info = xCAT::Utils->runcmd($redfish_session_cmd, -1); + if ($redfish_session_info =~ /$::CHANGE_PW_REQUIRED/) { + # RedFish session replied that password change is needed. Print instructions and exit + xCAT::MsgUtils->message("I", { data => ["${$live_ip}[$i]: $::CHANGE_PW_REQUIRED"] }, $::CALLBACK); + xCAT::MsgUtils->message("I", { data => ["$::CHANGE_PW_INSTRUCTIONS_1"] }, $::CALLBACK); + xCAT::MsgUtils->message("I", { data => ["$::CHANGE_PW_INSTRUCTIONS_2"] }, $::CALLBACK); + } + } + } close($parent_fd); exit 0; } else { From 5094f7a74d98318e710f23c9cc621f329f31dc95 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Thu, 9 Jan 2020 14:29:42 -0500 Subject: [PATCH 054/139] Update Usage output formatting --- xCAT-server/lib/xcat/plugins/bmcdiscover.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-server/lib/xcat/plugins/bmcdiscover.pm b/xCAT-server/lib/xcat/plugins/bmcdiscover.pm index 64b701fe4..353dbc97e 100644 --- a/xCAT-server/lib/xcat/plugins/bmcdiscover.pm +++ b/xCAT-server/lib/xcat/plugins/bmcdiscover.pm @@ -200,7 +200,7 @@ sub bmcdiscovery_usage { push @{ $rsp->{data} }, "Usage:"; push @{ $rsp->{data} }, "\tbmcdiscover [-?|-h|--help]"; push @{ $rsp->{data} }, "\tbmcdiscover [-v|--version]"; - push @{ $rsp->{data} }, "\tbmcdiscover [--sn ] [-s scan_method] [-u bmc_user] [-p bmc_passwd] [-z] [-w] --range ip_range\n"; + push @{ $rsp->{data} }, "\tbmcdiscover --range ip_range [--sn ] [-s ] [-u ] [-p ] [-z] [-w]\n"; xCAT::MsgUtils->message("I", $rsp, $::CALLBACK); return 0; From 5fd937b133f50bf3803479ef572e180ba88ed15a Mon Sep 17 00:00:00 2001 From: cxhong Date: Tue, 14 Jan 2020 09:49:48 -0500 Subject: [PATCH 055/139] Add isserv to sle15 pkglist --- .../share/xcat/install/sles/compute.sle15.pkglist | 1 + .../share/xcat/install/sles/service.sle15.pkglist | 1 + .../share/xcat/netboot/sles/compute.sle15.pkglist | 1 + .../xcat/netboot/sles/compute.sle15.x86_64.pkglist | 1 + .../share/xcat/netboot/sles/service.sle15.pkglist | 1 + xCAT-test/xcattest | 12 +++++++++--- 6 files changed, 14 insertions(+), 3 deletions(-) diff --git a/xCAT-server/share/xcat/install/sles/compute.sle15.pkglist b/xCAT-server/share/xcat/install/sles/compute.sle15.pkglist index c660ed5ed..d0e2349c4 100644 --- a/xCAT-server/share/xcat/install/sles/compute.sle15.pkglist +++ b/xCAT-server/share/xcat/install/sles/compute.sle15.pkglist @@ -2,3 +2,4 @@ iputils vim openssl rsync +insserv diff --git a/xCAT-server/share/xcat/install/sles/service.sle15.pkglist b/xCAT-server/share/xcat/install/sles/service.sle15.pkglist index 23c37900d..5ef5e42e6 100644 --- a/xCAT-server/share/xcat/install/sles/service.sle15.pkglist +++ b/xCAT-server/share/xcat/install/sles/service.sle15.pkglist @@ -3,6 +3,7 @@ openssl ntp rsync +insserv nmap perl-DBI vsftpd diff --git a/xCAT-server/share/xcat/netboot/sles/compute.sle15.pkglist b/xCAT-server/share/xcat/netboot/sles/compute.sle15.pkglist index f15625428..85c179ae5 100644 --- a/xCAT-server/share/xcat/netboot/sles/compute.sle15.pkglist +++ b/xCAT-server/share/xcat/netboot/sles/compute.sle15.pkglist @@ -46,3 +46,4 @@ kernel-default kernel-firmware adaptec-firmware xz +insserv diff --git a/xCAT-server/share/xcat/netboot/sles/compute.sle15.x86_64.pkglist b/xCAT-server/share/xcat/netboot/sles/compute.sle15.x86_64.pkglist index 20881c2af..2d2bb3c8b 100644 --- a/xCAT-server/share/xcat/netboot/sles/compute.sle15.x86_64.pkglist +++ b/xCAT-server/share/xcat/netboot/sles/compute.sle15.x86_64.pkglist @@ -47,3 +47,4 @@ kernel-firmware adaptec-firmware xz SLE_HPC-release +insserv diff --git a/xCAT-server/share/xcat/netboot/sles/service.sle15.pkglist b/xCAT-server/share/xcat/netboot/sles/service.sle15.pkglist index 447e5a3ea..94909bff9 100644 --- a/xCAT-server/share/xcat/netboot/sles/service.sle15.pkglist +++ b/xCAT-server/share/xcat/netboot/sles/service.sle15.pkglist @@ -57,6 +57,7 @@ vsftpd wget which zypper +insserv #for database unixODBC diff --git a/xCAT-test/xcattest b/xCAT-test/xcattest index 500f33b08..7cc2a4641 100755 --- a/xCAT-test/xcattest +++ b/xCAT-test/xcattest @@ -848,7 +848,7 @@ sub load_config_file { } } elsif ($type eq "Varible") { ##NODE_BLOCK## - if ($line =~ /(\w+)\s*=\s*([\w\.\-\+\/:]+)/) { + if ($line =~ /(\w+)\s*=\s*([\w\.\-\+\ \/:]+)/) { $$config_ref{var}{$1} = $2; } } @@ -1796,10 +1796,16 @@ sub is_valid_case_name { sub get_current_os { if (-f "/etc/redhat-release") { return "rhels"; - } elsif (-f "/etc/SuSE-release") { - return "sles"; } elsif (-f "/etc/lsb-release") { return "ubuntu"; + } elsif (-f "/etc/os-release") { + my $file="/etc/os-release"; + &runcmd("grep -q sles $file"); + if ($::RUNCMD_RC == 0) { + return "sles"; + } + } elsif (-f "/etc/SuSE-release") { + return "sles"; } else { return "aix"; } From 2dfd99be1ddb3a5ef06cb503138ab988e44d4c98 Mon Sep 17 00:00:00 2001 From: cxhong Date: Tue, 14 Jan 2020 10:35:50 -0500 Subject: [PATCH 056/139] change insserv to insserv-compat --- xCAT-server/share/xcat/install/sles/compute.sle15.pkglist | 2 +- xCAT-server/share/xcat/install/sles/service.sle15.pkglist | 2 +- xCAT-server/share/xcat/netboot/sles/compute.sle15.pkglist | 2 +- .../share/xcat/netboot/sles/compute.sle15.x86_64.pkglist | 2 +- xCAT-server/share/xcat/netboot/sles/service.sle15.pkglist | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/xCAT-server/share/xcat/install/sles/compute.sle15.pkglist b/xCAT-server/share/xcat/install/sles/compute.sle15.pkglist index d0e2349c4..a49fdbcb6 100644 --- a/xCAT-server/share/xcat/install/sles/compute.sle15.pkglist +++ b/xCAT-server/share/xcat/install/sles/compute.sle15.pkglist @@ -2,4 +2,4 @@ iputils vim openssl rsync -insserv +insserv-compat diff --git a/xCAT-server/share/xcat/install/sles/service.sle15.pkglist b/xCAT-server/share/xcat/install/sles/service.sle15.pkglist index 5ef5e42e6..a54f4327b 100644 --- a/xCAT-server/share/xcat/install/sles/service.sle15.pkglist +++ b/xCAT-server/share/xcat/install/sles/service.sle15.pkglist @@ -3,7 +3,7 @@ openssl ntp rsync -insserv +insserv-compat nmap perl-DBI vsftpd diff --git a/xCAT-server/share/xcat/netboot/sles/compute.sle15.pkglist b/xCAT-server/share/xcat/netboot/sles/compute.sle15.pkglist index 85c179ae5..e5d22e067 100644 --- a/xCAT-server/share/xcat/netboot/sles/compute.sle15.pkglist +++ b/xCAT-server/share/xcat/netboot/sles/compute.sle15.pkglist @@ -46,4 +46,4 @@ kernel-default kernel-firmware adaptec-firmware xz -insserv +insserv-compat diff --git a/xCAT-server/share/xcat/netboot/sles/compute.sle15.x86_64.pkglist b/xCAT-server/share/xcat/netboot/sles/compute.sle15.x86_64.pkglist index 2d2bb3c8b..03cddb1b0 100644 --- a/xCAT-server/share/xcat/netboot/sles/compute.sle15.x86_64.pkglist +++ b/xCAT-server/share/xcat/netboot/sles/compute.sle15.x86_64.pkglist @@ -47,4 +47,4 @@ kernel-firmware adaptec-firmware xz SLE_HPC-release -insserv +insserv-compat diff --git a/xCAT-server/share/xcat/netboot/sles/service.sle15.pkglist b/xCAT-server/share/xcat/netboot/sles/service.sle15.pkglist index 94909bff9..b10f772d1 100644 --- a/xCAT-server/share/xcat/netboot/sles/service.sle15.pkglist +++ b/xCAT-server/share/xcat/netboot/sles/service.sle15.pkglist @@ -57,7 +57,7 @@ vsftpd wget which zypper -insserv +insserv-compat #for database unixODBC From 70fda5611ce8f6e47b90a8f95a0cb44540c4878e Mon Sep 17 00:00:00 2001 From: cxhong Date: Tue, 14 Jan 2020 15:08:15 -0500 Subject: [PATCH 057/139] Add net-tools-deprecated package to SLE15 package list --- xCAT-server/share/xcat/install/sles/compute.sle15.pkglist | 1 + xCAT-server/share/xcat/install/sles/service.sle15.pkglist | 1 + xCAT-server/share/xcat/netboot/sles/compute.sle15.pkglist | 1 + .../share/xcat/netboot/sles/compute.sle15.x86_64.pkglist | 1 + xCAT-server/share/xcat/netboot/sles/service.sle15.pkglist | 2 +- 5 files changed, 5 insertions(+), 1 deletion(-) diff --git a/xCAT-server/share/xcat/install/sles/compute.sle15.pkglist b/xCAT-server/share/xcat/install/sles/compute.sle15.pkglist index a49fdbcb6..5ff28fc84 100644 --- a/xCAT-server/share/xcat/install/sles/compute.sle15.pkglist +++ b/xCAT-server/share/xcat/install/sles/compute.sle15.pkglist @@ -3,3 +3,4 @@ vim openssl rsync insserv-compat +net-tools-deprecated diff --git a/xCAT-server/share/xcat/install/sles/service.sle15.pkglist b/xCAT-server/share/xcat/install/sles/service.sle15.pkglist index a54f4327b..d90750118 100644 --- a/xCAT-server/share/xcat/install/sles/service.sle15.pkglist +++ b/xCAT-server/share/xcat/install/sles/service.sle15.pkglist @@ -4,6 +4,7 @@ openssl ntp rsync insserv-compat +net-tools-deprecated nmap perl-DBI vsftpd diff --git a/xCAT-server/share/xcat/netboot/sles/compute.sle15.pkglist b/xCAT-server/share/xcat/netboot/sles/compute.sle15.pkglist index e5d22e067..e54445878 100644 --- a/xCAT-server/share/xcat/netboot/sles/compute.sle15.pkglist +++ b/xCAT-server/share/xcat/netboot/sles/compute.sle15.pkglist @@ -47,3 +47,4 @@ kernel-firmware adaptec-firmware xz insserv-compat +net-tools-deprecated diff --git a/xCAT-server/share/xcat/netboot/sles/compute.sle15.x86_64.pkglist b/xCAT-server/share/xcat/netboot/sles/compute.sle15.x86_64.pkglist index 03cddb1b0..e4b0ff54f 100644 --- a/xCAT-server/share/xcat/netboot/sles/compute.sle15.x86_64.pkglist +++ b/xCAT-server/share/xcat/netboot/sles/compute.sle15.x86_64.pkglist @@ -48,3 +48,4 @@ adaptec-firmware xz SLE_HPC-release insserv-compat +net-tools-deprecated diff --git a/xCAT-server/share/xcat/netboot/sles/service.sle15.pkglist b/xCAT-server/share/xcat/netboot/sles/service.sle15.pkglist index b10f772d1..159d86bd2 100644 --- a/xCAT-server/share/xcat/netboot/sles/service.sle15.pkglist +++ b/xCAT-server/share/xcat/netboot/sles/service.sle15.pkglist @@ -58,7 +58,7 @@ wget which zypper insserv-compat - +net-tools-deprecated #for database unixODBC perl-DBD-mysql From ed3fcefefffbdc753b187370c5cecfe9220a1999 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Tue, 14 Jan 2020 15:29:11 -0500 Subject: [PATCH 058/139] Depricate nodechmac command --- .../admin-guides/references/man1/nodechmac.1.rst | 10 ++++++++++ xCAT-client/pods/man1/nodechmac.1.pod | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/docs/source/guides/admin-guides/references/man1/nodechmac.1.rst b/docs/source/guides/admin-guides/references/man1/nodechmac.1.rst index 0d35e40dc..cd8d9efd0 100644 --- a/docs/source/guides/admin-guides/references/man1/nodechmac.1.rst +++ b/docs/source/guides/admin-guides/references/man1/nodechmac.1.rst @@ -29,6 +29,16 @@ DESCRIPTION *********** +\ **Note:**\ The command \ **nodechmac**\ has been deprecated. To change the MAC address of the node: + + +.. code-block:: perl + + makedhcp -d + chdef -t node -o mac= + makedhcp + + The \ **nodechmac**\ command changes the MAC address for provisioned node's network interface. You can use this command to keep an existing node configuration. For example, if an existing node has hardware problems, the replacement node can use the old configurations. By using the nodechmac command, the node name and network settings of the old node can be used by the new node. diff --git a/xCAT-client/pods/man1/nodechmac.1.pod b/xCAT-client/pods/man1/nodechmac.1.pod index c0a674cba..daf830b56 100644 --- a/xCAT-client/pods/man1/nodechmac.1.pod +++ b/xCAT-client/pods/man1/nodechmac.1.pod @@ -10,6 +10,12 @@ B I BI =head1 DESCRIPTION +B The command B has been deprecated. To change the MAC address of the node: + + makedhcp -d + chdef -t node -o mac= + makedhcp + The B command changes the MAC address for provisioned node's network interface. You can use this command to keep an existing node configuration. For example, if an existing node has hardware problems, the replacement node can use the old configurations. By using the nodechmac command, the node name and network settings of the old node can be used by the new node. From 00ad314ae2ab0b3f5da35de3c9ab79c39a9a7b40 Mon Sep 17 00:00:00 2001 From: Markus Hilger Date: Wed, 15 Jan 2020 11:17:20 +0100 Subject: [PATCH 059/139] Fix service.sle15.tmpl product was missing and script paths were wrong --- xCAT-server/share/xcat/install/sles/service.sle15.tmpl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/xCAT-server/share/xcat/install/sles/service.sle15.tmpl b/xCAT-server/share/xcat/install/sles/service.sle15.tmpl index bf5a3764a..054fac79e 100644 --- a/xCAT-server/share/xcat/install/sles/service.sle15.tmpl +++ b/xCAT-server/share/xcat/install/sles/service.sle15.tmpl @@ -44,6 +44,9 @@ + + SLES + #INCLUDE_DEFAULT_PTRNLIST_S# @@ -83,9 +86,9 @@ - #INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/pre.sles# + #INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/pre.sle# #INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/chroot.sles# - #INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/post.sles11# + #INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/post.sle# From 2d07085122700d6e7af5b09c32e6df0e80de0638 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Wed, 15 Jan 2020 11:10:03 -0500 Subject: [PATCH 060/139] Display VM disk purge message instead of just logging it --- .../source/guides/admin-guides/references/man1/rmvm.1.rst | 8 ++++++-- xCAT-client/pods/man1/rmvm.1.pod | 8 ++++++-- xCAT-server/lib/xcat/plugins/kvm.pm | 6 +++--- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/docs/source/guides/admin-guides/references/man1/rmvm.1.rst b/docs/source/guides/admin-guides/references/man1/rmvm.1.rst index 39a083ec7..304d32dc0 100644 --- a/docs/source/guides/admin-guides/references/man1/rmvm.1.rst +++ b/docs/source/guides/admin-guides/references/man1/rmvm.1.rst @@ -45,7 +45,7 @@ DESCRIPTION *********** -The rmvm command removes the partitions specified in noderange. If noderange is an CEC, all the partitions associated with that CEC will be removed. Note that removed partitions are automatically removed from the xCAT database. For IVM-managed systems, care must be taken to not remove the VIOS partition, or all the associated partitions will be removed as well. +The \ **rmvm**\ command removes the partitions specified in \ *noderange*\ . If \ *noderange*\ is an CEC, all the partitions associated with that CEC will be removed. Note that removed partitions are automatically removed from the xCAT database. For IVM-managed systems, care must be taken to not remove the VIOS partition, or all the associated partitions will be removed as well. For DFM-managed (short For Direct FSP Management mode) normal power machines, only partitions can be removed. No options is needed. @@ -65,7 +65,11 @@ OPTIONS \ **-**\ **-service**\ Remove the service partitions of the specified CECs. -\ **-p**\ KVM: Purge the existence of the VM from persistent storage. This will erase all storage related to the VM in addition to removing it from the active virtualization configuration. PPC: Remove the specified partition on normal power machine. +\ **-p**\ + +KVM: Purge the existence of the VM from persistent storage. This will erase all storage related to the VM in addition to removing it from the active virtualization configuration. Storage devices of "raw" or "block" type are not removed. + +PPC: Remove the specified partition on normal power machine. \ **-f**\ Force remove the VM, even if the VM appears to be online. This will bring down a live VM if requested. diff --git a/xCAT-client/pods/man1/rmvm.1.pod b/xCAT-client/pods/man1/rmvm.1.pod index 139cf2d56..a649b5ac5 100644 --- a/xCAT-client/pods/man1/rmvm.1.pod +++ b/xCAT-client/pods/man1/rmvm.1.pod @@ -20,7 +20,7 @@ B I =head1 DESCRIPTION -The rmvm command removes the partitions specified in noderange. If noderange is an CEC, all the partitions associated with that CEC will be removed. Note that removed partitions are automatically removed from the xCAT database. For IVM-managed systems, care must be taken to not remove the VIOS partition, or all the associated partitions will be removed as well. +The B command removes the partitions specified in I. If I is an CEC, all the partitions associated with that CEC will be removed. Note that removed partitions are automatically removed from the xCAT database. For IVM-managed systems, care must be taken to not remove the VIOS partition, or all the associated partitions will be removed as well. For DFM-managed (short For Direct FSP Management mode) normal power machines, only partitions can be removed. No options is needed. @@ -37,7 +37,11 @@ B<-r> Retain the data object definitions of the nodes. B<--service> Remove the service partitions of the specified CECs. -B<-p> KVM: Purge the existence of the VM from persistent storage. This will erase all storage related to the VM in addition to removing it from the active virtualization configuration. PPC: Remove the specified partition on normal power machine. +B<-p> + +KVM: Purge the existence of the VM from persistent storage. This will erase all storage related to the VM in addition to removing it from the active virtualization configuration. Storage devices of "raw" or "block" type are not removed. + +PPC: Remove the specified partition on normal power machine. B<-f> Force remove the VM, even if the VM appears to be online. This will bring down a live VM if requested. diff --git a/xCAT-server/lib/xcat/plugins/kvm.pm b/xCAT-server/lib/xcat/plugins/kvm.pm index 8a75d39dc..54b2c56fc 100755 --- a/xCAT-server/lib/xcat/plugins/kvm.pm +++ b/xCAT-server/lib/xcat/plugins/kvm.pm @@ -1802,13 +1802,13 @@ sub rmvm { unless ($driver[0]) { next; } my $drivertype = $driver[0]->getAttribute("type"); if (($drivertype eq "raw") || ($disktype eq "block")) { - #For raw or block devices, do not remove, even if purge was specified. Log info message. - xCAT::MsgUtils->trace(0, "i", "Not purging raw or block storage device: $disk"); + # For raw or block devices, do not remove device, even if purge was specified. Display info message. + xCAT::SvrUtils::sendmsg("Not purging raw or block storage device: $disk", $callback, $node); next; } my $file = $disk->getAttribute("file"); unless ($file) { - xCAT::MsgUtils->trace(0, "w", "Not able to find 'file' attribute value for: $disk"); + xCAT::SvrUtils::sendmsg("Not able to find 'file' attribute value for: $disk", $callback, $node); next; } From 36dd1d14db6854c47a7de350e9c9bea21d71ab26 Mon Sep 17 00:00:00 2001 From: Markus Hilger Date: Wed, 15 Jan 2020 18:29:29 +0100 Subject: [PATCH 061/139] SLE15: Fix makenamed.conf --- xCAT-server/sbin/makenamed.conf | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/xCAT-server/sbin/makenamed.conf b/xCAT-server/sbin/makenamed.conf index 22e1fbbc6..66487f9d9 100755 --- a/xCAT-server/sbin/makenamed.conf +++ b/xCAT-server/sbin/makenamed.conf @@ -30,7 +30,10 @@ is_lsb_ubuntu () DIRECTORY=/var/named -if [ -f /etc/SuSE-release ]; then +# check for SLES +grep -s -q sles /etc/os-release +IS_SLES=$? +if [ -f /etc/SuSE-release ] || [ $IS_SLES -eq 0 ]; then DIRECTORY=/var/lib/named fi FILE=/etc/named.conf From e1379fe11e58f816f5c52e8feac7a6f360e46f31 Mon Sep 17 00:00:00 2001 From: Markus Hilger Date: Thu, 16 Jan 2020 11:15:43 +0100 Subject: [PATCH 062/139] Remove plymouth from SLE15 pkglist It causes issues during genimage (zypper RC 107) and is not needed anyways --- xCAT-server/share/xcat/netboot/sles/compute.sle15.pkglist | 2 -- .../share/xcat/netboot/sles/compute.sle15.x86_64.pkglist | 2 -- 2 files changed, 4 deletions(-) diff --git a/xCAT-server/share/xcat/netboot/sles/compute.sle15.pkglist b/xCAT-server/share/xcat/netboot/sles/compute.sle15.pkglist index e54445878..d59b44159 100644 --- a/xCAT-server/share/xcat/netboot/sles/compute.sle15.pkglist +++ b/xCAT-server/share/xcat/netboot/sles/compute.sle15.pkglist @@ -28,7 +28,6 @@ binutils tar open-iscsi curl -plymouth btrfsprogs cryptsetup dmraid @@ -40,7 +39,6 @@ cifs-utils open-lldp fcoe-utils util-linux-systemd -plymouth-dracut udev kernel-default kernel-firmware diff --git a/xCAT-server/share/xcat/netboot/sles/compute.sle15.x86_64.pkglist b/xCAT-server/share/xcat/netboot/sles/compute.sle15.x86_64.pkglist index e4b0ff54f..860b71366 100644 --- a/xCAT-server/share/xcat/netboot/sles/compute.sle15.x86_64.pkglist +++ b/xCAT-server/share/xcat/netboot/sles/compute.sle15.x86_64.pkglist @@ -28,7 +28,6 @@ binutils tar open-iscsi curl -plymouth btrfsprogs cryptsetup dmraid @@ -40,7 +39,6 @@ cifs-utils open-lldp fcoe-utils util-linux-systemd -plymouth-dracut udev kernel-default kernel-firmware From 89596acdf2d04b7cdfd393f4263e0dacace97407 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Thu, 16 Jan 2020 09:43:44 -0500 Subject: [PATCH 063/139] Update test script to print more debug info --- xCAT-test/autotest/testcase/genesis/test.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/xCAT-test/autotest/testcase/genesis/test.sh b/xCAT-test/autotest/testcase/genesis/test.sh index fe605dac9..28d3d659d 100755 --- a/xCAT-test/autotest/testcase/genesis/test.sh +++ b/xCAT-test/autotest/testcase/genesis/test.sh @@ -5,10 +5,10 @@ function runcmd(){ echo "Run command $* ..." result=`$*` if [[ $? -eq 0 ]];then - echo -e "Run command $*... [Succeed]\n"; + echo -e "Run command $* ... [Succeed]\n"; return 0; else - echo -e "Run command $*... [Failed]\n"; + echo -e "Run command $* ... [Failed]\n"; return 1; fi } @@ -41,11 +41,14 @@ function check_destiny() { else cmd="ip addr add $MASTER_PRIVATE_IP/$MASTER_PRIVATE_NETMASK dev $NET2"; runcmd $cmd; + echo "Check if ip addess $MASTER_PRIVATE_IP/$MASTER_PRIVATE_NETMASK is added for $NET2" + ip addr show $NET2 cmd="makenetworks"; runcmd $cmd; - ip addr show + tabdump networks cmd="makehosts ${TESTNODE}" runcmd $cmd + echo "Check if ${TESTNODE} can be found in /etc/hosts" grep ${TESTNODE} /etc/hosts cmd="nodeset ${TESTNODE} shell"; runcmd $cmd; From 3456d4dd982398ec340324c356b08474ff7fb9fb Mon Sep 17 00:00:00 2001 From: cxhong Date: Thu, 16 Jan 2020 16:07:31 -0500 Subject: [PATCH 064/139] Add SLE15 Hierarchy support for ppc64le --- xCAT-server/lib/xcat/plugins/dhcp.pm | 2 +- .../share/xcat/install/sles/compute.sle15.pkglist | 1 + .../share/xcat/install/sles/service.sle15.pkglist | 12 ++++++------ .../sles/service.sle15.ppc64le.otherpkgs.pkglist | 2 +- .../share/xcat/install/sles/service.sle15.tmpl | 7 ++++++- .../share/xcat/netboot/sles/compute.sle15.pkglist | 2 ++ .../xcat/netboot/sles/compute.sle15.x86_64.pkglist | 1 + .../share/xcat/netboot/sles/service.sle15.pkglist | 6 ++++-- xCAT/postscripts/otherpkgs | 2 +- 9 files changed, 23 insertions(+), 12 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/dhcp.pm b/xCAT-server/lib/xcat/plugins/dhcp.pm index 87c822d66..b20080960 100644 --- a/xCAT-server/lib/xcat/plugins/dhcp.pm +++ b/xCAT-server/lib/xcat/plugins/dhcp.pm @@ -63,7 +63,7 @@ my $checkdomain=0; # dhcp 4.x will use /etc/dhcp/dhcpd.conf as the config file my $dhcp6conffile; -if ($^O ne 'aix' and -d "/etc/dhcp") { +if ($^O ne 'aix' and not -e $dhcpconffile and -d "/etc/dhcp") { $dhcpconffile = '/etc/dhcp/dhcpd.conf'; $dhcp6conffile = '/etc/dhcp/dhcpd6.conf'; } diff --git a/xCAT-server/share/xcat/install/sles/compute.sle15.pkglist b/xCAT-server/share/xcat/install/sles/compute.sle15.pkglist index 5ff28fc84..ef3a0b8ba 100644 --- a/xCAT-server/share/xcat/install/sles/compute.sle15.pkglist +++ b/xCAT-server/share/xcat/install/sles/compute.sle15.pkglist @@ -4,3 +4,4 @@ openssl rsync insserv-compat net-tools-deprecated +rsyslog diff --git a/xCAT-server/share/xcat/install/sles/service.sle15.pkglist b/xCAT-server/share/xcat/install/sles/service.sle15.pkglist index d90750118..d782eb9cd 100644 --- a/xCAT-server/share/xcat/install/sles/service.sle15.pkglist +++ b/xCAT-server/share/xcat/install/sles/service.sle15.pkglist @@ -1,8 +1,10 @@ @base @x11 openssl +iputils ntp rsync +rsyslog insserv-compat net-tools-deprecated nmap @@ -13,12 +15,10 @@ perl-Expect perl-SNMP unixODBC perl-Net-DNS +perl-DBD-Pg +postgresql-server perl-DBD-mysql mariadb-client -libmysqlclient18 -# The following rpms are available on the SLES SDK -# You will need to locate and make these rpms available in your zypper -# repository for service node installs and uncomment the following lines: -#MyODBC-unixODBC -#perl-DBD-Pg +#libmysqlclient18 +vim diff --git a/xCAT-server/share/xcat/install/sles/service.sle15.ppc64le.otherpkgs.pkglist b/xCAT-server/share/xcat/install/sles/service.sle15.ppc64le.otherpkgs.pkglist index 096209962..df2bb04d7 100644 --- a/xCAT-server/share/xcat/install/sles/service.sle15.ppc64le.otherpkgs.pkglist +++ b/xCAT-server/share/xcat/install/sles/service.sle15.ppc64le.otherpkgs.pkglist @@ -1,2 +1,2 @@ xcat/xcat-core/xCATsn -xcat/xcat-dep/sles12/ppc64le/goconserver +xcat/xcat-dep/sles15/ppc64le/goconserver diff --git a/xCAT-server/share/xcat/install/sles/service.sle15.tmpl b/xCAT-server/share/xcat/install/sles/service.sle15.tmpl index 054fac79e..e75529258 100644 --- a/xCAT-server/share/xcat/install/sles/service.sle15.tmpl +++ b/xCAT-server/share/xcat/install/sles/service.sle15.tmpl @@ -43,9 +43,14 @@ + + + #INSTALL_SOURCES# + + - SLES + SLES #INCLUDE_DEFAULT_PTRNLIST_S# diff --git a/xCAT-server/share/xcat/netboot/sles/compute.sle15.pkglist b/xCAT-server/share/xcat/netboot/sles/compute.sle15.pkglist index e54445878..a7024fc1c 100644 --- a/xCAT-server/share/xcat/netboot/sles/compute.sle15.pkglist +++ b/xCAT-server/share/xcat/netboot/sles/compute.sle15.pkglist @@ -48,3 +48,5 @@ adaptec-firmware xz insserv-compat net-tools-deprecated +rsyslog +iputils diff --git a/xCAT-server/share/xcat/netboot/sles/compute.sle15.x86_64.pkglist b/xCAT-server/share/xcat/netboot/sles/compute.sle15.x86_64.pkglist index e4b0ff54f..09bafa467 100644 --- a/xCAT-server/share/xcat/netboot/sles/compute.sle15.x86_64.pkglist +++ b/xCAT-server/share/xcat/netboot/sles/compute.sle15.x86_64.pkglist @@ -49,3 +49,4 @@ xz SLE_HPC-release insserv-compat net-tools-deprecated +rsyslog diff --git a/xCAT-server/share/xcat/netboot/sles/service.sle15.pkglist b/xCAT-server/share/xcat/netboot/sles/service.sle15.pkglist index 159d86bd2..a01b69831 100644 --- a/xCAT-server/share/xcat/netboot/sles/service.sle15.pkglist +++ b/xCAT-server/share/xcat/netboot/sles/service.sle15.pkglist @@ -59,13 +59,15 @@ which zypper insserv-compat net-tools-deprecated +rsyslog #for database unixODBC perl-DBD-mysql mariadb-client -libmysqlclient18 +#libmysqlclient18 # The following rpms are available on the SLES SDK # You will need to locate and make these rpms available in your zypper # repository for service node installs and uncomment the following lines: #MyODBC-unixODBC -#perl-DBD-Pg +perl-DBD-Pg +iputils diff --git a/xCAT/postscripts/otherpkgs b/xCAT/postscripts/otherpkgs index 1161d1836..f595b1dc1 100755 --- a/xCAT/postscripts/otherpkgs +++ b/xCAT/postscripts/otherpkgs @@ -343,7 +343,7 @@ fi # (4) for other os, we just keep it here. # For other pkg paths, we just keep it here. if [ $dir == $default_pkgdir ] || [ $dir == "$default_pkgdir/" ]; then - if ( pmatch "$OSVER" "sles*" ); then + if ( pmatch "$OSVER" "sle*" ); then OSPKGDIR="$OSPKGDIR/1" ospkgdir="$ospkgdir/1" elif ( pmatch "$OSVER" "SL5*" ); then From 142c6d6492be99d64e02982777e45156a2294d5e Mon Sep 17 00:00:00 2001 From: cxhong Date: Thu, 16 Jan 2020 16:32:38 -0500 Subject: [PATCH 065/139] support syslog for sle15 --- xCAT/postscripts/syslog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT/postscripts/syslog b/xCAT/postscripts/syslog index 845e49be2..ff2381495 100755 --- a/xCAT/postscripts/syslog +++ b/xCAT/postscripts/syslog @@ -329,7 +329,7 @@ if [ "$(uname -s)" = "Linux" ]; then fi fi else - if ( pmatch $OSVER "sles*" ) || ( pmatch $OSVER "suse*" ) || [ -f /etc/SuSE-release ]; then + if ( pmatch $OSVER "sle*" ) || ( pmatch $OSVER "suse*" ) || [ -f /etc/SuSE-release ]; then #find out which syslog is used for SLES, syslog or syslog-ng result=`grep "^SYSLOG_DAEMON=" $sysconfig 2>&1` if ( pmatch $result "*syslog-ng*" ); then From 2245b278fac6d300a10c11556f0a833810118257 Mon Sep 17 00:00:00 2001 From: cxhong Date: Thu, 16 Jan 2020 17:34:27 -0500 Subject: [PATCH 066/139] Support otherpkgs as postbootscript for SLE15 --- xCAT-server/share/xcat/install/scripts/post.xcat | 4 ++-- xCAT/postscripts/enablekdump | 4 ++-- xCAT/postscripts/setupntp.traditional | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/xCAT-server/share/xcat/install/scripts/post.xcat b/xCAT-server/share/xcat/install/scripts/post.xcat index 32298bb92..0a9e943b5 100755 --- a/xCAT-server/share/xcat/install/scripts/post.xcat +++ b/xCAT-server/share/xcat/install/scripts/post.xcat @@ -282,7 +282,7 @@ if [ $? -eq 0 ]; then fi if [ $hassystemd -eq 1 ] ; then - if [[ $OSVER == sles12* ]]; then + if [[ $OSVER =~ sle && $OSVER != sles11* ]]; then cat >/etc/systemd/system/xcatpostinit1.service <<'EOF' #INCLUDE:/install/postscripts/xcatpostinit1.service.yast2# EOF @@ -514,7 +514,7 @@ cd / # To skip the conflict, the network service should be stoped in the yast first stage. Then base on the service # dependency, the service start order will be 'YaST2-Second-Stage.service'->'network'->'xcatpostinit1' in serial. # Then the Yast2 will be stopped before running the zypper in otherpkgs. -if [[ $OSVER =~ sles && $OSVER != sles11* ]]; then +if [[ $OSVER =~ sle && $OSVER != sles11* ]]; then service network stop fi diff --git a/xCAT/postscripts/enablekdump b/xCAT/postscripts/enablekdump index 92fd65881..30349eb48 100755 --- a/xCAT/postscripts/enablekdump +++ b/xCAT/postscripts/enablekdump @@ -40,7 +40,7 @@ for i in `/bin/cat /proc/cmdline`; do done if [ ! -z "$MACX" ] && [ ! -z "$ETHX" ]; then - if (pmatch $OSVER "sles*") || (pmatch $OSVER "suse*") || [ -f /etc/SuSE-release ]; then + if (pmatch $OSVER "sle*") || (pmatch $OSVER "suse*") || [ -f /etc/SuSE-release ]; then CONFFILE=$MNTDIR/etc/sysconfig/network/ifcfg-$ETHX fi if (pmatch $OSVER "fedora*") || (pmatch $OSVER "rhel6*") || (pmatch $OSVER "rhels6*") || [ -f /etc/fedora-release ] || [ -f /etc/redhat-release ];then @@ -108,7 +108,7 @@ if [ ! -z "$DUMP" ]; then fi if [ "$KDPROTO" = "nfs" ]; then - if (pmatch $OSVER "sles*") || (pmatch $OSVER "suse*") || [ -f /etc/SuSE-release ]; then + if (pmatch $OSVER "sle*") || (pmatch $OSVER "suse*") || [ -f /etc/SuSE-release ]; then if (pmatch $OSVER "*10*"); then #run mkinitrd to generater the kdump-init base if (pmatch $ARCH "x86*"); then diff --git a/xCAT/postscripts/setupntp.traditional b/xCAT/postscripts/setupntp.traditional index 788f4d191..51fb23e73 100755 --- a/xCAT/postscripts/setupntp.traditional +++ b/xCAT/postscripts/setupntp.traditional @@ -94,7 +94,7 @@ if [ $OS_TYPE = Linux ]; then mkdir -p /var/lib/ntp chown ntp /var/lib/ntp - if ( pmatch $OSVER "sles*" ) || ( pmatch $OSVER "suse*" ) || [ -f /etc/SuSE-release ];then + if ( pmatch $OSVER "sle*" ) || ( pmatch $OSVER "suse*" ) || [ -f /etc/SuSE-release ];then echo "driftfile /var/lib/ntp/drift/ntp.drift" >>$conf_file else echo "driftfile /var/lib/ntp/drift" >>$conf_file @@ -135,7 +135,7 @@ if [ $OS_TYPE = Linux ]; then hwclock --systohc --utc #setup the RTC is UTC format, which will be used by os - if ( pmatch $OSVER "sles*" ) || ( pmatch $OSVER "suse*" ) || [ -f /etc/SuSE-release ];then + if ( pmatch $OSVER "sle*" ) || ( pmatch $OSVER "suse*" ) || [ -f /etc/SuSE-release ];then grep -i -q "HWCLOCK" /etc/sysconfig/clock if [ $? -eq 0 ];then sed -i 's/.*HWCLOCK.*/HWCLOCK=\"-u\"/' /etc/sysconfig/clock From 9ebdcafa63a324763f597f8cac557349cede0286 Mon Sep 17 00:00:00 2001 From: Markus Hilger Date: Fri, 17 Jan 2020 10:25:36 +0100 Subject: [PATCH 067/139] SLE15: genimage fix $osver_host detection --- xCAT-server/share/xcat/netboot/sles/genimage | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-server/share/xcat/netboot/sles/genimage b/xCAT-server/share/xcat/netboot/sles/genimage index 5792b3c6c..9d4f0d706 100755 --- a/xCAT-server/share/xcat/netboot/sles/genimage +++ b/xCAT-server/share/xcat/netboot/sles/genimage @@ -203,7 +203,7 @@ unless (grep /af_packet/, @ndrivers) { } my $osver_host; -if (`grep VERSION /etc/os-release` =~ /VERSION = (\d+)/) { +if (`grep VERSION /etc/os-release` =~ /VERSION="(\d+)/) { $osver_host = $1; } else { $osver_host = 11; From 8e9428986da0e01d7b41293e94ecf493f35cb616 Mon Sep 17 00:00:00 2001 From: Markus Hilger Date: Fri, 17 Jan 2020 18:02:50 +0100 Subject: [PATCH 068/139] SLE15: genimage fixes - Mount /sys and /proc - needed for newer versions of the SLE permissions RPM. See: https://github.com/openSUSE/permissions/commit/2d0ef5d55b30f72322d18951214353ecfd9c4245 - Create /sys to have /sys/kernel/fscaps. Fixes: "Warning: running kernel does not support fscaps" - Fix permissions of /dev devices - Make sure /sys and /proc are unmounted everytime --- xCAT-server/share/xcat/netboot/sles/genimage | 60 +++++++++++++------- 1 file changed, 40 insertions(+), 20 deletions(-) diff --git a/xCAT-server/share/xcat/netboot/sles/genimage b/xCAT-server/share/xcat/netboot/sles/genimage index 9d4f0d706..ab1d79707 100755 --- a/xCAT-server/share/xcat/netboot/sles/genimage +++ b/xCAT-server/share/xcat/netboot/sles/genimage @@ -72,6 +72,31 @@ sub xdie { die @_; } +sub umount { + # some rpms mounts the imageroot/proc on the /proc, need to release it, + # otherwise got kernal panic when installing + # sometimes, the proc fs is not mounted, so one warning/error message will display, + # and I add one check point here. + my $MFD; + open MFD, "/proc/mounts"; + my @lines = ; + close MFD; + + my $ret = grep m{$rootimg_dir/proc}, @lines; + if ($ret > 0) { + system("umount -l $rootimg_dir/proc"); + } + $ret = grep m{$rootimg_dir/sys}, @lines; + if ($ret > 0) { + system("umount -l $rootimg_dir/sys"); + } +} + +# Make sure we clean up all mounts everytime +END { + umount(); +} + #-- fetch current version form CVS (overwrite locally changed versions) # if (opendir(CVS,"$pathtofiles/CVS")){ # close CVS; @@ -225,26 +250,32 @@ unless ($onlyinitrd) { mkpath "$rootimg_dir/etc"; mkpath "$rootimg_dir/dev"; + mkpath "$rootimg_dir/proc"; + mkpath "$rootimg_dir/sys"; + + #needed for newer versions of the SLE permissions RPM. See: https://github.com/openSUSE/permissions/commit/2d0ef5d55b30f72322d18951214353ecfd9c4245 + system "mount -t proc none $rootimg_dir/proc"; + #Create /sys to have /sys/kernel/fscaps. Fixes: "Warning: running kernel does not support fscaps" + system "mount -o bind /sys $rootimg_dir/sys"; #system "mount -o bind /dev $rootimg_dir/dev"; unless (-e "$rootimg_dir/dev/zero") { - system "mknod $rootimg_dir/dev/zero c 1 5"; + system "mknod -m 0666 $rootimg_dir/dev/zero c 1 5"; } unless (-e "$rootimg_dir/dev/null") { - system "mknod $rootimg_dir/dev/null c 1 3"; #that's neccessary for SLES11 + system "mknod -m 0666 $rootimg_dir/dev/null c 1 3"; #that's neccessary for SLES11+ } - unless (-e "$rootimg_dir/dev/random") { - system "mknod $rootimg_dir/dev/random c 1 8"; #that's neccessary for SLES11 + system "mknod -m 0666 $rootimg_dir/dev/random c 1 8"; #that's neccessary for SLES11+ } unless (-e "$rootimg_dir/dev/urandom") { - system "mknod $rootimg_dir/dev/urandom c 1 9"; #that's neccessary for SLES11 + system "mknod -m 0666 $rootimg_dir/dev/urandom c 1 9"; #that's neccessary for SLES11+ } for (my $i = 0 ; $i <= 12 ; $i++) { unless (-e "$rootimg_dir/dev/tty$i") { - system "mknod $rootimg_dir/dev/tty$i c 4 $i"; #that's neccessary for SLES11 + system "mknod -m 0620 $rootimg_dir/dev/tty$i c 4 $i"; #that's neccessary for SLES11+ } } @@ -872,19 +903,8 @@ system("cd $rootimg_dir/usr/bin/; ln -s ../../bin/keyctl $rootimg_dir/usr/bin/ke # which is different from the Redhat family -# some rpms mounts the imageroot/proc on the /proc, need to release it, -# otherwise got kernal panic when installing -# sometimes, the proc fs is not mounted, so one warning/error message will display, -# and I add one check point here. -my $MFD; -open MFD, "/proc/mounts"; -my @lines = ; -close MFD; - -my $ret = grep m{$rootimg_dir/proc}, @lines; -if ($ret > 0) { - system("umount -l $rootimg_dir/proc"); -} +# umount /proc and /sys from rootimg +umount(); # Load driver update disk, and copy them to the root image my @dd_drivers = &load_dd(); @@ -1953,7 +1973,7 @@ sub generic_post { # This function is meant to leave the image in a state approx } unlink("$rootimg_dir/dev/null"); - system("mknod $rootimg_dir/dev/null c 1 3"); + system("mknod -m 0666 $rootimg_dir/dev/null c 1 3"); open($cfgfile, ">", "$rootimg_dir/etc/fstab"); print $cfgfile "devpts /dev/pts devpts gid=5,mode=620 0 0\n"; print $cfgfile "tmpfs /dev/shm tmpfs defaults 0 0\n"; From d127ba06cdf20d5563c90a8024a7f3f6a645d83e Mon Sep 17 00:00:00 2001 From: Markus Hilger Date: Fri, 17 Jan 2020 18:21:46 +0100 Subject: [PATCH 069/139] SLE15: Correct proc mount --- xCAT-server/share/xcat/netboot/sles/genimage | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-server/share/xcat/netboot/sles/genimage b/xCAT-server/share/xcat/netboot/sles/genimage index ab1d79707..2dc96f403 100755 --- a/xCAT-server/share/xcat/netboot/sles/genimage +++ b/xCAT-server/share/xcat/netboot/sles/genimage @@ -254,7 +254,7 @@ unless ($onlyinitrd) { mkpath "$rootimg_dir/sys"; #needed for newer versions of the SLE permissions RPM. See: https://github.com/openSUSE/permissions/commit/2d0ef5d55b30f72322d18951214353ecfd9c4245 - system "mount -t proc none $rootimg_dir/proc"; + system "mount -t proc proc $rootimg_dir/proc"; #Create /sys to have /sys/kernel/fscaps. Fixes: "Warning: running kernel does not support fscaps" system "mount -o bind /sys $rootimg_dir/sys"; From cba331e84739b374909b0c7f021fce220e372e3f Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 2 Apr 2019 09:43:53 -0400 Subject: [PATCH 070/139] Correct hwclock in other SLE xml --- xCAT-server/share/xcat/install/sles/service.sle15.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-server/share/xcat/install/sles/service.sle15.tmpl b/xCAT-server/share/xcat/install/sles/service.sle15.tmpl index e75529258..b1ed324ea 100644 --- a/xCAT-server/share/xcat/install/sles/service.sle15.tmpl +++ b/xCAT-server/share/xcat/install/sles/service.sle15.tmpl @@ -12,7 +12,7 @@ - GMT + UTC #TABLE:site:key=timezone:value# From a9a0145f8c72b0d3ce9e23404e1f20068c9c714e Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 2 Apr 2019 09:50:46 -0400 Subject: [PATCH 071/139] Change more SLE to UTC from GMT --- xCAT-server/share/xcat/install/sles/compute.sles12.tmpl | 2 +- xCAT-server/share/xcat/install/sles/service.sles12.tmpl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/xCAT-server/share/xcat/install/sles/compute.sles12.tmpl b/xCAT-server/share/xcat/install/sles/compute.sles12.tmpl index bf5a3764a..7062fedaa 100644 --- a/xCAT-server/share/xcat/install/sles/compute.sles12.tmpl +++ b/xCAT-server/share/xcat/install/sles/compute.sles12.tmpl @@ -12,7 +12,7 @@ - GMT + UTC #TABLE:site:key=timezone:value# diff --git a/xCAT-server/share/xcat/install/sles/service.sles12.tmpl b/xCAT-server/share/xcat/install/sles/service.sles12.tmpl index bf5a3764a..7062fedaa 100644 --- a/xCAT-server/share/xcat/install/sles/service.sles12.tmpl +++ b/xCAT-server/share/xcat/install/sles/service.sles12.tmpl @@ -12,7 +12,7 @@ - GMT + UTC #TABLE:site:key=timezone:value# From 101cfe4b1c175ab73bef87838bdb64494552e304 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 12 Nov 2019 14:15:33 -0500 Subject: [PATCH 072/139] Implement sle15.N for SuSE 15 service packs --- xCAT-server/lib/xcat/plugins/sles.pm | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/sles.pm b/xCAT-server/lib/xcat/plugins/sles.pm index 7054fb6b3..0eb2e9a4d 100644 --- a/xCAT-server/lib/xcat/plugins/sles.pm +++ b/xCAT-server/lib/xcat/plugins/sles.pm @@ -1753,10 +1753,22 @@ sub copycd } if ($dsc =~ /Installer/ and $dsc =~ /SLE-15/) { $discnumber = 1; - unless ($distname) { $distname = "sle15" }; + unless ($distname) { + if ($dsc =~ /SLE-15-SP(\d)/) { + $distname = "sle15.$1"; + } else { + $distname = "sle15"; + } + }; } elsif ($dsc =~ /SLE-15/ and $dsc =~ /Packages/) { $discnumber = 2; - unless ($distname) { $distname = "sle15" }; + unless ($distname) { + if ($dsc =~ /SLE-15-SP(\d)/) { + $distname = "sle15.$1"; + } else { + $distname = "sle15"; + } + }; } } From a5b206086690f24297c50e582411cff65515a138 Mon Sep 17 00:00:00 2001 From: Markus Hilger Date: Fri, 17 Jan 2020 20:54:52 +0100 Subject: [PATCH 073/139] Fix SLE15 genimage with existing passwd from https://github.com/jjohnson42/xcat-core/commit/3110dc8fd781c704c53052c4d5ff1f426fdb22c4 --- xCAT-server/share/xcat/netboot/sles/genimage | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/xCAT-server/share/xcat/netboot/sles/genimage b/xCAT-server/share/xcat/netboot/sles/genimage index 2dc96f403..37e0b5781 100755 --- a/xCAT-server/share/xcat/netboot/sles/genimage +++ b/xCAT-server/share/xcat/netboot/sles/genimage @@ -428,11 +428,13 @@ unless ($onlyinitrd) { #my $yumcmd = "yum -y -c /tmp/genimage.$$.yum.conf --installroot=$rootimg_dir --disablerepo=* "; #$yumcmd .= "install "; #mkpath("$rootimg_dir/var/lib/yum"); - mkpath("$rootimg_dir/etc/"); - my $passwdfile; - open($passwdfile, ">", "$rootimg_dir/etc/passwd"); - print $passwdfile "root:x:0:0:root:/root:/bin/bash\n"; - my $yumcmd; + if (! -f "$rootimg_dir/etc/passwd") { + mkpath("$rootimg_dir/etc/"); + my $passwdfile; + open($passwdfile, ">", "$rootimg_dir/etc/passwd"); + print $passwdfile "root:x:0:0:root:/root:/bin/bash\n"; + } + my $yumcmd; if ($osver_host < 11) { $yumcmd = "zypper -R $rootimg_dir $non_interactive install "; } else { @@ -987,6 +989,7 @@ if ($dracutmode) { push @ndrivers, @drivers; mkinitrd("stateless"); } +print "It is safe to ignore message 'Failed to connect to bus: No such file or directory' that may have appeared above one or more times.\n"; sub getlibs { my $file = shift; From 8671114cc670eb6b2ad4d2953a3e4d4a09a92c1a Mon Sep 17 00:00:00 2001 From: Markus Hilger Date: Fri, 17 Jan 2020 21:21:42 +0100 Subject: [PATCH 074/139] Combine redundant pkglists --- .../netboot/sles/compute.sle15.x86_64.pkglist | 51 +------------------ 1 file changed, 1 insertion(+), 50 deletions(-) mode change 100644 => 120000 xCAT-server/share/xcat/netboot/sles/compute.sle15.x86_64.pkglist diff --git a/xCAT-server/share/xcat/netboot/sles/compute.sle15.x86_64.pkglist b/xCAT-server/share/xcat/netboot/sles/compute.sle15.x86_64.pkglist deleted file mode 100644 index 02d11dd47..000000000 --- a/xCAT-server/share/xcat/netboot/sles/compute.sle15.x86_64.pkglist +++ /dev/null @@ -1,50 +0,0 @@ -aaa_base -coreutils -bash -dbus-1 -wicked -device-mapper -dracut -nfs-kernel-server -keyutils -lvm2 -openssl -dhcp-client -openssh -procps -psmisc -wget -sysconfig -rsyslog -vim -rsync -timezone -bc -ntp -gzip -e2fsprogs -parted -binutils -tar -open-iscsi -curl -btrfsprogs -cryptsetup -dmraid -mdadm -multipath-tools -gpg2 -which -cifs-utils -open-lldp -fcoe-utils -util-linux-systemd -udev -kernel-default -kernel-firmware -adaptec-firmware -xz -SLE_HPC-release -insserv-compat -net-tools-deprecated -rsyslog diff --git a/xCAT-server/share/xcat/netboot/sles/compute.sle15.x86_64.pkglist b/xCAT-server/share/xcat/netboot/sles/compute.sle15.x86_64.pkglist new file mode 120000 index 000000000..0e114f64f --- /dev/null +++ b/xCAT-server/share/xcat/netboot/sles/compute.sle15.x86_64.pkglist @@ -0,0 +1 @@ +compute.sle15.pkglist \ No newline at end of file From c5f4918c0cba36f02c503e132aa3c6f08f2d59cd Mon Sep 17 00:00:00 2001 From: Markus Hilger Date: Fri, 17 Jan 2020 21:28:59 +0100 Subject: [PATCH 075/139] Fix syntax --- xCAT-server/share/xcat/netboot/sles/genimage | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xCAT-server/share/xcat/netboot/sles/genimage b/xCAT-server/share/xcat/netboot/sles/genimage index 37e0b5781..303cd0a0a 100755 --- a/xCAT-server/share/xcat/netboot/sles/genimage +++ b/xCAT-server/share/xcat/netboot/sles/genimage @@ -433,8 +433,8 @@ unless ($onlyinitrd) { my $passwdfile; open($passwdfile, ">", "$rootimg_dir/etc/passwd"); print $passwdfile "root:x:0:0:root:/root:/bin/bash\n"; - } - my $yumcmd; + } + my $yumcmd; if ($osver_host < 11) { $yumcmd = "zypper -R $rootimg_dir $non_interactive install "; } else { From 74daba97eefe4bc8602e364c07aa90c88cc02b02 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Sat, 11 Aug 2018 20:51:30 -0400 Subject: [PATCH 076/139] Actually set up ifcfg correctly in SLE15 xcatroot is actually responsible, not prepivot.sh --- .../xcat/netboot/sles/dracut_033/xcat-prepivot.sh | 10 +++++----- .../share/xcat/netboot/sles/dracut_033/xcatroot | 12 ++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/xCAT-server/share/xcat/netboot/sles/dracut_033/xcat-prepivot.sh b/xCAT-server/share/xcat/netboot/sles/dracut_033/xcat-prepivot.sh index 9471787b7..f52312e38 100755 --- a/xCAT-server/share/xcat/netboot/sles/dracut_033/xcat-prepivot.sh +++ b/xCAT-server/share/xcat/netboot/sles/dracut_033/xcat-prepivot.sh @@ -153,11 +153,11 @@ function getdevfrommac() { done } -for lf in /tmp/dhclient.*.lease; do - netif=${lf#*.} - netif=${netif%.*} - cp $lf "$NEWROOT/var/lib/dhclient/dhclient-$netif.leases" -done +bootif=$(ls /tmp/net.*.conf|sed -e s/.*net\.// -e s/\.conf//) +cat < $NEWROOT/etc/sysconfig/network/ifcfg-$bootif +BOOTPROTO='dhcp' +STARTMODE='auto' +EOF if [ -f $NEWROOT/etc/hostname ]; then echo `hostname -s` > $NEWROOT/etc/hostname diff --git a/xCAT-server/share/xcat/netboot/sles/dracut_033/xcatroot b/xCAT-server/share/xcat/netboot/sles/dracut_033/xcatroot index a1f39ac71..4b6c9aeaf 100755 --- a/xCAT-server/share/xcat/netboot/sles/dracut_033/xcatroot +++ b/xCAT-server/share/xcat/netboot/sles/dracut_033/xcatroot @@ -295,12 +295,12 @@ function getdevfrommac() { if [ -z $STATEMNT ]; then - for lf in /tmp/dhclient.*.lease; do - netif=${lf#*.} - netif=${netif%.*} - cp $lf "$NEWROOT/var/lib/dhclient/dhclient-$netif.leases" - [ "$xcatdebugmode" > "0" ] && logger -t $log_label -p debug "saving $NEWROOT/var/lib/dhclient/dhclient-$netif.leases" - done + bootif=$(ls /tmp/net.*.conf|sed -e s/.*net\.// -e s/\.conf//) + cat < $NEWROOT/etc/sysconfig/network/ifcfg-$bootif +BOOTPROTO='dhcp' +STARTMODE='auto' +EOF + [ "$xcatdebugmode" > "0" ] && logger -t $log_label -p debug "saving $NEWROOT/etc/sysconfig/network/ifcfg-$bootif" if [ ! -z "$ifname" ]; then MACX=${ifname#*:} From b26e6bcb7bb3111ff3648545ccc8002071ec077d Mon Sep 17 00:00:00 2001 From: Markus Hilger Date: Mon, 20 Jan 2020 00:48:21 +0100 Subject: [PATCH 077/139] SLE15: Fix /etc/resolv.conf overwrite In SLE15 /etc/resolv.conf is a symlink to /run/netconfig/resolv.conf. The package sysconfig-netconfig creates the symlink to /run/netconfig/resolv.conf on the host OS. It does not stay in the chroot environment. Therefore, genimage overwrites /etc/resolv.conf of the host. Let's not create a dummy file if /etc/resolv.conf is a symlink. --- xCAT-server/share/xcat/netboot/sles/genimage | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/xCAT-server/share/xcat/netboot/sles/genimage b/xCAT-server/share/xcat/netboot/sles/genimage index 303cd0a0a..f345dbd42 100755 --- a/xCAT-server/share/xcat/netboot/sles/genimage +++ b/xCAT-server/share/xcat/netboot/sles/genimage @@ -1999,9 +1999,12 @@ sub generic_post { # This function is meant to leave the image in a state approx print $cfgfile "NETWORKING=yes\n"; close($cfgfile); - open($cfgfile, ">", "$rootimg_dir/etc/resolv.conf"); - print $cfgfile "#Dummy resolv.conf to make boot cleaner"; - close($cfgfile); + # SLE15 has a symlink to /run/netconfig/resolv.conf and does not need a dummy file + if (! -l "$rootimg_dir/etc/resolv.conf") { + open($cfgfile, ">", "$rootimg_dir/etc/resolv.conf"); + print $cfgfile "#Dummy resolv.conf to make boot cleaner"; + close($cfgfile); + } # Create the ifcfg-x file for diskless node. But keep the ONBOOT=no # to skip the break of nfs-based boot From bc18c25cd2f848a71b4b414c5600ff4e2ee32b55 Mon Sep 17 00:00:00 2001 From: Markus Hilger Date: Mon, 20 Jan 2020 00:54:30 +0100 Subject: [PATCH 078/139] Fix rcons boot output Boot process was not shown via rcons with strict permissions --- xCAT-server/share/xcat/netboot/sles/genimage | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-server/share/xcat/netboot/sles/genimage b/xCAT-server/share/xcat/netboot/sles/genimage index f345dbd42..c406cdc9c 100755 --- a/xCAT-server/share/xcat/netboot/sles/genimage +++ b/xCAT-server/share/xcat/netboot/sles/genimage @@ -275,7 +275,7 @@ unless ($onlyinitrd) { for (my $i = 0 ; $i <= 12 ; $i++) { unless (-e "$rootimg_dir/dev/tty$i") { - system "mknod -m 0620 $rootimg_dir/dev/tty$i c 4 $i"; #that's neccessary for SLES11+ + system "mknod $rootimg_dir/dev/tty$i c 4 $i"; #that's neccessary for SLES11+ } } From 4bc8659be689fed240745de0fd02d7cf8c4a173e Mon Sep 17 00:00:00 2001 From: Markus Hilger Date: Mon, 20 Jan 2020 01:02:02 +0100 Subject: [PATCH 079/139] Remove "Failed to connect to bus" note This does not happen anymore with fixed mounts of 8e9428986da0e01d7b41293e94ecf493f35cb616 --- xCAT-server/share/xcat/netboot/sles/genimage | 1 - 1 file changed, 1 deletion(-) diff --git a/xCAT-server/share/xcat/netboot/sles/genimage b/xCAT-server/share/xcat/netboot/sles/genimage index c406cdc9c..049c1b681 100755 --- a/xCAT-server/share/xcat/netboot/sles/genimage +++ b/xCAT-server/share/xcat/netboot/sles/genimage @@ -989,7 +989,6 @@ if ($dracutmode) { push @ndrivers, @drivers; mkinitrd("stateless"); } -print "It is safe to ignore message 'Failed to connect to bus: No such file or directory' that may have appeared above one or more times.\n"; sub getlibs { my $file = shift; From 66fba2de7938a478e4a35ee035228d649218f820 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Wed, 22 Jan 2020 10:07:21 -0500 Subject: [PATCH 080/139] linux_diskless_kdump testcase enhancement2 --- xCAT-test/autotest/testcase/kdump/linux_diskless_kdump | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/xCAT-test/autotest/testcase/kdump/linux_diskless_kdump b/xCAT-test/autotest/testcase/kdump/linux_diskless_kdump index 50ccf16f4..9bffc50fd 100644 --- a/xCAT-test/autotest/testcase/kdump/linux_diskless_kdump +++ b/xCAT-test/autotest/testcase/kdump/linux_diskless_kdump @@ -47,6 +47,10 @@ check:rc==0 cmd:chdef -t node $$CN -p postscripts=enablekdump check:rc==0 +# Verify kdump related attributes showup in the osimage and node definitions +cmd:lsdef -t node $$CN -i postscripts +cmd:lsdef -t osimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute -i crashkernelsize,dump + cmd:rmimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute cmd:genimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute check:rc==0 @@ -79,6 +83,9 @@ cmd:a=`xdsh $$CN rpm -q at`;if [[ $a =~ "package at is not installed" ]]; then x cmd:xdsh $$CN "service atd start" check:rc==0 +# Verify that kdump directory from management node is still mounted on the compute node +cmd:xdsh $$CN df -H + cmd:xdsh $$CN "at now +1 minutes <<< /tmp/kdump.trigger" cmd:sleep 300 From b6c81908cd71494a8c53ec03980615fb538bb336 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Wed, 22 Jan 2020 10:22:43 -0500 Subject: [PATCH 081/139] Verify enablekdump postscript was executed --- xCAT-test/autotest/testcase/kdump/linux_diskless_kdump | 3 +++ 1 file changed, 3 insertions(+) diff --git a/xCAT-test/autotest/testcase/kdump/linux_diskless_kdump b/xCAT-test/autotest/testcase/kdump/linux_diskless_kdump index 9bffc50fd..d94302b66 100644 --- a/xCAT-test/autotest/testcase/kdump/linux_diskless_kdump +++ b/xCAT-test/autotest/testcase/kdump/linux_diskless_kdump @@ -86,6 +86,9 @@ check:rc==0 # Verify that kdump directory from management node is still mounted on the compute node cmd:xdsh $$CN df -H +# Verify enablekdump postscript was executed on the compute node +cmd:xdsh $$CN grep "enablekdump return with" /var/log/xcat/xcat.log + cmd:xdsh $$CN "at now +1 minutes <<< /tmp/kdump.trigger" cmd:sleep 300 From b1dc4d8dcae8cf20360f03aa44ec1fe967bdd905 Mon Sep 17 00:00:00 2001 From: Markus Hilger Date: Fri, 17 Jan 2020 20:49:37 +0100 Subject: [PATCH 082/139] SLE15: compute template change to UTC --- xCAT-server/share/xcat/install/sles/compute.sle15.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-server/share/xcat/install/sles/compute.sle15.tmpl b/xCAT-server/share/xcat/install/sles/compute.sle15.tmpl index b5254111d..4d9a5884e 100644 --- a/xCAT-server/share/xcat/install/sles/compute.sle15.tmpl +++ b/xCAT-server/share/xcat/install/sles/compute.sle15.tmpl @@ -12,7 +12,7 @@ - GMT + UTC #TABLE:site:key=timezone:value# From 755d918d0613f59be045887379c08861de4d6b22 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Mon, 27 Jan 2020 11:26:40 -0500 Subject: [PATCH 083/139] Add more output to runcmdinstaller_command testcase --- xCAT-test/autotest/testcase/runcmdinstaller/cases0 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-test/autotest/testcase/runcmdinstaller/cases0 b/xCAT-test/autotest/testcase/runcmdinstaller/cases0 index b741d6af6..bb997b9ca 100644 --- a/xCAT-test/autotest/testcase/runcmdinstaller/cases0 +++ b/xCAT-test/autotest/testcase/runcmdinstaller/cases0 @@ -16,7 +16,7 @@ check:rc==0 cmd:rinstall $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-compute check:rc==0 check:output=~Provision node\(s\)\: $$CN -cmd:a=0;while ! `lsdef -l $$CN|grep status|grep installing >/dev/null`; do sleep 20;((a++));if [ $a -gt 30 ];then break;fi done +cmd:a=0;while ! `lsdef -l $$CN|grep status|grep installing >/dev/null`; do sleep 20; echo "[$a] " $(lsdef $$CN -i status -c); ((a++));if [ $a -gt 30 ];then break;fi done cmd:lsdef -l $$CN | grep status cmd:runcmdinstaller $$CN "ls /" check:rc==0 From a2543f8285f13c31122361e5a4cfc6953a0c020e Mon Sep 17 00:00:00 2001 From: cxhong Date: Mon, 27 Jan 2020 15:44:40 -0500 Subject: [PATCH 084/139] Failed to run otherpkgs for rhel8.1.0 service node --- xCAT/postscripts/ospkgs | 3 +++ xCAT/postscripts/otherpkgs | 1 + 2 files changed, 4 insertions(+) diff --git a/xCAT/postscripts/ospkgs b/xCAT/postscripts/ospkgs index dfe18b891..c41c86097 100755 --- a/xCAT/postscripts/ospkgs +++ b/xCAT/postscripts/ospkgs @@ -23,6 +23,8 @@ #=cut #------------------------------------------------------------------------------- +#set -x + if [ -n "$LOGLABEL" ]; then log_label=$LOGLABEL else @@ -891,6 +893,7 @@ else fi echo "enabled=1" >> $REPOFILE echo "gpgcheck=0" >> $REPOFILE + echo "skip_if_unavailable=True" >> $REPOFILE fi i=$((i+1)) done diff --git a/xCAT/postscripts/otherpkgs b/xCAT/postscripts/otherpkgs index f595b1dc1..38a535a98 100755 --- a/xCAT/postscripts/otherpkgs +++ b/xCAT/postscripts/otherpkgs @@ -573,6 +573,7 @@ elif ( ((pmatch "$OSVER" "rhel*") || (pmatch "$OSVER" "centos*") || (pmatch "$OS fi echo "enabled=1" >> $REPOFILE echo "gpgcheck=0" >> $REPOFILE + echo "skip_if_unavailable=True" >> $REPOFILE fi i=$((i+1)) done From c02bc58586917b6189afa78353eb2b25941e81ec Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Mon, 27 Jan 2020 16:22:56 -0500 Subject: [PATCH 085/139] RPM permission verify --- builddep.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/builddep.sh b/builddep.sh index 9cfde7ab8..cb8878688 100755 --- a/builddep.sh +++ b/builddep.sh @@ -22,6 +22,7 @@ # Verifies no broken link files in ..../// # Verifies there are no multiple, real (non-link) files with the same name # Verifies all real (non-link) files have a link to it +# Verifies all files have read permission set for all # VERBOSE=1 - Set to 1 to see more VERBOSE output # This script should only be run on RPM based machines @@ -189,6 +190,15 @@ if [[ ${CHECK} -eq 1 ]]; then fi done + # Find files that have read permission missing for "all" + MISSING_PERMISSION=`find $GSA/* -type f -not -perm 644 -a -type f -not -perm 645 -a -type f -not -perm 646 -a -type f -not -perm 647 -a -type f -not -perm 664 -a -type f -not -perm 665 -a -type f -not -perm 666 -a -type f -not -perm 667` + for file in $MISSING_PERMISSION; do + echo "Verify permission for file: " + echo " " $(ls -l $file) + ERROR=1 + done + + if [[ ${ERROR} -eq 1 ]]; then echo -e "\nErrors found verifying files. Rerun this script with CHECK=0 to skip file verification." exit 1 From efa534fdb99ccfdbc034946ae396caf8c005c1bf Mon Sep 17 00:00:00 2001 From: cxhong Date: Tue, 28 Jan 2020 10:13:29 -0500 Subject: [PATCH 086/139] Missing tftpserver and xcatmaster for the testnode --- xCAT-test/autotest/testcase/genesis/test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-test/autotest/testcase/genesis/test.sh b/xCAT-test/autotest/testcase/genesis/test.sh index 28d3d659d..4b46ea617 100755 --- a/xCAT-test/autotest/testcase/genesis/test.sh +++ b/xCAT-test/autotest/testcase/genesis/test.sh @@ -23,7 +23,7 @@ MASTER_PRIVATE_NETWORK="192_168_0_0-255_255_0_0" function check_destiny() { - cmd="chdef ${TESTNODE} arch=ppc64le cons=ipmi groups=all ip=${TESTNODE_IP} mac=4e:ee:ee:ee:ee:0e netboot=$NETBOOT" tftpserver=$MASTER_PRIVATE_IP xcatmaster=$MASTER_PRIVATE_IP; + cmd="chdef ${TESTNODE} arch=ppc64le cons=ipmi groups=all ip=${TESTNODE_IP} mac=4e:ee:ee:ee:ee:0e netboot=$NETBOOT tftpserver=$MASTER_PRIVATE_IP xcatmaster=$MASTER_PRIVATE_IP"; runcmd $cmd; lsdef ${TESTNODE} From cdd52eb6d99871a2609054718cbb59da156645f4 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Tue, 28 Jan 2020 15:06:20 -0500 Subject: [PATCH 087/139] OpenBMC rvitals command to handle varable number of fans --- .../manage_clusters/common/parallel_cmd.rst | 2 +- xCAT-server/lib/xcat/plugins/openbmc.pm | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/source/guides/admin-guides/manage_clusters/common/parallel_cmd.rst b/docs/source/guides/admin-guides/manage_clusters/common/parallel_cmd.rst index 07b52060a..a079f6082 100644 --- a/docs/source/guides/admin-guides/manage_clusters/common/parallel_cmd.rst +++ b/docs/source/guides/admin-guides/manage_clusters/common/parallel_cmd.rst @@ -31,7 +31,7 @@ Examples for xdsh - To run the ``ps`` command on node targets node1 and run the remote command with the ``-v`` and ``-t`` flag, enter: :: - xdsh node1,node2 -o"-v -t" ps =item * + xdsh node1,node2 -o "-v -t" ps - To execute the commands contained in myfile in the XCAT context on several node targets, with a fanout of 1, enter: :: diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index 55a69df29..6681768f9 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -4409,6 +4409,7 @@ sub rvitals_response { my @sorted_output; my %leds = (); + my $number_of_fan_leds = 0; foreach my $key_url (keys %{$response_info->{data}}) { my %content = %{ ${ $response_info->{data} }{$key_url} }; @@ -4425,10 +4426,11 @@ sub rvitals_response { $calc_value = (split(/\./, $content{State}))[-1]; $content_info = $label . ": " . $calc_value ; - if ($key_url =~ "fan0") { $leds{fan0} = $calc_value; } - if ($key_url =~ "fan1") { $leds{fan1} = $calc_value; } - if ($key_url =~ "fan2") { $leds{fan2} = $calc_value; } - if ($key_url =~ "fan3") { $leds{fan3} = $calc_value; } + # There could be multiple fan LEDs. Match a string "fan" followed by digits, but only at the end of a string + if ($key_url =~ /fan(\d+)$/) { + $leds{"fan" . $1} = $calc_value; + $number_of_fan_leds++; + } if ($key_url =~ "front_id") { $leds{front_id} = $calc_value; } if ($key_url =~ "front_fault") { $leds{front_fault} = $calc_value; } if ($key_url =~ "front_power") { $leds{front_power} = $calc_value; } @@ -4500,7 +4502,7 @@ sub rvitals_response { } } # Fans - for (my $i = 0; $i < 4; $i++) { + for (my $i = 0; $i < $number_of_fan_leds; $i++) { my $tmp_key = "fan" . $i; $content_info = "LEDs Fan$i: $leds{$tmp_key}"; push (@sorted_output, $content_info); From a2df0127214397a652e68b75070fa8df43603b78 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Wed, 29 Jan 2020 14:53:10 -0500 Subject: [PATCH 088/139] Update xcattest man page with missing options and descriptions --- .../references/man1/xcattest.1.rst | 109 +++++++++++++----- xCAT-test/pods/man1/xcattest.1.pod | 83 ++++++++----- 2 files changed, 132 insertions(+), 60 deletions(-) diff --git a/docs/source/guides/admin-guides/references/man1/xcattest.1.rst b/docs/source/guides/admin-guides/references/man1/xcattest.1.rst index ba6727629..f24f6f324 100644 --- a/docs/source/guides/admin-guides/references/man1/xcattest.1.rst +++ b/docs/source/guides/admin-guides/references/man1/xcattest.1.rst @@ -21,21 +21,15 @@ SYNOPSIS \ **xcattest**\ [\ **-?|-h**\ ] -\ **xcattest**\ [\ **-f**\ \ *configure file*\ ] [\ **-b**\ \ *case bundle list*\ ] +\ **xcattest**\ [\ **-f**\ \ *configure file*\ [\ **:System**\ ]] [\ **-l**\ [{\ **caselist|caseinfo|casenum**\ }]] [\ **-r**\ ] [\ **-q**\ ] [\ **-b**\ \ *testcase bundle list*\ ] -\ **xcattest**\ [\ **-f**\ \ *configure file*\ ] [\ **-t**\ \ *case list*\ ] +\ **xcattest**\ [\ **-f**\ \ *configure file*\ [\ **:System**\ ]] [\ **-l**\ [{\ **caselist|caseinfo|casenum**\ }]] [\ **-r**\ ] [\ **-q**\ ] [\ **-t**\ \ *testcase name list*\ ] -\ **xcattest**\ [\ **-f**\ \ *configure file*\ ] [\ **-c**\ \ *cmd list*\ ] +\ **xcattest**\ [\ **-f**\ \ *configure file*\ [\ **:System**\ ]] [\ **-l**\ [{\ **caselist|caseinfo|casenum**\ }]] [\ **-r**\ ] [\ **-q**\ ] [\ **-c**\ \ *testcase command list*\ ] -\ **xcattest**\ [\ **-b**\ \ *case bundle list*\ ] [\ **-l**\ ] +\ **xcattest**\ [\ **-f**\ \ *configure file*\ [\ **:System**\ ]] [\ **-l**\ [{\ **caselist|caseinfo|casenum**\ }]] [\ **-r**\ ] [\ **-q**\ ] [\ **-s**\ \ *testcase filter expression*\ ] -\ **xcattest**\ [\ **-t**\ \ *case list*\ ] [\ **-l**\ ] - -\ **xcattest**\ [\ **-c**\ \ *cmd list*\ ] [\ **-l**\ ] - -\ **xcattest**\ [\ **-s**\ \ **command**\ ] - -\ **xcattest**\ [\ **-s**\ \ **bundle**\ ] +\ **xcattest**\ [\ **-f**\ \ *configure file*\ [\ **:System**\ ]] \ **-l bundleinfo**\ *********** @@ -43,9 +37,9 @@ DESCRIPTION *********** -The xcattest command runs test cases to verify the xCAT functions, it can be used when you want to verify the xCAT functions for whatever reason, for example, to ensure the code changes you made do not break the existing commands; to run acceptance test for new build you got; to verify the xCAT snapshot build or development build before putting it onto your production system. The xcattest command is part of the xCAT package xCAT-test. +The \ **xcattest**\ command runs test cases to verify the xCAT functions. It can be used to ensure the code changes you made do not break the existing commands; to run acceptance test for new build you got; to verify the xCAT snapshot build or development build before putting it onto your production system. The \ **xcattest**\ command is part of the xCAT package \ *xCAT-test*\ . -The root directory for the xCAT-test package is /opt/xcat/share/xcat/tools/autotest/. All test cases are in the sub directory \ *testcase*\ , indexed by the xCAT command, you can add your own test cases according to the test cases format below. The subdirectory \ *bundle*\ contains all the test cases bundles definition files, you can customize or create any test cases bundle file as required. The testing result information will be written into the subdirectory \ *result*\ , the timestamps are used as the postfixes for all the result files. xCAT-test package ships two configuration files template \ *aix.conf.template*\ and \ *linux.conf.template*\ for AIX and Linux environment, you can use the template files as the start point of making your own configuration file. +The root directory for the \ *xCAT-test*\ package is \ */opt/xcat/share/xcat/tools/autotest/*\ . All test cases are in the sub directory \ *testcase*\ , indexed by the xCAT command, you can add your own test cases according to the test cases format below. The subdirectory \ *bundle*\ contains all the test cases bundle definition files, you can customize or create any test cases bundle file as required. The testing result information will be written into the subdirectory \ *result*\ , the timestamps are used as the postfixes for all the result files. \ *xCAT-test*\ package ships two configuration file templates: \ *aix.conf.template*\ and \ *linux.conf.template*\ for AIX and Linux environment, you can use the template files as the starting point of making your own configuration file. ******* @@ -62,37 +56,49 @@ OPTIONS \ **-f**\ \ *configure file*\ - Specifies the configuration file with full-path. xCAT supports an example config file: /opt/xcat/share/xcat/tools/autotest/linux.conf.template + Specifies the configuration file with full-path. If not specified, an example config file: \ */opt/xcat/share/xcat/tools/autotest/linux.conf.template*\ is used by default. If \ **System**\ tag is used, only \ *[System]*\ section in the configuration file will be used. If \ **System**\ is not used, all other sections of the configuration file will be used, like \ *[Table]*\ , \ *[Object]*\ , etc. -\ **-b**\ \ *case bundle list*\ +\ **-b**\ \ *testcase bundle list*\ - Comma separated list of test cases bundle files, each test cases bundle can contain multiple lines and each line for one test case name. The bundle files should be listed in: /opt/xcat/share/xcat/tools/autotest/bundle. + Comma separated list of test case bundle files, each test cases bundle can contain multiple lines and each line for one test case name. The bundle files should be placed in \ */opt/xcat/share/xcat/tools/autotest/bundle*\ . -\ **-t**\ \ *cases list*\ +\ **-t**\ \ *testcase name list*\ - Comma separated list of test cases that will be run. + Comma separated list of test cases to run. -\ **-c**\ \ *cmd list*\ +\ **-c**\ \ *testcase command list*\ Comma separated list of commands which will be tested, i.e., all the test cases under the command sub directory will be run. -\ **-l**\ +\ **-s**\ \ *filter expression*\ - Display the test cases names specified by the flag -b, -t or -c. + Run testcases with testcase \ **label**\ attribute matching \ *filter expression*\ . Operators \ **|**\ , \ **+**\ , and \ **-**\ can be used. Expresson \ *"label1+label2-label3|label4|label5"*\ will match testcases that have \ **label**\ attribute matching "label1" and "label2", but not "label3" or testcases that have \ **label**\ attribute matching "label4" or testcases that have \ **label**\ attribute matching "label5" -\ **-s**\ +\ **-l {caselist|caseinfo|casenum|bundleinfo}**\ - Display the bundle files and command with value: bundle or command. + Display rather than run the test cases. The \ **caselist**\ is a default and will display a list of testcase names. \ **caseinfo**\ will display testcase names and descriptions. \ **casenum**\ will display the number of testcases. \ **bundleinfo**\ will display testcase bundle names and descriptions. + + + +\ **-r**\ + + Back up the original environment settings before running test, and restore them after running test. + + + +\ **-q**\ + + Do not print output of test cases to STDOUT, instead, log output to \ */opt/xcat/share/xcat/tools/autotest/result*\ . @@ -127,6 +133,8 @@ The xCAT-test test cases are in flat text format, the testing framework will par arch:ppc/x86 #optional, environment requirements hcp:hmc/mm/bmc/fsp + #optional, label + label:label1 #required, command need to run cmd:comand #optional, check return code of last executed command @@ -185,7 +193,7 @@ EXAMPLES 4. - To add a new case to test chvm. In the example, we assume that the min_mem should not be equal to 16 in the lpar profile of computenode. The case name is chvm_custom. It create a test lpar named testnode firstly, that change the min_mem of the lpar to 16 using chvm, then check if min_mem have changed correctly. At last, the testnode be remove to ensure no garbage produced in the cases. + To add a new case to test \ **chvm**\ . In the example, we assume that the min_mem should not be equal to 16 in the lpar profile of computenode. The case name is chvm_custom. It create a test lpar named testnode firstly, that change the min_mem of the lpar to 16 using chvm, then check if min_mem have changed correctly. At last, the testnode be remove to ensure no garbage produced in the cases. .. code-block:: perl @@ -211,6 +219,30 @@ EXAMPLES +5. + + To run all test cases that have \ *label:kdump*\ or \ *label:parallel_cmds*\ : + + + .. code-block:: perl + + xcattest -s kdump|parallel_cmds + + + + +6. + + To display all bundles and their descriptions: + + + .. code-block:: perl + + xcattest -l bundleinfo + + + + **************** INLINE FUNCTIONS @@ -219,19 +251,32 @@ INLINE FUNCTIONS The xCAT-test testing framework provides some inline functions. The inline functions can be called in test cases as __FUNCTIONNAME(PARAMTERLIST)__ to get some necessary attributes defined in the configuration file. The inline functions can be used in \ *cmd*\ section and the \ *check:output*\ section. -1. \ **GETNODEATTR(nodename, attribute)**\ To get the value of specified node's attribute -2. \ **INC(digit)**\ To get value of digit+1. - -For example, to run rscan command against the hardware control point of compute node specified in the configuration file: +1. + + \ **GETNODEATTR(nodename, attribute)**\ To get the value of specified node's attribute + -.. code-block:: perl - - rscan __GETNODEATTR($$CN, hcp)__ -z +2. + + \ **INC(digit)**\ To get value of digit+1. + + For example, to run \ **rscan**\ command against the hardware control point of compute node specified in the configuration file: + + + .. code-block:: perl + + rscan __GETNODEATTR($$CN, hcp)__ -z + + -3. \ **GETTABLEVALUE(keyname, key, colname, table)**\ To get the value of column where keyname == key in specified table. +3. + + \ **GETTABLEVALUE(keyname, key, colname, table)**\ To get the value of column where keyname == key in specified table. + + ***** diff --git a/xCAT-test/pods/man1/xcattest.1.pod b/xCAT-test/pods/man1/xcattest.1.pod index 4867a731b..ce3bf1401 100644 --- a/xCAT-test/pods/man1/xcattest.1.pod +++ b/xCAT-test/pods/man1/xcattest.1.pod @@ -6,27 +6,21 @@ B - Run automated xCAT test cases. B [B<-?|-h>] -B [B<-f> I] [B<-b> I] +B [B<-f> I[B<:System>]] [B<-l> [{B}]] [B<-r>] [B<-q>] [B<-b> I] -B [B<-f> I] [B<-t> I] +B [B<-f> I[B<:System>]] [B<-l> [{B}]] [B<-r>] [B<-q>] [B<-t> I] -B [B<-f> I] [B<-c> I] +B [B<-f> I[B<:System>]] [B<-l> [{B}]] [B<-r>] [B<-q>] [B<-c> I] -B [B<-b> I] [B<-l>] +B [B<-f> I[B<:System>]] [B<-l> [{B}]] [B<-r>] [B<-q>] [B<-s> I] -B [B<-t> I] [B<-l>] - -B [B<-c> I] [B<-l>] - -B [B<-s> B] - -B [B<-s> B] +B [B<-f> I[B<:System>]] B<-l bundleinfo> =head1 DESCRIPTION -The xcattest command runs test cases to verify the xCAT functions, it can be used when you want to verify the xCAT functions for whatever reason, for example, to ensure the code changes you made do not break the existing commands; to run acceptance test for new build you got; to verify the xCAT snapshot build or development build before putting it onto your production system. The xcattest command is part of the xCAT package xCAT-test. +The B command runs test cases to verify the xCAT functions. It can be used to ensure the code changes you made do not break the existing commands; to run acceptance test for new build you got; to verify the xCAT snapshot build or development build before putting it onto your production system. The B command is part of the xCAT package I. -The root directory for the xCAT-test package is /opt/xcat/share/xcat/tools/autotest/. All test cases are in the sub directory I, indexed by the xCAT command, you can add your own test cases according to the test cases format below. The subdirectory I contains all the test cases bundles definition files, you can customize or create any test cases bundle file as required. The testing result information will be written into the subdirectory I, the timestamps are used as the postfixes for all the result files. xCAT-test package ships two configuration files template I and I for AIX and Linux environment, you can use the template files as the start point of making your own configuration file. +The root directory for the I package is I. All test cases are in the sub directory I, indexed by the xCAT command, you can add your own test cases according to the test cases format below. The subdirectory I contains all the test cases bundle definition files, you can customize or create any test cases bundle file as required. The testing result information will be written into the subdirectory I, the timestamps are used as the postfixes for all the result files. I package ships two configuration file templates: I and I for AIX and Linux environment, you can use the template files as the starting point of making your own configuration file. =head1 OPTIONS @@ -38,27 +32,36 @@ Display usage message. =item B<-f> I -Specifies the configuration file with full-path. xCAT supports an example config file: /opt/xcat/share/xcat/tools/autotest/linux.conf.template +Specifies the configuration file with full-path. If not specified, an example config file: I is used by default. If B tag is used, only I<[System]> section in the configuration file will be used. If B is not used, all other sections of the configuration file will be used, like I<[Table]>, I<[Object]>, etc. -=item B<-b> I +=item B<-b> I -Comma separated list of test cases bundle files, each test cases bundle can contain multiple lines and each line for one test case name. The bundle files should be listed in: /opt/xcat/share/xcat/tools/autotest/bundle. +Comma separated list of test case bundle files, each test cases bundle can contain multiple lines and each line for one test case name. The bundle files should be placed in I. -=item B<-t> I +=item B<-t> I -Comma separated list of test cases that will be run. +Comma separated list of test cases to run. -=item B<-c> I +=item B<-c> I Comma separated list of commands which will be tested, i.e., all the test cases under the command sub directory will be run. -=item B<-l> +=item B<-s> I -Display the test cases names specified by the flag -b, -t or -c. +Run testcases with testcase B