From a13dc3db501fbbf3d55b9970dd30ec1bc43a0a08 Mon Sep 17 00:00:00 2001 From: lissav Date: Thu, 15 Aug 2013 07:34:54 -0400 Subject: [PATCH 01/47] fix syntax --- xCAT-client/pods/man8/xcatconfig.8.pod | 1 - 1 file changed, 1 deletion(-) diff --git a/xCAT-client/pods/man8/xcatconfig.8.pod b/xCAT-client/pods/man8/xcatconfig.8.pod index e65e90a54..fe8b07110 100644 --- a/xCAT-client/pods/man8/xcatconfig.8.pod +++ b/xCAT-client/pods/man8/xcatconfig.8.pod @@ -74,7 +74,6 @@ Redistribute credentials and ssh keys to the service nodes and ssh keys to the n This option will add the Management Node to the database with the correct attributes set to be recognized by xCAT. This should be run after the hostname of the Management Node is set to the name that will resolve to the cluster-facing NIC. - =item B<-t|--tunables> This option will set tunable parameters on the Management and Service nodes recommended for your Linux cluster. It will only set them during initial install, if you run xcatconfig -f or xcatconfig -t. From 433866fb0b3034001c8a616afc4d0ec4b1db3fb7 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Thu, 15 Aug 2013 11:35:12 -0400 Subject: [PATCH 02/47] Default in user/password in the same way that ipmi works in plugin --- xCAT-client/bin/pasu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-client/bin/pasu b/xCAT-client/bin/pasu index d8c380c7a..3ebdb6038 100755 --- a/xCAT-client/bin/pasu +++ b/xCAT-client/bin/pasu @@ -386,7 +386,7 @@ sub getdefaultcredentials { last; } } - if (!defined($user) || !defined($pw)) { die "Did not find the ipmi username and password in the xCAT passwd table.\n"; } + if (!defined($user) || !defined($pw)) { $user = "USERID"; $pw = "PASSW0RD"; } return ($user, $pw); } From 3cef537a5f98223a9de48fe764d8b6444487ba9a Mon Sep 17 00:00:00 2001 From: immarvin Date: Thu, 15 Aug 2013 20:18:47 -0700 Subject: [PATCH 03/47] update the nodelist.status to installing/netbooting via feedback from node during provision --- xCAT-server/share/xcat/install/scripts/pre.rh | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/xCAT-server/share/xcat/install/scripts/pre.rh b/xCAT-server/share/xcat/install/scripts/pre.rh index a0d8675c6..8fc78775f 100644 --- a/xCAT-server/share/xcat/install/scripts/pre.rh +++ b/xCAT-server/share/xcat/install/scripts/pre.rh @@ -13,6 +13,24 @@ if [ -r /tmp/updates/etc/pki/tls/certs/ca-bundle.crt ]; then cp -f /tmp/updates/etc/pki/tls/certs/ca-bundle.crt /etc/pki/tls/certs/ fi +cat >/tmp/baz.py </tmp/foo.py </foo.log 2>&1 & #time to ascertain fstype and PReP/UEFI/legacy From 908508f44c48ae0f52679752427ef7688f77b35b Mon Sep 17 00:00:00 2001 From: immarvin Date: Thu, 15 Aug 2013 20:24:34 -0700 Subject: [PATCH 04/47] update the nodelist.status to installing/netbooting via feedback from node during provision --- .../share/xcat/install/scripts/pre.sles | 39 ++++++++++++------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/xCAT-server/share/xcat/install/scripts/pre.sles b/xCAT-server/share/xcat/install/scripts/pre.sles index 8951c234d..6c616c9e8 100644 --- a/xCAT-server/share/xcat/install/scripts/pre.sles +++ b/xCAT-server/share/xcat/install/scripts/pre.sles @@ -14,28 +14,30 @@ cat >/tmp/bar.awk </tmp/foo.log 2>&1 & + shopt -s nullglob for disk in /dev/vd*[^0-9];do if [ -z "$firstdirectdisk" ]; then firstdirectdisk=$disk; fi #remember first disk as a guess of medium resort From e918aa27a44199090e846d7999ee1bcc0a7e9703 Mon Sep 17 00:00:00 2001 From: immarvin Date: Thu, 15 Aug 2013 20:27:20 -0700 Subject: [PATCH 05/47] update the nodelist.status to installing/netbooting via feedback from node during provision --- xCAT-server/share/xcat/netboot/rh/dracut/install.netboot | 1 + 1 file changed, 1 insertion(+) diff --git a/xCAT-server/share/xcat/netboot/rh/dracut/install.netboot b/xCAT-server/share/xcat/netboot/rh/dracut/install.netboot index e9beb2376..d9cd35d83 100755 --- a/xCAT-server/share/xcat/netboot/rh/dracut/install.netboot +++ b/xCAT-server/share/xcat/netboot/rh/dracut/install.netboot @@ -4,5 +4,6 @@ dracut_install wget cpio gzip dash modprobe touch echo cut wc dracut_install grep ifconfig hostname awk egrep grep dirname expr dracut_install mount.nfs dracut_install parted mke2fs bc mkswap swapon chmod +inst "$moddir/xcat-updateflag" "/tmp/updateflag" inst "$moddir/xcatroot" "/sbin/xcatroot" inst_hook cmdline 10 "$moddir/xcat-cmdline.sh" From c8ca832460e7e0cf8dddefbeea4a1b24ec457df1 Mon Sep 17 00:00:00 2001 From: immarvin Date: Thu, 15 Aug 2013 20:29:27 -0700 Subject: [PATCH 06/47] update the nodelist.status to installing/netbooting via feedback from node during provision --- xCAT-server/share/xcat/netboot/rh/dracut/install.statelite | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xCAT-server/share/xcat/netboot/rh/dracut/install.statelite b/xCAT-server/share/xcat/netboot/rh/dracut/install.statelite index 456fe5799..727f2b864 100755 --- a/xCAT-server/share/xcat/netboot/rh/dracut/install.statelite +++ b/xCAT-server/share/xcat/netboot/rh/dracut/install.statelite @@ -3,4 +3,6 @@ echo $drivers dracut_install wget cpio gzip dash modprobe wc touch echo cut dracut_install grep ifconfig hostname awk egrep grep dirname expr dracut_install parted mke2fs bc mkswap swapon chmod +inst "$moddir/xcat-updateflag" "/tmp/updateflag" +inst_hook pre-mount 5 "$moddir/xcat-premount.sh" inst_hook pre-pivot 5 "$moddir/xcat-prepivot.sh" From 988da99f89fbe09555ffbffb4e392ba8a8af074d Mon Sep 17 00:00:00 2001 From: immarvin Date: Thu, 15 Aug 2013 20:31:29 -0700 Subject: [PATCH 07/47] update the nodelist.status to installing/netbooting via feedback from node during provision --- .../share/xcat/netboot/rh/dracut/xcatroot | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/xCAT-server/share/xcat/netboot/rh/dracut/xcatroot b/xCAT-server/share/xcat/netboot/rh/dracut/xcatroot index 45c663ee7..477a7c549 100755 --- a/xCAT-server/share/xcat/netboot/rh/dracut/xcatroot +++ b/xCAT-server/share/xcat/netboot/rh/dracut/xcatroot @@ -5,6 +5,22 @@ XCATMASTER=$XCAT . /lib/dracut-lib.sh rootlimit="$(getarg rootlimit=)" + + +getarg nonodestatus +NODESTATUS=$? + +MASTER=`echo $XCATMASTER |awk -F: '{print $1}'` +XCATIPORT="$(getarg XCATIPORT=)" +if [ $? -ne 0 ]; then +XCATIPORT="3002" +fi + + +if [ $NODESTATUS -ne 0 ];then +/tmp/updateflag $MASTER $XCATIPORT "installstatus netbooting" +fi + if [ ! -z "$imgurl" ]; then if [ xhttp = x${imgurl%%:*} ]; then NFS=0 From 61319213071341dcbd7afbb58a119edf0ad859e4 Mon Sep 17 00:00:00 2001 From: immarvin Date: Thu, 15 Aug 2013 22:10:07 -0700 Subject: [PATCH 08/47] update the nodelist.status to installing/netbooting via feedback from node during provision --- xCAT-server/share/xcat/netboot/rh/genimage | 70 +++++++++++++++++++++- 1 file changed, 69 insertions(+), 1 deletion(-) diff --git a/xCAT-server/share/xcat/netboot/rh/genimage b/xCAT-server/share/xcat/netboot/rh/genimage index 8d92bf32c..aca1fc013 100755 --- a/xCAT-server/share/xcat/netboot/rh/genimage +++ b/xCAT-server/share/xcat/netboot/rh/genimage @@ -538,6 +538,7 @@ if (-d "$rootimg_dir/usr/share/dracut") { print "Enter the dracut mode. Dracut version: $dracutver. Dracut directory: $dracutdir.\n"; } + #-- for centos, disable the internet repository if( -e "$rootimg_dir/etc/yum.repos.d/CentOS-Base.repo" ) { my $repo_content=`sed -e '/enabled/d' $rootimg_dir/etc/yum.repos.d/CentOS-Base.repo | sed -e '/^gpgkey/i enabled=0'`; @@ -778,11 +779,19 @@ sub mkinitrd_dracut { $perm = (stat("$fullpath/$dracutdir/install.statelite"))[2]; chmod($perm&07777, "$dracutmpath/install"); + cp("$fullpath/$dracutdir/xcat-updateflag",$dracutmpath); + $perm = (stat("$fullpath/$dracutdir/xcat-updateflag"))[2]; + chmod($perm&07777, "$dracutmpath/xcat-updateflag"); + cp("$fullpath/$dracutdir/xcat-prepivot.sh",$dracutmpath); $perm = (stat("$fullpath/$dracutdir/xcat-prepivot.sh"))[2]; chmod($perm&07777, "$dracutmpath/xcat-prepivot.sh"); - # update etc/dracut.conf + cp("$fullpath/$dracutdir/xcat-premount.sh",$dracutmpath); + $perm = (stat("$fullpath/$dracutdir/xcat-premount.sh"))[2]; + chmod($perm&07777, "$dracutmpath/xcat-premount.sh"); + + #update etc/dracut.conf open($DRACUTCONF, '>', "$rootimg_dir/etc/dracut.conf"); if (-d glob("$rootimg_dir/usr/share/dracut/modules.d/[0-9]*fadump")){ print $DRACUTCONF qq{dracutmodules+="xcat nfs base network kernel-modules fadump"\n}; @@ -802,6 +811,10 @@ sub mkinitrd_dracut { $perm = (stat("$fullpath/$dracutdir/xcat-cmdline.sh"))[2]; chmod($perm&07777, "$dracutmpath/xcat-cmdline.sh"); + cp("$fullpath/$dracutdir/xcat-updateflag",$dracutmpath); + $perm = (stat("$fullpath/$dracutdir/xcat-updateflag"))[2]; + chmod($perm&07777, "$dracutmpath/xcat-updateflag"); + if ($prinic) { my $optspec; open($optspec,'>>',"$dracutmpath/xcat-cmdline.sh"); @@ -1058,6 +1071,7 @@ grep '\(debug\)' /proc/cmdline > /dev/null && export DEBUG=1 # TODO: does "anaconda.busybox sh" support "set " ? PRINIC=$prinic +NODESTATUS='y' for i in `cat /proc/cmdline`; do KEY=`echo \$i |awk -F= '{print \$1}'` @@ -1070,6 +1084,14 @@ for i in `cat /proc/cmdline`; do VALUE=`echo \$i |awk -F= '{print \$2}'` # format: XCAT=xcatmaster:3001 XCATSERVER=\$VALUE + elif [ "\$KEY" == 'XCATIPORT' ]; then + VALUE=`echo \$i |awk -F= '{print \$2}'` + # format: XCAT=xcatmaster:3001 + XCATIPORT=\$VALUE + fi + #if "nonodestatus" specified,do not update the nodestatus + if [ \$i == 'nonodestatus' ]; then + NODESTATUS='n' fi done @@ -1098,6 +1120,18 @@ while ! ifconfig | grep inet; do done ifconfig lo 127.0.0.1 ifconfig lo up + +XCATMASTER=`echo \$XCATSERVER|awk -F: '{print \$1}'` + +if [ -z \$XCATIPORT ]; then + XCATIPORT="3002" +fi + +#update nodelist.nodestatus to "netbooting" +if [ \$NODESTATUS != 'n' ]; then + /tmp/updateflag \$XCATMASTER \$XCATIPORT "installstatus netbooting" +fi + cd / for i in `cat /proc/cmdline`; do KEY=`echo \$i |awk -F= '{print \$1}'` @@ -1144,6 +1178,10 @@ for i in `cat /proc/cmdline`; do fi done + + + + # show xCAT logo fancydisplay @@ -1353,8 +1391,38 @@ EOMS open($inifile,">"."/tmp/xcatinitrd.$$/bin/netstart"); print $inifile "#!/sbin/nash\n"; close($inifile); + + #/tmp/updateflag: a script to feedback node provision status to xcatd + system("mkdir -p /tmp/xcatinitrd.$$/tmp/"); + open($inifile, ">","/tmp/xcatinitrd.$$/tmp/updateflag"); + + print $inifile < /tmp/ncarg + nc \$1 \$2 -w 60 -e /tmp/updateflag +else + retrytimes=0 + cmd="" + while [ "\$cmd" != "done" ]; do + retrytimes=`expr \$retrytimes + 1` + if [ \$retrytimes -eq 60 ]; then + break; + fi + read -t 60 cmd + if [ "\$cmd" == "ready" ]; then + head -n 1 /tmp/ncarg + rm -rf /tmp/ncarg + fi + done + +fi +EOMS + close($inifile); + chmod(0755,"/tmp/xcatinitrd.$$/init"); chmod(0755,"/tmp/xcatinitrd.$$/bin/netstart"); + chmod(0755,"/tmp/xcatinitrd.$$/tmp/updateflag"); @filestoadd=(); foreach (@ndrivers) { if (-f "$customdir/$_") { From 7cbc8b1bea68a80f72a8de8d95e3af8fee883b89 Mon Sep 17 00:00:00 2001 From: immarvin Date: Thu, 15 Aug 2013 22:33:51 -0700 Subject: [PATCH 09/47] update the nodelist.status to installing/netbooting via feedback from node during provision --- xCAT-server/share/xcat/netboot/sles/genimage | 59 +++++++++++++++++++- 1 file changed, 56 insertions(+), 3 deletions(-) diff --git a/xCAT-server/share/xcat/netboot/sles/genimage b/xCAT-server/share/xcat/netboot/sles/genimage index b4a018698..a619a80e0 100755 --- a/xCAT-server/share/xcat/netboot/sles/genimage +++ b/xCAT-server/share/xcat/netboot/sles/genimage @@ -472,7 +472,7 @@ unless ($onlyinitrd) { } } - foreach $pass (sort {$a <=> $b} (keys(%extra_hash))) { + foreach $pass (sort {$a <=> $b} (keys(%extra_hash))) { my $index=1; #remove the old repository for extra packages @@ -1032,6 +1032,7 @@ EOMS # check the kernel parameters firstly # if one parameter for the booting device is here, it will be used PRINIC=$prinic +NODESTATUS='y' XCATMNTOPTS='nolock,tcp' for i in `cat /proc/cmdline`; do KEY=`echo \$i |awk -F= '{print \$1}'` @@ -1050,6 +1051,11 @@ for i in `cat /proc/cmdline`; do XCATMNTOPTS=\$VALUE fi + + + if [ \$i == 'nonodestatus' ]; then + NODESTATUS='n' + fi done if [ -z "\$IFACE" ]; then @@ -1083,6 +1089,18 @@ echo "STARTMODE=nfsroot" > /tmp/ifcfg-\$IFACE ip addr add dev lo 127.0.0.1/8 ip link set lo up + + +XCATMASTER=`echo \$XCATSERVER|awk -F: '{print \$1}'` + +if [ -z \$XCATIPORT ]; then + XCATIPORT="3002" +fi + +if [ \$NODESTATUS != 'n' ]; then + /tmp/updateflag \$XCATMASTER \$XCATIPORT "installstatus netbooting" +fi + cd / for i in `cat /proc/cmdline`; do KEY=`echo \$i |awk -F= '{print \$1}'` @@ -1373,8 +1391,43 @@ cat /var/lib/dhcpcd/*info | grep HOSTNAME | uniq | awk -F= '{print \$2}'| sed \" END close($inifile); - chmod(0755,"/tmp/xcatinitrd.$$/init"); - chmod(0755,"/tmp/xcatinitrd.$$/bin/netstart"); + + #if "nonodestatus" specified,do not update the nodestatus + system("mkdir -p /tmp/xcatinitrd.$$/tmp/"); + open($inifile, ">","/tmp/xcatinitrd.$$/tmp/updateflag"); + + print $inifile < Date: Thu, 15 Aug 2013 22:38:32 -0700 Subject: [PATCH 10/47] update the nodelist.status to installing/netbooting via feedback from node during provision --- xCAT-server/lib/xcat/plugins/debian.pm | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/xCAT-server/lib/xcat/plugins/debian.pm b/xCAT-server/lib/xcat/plugins/debian.pm index 8a3e81c82..76ef5e2fa 100644 --- a/xCAT-server/lib/xcat/plugins/debian.pm +++ b/xCAT-server/lib/xcat/plugins/debian.pm @@ -897,6 +897,8 @@ sub mknetboot my $installroot; $installroot = "/install"; my $xcatdport = "3001"; + my $xcatiport = "3002"; + my $nodestatus = "y"; if ($sitetab) { @@ -910,11 +912,21 @@ sub mknetboot { $xcatdport = $ref->{value}; } + ($ref) = $sitetab->getAttribs({key => 'xcatiport'}, 'value'); + if ($ref and $ref->{value}) + { + $xcatiport = $ref->{value}; + } ($ref) = $sitetab->getAttribs({key => 'tftpdir'}, 'value'); if ($ref and $ref->{value}) { $globaltftpdir = $ref->{value}; } + ($ref) = $sitetab->getAttribs({key => 'nodestatus'}, 'value'); + if ($ref and $ref->{value}) + { + $nodestatus = $ref->{value}; + } } my %donetftp=(); my %oents = %{$ostab->getNodesAttribs(\@nodes,[qw(os arch profile provmethod)])}; @@ -1317,6 +1329,7 @@ sub mknetboot + # add support for subVars in the value of "statemnt" my $statemnt = ""; if (exists($stateHash->{$node})) { @@ -1366,6 +1379,10 @@ sub mknetboot $kcmdline .= "XCAT=$xcatmaster:$xcatdport "; } + # if site.nodestatus='n', add "nonodestatus" to kcmdline to inform the node not to update nodestatus during provision + if(($nodestatus eq "n") or ($nodestatus eq "N") or ($nodestatus eq "0")){ + $kcmdline .= " nonodestatus "; + } # add one parameter: ifname=: # which is used for dracut # the redhat5.x os will ignore it From 125fb4d8129ef3a91db3637e9c2cd084a5fd1818 Mon Sep 17 00:00:00 2001 From: immarvin Date: Thu, 15 Aug 2013 22:40:47 -0700 Subject: [PATCH 11/47] update the nodelist.status to installing/netbooting via feedback from node during provision --- .../share/xcat/install/scripts/pre.ubuntu | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/xCAT-server/share/xcat/install/scripts/pre.ubuntu b/xCAT-server/share/xcat/install/scripts/pre.ubuntu index 95c95ece9..b6a86c2d1 100644 --- a/xCAT-server/share/xcat/install/scripts/pre.ubuntu +++ b/xCAT-server/share/xcat/install/scripts/pre.ubuntu @@ -63,9 +63,18 @@ cat >/tmp/foo.sh < Date: Fri, 16 Aug 2013 05:50:59 -0400 Subject: [PATCH 12/47] Enchancement for drvier injection to initrd: 1. add the updateonly keyword for netdrivers att that only update the existed drivers from new distro update instead of copying all the drivers, this is helpful to reduce the size of new built initrd; 2. the drivers for old kernel will be removed if there's new kernel will be used. And merge the status update commit which checked in by Yang Song from 2.8 --- xCAT-server/lib/xcat/plugins/anaconda.pm | 133 +++++++++++++++++------ xCAT-server/lib/xcat/plugins/sles.pm | 77 ++++++++++--- 2 files changed, 162 insertions(+), 48 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/anaconda.pm b/xCAT-server/lib/xcat/plugins/anaconda.pm index ac4493666..77da2276a 100644 --- a/xCAT-server/lib/xcat/plugins/anaconda.pm +++ b/xCAT-server/lib/xcat/plugins/anaconda.pm @@ -180,6 +180,8 @@ sub mknetboot my $installroot; $installroot = "/install"; my $xcatdport = "3001"; + my $xcatiport = "3002"; + my $nodestatus = "y"; #if ($sitetab) #{ @@ -190,6 +192,12 @@ sub mknetboot { $installroot = $site_ent; } + @ents = xCAT::TableUtils->get_site_attribute("nodestatus"); + $site_ent = $ents[0]; + if ( defined($site_ent) ) + { + $nodestatus = $site_ent; + } # ($ref) = $sitetab->getAttribs({key => 'xcatdport'}, 'value'); @ents = xCAT::TableUtils->get_site_attribute("xcatdport"); $site_ent = $ents[0]; @@ -197,6 +205,12 @@ sub mknetboot { $xcatdport = $site_ent; } + @ents = xCAT::TableUtils->get_site_attribute("xcatiport"); + $site_ent = $ents[0]; + if ( defined($site_ent) ) + { + $xcatiport = $site_ent; + } # ($ref) = $sitetab->getAttribs({key => 'tftpdir'}, 'value'); @ents = xCAT::TableUtils->get_site_attribute("tftpdir"); $site_ent = $ents[0]; @@ -679,8 +693,10 @@ sub mknetboot } else { $xcatmasterip = $xcatmaster; } - $kcmdline .= - "XCAT=$xcatmasterip:$xcatdport "; + + $kcmdline .= "XCAT=$xcatmaster:$xcatdport "; + + if ($rootfstype ne "ramdisk") { # BEGIN service node my $isSV = xCAT::Utils->isServiceNode(); @@ -701,9 +717,14 @@ sub mknetboot else { $kcmdline = "imgurl=$httpmethod://$imgsrv:$httpport/$rootimgdir/rootimg.$suffix "; - $kcmdline .= "XCAT=$xcatmaster:$xcatdport "; + $kcmdline .= "XCAT=$xcatmaster:$xcatdport "; $kcmdline .= "NODE=$node "; } + #inform statelite/stateless node not to update the nodestatus during provision + if(($nodestatus eq "n") or ($nodestatus eq "N") or ($nodestatus eq "0")){ + $kcmdline .= " nonodestatus "; + } + # add one parameter: ifname=: # which is used for dracut @@ -913,7 +934,6 @@ sub mkinstall my $doreq = shift; my @nodes = @{$request->{node}}; my $noupdateinitrd = $request->{'noupdateinitrd'}; - #my $sitetab = xCAT::Table->new('site'); my $linuximagetab; my $osimagetab; @@ -2409,6 +2429,7 @@ sub insert_dd { my @rpm_list; my @driver_list; my $Injectalldriver; + my $updatealldriver; my @rpm_drivers; @@ -2453,6 +2474,9 @@ sub insert_dd { if (/^allupdate$/) { $Injectalldriver = 1; next; + } elsif (/^updateonly$/) { + $updatealldriver = 1; + next; } unless (/\.ko$/) { s/$/.ko/; @@ -2463,7 +2487,7 @@ sub insert_dd { chomp(@dd_list); chomp(@rpm_list); - unless (@dd_list || (@rpm_list && ($Injectalldriver || @driver_list))) { + unless (@dd_list || (@rpm_list && ($Injectalldriver || $updatealldriver || @driver_list))) { return (); } @@ -2474,7 +2498,7 @@ sub insert_dd { # dracut + drvier rpm # !dracut + driver rpm # !dracut + driver disk - if (!<$install_dir/$os/$arch/Packages/dracut*> || (@rpm_list && ($Injectalldriver || @driver_list))) { + if (!<$install_dir/$os/$arch/Packages/dracut*> || (@rpm_list && ($Injectalldriver || $updatealldriver || @driver_list))) { mkpath "$dd_dir/initrd_img"; # The dir for the new initrd # unzip the initrd image @@ -2537,13 +2561,12 @@ sub insert_dd { } my $new_kernel_ver; - if (@rpm_list && ($Injectalldriver || @driver_list)) { + if (@rpm_list && ($Injectalldriver || $updatealldriver || @driver_list)) { # Extract the files from rpm to the tmp dir mkpath "$dd_dir/rpm"; foreach my $rpm (@rpm_list) { if (-r $rpm) { $cmd = "cd $dd_dir/rpm; rpm2cpio $rpm | cpio -idum"; - #$cmd = "rpm -i --quiet --nodeps --force --ignorearch --ignoreos --nosignature --root $dd_dir/rpm $rpm"; xCAT::Utils->runcmd($cmd, -1); if ($::RUNCMD_RC != 0) { my $rsp; @@ -2560,17 +2583,17 @@ sub insert_dd { # and copy it to the /tftpboot my @new_kernels = <$dd_dir/rpm/boot/vmlinuz*>; foreach my $new_kernel (@new_kernels) { - if (-r $new_kernel && $new_kernel =~ /\/vmlinuz-(.*(x86_64|ppc64))$/) { - $new_kernel_ver = $1; - $cmd = "/bin/mv -f $new_kernel $kernelpath"; - xCAT::Utils->runcmd($cmd, -1); - if ($::RUNCMD_RC != 0) { - my $rsp; - push @{$rsp->{data}}, "Handle the driver update failed. Could not move $new_kernel to $kernelpath."; - xCAT::MsgUtils->message("I", $rsp, $callback); + if (-r $new_kernel && $new_kernel =~ /\/vmlinuz-(.*(x86_64|ppc64|el\d+))$/) { + $new_kernel_ver = $1; + $cmd = "/bin/mv -f $new_kernel $kernelpath"; + xCAT::Utils->runcmd($cmd, -1); + if ($::RUNCMD_RC != 0) { + my $rsp; + push @{$rsp->{data}}, "Handle the driver update failed. Could not move $new_kernel to $kernelpath."; + xCAT::MsgUtils->message("I", $rsp, $callback); + } } } - } # 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 @@ -2601,7 +2624,7 @@ sub insert_dd { # For dracut mode, only copy the drivers from rpm packages to the /lib/modules/ # The driver disk will be handled that append the whole disk to the orignial initrd - if (@rpm_list && ($Injectalldriver || @driver_list)) { + if (@rpm_list && ($Injectalldriver || $updatealldriver || @driver_list)) { # Copy the firmware to the rootimage if (-d "$dd_dir/rpm/lib/firmware") { if (! -d "$dd_dir/initrd_img/lib/firmware") { @@ -2616,14 +2639,15 @@ sub insert_dd { } } - # if the new kernel from update distro is not existed in initrd, copy all the modules for the new kernel to initrd - if ((! -r "$dd_dir/initrd_img/lib/modules/$new_kernel_ver") && (-r "$dd_dir/rpm/lib/modules/$new_kernel_ver")) { - $cmd = "/bin/cp -rf $dd_dir/rpm/lib/modules/$new_kernel_ver $dd_dir/initrd_img/lib/modules/"; - xCAT::Utils->runcmd($cmd, -1); - if ($::RUNCMD_RC != 0) { - my $rsp; - push @{$rsp->{data}}, "Handle the driver update failed. Could not copy $dd_dir/rpm/lib/modules/$new_kernel_ver to $dd_dir/initrd_img/lib/modules."; - xCAT::MsgUtils->message("E", $rsp, $callback); + # get the name list for all drivers in the original initrd if 'netdrivers=updateonly' + # then only the drivers in this list will be updated from the drvier rpms + if ($updatealldriver) { + $driver_name = "\*\.ko"; + @all_real_path = (); + find(\&get_all_path, <$dd_dir/initrd_img/lib/modules/*>); + foreach my $real_path (@all_real_path) { + my $driver = basename($real_path); + push @driver_list, $driver; } } @@ -2631,9 +2655,19 @@ sub insert_dd { # Figure out the kernel version my @kernelpaths = <$dd_dir/initrd_img/lib/modules/*>; my @kernelvers; + if ($new_kernel_ver) { + push @kernelvers, $new_kernel_ver; + } + + # if new kernel is used, remove all the original kernel directories foreach (@kernelpaths) { - if (basename($_) =~ /^[\d\.]+/) { - push @kernelvers, basename($_); + my $kernelv = basename($_); + if ($kernelv =~ /^[\d\.]+/) { + if ($new_kernel_ver) { + rmtree ("$dd_dir/initrd_img/lib/modules/$kernelv"); + } else { + push @kernelvers, $kernelv; + } } } @@ -2643,6 +2677,7 @@ sub insert_dd { } if (@driver_list) { foreach my $driver (@driver_list) { + $driver =~ s/\.gz$//; $driver_name = $driver; @all_real_path = (); find(\&get_all_path, <$dd_dir/rpm/lib/modules/$kernelver/*>); @@ -2805,7 +2840,7 @@ sub insert_dd { } # Merge the drviers from rpm packages to the initrd - if (@rpm_list && ($Injectalldriver || @driver_list)) { + if (@rpm_list && ($Injectalldriver || $updatealldriver || @driver_list)) { # Copy the firmware to the rootimage if (-d "$dd_dir/rpm/lib/firmware") { if (! -d "$dd_dir/initrd_img/lib") { @@ -2825,18 +2860,44 @@ sub insert_dd { mkpath ("$dd_dir/modules/$new_kernel_ver/$arch/"); } + # get the name list for all drivers in the original initrd if 'netdrivers=updateonly' + # then only the drivers in this list will be updated from the drvier rpms + if ($updatealldriver) { + $driver_name = "\*\.ko"; + @all_real_path = (); + find(\&get_all_path, <$dd_dir/modules/*>); + foreach my $real_path (@all_real_path) { + my $driver = basename($real_path); + push @driver_list, $driver; + } + } + # Copy the drivers to the initrd # Figure out the kernel version my @kernelpaths = <$dd_dir/modules/*>; my @kernelvers; + if ($new_kernel_ver) { + push @kernelvers, $new_kernel_ver; + } foreach (@kernelpaths) { - push @kernelvers, basename($_); + my $kernelv = basename($_); + if ($kernelv =~ /^[\d\.]+/) { + if ($new_kernel_ver) { + rmtree ("$dd_dir/modules/$kernelv"); + } else { + push @kernelvers, $kernelv; + } + } } foreach my $kernelver (@kernelvers) { unless (-d "$dd_dir/rpm/lib/modules/$kernelver") { next; } + # create path for the new kernel in the modules package + unless (-d "$dd_dir/modules/$kernelver") { + mkpath ("$dd_dir/modules/$kernelver/$arch/"); + } # find the $kernelver/$arch dir in the $dd_dir/modules my $arch4modules; foreach (<$dd_dir/modules/$kernelver/*>) { @@ -2912,13 +2973,23 @@ sub insert_dd { if (-d $ma) { mkpath "$dd_dir/depmod/lib/modules/$mk"; xCAT::Utils->runcmd("/bin/cp -rf $ma/* $dd_dir/depmod/lib/modules/$mk", -1); - $cmd = "depmod -b $dd_dir/depmod/"; + $cmd = "depmod -b $dd_dir/depmod/ $mk"; + #$cmd = "depmod -b $dd_dir/depmod/"; xCAT::Utils->runcmd($cmd, -1); if ($::RUNCMD_RC != 0) { my $rsp; push @{$rsp->{data}}, "Handle the driver update failed. Could not generate the depdency for the drivers in the initrd."; xCAT::MsgUtils->message("I", $rsp, $callback); } + # remove the .ko postfix from the driver name for rh5 + $cmd = "/bin/sed ".'s/\.ko//g'." $dd_dir/depmod/lib/modules/$mk/modules.dep > $dd_dir/depmod/lib/modules/$mk/modules.dep1; mv -f $dd_dir/depmod/lib/modules/$mk/modules.dep1 $dd_dir/depmod/lib/modules/$mk/modules.dep"; + xCAT::Utils->runcmd($cmd, -1); + if ($::RUNCMD_RC != 0) { + my $rsp; + push @{$rsp->{data}}, "Handle the driver update failed. Could not generate the depdency for the drivers in the initrd."; + xCAT::MsgUtils->message("I", $rsp, $callback); + } + if (-f "$dd_dir/depmod/lib/modules/$mk/modules.dep") { copy ("$dd_dir/depmod/lib/modules/$mk/modules.dep", "$dd_dir/initrd_img/modules/modules.dep"); } diff --git a/xCAT-server/lib/xcat/plugins/sles.pm b/xCAT-server/lib/xcat/plugins/sles.pm index 3404b7566..72677014a 100644 --- a/xCAT-server/lib/xcat/plugins/sles.pm +++ b/xCAT-server/lib/xcat/plugins/sles.pm @@ -64,7 +64,8 @@ sub mknetboot $installroot = "/install"; my $xcatdport = "3001"; - + my $xcatiport = "3002"; + my $nodestatus = "y"; #if ($sitetab) #{ #(my $ref) = $sitetab->getAttribs({key => 'installdir'}, 'value'); @@ -79,6 +80,17 @@ sub mknetboot if ( defined($t_entry) ) { $xcatdport = $t_entry; } + @entries = xCAT::TableUtils->get_site_attribute("xcatiport"); + $t_entry = $entries[0]; + if ( defined($t_entry) ) { + $xcatiport = $t_entry; + } + @entries = xCAT::TableUtils->get_site_attribute("nodestatus"); + $t_entry = $entries[0]; + if ( defined($t_entry) ) { + $nodestatus = $t_entry; + } + #} my $ntents = $ostab->getNodesAttribs($req->{node}, ['os', 'arch', 'profile', 'provmethod']); @@ -553,6 +565,13 @@ sub mknetboot "imgurl=$httpmethod://$imgsrv/$rootimgdir/rootimg.$suffix "; } $kcmdline .= "XCAT=$xcatmaster:$xcatdport quiet "; + + #if site.nodestatus="n", append "nonodestatus" to kcmdline + #to inform the statelite/stateless node not to update the nodestatus during provision + if(($nodestatus eq "n") or ($nodestatus eq "N") or ($nodestatus eq "0")){ + $kcmdline .= " nonodestatus "; + } + $kcmdline .= "NODE=$node "; # add the kernel-booting parameter: netdev=, or BOOTIF= @@ -1670,6 +1689,7 @@ sub insert_dd () { my @rpm_list; my @driver_list; my $Injectalldriver; + my $updatealldriver; my @rpm_drivers; @@ -1715,6 +1735,9 @@ sub insert_dd () { if (/^allupdate$/) { $Injectalldriver = 1; next; + } elsif (/^updateonly$/) { + $updatealldriver = 1; + next; } unless (/\.ko$/) { s/$/.ko/; @@ -1725,7 +1748,7 @@ sub insert_dd () { chomp(@dd_list); chomp(@rpm_list); - unless (@dd_list || (@rpm_list && ($Injectalldriver || @driver_list))) { + unless (@dd_list || (@rpm_list && ($Injectalldriver || $updatealldriver || @driver_list))) { return (); } @@ -1738,7 +1761,7 @@ sub insert_dd () { # Unzip the original initrd # This only needs to be done for ppc or handling the driver rpm # For the driver disk against x86, append the driver disk to initrd directly - if ($arch =~/ppc/ || (@rpm_list && ($Injectalldriver || @driver_list))) { + if ($arch =~/ppc/ || (@rpm_list && ($Injectalldriver || $updatealldriver || @driver_list))) { if ($arch =~ /ppc/) { $cmd = "gunzip --quiet -c $pkgdir/1/suseboot/initrd64 > $dd_dir/initrd"; } elsif ($arch =~ /x86/) { @@ -1763,7 +1786,7 @@ sub insert_dd () { } # Start to load the drivers from rpm packages - if (@rpm_list && ($Injectalldriver || @driver_list)) { + if (@rpm_list && ($Injectalldriver || $updatealldriver || @driver_list)) { # Extract the files from rpm to the tmp dir mkpath "$dd_dir/rpm"; my $new_kernel_ver; @@ -1785,17 +1808,17 @@ sub insert_dd () { # get the new kernel if it exists in the update distro my @new_kernels = <$dd_dir/rpm/boot/vmlinu*>; foreach my $new_kernel (@new_kernels) { - if (-r $new_kernel && $new_kernel =~ /\/vmlinu[zx]-(.*(x86_64|ppc64|default))$/) { - $new_kernel_ver = $1; - $cmd = "/bin/mv -f $new_kernel $dd_dir/rpm/newkernel"; - xCAT::Utils->runcmd($cmd, -1); - if ($::RUNCMD_RC != 0) { - my $rsp; - push @{$rsp->{data}}, "Handle the driver update failed. Could not move $new_kernel to $dd_dir/rpm/newkernel."; - xCAT::MsgUtils->message("I", $rsp, $callback); + if (-r $new_kernel && $new_kernel =~ /\/vmlinu[zx]-(.*(x86_64|ppc64|default))$/) { + $new_kernel_ver = $1; + $cmd = "/bin/mv -f $new_kernel $dd_dir/rpm/newkernel"; + xCAT::Utils->runcmd($cmd, -1); + if ($::RUNCMD_RC != 0) { + my $rsp; + push @{$rsp->{data}}, "Handle the driver update failed. Could not move $new_kernel to $dd_dir/rpm/newkernel."; + xCAT::MsgUtils->message("I", $rsp, $callback); + } } } - } # 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 @@ -1842,13 +1865,35 @@ sub insert_dd () { xCAT::MsgUtils->message("I", $rsp, $callback); } } + + # get the name list for all drivers in the original initrd if 'netdrivers=updateonly' + # then only the drivers in this list will be updated from the drvier rpms + if ($updatealldriver) { + $driver_name = "\*\.ko"; + @all_real_path = (); + find(\&get_all_path, <$dd_dir/initrd_img/lib/modules/*>); + foreach my $real_path (@all_real_path) { + my $driver = basename($real_path); + push @driver_list, $driver; + } + } # Copy the drivers to the rootimage # Figure out the kernel version my @kernelpaths = <$dd_dir/initrd_img/lib/modules/*>; my @kernelvers; + if ($new_kernel_ver) { + push @kernelvers, $new_kernel_ver; + } foreach (@kernelpaths) { - push @kernelvers, basename($_); + my $kernelv = basename($_); + if ($kernelv =~ /^[\d\.]+/) { + if ($new_kernel_ver) { + rmtree ("$dd_dir/initrd_img/lib/modules/$kernelv"); + } else { + push @kernelvers, $kernelv; + } + } } foreach my $kernelver (@kernelvers) { @@ -1861,7 +1906,6 @@ sub insert_dd () { $driver_name = $driver; @all_real_path = (); find(\&get_all_path, <$dd_dir/rpm/lib/modules/$kernelver/*>); - #if ($real_path && $real_path =~ m!$dd_dir/rpm(/lib/modules/$kernelver/.*?)[^\/]*$!) { # NOTE: for the initrd of sles that the drivers are put in the /lib/modules/$kernelver/initrd/ foreach my $real_path (@all_real_path) { if ($real_path && $real_path =~ m!$dd_dir/rpm/lib/modules/$kernelver/!) { @@ -1885,8 +1929,7 @@ sub insert_dd () { $driver_name = "\*\.ko"; @all_real_path = (); find(\&get_all_path, <$dd_dir/rpm/lib/modules/$kernelver/*>); - foreach $real_path (@all_real_path) { - #if ($real_path && $real_path =~ m!$dd_dir/rpm(/lib/modules/$kernelver/.*?)[^\/]*$!) { + foreach my $real_path (@all_real_path) { # NOTE: for the initrd of sles that the drivers are put in the /lib/modules/$kernelver/initrd/ if ($real_path && $real_path =~ m!$dd_dir/rpm/lib/modules/$kernelver/!) { if (! -d "$dd_dir/initrd_img/lib/modules/$kernelver/initrd") { From f78ec64c2539d1ecca59f548f1c3326feda244d1 Mon Sep 17 00:00:00 2001 From: zhaoertao Date: Thu, 15 Aug 2013 20:10:50 -0700 Subject: [PATCH 13/47] The item of updating pre-defined groups for nodes --- perl-xCAT/xCAT/FSPscan.pm | 33 ++++++++++++-- perl-xCAT/xCAT/PPCdb.pm | 9 ++++ perl-xCAT/xCAT/PPCinv.pm | 13 +++++- perl-xCAT/xCAT/PPCscan.pm | 32 +++++++++++-- perl-xCAT/xCAT/TableUtils.pm | 47 ++++++++++++++++++++ perl-xCAT/xCAT/Usage.pm | 8 ++-- perl-xCAT/xCAT/data/ibmhwtypes.pm | 43 ++++++++++++++++++ xCAT-server/lib/xcat/plugins/blade.pm | 42 ++++++++++++++++- xCAT-server/lib/xcat/plugins/ipmi.pm | 30 ++++++++++--- xCAT-server/lib/xcat/plugins/lsslp.pm | 23 ++++++++-- xCAT-server/lib/xcat/plugins/seqdiscovery.pm | 10 ++++- 11 files changed, 266 insertions(+), 24 deletions(-) create mode 100755 perl-xCAT/xCAT/data/ibmhwtypes.pm diff --git a/perl-xCAT/xCAT/FSPscan.pm b/perl-xCAT/xCAT/FSPscan.pm index 90a985caf..6ed064c17 100644 --- a/perl-xCAT/xCAT/FSPscan.pm +++ b/perl-xCAT/xCAT/FSPscan.pm @@ -13,6 +13,7 @@ use xCAT::GlobalDef; use xCAT::Usage; use xCAT::NetworkUtils; use xCAT::FSPUtils; +require xCAT::data::ibmhwtypes; #use Data::Dumper; ############################################## @@ -391,6 +392,7 @@ sub format_stanza { ################################# # Add each attribute ################################# + my $mtm = undef; foreach ( @attribs ) { my $d = $data[$i++]; @@ -401,7 +403,8 @@ sub format_stanza { } elsif ( /^hwtype$/ ) { $d = $globalhwtype{$type}; } elsif ( /^groups$/ ) { - $d = "$type,all"; + next; + #$d = "$type,all"; } elsif ( /^mgt$/ ) { $d = $hwtype; } elsif ( /^cons$/ ) { @@ -414,7 +417,9 @@ sub format_stanza { } elsif ( /^(mtm|serial)$/ ) { if ( $type eq "lpar" ) { $d = undef; - } + } elsif (/^mtm$/) { + $mtm = $d; + } } elsif (/^side$/) { unless ( $type =~ /^fsp|bpa$/ ) { next; @@ -422,6 +427,15 @@ sub format_stanza { } $result .= "\t$_=$d\n"; } + my $tmp_groups = "$type,all"; + if (defined($mtm)) { + my $tmp_pre = xCAT::data::ibmhwtypes::parse_group($mtm); + if (defined($tmp_pre)) { + $tmp_groups .= ",$tmp_pre"; + } + } + $result .= "\tgroups=$tmp_groups\n"; + } return( $result ); } @@ -464,6 +478,7 @@ sub format_xml { ################################# # Add each attribute ################################# + my $mtm = undef; foreach ( @attribs ) { my $d = $data[$i++]; @@ -472,7 +487,8 @@ sub format_xml { } elsif ( /^hwtype$/ ) { $d = $globalhwtype{$type}; } elsif ( /^groups$/ ) { - $d = "$type,all"; + next; + #$d = "$type,all"; } elsif ( /^mgt$/ ) { $d = $hwtype; } elsif ( /^cons$/ ) { @@ -484,6 +500,8 @@ sub format_xml { } elsif ( /^(mtm|serial)$/ ) { if ( $type eq "lpar" ) { $d = undef; + } elsif (/^mtm$/) { + $mtm = $d; } } elsif (/^side$/) { unless ( $type =~ /^fsp|bpa$/ ) { @@ -492,6 +510,15 @@ sub format_xml { } $href->{Node}->{$_} = $d; } + my $tmp_groups = "$type,all"; + if (defined($mtm)) { + my $tmp_pre = xCAT::data::ibmhwtypes::parse_group($mtm); + if (defined($tmp_pre)) { + $tmp_groups .= ",$tmp_pre"; + } + } + $href->{Node}->{groups}=$tmp_groups; + #print Dumper($href); ################################# # XML encoding diff --git a/perl-xCAT/xCAT/PPCdb.pm b/perl-xCAT/xCAT/PPCdb.pm index 52bc3a804..145652510 100644 --- a/perl-xCAT/xCAT/PPCdb.pm +++ b/perl-xCAT/xCAT/PPCdb.pm @@ -7,6 +7,7 @@ use xCAT::GlobalDef; use xCAT::Utils; use xCAT::TableUtils; use xCAT::NetworkUtils; +require xCAT::data::ibmhwtypes; ########################################### # Factory defaults @@ -168,6 +169,10 @@ sub add_ppc { # Update nodelist table ########################### updategroups( $name, $db{nodelist}, $type ); + my $tmp_group = xCAT::data::ibmhwtypes::parse_group($model); + if (defined($tmp_group)) { + updategroups($name, $db{nodelist}, $tmp_group); + } if ( $type =~ /^(fsp|bpa)$/ ) { $db{nodelist}->setNodeAttribs( $name, {hidden => '1'}); } else { @@ -525,6 +530,10 @@ sub update_node_attribs if ( $namediff) { updategroups( $name, $db->{nodelist}, $type ); + my $tmp_group = xCAT::data::ibmhwtypes::parse_group($model); + if (defined($tmp_group)) { + updategroups($name, $db->{nodelist}, $tmp_group); + } $db->{nodelist}->setNodeAttribs( $name, {status=>$nodelisthash->{status}, appstatus=>$nodelisthash->{appstatus}, primarysn=>$nodelisthash->{primarysn}, diff --git a/perl-xCAT/xCAT/PPCinv.pm b/perl-xCAT/xCAT/PPCinv.pm index 640cc1dd9..ea7f0d0c0 100644 --- a/perl-xCAT/xCAT/PPCinv.pm +++ b/perl-xCAT/xCAT/PPCinv.pm @@ -5,6 +5,8 @@ use strict; use Getopt::Long; use xCAT::PPCcli qw(SUCCESS EXPECT_ERROR RC_ERROR NR_ERROR); use xCAT::Usage; +use xCAT::TableUtils; +require xCAT::data::ibmhwtypes; ########################################## @@ -59,7 +61,7 @@ sub parse_args { $Getopt::Long::ignorecase = 0; Getopt::Long::Configure( "bundling" ); - if ( !GetOptions( \%opt, qw(V|verbose) )) { + if ( !GetOptions( \%opt, qw(V|verbose t) )) { return( usage() ); } #################################### @@ -75,6 +77,9 @@ sub parse_args { if ( !defined( $cmd )) { return(usage( "Invalid command: $ARGV[0]" )); } + if (exists($opt{t}) and $cmd ne "model") { + return(["Option 't' can only work with 'model'."]); + } #################################### # Check for an extra argument #################################### @@ -411,6 +416,12 @@ sub vpd { ############################# # Output value ############################# + if ($_ eq 'model' and exists($request->{opt}->{t})) { + my $tmp_pre = xCAT::data::ibmhwtypes::parse_args($data->{$_}); + if (defined($tmp_pre)) { + xCAT::TableUtils->updatenodegroups($name, $tmp_pre); + } + } my $value = "@{$prefix{$_}}[0]: $data->{$_}"; push @result, [$name,$value,$Rc]; } diff --git a/perl-xCAT/xCAT/PPCscan.pm b/perl-xCAT/xCAT/PPCscan.pm index 513d52c88..413e93f05 100644 --- a/perl-xCAT/xCAT/PPCscan.pm +++ b/perl-xCAT/xCAT/PPCscan.pm @@ -11,7 +11,7 @@ use xCAT::PPCdb; use xCAT::GlobalDef; use xCAT::Usage; use xCAT::NetworkUtils; - +require xCAT::data::ibmhwtypes; ############################################## # Globals @@ -545,6 +545,7 @@ sub format_stanza { ################################# # Add each attribute ################################# + my $mtm = undef; foreach ( @attribs ) { my $d = $data[$i++]; @@ -555,7 +556,8 @@ sub format_stanza { } elsif ( /^hwtype$/ ) { $d = $globalhwtype{$type}; } elsif ( /^groups$/ ) { - $d = "$type,all"; + next; + #$d = "$type,all"; } elsif ( /^mgt$/ ) { $d = $hwtype; } elsif ( /^cons$/ ) { @@ -568,7 +570,9 @@ sub format_stanza { } elsif ( /^(mtm|serial)$/ ) { if ( $type eq "lpar" ) { $d = undef; - } + } elsif (/^mtm$/) { + $mtm = $d; + } } elsif (/^side$/) { unless ( $type =~ /^fsp|bpa$/ ) { next; @@ -576,6 +580,14 @@ sub format_stanza { } $result .= "\t$_=$d\n"; } + my $tmp_groups = "$type,all"; + if (defined($mtm)) { + my $tmp_pre = xCAT::data::ibmhwtypes::parse_group($mtm); + if (defined($tmp_pre)) { + $tmp_groups .= ",$tmp_pre"; + } + } + $result .= "\tgroups=$tmp_groups\n"; } return( $result ); } @@ -623,6 +635,7 @@ sub format_xml { ################################# # Add each attribute ################################# + my $mtm = undef; foreach ( @attribs ) { my $d = $data[$i++]; @@ -631,7 +644,8 @@ sub format_xml { } elsif ( /^hwtype$/ ) { $d = $globalhwtype{$type}; } elsif ( /^groups$/ ) { - $d = "$type,all"; + next; + #$d = "$type,all"; } elsif ( /^mgt$/ ) { $d = $hwtype; } elsif ( /^cons$/ ) { @@ -643,6 +657,8 @@ sub format_xml { } elsif ( /^(mtm|serial)$/ ) { if ( $type eq "lpar" ) { $d = undef; + } elsif (/^mtm$/){ + $mtm = $d; } } elsif (/^side$/) { unless ( $type =~ /^fsp|bpa$/ ) { @@ -651,6 +667,14 @@ sub format_xml { } $href->{Node}->{$_} = $d; } + my $tmp_groups = "$type,all"; + if (defined($mtm)) { + my $tmp_pre = xCAT::data::ibmhwtypes::parse_group($mtm); + if (defined($tmp_pre)) { + $tmp_groups .= ",$tmp_pre"; + } + } + $href->{Node}->{groups}=$tmp_groups; ################################# # XML encoding ################################# diff --git a/perl-xCAT/xCAT/TableUtils.pm b/perl-xCAT/xCAT/TableUtils.pm index a6b2128ff..da113712a 100644 --- a/perl-xCAT/xCAT/TableUtils.pm +++ b/perl-xCAT/xCAT/TableUtils.pm @@ -1735,4 +1735,51 @@ sub getimagenames() $nodetab->close; return @imagenames; } +#----------------------------------------------------------------------------- + + +=head3 updatenodegroups + Update groups attribute for the specified node + + Arguments: + node + tabhd: the handler of 'nodelist' table, + groups: the groups attribute need to be merged. + Can be an array or string. + Globals: + none + Error: + Example: + xCAT::TableUtils->updatenodegroups($node, $tab, $groups); + +=cut + +#----------------------------------------------------------------------------- + +sub updatenodegroups { + my ($class, $node, $tabhd, $groups) = @_; + if (!$groups) { + $groups = $tabhd; + $tabhd = xCAT::Table->new('nodelist'); + unless ($tabhd) { + xCAT::MsgUtils->message("E", " Could not read the nodelist table\n"); + return; + } + } + my ($ent) = $tabhd->getNodeAttribs($node, ['groups']); + my @list = qw(all); + if (defined($ent) and $ent->{groups}) { + push @list, split(/,/,$ent->{groups}); + } + if (ref($groups) eq 'ARRAY') { + push @list, @$groups; + } else { + push @list, split(/,/,$groups); + } + my %saw; + @saw{@list} = (); + @list = keys %saw; + $tabhd->setNodeAttribs($node, {groups=>join(",",@list)}); +} + 1; diff --git a/perl-xCAT/xCAT/Usage.pm b/perl-xCAT/xCAT/Usage.pm index 52e362627..242104d2e 100644 --- a/perl-xCAT/xCAT/Usage.pm +++ b/perl-xCAT/xCAT/Usage.pm @@ -72,16 +72,16 @@ my %usage = ( rinv [all|model|serial] [-V|--verbose] rinv [-h|--help|-v|--version] BMC specific: - rinv [vpd|mprom|deviceid|uuid|guid] + rinv [mprom|deviceid|uuid|guid|vpd [-t]|all [-t]] MPA specific: - rinv [firm|bios|diag|mprom|sprom|mparom|mac|mtm] + rinv [firm|bios|diag|mprom|sprom|mparom|mac|mtm [-t]] PPC specific(with HMC): - rinv [bus|config|serial|model|firm|all] + rinv [all|bus|config|serial|model|firm [-t]] PPC specific(using Direct FSP Management): rinv [firm] rinv [deconfig [-x]] Blade specific: - rinv [mtm|serial|mac|bios|diag|mprom|mparom|firm|all] + rinv [all|serial|mac|bios|diag|mprom|mparom|firm|mtm [-t]] IBM Flex System Compute Node specific: rinv [firm] VMware specific: diff --git a/perl-xCAT/xCAT/data/ibmhwtypes.pm b/perl-xCAT/xCAT/data/ibmhwtypes.pm new file mode 100755 index 000000000..efe78c025 --- /dev/null +++ b/perl-xCAT/xCAT/data/ibmhwtypes.pm @@ -0,0 +1,43 @@ +#!/usr/bin/env perl +# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html + +package xCAT::data::ibmhwtypes; +require Exporter; +@EXPORT_OK=qw(parse_group mt2group); +use Data::Dumper; +my %groups2mtm = ( + "x3250" => ["2583","4251","4252"], + "x3550" => ["7914","7944","7946"], + "x3650" => ["7915","7945"], + "dx360" => [], + "x220" => ["7906"], + "x240" => ["8737","7863"], + "x440" => ["7917"], + "p260" => ["7895"], #789522X, 789523X + "p460" => [], #789542X + "p470" => ["7954"], +); + +%mt2group = (); +foreach my $group (keys %groups2mtm) { + foreach my $mtm (@{$groups2mtm{$group}}) { + $mt2group{$mtm} = $group; + } +} + +sub parse_group { + my $mtm = shift; + if ($mtm =~ /xCAT::data/) { + $mtm = shift; + } + if ($mtm =~ /^(\w{4})/) { + $mt = $1; + if ($mt eq "7895" and $mtm =~ /789542X/i) { + return "p460"; + } + return $mt2group{$mt}; + } + return undef; +} + +1; diff --git a/xCAT-server/lib/xcat/plugins/blade.pm b/xCAT-server/lib/xcat/plugins/blade.pm index 5fda1e917..256ab8c99 100644 --- a/xCAT-server/lib/xcat/plugins/blade.pm +++ b/xCAT-server/lib/xcat/plugins/blade.pm @@ -28,6 +28,7 @@ use xCAT::GlobalDef; use xCAT_monitoring::monitorctrl; use strict; use LWP; +require xCAT::data::ibmhwtypes; #use warnings; my %mm_comm_pids; @@ -1773,6 +1774,7 @@ sub rscan_xml { my $href = { Node => { } }; + my $mtm = undef; foreach ( @rscan_attribs ) { my $d = $data[$i++]; @@ -1789,6 +1791,7 @@ sub rscan_xml { } } elsif ( /^groups$/ ) { $d = "$type,all"; + $ignore = 1; } elsif ( /^mgt$/ ) { if ($origtype eq "ppcblade") { $d = "fsp"; @@ -1831,13 +1834,23 @@ sub rscan_xml { } else { $ignore = 1; } + } elsif (/^mtm$/) { + $d =~ /^(\w{4})/; + $mtm = $1; } if (!$ignore) { $href->{Node}->{$_} = $d; } } - + my $tmp_groups = "$type,all"; + if (defined($mtm)) { + my $tmp_pre = xCAT::data::ibmhwtypes::parse_group($mtm); + if (defined($tmp_pre)) { + $tmp_groups .= ",$tmp_pre"; + } + } + $href->{Node}->{groups} = $tmp_groups; $xml.= XMLout($href,NoAttr=>1,KeyAttr=>[],RootName=>undef); } return( $xml ); @@ -1872,7 +1885,7 @@ sub rscan_stanza { $objname = $data[1]; } $result .= "$objname:\n\tobjtype=node\n"; - + my $mtm = undef; foreach ( @rscan_attribs ) { my $d = $data[$i++]; @@ -1889,6 +1902,7 @@ sub rscan_stanza { } } elsif ( /^groups$/ ) { $d = "$type,all"; + $ignore = 1; } elsif ( /^mgt$/ ) { if ($origtype eq "ppcblade") { $d = "fsp"; @@ -1931,12 +1945,23 @@ sub rscan_stanza { } else { $ignore = 1; } + } elsif (/^mtm$/) { + $d =~ /^(\w{4})/; + $mtm = $1; } if (!$ignore) { $result .= "\t$_=$d\n"; } } + my $tmp_groups = "$type,all"; + if (defined ($mtm)) { + my $tmp_pre = xCAT::data::ibmhwtypes::parse_group($mtm); + if (defined ($tmp_pre)) { + $tmp_groups .= ",$tmp_pre"; + } + } + $result .= "\tgroups=$tmp_groups\n"; } return( $result ); } @@ -2246,6 +2271,13 @@ sub inv { } } } + if ($updatetable and $updatehash{mtm}) { + #updatenodegroups + my $tmp_pre = xCAT::data::ibmhwtypes::parse_group($updatehash{mtm}) ; + if (defined($tmp_pre)) { + xCAT::TableUtils->updatenodegroups($currnode, $tmp_pre); + } + } if ($updatetable and keys %updatehash) { my $vpdtab = xCAT::Table->new('vpd'); $vpdtab->setNodeAttribs($currnode,\%updatehash); @@ -4388,6 +4420,12 @@ sub process_request { unless ($node) { return 1; #failure } + if ($request->{mtm} and $request->{mtm} =~ /^(\w{4})/) { + my $group = xCAT::data::ibmhwtypes::parse_group($request->{mtm}); + if (defined($group)) { + xCAT::TableUtils->updatenodegroups($node, $group); + } + } if ($mac) { my $mactab = xCAT::Table->new('mac',-create=>1); $mactab->setNodeAttribs($macmap{$mac},{mac=>$mac}); diff --git a/xCAT-server/lib/xcat/plugins/ipmi.pm b/xCAT-server/lib/xcat/plugins/ipmi.pm index ae7104d07..e746c1d7c 100644 --- a/xCAT-server/lib/xcat/plugins/ipmi.pm +++ b/xCAT-server/lib/xcat/plugins/ipmi.pm @@ -34,6 +34,7 @@ my $iem_support; my $vpdhash; my %allerrornodes=(); my $global_sessdata; +require xCAT::data::ibmhwtypes; eval { require IBM::EnergyManager; @@ -1591,6 +1592,11 @@ sub inv { sub fru_initted { my $sessdata = shift; my $key; + my @args = @{$sessdata->{extraargs}}; + my $up_group = undef; + if (grep /-t/, @args) { + $up_group = '1'; + } my @types = @{$sessdata->{invtypes}}; my $format = "%-20s %s"; @@ -1599,11 +1605,17 @@ sub fru_initted { my $type; foreach $type (split /,/,$fru->rec_type) { if(grep {$_ eq $type} @types) { - my $bmcifo=""; - if ($sessdata->{bmcnum} != 1) { - $bmcifo=" on BMC ".$sessdata->{bmcnum}; - } - xCAT::SvrUtils::sendmsg(sprintf($format.$bmcifo,$sessdata->{fru_hash}->{$key}->desc . ":",$sessdata->{fru_hash}->{$key}->value),$callback,$sessdata->{node},%allerrornodes); + my $bmcifo=""; + if ($sessdata->{bmcnum} != 1) { + $bmcifo=" on BMC ".$sessdata->{bmcnum}; + } + xCAT::SvrUtils::sendmsg(sprintf($format.$bmcifo,$sessdata->{fru_hash}->{$key}->desc . ":",$sessdata->{fru_hash}->{$key}->value),$callback,$sessdata->{node},%allerrornodes); + if ($up_group and $type eq "model" and $fru->desc =~ /MTM/) { + my $tmp_pre = xCAT::data::ibmhwtypes::parse_group($fru->value); + if (defined($tmp_pre)) { + xCAT::TableUtils->updatenodegroups($sessdata->{node}, $tmp_pre); + } + } last; } } @@ -6124,6 +6136,14 @@ sub preprocess_request { my (@bmcnodes, @nohandle); xCAT::Utils->filter_nodes($request, undef, undef, \@bmcnodes, \@nohandle); $realnoderange = \@bmcnodes; + } elsif ($command eq "rinv") { + if ($exargs[0] eq "-t" and $#exargs == 0) { + unshift @{$request->{arg}}, 'all'; + } elsif ((grep /-t/, @exargs) and !(grep /(all|vpd)/, @exargs) ) { + $callback->({errorcode=>[1],error=>["option '-t' can only work with 'all' or 'vpd'"]}); + $request = {}; + return 0; + } } if (!$realnoderange) { diff --git a/xCAT-server/lib/xcat/plugins/lsslp.pm b/xCAT-server/lib/xcat/plugins/lsslp.pm index f5d4eac94..f2b4a6dd2 100644 --- a/xCAT-server/lib/xcat/plugins/lsslp.pm +++ b/xCAT-server/lib/xcat/plugins/lsslp.pm @@ -20,6 +20,7 @@ use xCAT::MacMap; use xCAT::IMMUtils; use xCAT_plugin::blade; use xCAT::SLP; +require xCAT::data::ibmhwtypes; my $mpahash; @@ -1418,11 +1419,18 @@ sub xCATdB { my $id = ($type =~ /bpa|frame/) ? $frameid:$cageid; my $hidden = ($type =~ /bpa|fsp/)? 1:0; + my $groups = lc($type).",all"; + my $tmp_pre = xCAT::data::ibmhwtypes::parse_group($model); + + if (defined($tmp_pre)) { + $groups .= ",$tmp_pre"; + } ######################################## # Write result to every tables, ######################################## if ( $type =~ /^bpa|fsp|cec|frame$/ ) { - $nodelisthash{$hostname} = {groups=>"$type,all", hidden=>$hidden}; + #$nodelisthash{$hostname} = {groups=>"$type,all", hidden=>$hidden}; + $nodelisthash{$hostname} = {groups=>$groups, hidden=>$hidden}; $ppchash{$hostname} = {id=>$id, parent=>$parent, hcp=>$hostname, nodetype=>$globalhwtype{$type}}; $vpdhash{$hostname} = {mtm=>$model, serial=>$serial, side=>$side}; $nodehmhash{$hostname} = {mgt=>$globalmgt{$type}}; @@ -1433,7 +1441,7 @@ sub xCATdB { my @data = ($type, $model, $serial, $side, $ip, $frameid, $cageid, $parent, $mac); xCAT::PPCdb::add_systemX( $type, $hostname, \@data ); } elsif ( $type =~ /^(hmc|ivm)$/ ) { - $nodelisthash{$hostname} = {groups=>"$type,all", hidden=>$hidden}; + $nodelisthash{$hostname} = {groups=>$groups, hidden=>$hidden}; $ppchash{$hostname} = {nodetype=>$globalhwtype{$type}}; $vpdhash{$hostname} = {mtm=>$model, serial=>$serial}; $nodetypehash{$hostname} = {nodetype=>$globalnodetype{$type}}; @@ -1441,7 +1449,7 @@ sub xCATdB { $hostshash{$hostname} = {ip=>$ip}; $machash{$hostname} = {mac=>$mac}; }elsif ($type =~ /^cmm$/){ - $nodelisthash{$hostname} = {groups=>"cmm,all", hidden=>$hidden}; + $nodelisthash{$hostname} = {groups=>$groups, hidden=>$hidden}; $vpdhash{$hostname} = {mtm=>$model, serial=>$serial}; $nodetypehash{$hostname} = {nodetype=>$globalnodetype{$type}}; $nodehmhash{$hostname} = {mgt=>"blade"}; @@ -1491,6 +1499,12 @@ sub format_stanza { $ip = $2; } my $type = ${$outhash->{$name}}{type}; + my $groups = "$type,all"; + my $tmp_pre = xCAT::data::ibmhwtypes::parse_group(${$outhash->{$name}}{mtm}); + if (defined($tmp_pre)) { + $groups .= ",$tmp_pre"; + } + ################################# # Node attributes @@ -1507,7 +1521,8 @@ sub format_stanza { if ($type =~ /^fsp|bpa|cmm$/) { $result .= "\tside=${$outhash->{$name}}{side}\n"; } - $result .= "\tgroups=$type,all\n"; + #$result .= "\tgroups=$type,all\n"; + $result .= "\tgroups=$groups\n"; $result .= "\tmgt=$globalmgt{$type}\n"; if ($type =~ /^fsp|bpa|frame|cec$/) { $result .= "\tid=${$outhash->{$name}}{$globalid{$type}}\n"; diff --git a/xCAT-server/lib/xcat/plugins/seqdiscovery.pm b/xCAT-server/lib/xcat/plugins/seqdiscovery.pm index 10afe143d..e3d2d3116 100644 --- a/xCAT-server/lib/xcat/plugins/seqdiscovery.pm +++ b/xCAT-server/lib/xcat/plugins/seqdiscovery.pm @@ -27,6 +27,7 @@ use xCAT::NetworkUtils; use xCAT::MsgUtils; use xCAT::DiscoveryUtils; use xCAT::NodeRange qw/noderange/; +require xCAT::data::ibmhwtypes; use Time::HiRes qw(gettimeofday sleep); @@ -272,7 +273,14 @@ sub findme { $nltab->setNodeAttribs($node, {groups=>"all"}); } } - + # update node groups with pre-defined groups + if (defined($param{'mtm'})){ + my @list = (); + my $tmp_group = xCAT::data::ibmhwtypes::parse_group($param{'mtm'}); + if (defined($tmp_group)) { + xCAT::TableUtils->updatenodegroups($node, $nltab, $tmp_group); + } + } # set the mgt for the node my $hmtab = xCAT::Table->new('nodehm'); unless ($hmtab) { From 4c1c27c7534a2ed2c75d7f93e87deb3307890cb7 Mon Sep 17 00:00:00 2001 From: immarvin Date: Thu, 15 Aug 2013 23:13:01 -0700 Subject: [PATCH 14/47] update the nodelist.status to installing/netbooting via feedback from node during provision --- .../share/xcat/netboot/ubuntu/genimage | 54 ++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/xCAT-server/share/xcat/netboot/ubuntu/genimage b/xCAT-server/share/xcat/netboot/ubuntu/genimage index f3b634930..965de17a2 100755 --- a/xCAT-server/share/xcat/netboot/ubuntu/genimage +++ b/xCAT-server/share/xcat/netboot/ubuntu/genimage @@ -263,7 +263,7 @@ unless ($onlyinitrd) { my %pkg_hash=imgutils::get_package_names($pkglist); my $index=1; my $pass; - foreach $pass (sort {$a <=> $b} (keys(%pkg_hash))) { + foreach $pass (sort {$a <=> $b} (keys(%pkg_hash))) { my $pkgnames = ""; foreach (keys(%{$pkg_hash{$pass}})) { if (($_ eq "PRE_REMOVE") || ($_ eq "POST_REMOVE") || ($_ eq "ENVLIST")) { next;} @@ -959,6 +959,8 @@ grep '\(debug\)' /proc/cmdline > /dev/null && export DEBUG=1 # TODO: does "anaconda.busybox sh" support "set " ? PRINIC=$prinic +NODESTATUS='y' +XCATIPORT="3002" for i in `cat /proc/cmdline`; do KEY=`echo \$i |awk -F= '{print \$1}'` @@ -971,7 +973,17 @@ for i in `cat /proc/cmdline`; do VALUE=`echo \$i |awk -F= '{print \$2}'` # format: XCAT=xcatmaster:3001 XCATSERVER=\$VALUE + elif [ "\$KEY" == 'XCATIPORT' ]; then + VALUE=`echo \$i |awk -F= '{print \$2}'` + # format: XCAT=xcatmaster:3001 + XCATIPORT=\$VALUE fi + + #if "nonodestatus" specified,do not update the nodestatus + if [ \$i == 'nonodestatus' ]; then + NODESTATUS='n' + fi + done if [ -z "\$IFACE" ]; then @@ -998,6 +1010,16 @@ while ! ifconfig | grep 'inet addr'; do done ifconfig lo 127.0.0.1 ifconfig lo up + + +XCATMASTER=`echo \$XCATSERVER|awk -F: '{print \$1}'` + + +#update nodelist.nodestatus to "netbooting" +if [ \$NODESTATUS != 'n' ]; then + /tmp/updateflag \$XCATMASTER \$XCATIPORT "installstatus netbooting" +fi + cd / for i in `cat /proc/cmdline`; do KEY=`echo \$i |awk -F= '{print \$1}'` @@ -1309,10 +1331,40 @@ exit 0 EOF close($inifile); + + #if "nonodestatus" specified,do not update the nodestatus + system("mkdir -p /tmp/xcatinitrd.$$/tmp/"); + open($inifile, ">","/tmp/xcatinitrd.$$/tmp/updateflag"); + + print $inifile < /tmp/ncarg + nc \$1 \$2 -w 60 -e /tmp/updateflag +else + retrytimes=0 + cmd="" + while [ "\$cmd" != "done" ]; do + retrytimes=`expr \$retrytimes + 1` + if [ \$retrytimes -eq 60 ]; then + break; + fi + read -t 60 cmd + if [ "\$cmd" == "ready" ]; then + head -n 1 /tmp/ncarg + rm -rf /tmp/ncarg + fi + done + +fi +EOMS + close($inifile); + chmod(0755,"/tmp/xcatinitrd.$$/usr/share/udhcpc/default.script"); chmod(0755,"/tmp/xcatinitrd.$$/init"); chmod(0755,"/tmp/xcatinitrd.$$/bin/netstart"); + chmod(0755,"/tmp/xcatinitrd.$$/tmp/updateflag"); @filestoadd=(); foreach (@ndrivers) { if (-f "$customdir/$_") { From 6a42e3c11b047899683588d5b7362ed9bda50c42 Mon Sep 17 00:00:00 2001 From: immarvin Date: Thu, 15 Aug 2013 23:47:00 -0700 Subject: [PATCH 15/47] update the nodelist.status to installing/netbooting via feedback from node during provision --- perl-xCAT/xCAT/Utils.pm | 57 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/perl-xCAT/xCAT/Utils.pm b/perl-xCAT/xCAT/Utils.pm index d37ebdb19..c3e90a275 100644 --- a/perl-xCAT/xCAT/Utils.pm +++ b/perl-xCAT/xCAT/Utils.pm @@ -3330,4 +3330,61 @@ sub filter_nodes{ return 0; } +#------------------------------------------------------------------------------- +=head3 filter_nostatusupdate() + + filter out the nodes which support provision status feedback from the status-nodes hash + Returns: + returns the filtered status-nodes hash + Globals: + none + Error: + none + Input: + the ref of status-nodes hash to filter + Example: + my $mn=xCAT::Utils->filter_nostatusupdate(\%statusnodehash); + Comments: +=cut +#------------------------------------------------------------------------------- +sub filter_nostatusupdate{ + + my ($class,$inref)=@_; + my $nttabdata; + my @allnodes=(); + #read "nodetype" table to get the "os" attribs for all the nodes with status "installing" or "netbooting" + if(exists $inref->{$::STATUS_INSTALLING}){ + push @allnodes, @{$inref->{$::STATUS_INSTALLING}}; + } + if(exists $inref->{$::STATUS_NETBOOTING}){ + push @allnodes, @{$inref->{$::STATUS_NETBOOTING}}; + } + + my $nodetypetab = xCAT::Table->new('nodetype'); + if ($nodetypetab) { + $nttabdata = $nodetypetab->getNodesAttribs(\@allnodes, ['node', 'os']); + $nodetypetab->close(); + } + + #filter out the nodes which support the node provision status feedback + my @nodesfiltered=(); + if(exists $inref->{$::STATUS_INSTALLING}){ + map{ if($nttabdata->{$_}->[0]->{os} !~ /(fedora|rh|centos|sles|ubuntu)/) {push @nodesfiltered,$_;} } @{$inref->{$::STATUS_INSTALLING}}; + delete $inref->{$::STATUS_INSTALLING}; + if(@nodesfiltered){ + @{$inref->{$::STATUS_INSTALLING}}=@nodesfiltered; + } + } + + @nodesfiltered=(); + if(exists $inref->{$::STATUS_NETBOOTING}){ + map{ if($nttabdata->{$_}->[0]->{os} !~ /(fedora|rh|centos|sles|ubuntu)/) {push @nodesfiltered,$_;} } @{$inref->{$::STATUS_NETBOOTING}}; + delete $inref->{$::STATUS_NETBOOTING}; + if(@nodesfiltered){ + @{$inref->{$::STATUS_NETBOOTING}}=@nodesfiltered; + } + } + +} + 1; From 1e6f25b3955f23c158c4823390d55d64163bf6b2 Mon Sep 17 00:00:00 2001 From: immarvin Date: Thu, 15 Aug 2013 23:48:38 -0700 Subject: [PATCH 16/47] update the nodelist.status to installing/netbooting via feedback from node during provision --- xCAT-server/lib/perl/xCAT/PPC.pm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xCAT-server/lib/perl/xCAT/PPC.pm b/xCAT-server/lib/perl/xCAT/PPC.pm index 7921ffeb0..2285601e7 100644 --- a/xCAT-server/lib/perl/xCAT/PPC.pm +++ b/xCAT-server/lib/perl/xCAT/PPC.pm @@ -269,6 +269,8 @@ sub process_command { } } } + #donot update node provision status (installing or netbooting) here + xCAT::Utils->filter_nostatusupdate(\%newnodestatus); #print "newstatus" . Dumper(\%newnodestatus); xCAT_monitoring::monitorctrl::setNodeStatusAttributes(\%newnodestatus, 1); } From c507d9a7d1034399b65a42a844d66cb9062baa0a Mon Sep 17 00:00:00 2001 From: immarvin Date: Fri, 16 Aug 2013 00:10:58 -0700 Subject: [PATCH 17/47] update the nodelist.status to installing/netbooting via feedback from node during provision --- xCAT-server/lib/xcat/plugins/kvm.pm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xCAT-server/lib/xcat/plugins/kvm.pm b/xCAT-server/lib/xcat/plugins/kvm.pm index 53d7568ef..5679815d6 100644 --- a/xCAT-server/lib/xcat/plugins/kvm.pm +++ b/xCAT-server/lib/xcat/plugins/kvm.pm @@ -2813,6 +2813,8 @@ sub process_request { } } } + #donot update node provision status (installing or netbooting) here + xCAT::Utils->filter_nostatusupdate(\%newnodestatus); #print "newstatus" . Dumper(\%newnodestatus); xCAT_monitoring::monitorctrl::setNodeStatusAttributes(\%newnodestatus, 1); } From 8eb4b81c9022abc43cbbee3dc67de96e2078891b Mon Sep 17 00:00:00 2001 From: immarvin Date: Fri, 16 Aug 2013 01:38:09 -0700 Subject: [PATCH 18/47] update node provision status based on the feedback of nodes instead of rpower/rnetboot --- xCAT-server/lib/xcat/plugins/blade.pm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/xCAT-server/lib/xcat/plugins/blade.pm b/xCAT-server/lib/xcat/plugins/blade.pm index 256ab8c99..88e7f2fc0 100644 --- a/xCAT-server/lib/xcat/plugins/blade.pm +++ b/xCAT-server/lib/xcat/plugins/blade.pm @@ -5939,6 +5939,10 @@ sub dompa { } } } + + + #donot update node provision status (installing or netbooting) here + xCAT::Utils->filter_nostatusupdate(\%newnodestatus); #print "newstatus" . Dumper(\%newnodestatus); xCAT_monitoring::monitorctrl::setNodeStatusAttributes(\%newnodestatus, 1); } From ef4a9314408af9069d941621cc860e1e911bf1ae Mon Sep 17 00:00:00 2001 From: immarvin Date: Fri, 16 Aug 2013 01:42:10 -0700 Subject: [PATCH 19/47] update node provision status based on the feedback of nodes instead of rpower/rnetboot --- xCAT-server/lib/xcat/plugins/ipmi.pm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/xCAT-server/lib/xcat/plugins/ipmi.pm b/xCAT-server/lib/xcat/plugins/ipmi.pm index e746c1d7c..62e2c741f 100644 --- a/xCAT-server/lib/xcat/plugins/ipmi.pm +++ b/xCAT-server/lib/xcat/plugins/ipmi.pm @@ -6517,6 +6517,9 @@ sub process_request { } } } + + #donot update node provision status (installing or netbooting) here + xCAT::Utils->filter_nostatusupdate(\%newnodestatus); #print "newstatus" . Dumper(\%newnodestatus); xCAT_monitoring::monitorctrl::setNodeStatusAttributes(\%newnodestatus, 1); } From 50901d0ac106dd941f19d1d36a4c8709d0eced69 Mon Sep 17 00:00:00 2001 From: immarvin Date: Fri, 16 Aug 2013 01:42:53 -0700 Subject: [PATCH 20/47] update node provision status based on the feedback of nodes instead of rpower/rnetboot --- xCAT-server/lib/xcat/plugins/ipmi.pm.legacy | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xCAT-server/lib/xcat/plugins/ipmi.pm.legacy b/xCAT-server/lib/xcat/plugins/ipmi.pm.legacy index 1313d8ee0..82b307fe5 100644 --- a/xCAT-server/lib/xcat/plugins/ipmi.pm.legacy +++ b/xCAT-server/lib/xcat/plugins/ipmi.pm.legacy @@ -6203,6 +6203,8 @@ sub process_request { } } } + #donot update node provision status (installing or netbooting) here + xCAT::Utils->filter_nostatusupdate(\%newnodestatus); #print "newstatus" . Dumper(\%newnodestatus); xCAT_monitoring::monitorctrl::setNodeStatusAttributes(\%newnodestatus, 1); } From 6769c92f7e77c45e0f4137fd8d8e10776233e406 Mon Sep 17 00:00:00 2001 From: immarvin Date: Fri, 16 Aug 2013 01:43:38 -0700 Subject: [PATCH 21/47] update node provision status based on the feedback of nodes instead of rpower/rnetboot --- xCAT-server/lib/xcat/plugins/xen.pm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xCAT-server/lib/xcat/plugins/xen.pm b/xCAT-server/lib/xcat/plugins/xen.pm index c8468d656..daf520a3a 100644 --- a/xCAT-server/lib/xcat/plugins/xen.pm +++ b/xCAT-server/lib/xcat/plugins/xen.pm @@ -871,6 +871,8 @@ sub process_request { } } } + #donot update node provision status (installing or netbooting) here + xCAT::Utils->filter_nostatusupdate(\%newnodestatus); #print "newstatus" . Dumper(\%newnodestatus); xCAT_monitoring::monitorctrl::setNodeStatusAttributes(\%newnodestatus, 1); } From 565f67b9fe6613abf7933227e1b8be56d7d92319 Mon Sep 17 00:00:00 2001 From: immarvin Date: Fri, 16 Aug 2013 02:00:23 -0700 Subject: [PATCH 22/47] update node provision status based on the feedback of nodes instead of rpower/rnetboot --- .../xcat/netboot/rh/dracut/xcat-premount.sh | 18 ++++++++++++++ .../xcat/netboot/rh/dracut/xcat-updateflag | 24 +++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 xCAT-server/share/xcat/netboot/rh/dracut/xcat-premount.sh create mode 100755 xCAT-server/share/xcat/netboot/rh/dracut/xcat-updateflag diff --git a/xCAT-server/share/xcat/netboot/rh/dracut/xcat-premount.sh b/xCAT-server/share/xcat/netboot/rh/dracut/xcat-premount.sh new file mode 100644 index 000000000..40c1dbbe5 --- /dev/null +++ b/xCAT-server/share/xcat/netboot/rh/dracut/xcat-premount.sh @@ -0,0 +1,18 @@ +#!/bin/sh +#script to update nodelist.nodestatus during provision + +MASTER=`echo $XCAT |awk -F: '{print $1}'` + +getarg nonodestatus +NODESTATUS=$? + +XCATIPORT="$(getarg XCATIPORT=)" +if [ $? -ne 0 ]; then +XCATIPORT="3002" +fi + + + +if [ $NODESTATUS -ne 0 ];then +/tmp/updateflag $MASTER $XCATIPORT "installstatus netbooting" +fi diff --git a/xCAT-server/share/xcat/netboot/rh/dracut/xcat-updateflag b/xCAT-server/share/xcat/netboot/rh/dracut/xcat-updateflag new file mode 100755 index 000000000..2f9ac3165 --- /dev/null +++ b/xCAT-server/share/xcat/netboot/rh/dracut/xcat-updateflag @@ -0,0 +1,24 @@ +#!/bin/awk -f +#script to feedback the node provision status to xcatd +BEGIN { + + xcatdhost = ARGV[1] + xcatiport = ARGV[2] + + + ns = "/inet/tcp/0/" xcatdhost "/" xcatiport + print "xCAT_xcatd" |& ns + + while(1) { + ns |& getline + + if($0 == "ready") + print ARGV[3] |& ns + if($0 == "done") + break + } + + close(ns) + + exit 0 +} From fd0accd00c66cb35e98f59ec00cf4d4b95cf8341 Mon Sep 17 00:00:00 2001 From: immarvin Date: Fri, 16 Aug 2013 02:05:31 -0700 Subject: [PATCH 23/47] update node provision status based on the feedback of nodes instead of rpower/rnetboot --- xCAT-server/share/xcat/netboot/fedora/dracut/xcat-premount.sh | 1 + xCAT-server/share/xcat/netboot/fedora/dracut/xcat-updateflag | 1 + 2 files changed, 2 insertions(+) create mode 120000 xCAT-server/share/xcat/netboot/fedora/dracut/xcat-premount.sh create mode 120000 xCAT-server/share/xcat/netboot/fedora/dracut/xcat-updateflag diff --git a/xCAT-server/share/xcat/netboot/fedora/dracut/xcat-premount.sh b/xCAT-server/share/xcat/netboot/fedora/dracut/xcat-premount.sh new file mode 120000 index 000000000..862e21b2e --- /dev/null +++ b/xCAT-server/share/xcat/netboot/fedora/dracut/xcat-premount.sh @@ -0,0 +1 @@ +../../rh/dracut/xcat-premount.sh \ No newline at end of file diff --git a/xCAT-server/share/xcat/netboot/fedora/dracut/xcat-updateflag b/xCAT-server/share/xcat/netboot/fedora/dracut/xcat-updateflag new file mode 120000 index 000000000..ba998cfb2 --- /dev/null +++ b/xCAT-server/share/xcat/netboot/fedora/dracut/xcat-updateflag @@ -0,0 +1 @@ +../../rh/dracut/xcat-updateflag \ No newline at end of file From 6b546dbf85e0806d53f8ed0e914c84b157848417 Mon Sep 17 00:00:00 2001 From: immarvin Date: Fri, 16 Aug 2013 02:17:16 -0700 Subject: [PATCH 24/47] update node provision status based on the feedback of nodes instead of rpower/rnetboot --- .../fedora/dracut_009/xcat-premount.sh | 1 + .../fedora/dracut_009/xcat-prepivot.sh | 2 + .../netboot/fedora/dracut_009/xcat-updateflag | 1 + .../xcat/netboot/fedora/dracut_009/xcatroot | 38 +++++++++++++++++-- 4 files changed, 39 insertions(+), 3 deletions(-) create mode 120000 xCAT-server/share/xcat/netboot/fedora/dracut_009/xcat-premount.sh create mode 120000 xCAT-server/share/xcat/netboot/fedora/dracut_009/xcat-updateflag diff --git a/xCAT-server/share/xcat/netboot/fedora/dracut_009/xcat-premount.sh b/xCAT-server/share/xcat/netboot/fedora/dracut_009/xcat-premount.sh new file mode 120000 index 000000000..862e21b2e --- /dev/null +++ b/xCAT-server/share/xcat/netboot/fedora/dracut_009/xcat-premount.sh @@ -0,0 +1 @@ +../../rh/dracut/xcat-premount.sh \ No newline at end of file diff --git a/xCAT-server/share/xcat/netboot/fedora/dracut_009/xcat-prepivot.sh b/xCAT-server/share/xcat/netboot/fedora/dracut_009/xcat-prepivot.sh index f6571b82f..f82729557 100755 --- a/xCAT-server/share/xcat/netboot/fedora/dracut_009/xcat-prepivot.sh +++ b/xCAT-server/share/xcat/netboot/fedora/dracut_009/xcat-prepivot.sh @@ -68,6 +68,8 @@ if [ ! -z $SNAPSHOTSERVER ]; then 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 diff --git a/xCAT-server/share/xcat/netboot/fedora/dracut_009/xcat-updateflag b/xCAT-server/share/xcat/netboot/fedora/dracut_009/xcat-updateflag new file mode 120000 index 000000000..ba998cfb2 --- /dev/null +++ b/xCAT-server/share/xcat/netboot/fedora/dracut_009/xcat-updateflag @@ -0,0 +1 @@ +../../rh/dracut/xcat-updateflag \ No newline at end of file diff --git a/xCAT-server/share/xcat/netboot/fedora/dracut_009/xcatroot b/xCAT-server/share/xcat/netboot/fedora/dracut_009/xcatroot index ad17dc2f6..dbed8bfbd 100755 --- a/xCAT-server/share/xcat/netboot/fedora/dracut_009/xcatroot +++ b/xCAT-server/share/xcat/netboot/fedora/dracut_009/xcatroot @@ -3,6 +3,24 @@ NEWROOT=$3 RWDIR=.statelite XCATMASTER=$XCAT +. /lib/dracut-lib.sh +rootlimit="$(getarg rootlimit=)" + + +getarg nonodestatus +NODESTATUS=$? + +MASTER=`echo $XCATMASTER |awk -F: '{print $1}'` +XCATIPORT="$(getarg XCATIPORT=)" +if [ $? -ne 0 ]; then +XCATIPORT="3002" +fi + + +if [ $NODESTATUS -ne 0 ];then +/tmp/updateflag $MASTER $XCATIPORT "installstatus netbooting" +fi + if [ ! -z "$imgurl" ]; then if [ xhttp = x${imgurl%%:*} ]; then NFS=0 @@ -41,7 +59,12 @@ if [ -r /rootimg.sfs ]; then mount --move /rw $NEWROOT/rw elif [ -r /rootimg.gz ]; then echo Setting up RAM-root tmpfs. - mount -t tmpfs rootfs $NEWROOT + 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 @@ -49,10 +72,17 @@ elif [ -r /rootimg.gz ]; then else gzip -cd /rootimg.gz |cpio -idum fi + $NEWROOT/etc/init.d/localdisk echo Done elif [ -r /rootimg-statelite.gz ]; then echo Setting up RAM-root tmpfs for statelite mode. - mount -t tmpfs rootfs $NEWROOT + + 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 @@ -99,7 +129,8 @@ elif [ -r /rootimg-statelite.gz ]; then MAXTRIES=5 ITER=0 if [ -z $MNTOPTS ]; then - MNT_OPTIONS="nolock,rsize=32768,tcp,timeo=14" + MNT_OPTIONS="nolock,rsize=32768,tcp,timeo=14" + else MNT_OPTIONS=$MNTOPTS fi @@ -119,6 +150,7 @@ elif [ -r /rootimg-statelite.gz ]; then done fi + $NEWROOT/etc/init.d/localdisk $NEWROOT/etc/init.d/statelite fastboot=yes export fastboot From bae1fbbdf4b11cf4e41efcbb2db17647c8c0293c Mon Sep 17 00:00:00 2001 From: Bruce Potter Date: Sat, 17 Aug 2013 10:52:52 -0400 Subject: [PATCH 25/47] add --nonodecheck to the psh usage and man page --- xCAT-client/bin/psh | 2 +- xCAT-client/pods/man1/psh.1.pod | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/xCAT-client/bin/psh b/xCAT-client/bin/psh index 057ca7929..c25951266 100755 --- a/xCAT-client/bin/psh +++ b/xCAT-client/bin/psh @@ -32,7 +32,7 @@ if (!GetOptions( "nonodecheck" => \$::NONODECHECK, #does not check the noderange, in this case, noderange need to be a list of nodes. 'h|help' => \$help, ) || $help || scalar(@ARGV)<2 ) { - print "Usage: psh [-i ] [-l ] [-f ] \n"; + print "Usage: psh [-i ] [-l ] [-f ] [--nonodecheck] \n"; exit; } my %nodehdl; diff --git a/xCAT-client/pods/man1/psh.1.pod b/xCAT-client/pods/man1/psh.1.pod index 100f34e7c..a2a48c313 100644 --- a/xCAT-client/pods/man1/psh.1.pod +++ b/xCAT-client/pods/man1/psh.1.pod @@ -43,6 +43,12 @@ rently executing remote shell processes. Log into the nodes as the specified username. The default is to use the same username as you are running the psh command as. +=item B<-n|--nonodecheck> + +Do not send the noderange to xcatd to expand it into a list of nodes. Instead, use the noderange exactly as it is specified. +In this case, the noderange must be a simple list of comma-separated hostnames of the nodes. +This allows you to run B even when xcatd is not running. + =item B See L. From 6cac1a800198467d243e48837da5561a92304fc2 Mon Sep 17 00:00:00 2001 From: lissav Date: Mon, 19 Aug 2013 13:29:51 -0400 Subject: [PATCH 26/47] fix pid files did not get removed and the kill term showing up --- xCAT/postscripts/xcatflowrequest | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/xCAT/postscripts/xcatflowrequest b/xCAT/postscripts/xcatflowrequest index 79112ca68..ab1253ead 100644 --- a/xCAT/postscripts/xcatflowrequest +++ b/xCAT/postscripts/xcatflowrequest @@ -24,8 +24,7 @@ while ! grep 'resourcerequest: ok' /tmp/goahead.$parpid > /dev/null; do done sleeper=$(cat /tmp/sleeperpid.$parpid) sleeper=$(ps -ef|awk "\$3==$sleeper"|awk '{print $2}') -kill -TERM $sleeper rm /tmp/goahead.$parpid rm /tmp/sleeperpid.$parpid rm /tmp/killme.$parpid - +kill -TERM $sleeper From 19d72e6f84aa5a6d26f205587d1f56c4a4b10115 Mon Sep 17 00:00:00 2001 From: xq2005 Date: Mon, 19 Aug 2013 23:47:34 -0700 Subject: [PATCH 27/47] add debianpreconf into xcatlib.sh on master --- xCAT/postscripts/xcatlib.sh | 74 ++++++++++++++++++++++++++++++++----- 1 file changed, 65 insertions(+), 9 deletions(-) diff --git a/xCAT/postscripts/xcatlib.sh b/xCAT/postscripts/xcatlib.sh index e5b5da8fd..17a5adf6f 100644 --- a/xCAT/postscripts/xcatlib.sh +++ b/xCAT/postscripts/xcatlib.sh @@ -1,17 +1,73 @@ function hashencode(){ - local map="$1" - echo `echo $map | sed 's/\./xDOTx/g' | sed 's/:/xCOLONx/g' | sed 's/,/:xCOMMAx/g'` + local str_map="$1" + echo `echo $str_map | sed 's/\./xDOTx/g' | sed 's/:/xCOLONx/g' | sed 's/,/:xCOMMAx/g'` } function hashset(){ - local hashname="hash${1}${2}" - local value=$3 - hashname=$(hashencode $hashname) - eval "${hashname}='${value}'" + local str_hashname="hash${1}${2}" + local str_value=$3 + str_hashname=$(hashencode $str_hashname) + eval "${str_hashname}='${str_value}'" } function hashget(){ - local hashname="hash${1}${2}" - hashname=$(hashencode $hashname) - eval echo "\$${hashname}" + local str_hashname="hash${1}${2}" + str_hashname=$(hashencode $str_hashname) + eval echo "\$${str_hashname}" } + +function debianpreconf(){ + #create the config sub dir + if [ ! -d "/etc/network/interfaces.d" ];then + mkdir -p "/etc/network/interfaces.d" + fi + #search xcat flag + `grep "#XCAT_CONFIG" /etc/network/interfaces` + if [ $? -eq 0 ];then + return + fi + + #back up the old interface configure + if [ ! -e "/etc/network/interfaces.bak" ];then + mv /etc/network/interfaces /etc/network/interfaces.bak + fi + + #create the new config file + echo "#XCAT_CONFIG" > /etc/network/interfaces + echo "source /etc/network/interfaces.d/*" >> /etc/network/interfaces + + local str_conf_file='' + + #read the backfile + cat /etc/network/interfaces.bak | while read str_line + do + if [ ! "$str_line" ];then + continue + fi + local str_first_char=${str_line:0:1} + if [ $str_first_char = '#' ];then + continue + fi + + local str_conf_type=`echo $str_line | cut -d" " -f1` + if [ $str_conf_type = 'auto' -o $str_conf_type = 'allow-hotplug' ];then + str_line=${str_line#$str_conf_type} + for str_nic_name in $str_line; do + echo "$str_conf_type $str_nic_name" > "/etc/network/interfaces.d/$str_nic_name" + done + elif [ $str_conf_type = 'iface' -o $str_conf_type = 'mapping' ];then + #find out the nic name, should think about the eth0:1 + str_nic_name=`echo $str_line | cut -d" " -f 2 | cut -d":" -f 1` + str_conf_file="/etc/network/interfaces.d/$str_nic_name" + if [ ! -e $str_conf_file ];then + echo "auto $str_nic_name" > $str_conf_file + fi + + #write lines into the conffile + echo $str_line >> $str_conf_file + else + echo $str_line >> $str_conf_file + fi + done +} + From 3188ab14cc796e85a494e6c6bf8747e9ce7ef1bb Mon Sep 17 00:00:00 2001 From: xq2005 Date: Tue, 20 Aug 2013 02:09:46 -0700 Subject: [PATCH 28/47] postscripts modifiction about sysclone supporting for sles on master --- xCAT/postscripts/killsyslog | 11 +++++++++++ xCAT/postscripts/runxcatpost | 10 +++++++++- xCAT/postscripts/updatenetwork | 26 ++++++++++++++++++++++---- 3 files changed, 42 insertions(+), 5 deletions(-) create mode 100755 xCAT/postscripts/killsyslog diff --git a/xCAT/postscripts/killsyslog b/xCAT/postscripts/killsyslog new file mode 100755 index 000000000..47aa106b5 --- /dev/null +++ b/xCAT/postscripts/killsyslog @@ -0,0 +1,11 @@ +#!/bin/bash + +#only used in sysclone when the image os is sles + +if [ -f "/etc/SuSE-release" ];then + str_out=`ps -ef | grep -v grep | grep syslog-ng` + if [ $? -eq 0 ];then + str_id=`echo $str_out | awk '{print $2}'` + kill -9 $str_id + fi +fi diff --git a/xCAT/postscripts/runxcatpost b/xCAT/postscripts/runxcatpost index 0dbf33f5e..9d4647342 100644 --- a/xCAT/postscripts/runxcatpost +++ b/xCAT/postscripts/runxcatpost @@ -1 +1,9 @@ -/opt/xcat/xcatdsklspost \ No newline at end of file +#!/bin/bash +/opt/xcat/xcatdsklspost + +. /tmp/post-install/variables.txt + +if [ -x "/xcatpost/updateflag.awk" ];then + /xcatpost/updateflag.awk $IMAGESERVER 3002 +fi + diff --git a/xCAT/postscripts/updatenetwork b/xCAT/postscripts/updatenetwork index d40cfdbd2..4e7e9355d 100644 --- a/xCAT/postscripts/updatenetwork +++ b/xCAT/postscripts/updatenetwork @@ -1,17 +1,35 @@ #!/bin/bash . /tmp/post-install/variables.txt +#delete the udev rule in the image +rule_file=`ls /etc/udev/rules.d/*net_persistent_names.rules` +if [ -n "$rule_file" ];then + rm -f $rule_file +fi + echo "Updating hostname to $HOSTNAME" sed -i "s/HOSTNAME=.*/HOSTNAME=$HOSTNAME/g" /etc/sysconfig/network hostname $HOSTNAME +str_cfg_file='' +if [ -d "/etc/sysconfig/network-scripts/" ];then + #redhat + str_cfg_file="/etc/sysconfig/network-scripts/ifcfg-$DEVICE" +elif [ -d "/etc/sysconfig/network/" ];then + #suse + str_cfg_file="/etc/sysconfig/network/ifcfg-$DEVICE" +else + #ubuntu + str_cfg_file="/etc/network/interfaces.d/$DEVICE" +fi + echo "Old ifcfg-$DEVICE is:" -cat /etc/sysconfig/network-scripts/ifcfg-$DEVICE +cat $str_cfg_file HWADDR=`ifconfig $DEVICE|grep HWaddr|awk '{print $5}'` -sed -i "s/HWADDR=.*/HWADDR="$HWADDR"/g" /etc/sysconfig/network-scripts/ifcfg-$DEVICE -sed -i "s/UUID=.*//g" /etc/sysconfig/network-scripts/ifcfg-$DEVICE +sed -i "s/HWADDR=.*/HWADDR="$HWADDR"/g" $str_cfg_file +sed -i "s/UUID=.*//g" $str_cfg_file echo "New ifcfg-$DEVICE is:" -cat /etc/sysconfig/network-scripts/ifcfg-$DEVICE +cat $str_cfg_file From 8e48b6a40f3d588f4f1b786e8f126b701e75cbd0 Mon Sep 17 00:00:00 2001 From: lissav Date: Tue, 20 Aug 2013 10:24:06 -0400 Subject: [PATCH 29/47] fix defect 3750 --- perl-xCAT/xCAT/ServiceNodeUtils.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/perl-xCAT/xCAT/ServiceNodeUtils.pm b/perl-xCAT/xCAT/ServiceNodeUtils.pm index 242ccbf08..5bcf6508b 100644 --- a/perl-xCAT/xCAT/ServiceNodeUtils.pm +++ b/perl-xCAT/xCAT/ServiceNodeUtils.pm @@ -355,7 +355,7 @@ sub getSNList $servicenodetab->close; foreach my $node (@nodes) { - if ($service eq "") # want all the service nodes + if (! defined ($service) || ($service eq "")) # want all the service nodes { push @servicenodes, $node->{node}; } From 6439ab60eed75926d9ce9e64e5c7dcfe413305a0 Mon Sep 17 00:00:00 2001 From: wanghuaz Date: Tue, 20 Aug 2013 23:10:41 +0800 Subject: [PATCH 30/47] fixing bug 94319: handle the case of some postscript contains parameters --- xCAT-server/lib/xcat/plugins/kit.pm | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/kit.pm b/xCAT-server/lib/xcat/plugins/kit.pm index f16b15676..8bacb467e 100644 --- a/xCAT-server/lib/xcat/plugins/kit.pm +++ b/xCAT-server/lib/xcat/plugins/kit.pm @@ -2427,7 +2427,6 @@ sub rmkitcomp my %rsp; push@{ $rsp{data} }, "kitcomponent $kitcompdep basename does not exist"; xCAT::MsgUtils->message( "E", \%rsp, $callback ); - return 1; } my $kitcompdepname = get_highest_version('kitcompname', 'version', 'release', @entries); @@ -2486,7 +2485,7 @@ sub rmkitcomp foreach my $kitcomponent (keys %kitcomps) { my @kitcompscripts = split( ',', $kitcomps{$kitcomponent}{postbootscripts} ); foreach my $kitcompscript ( @kitcompscripts ) { - if ( $osimagescript =~ /^$kitcompscript$/ ) { + if ( $osimagescript =~ /^$kitcompscript/ ) { $match = 1; last; } From 21e8a18c9e1b107afde39c74a3fb52d1b3b48ff7 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 20 Aug 2013 15:34:16 -0400 Subject: [PATCH 31/47] Fix problem where values after parenthitcal group were not evaluated correctly --- perl-xCAT/xCAT/NodeRange.pm | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/perl-xCAT/xCAT/NodeRange.pm b/perl-xCAT/xCAT/NodeRange.pm index 66df2c45c..3c01fb005 100644 --- a/perl-xCAT/xCAT/NodeRange.pm +++ b/perl-xCAT/xCAT/NodeRange.pm @@ -611,19 +611,7 @@ sub noderange { %nodes = map { $_ => 1 } noderange($start,$verify,$exsitenode,%options); my %innernodes = map { $_ => 1 } noderange($middle,$verify,$exsitenode,%options); set_arith(\%nodes,$op,\%innernodes); - $op=","; - if ($end =~ m/^,-/) { - $op = ",-"; - $end =~ s/^,-//; - } elsif ($end =~ m/^@/) { - $op = "@"; - $end =~ s/^@//; - } else { - $end =~ s/^,//; - } - my %endnodes = map { $_ => 1 } noderange($end,$verify,$exsitenode,%options); - set_arith(\%nodes,$op,\%endnodes); - return sort(keys %nodes) + $range = $end; } my $op = ","; @@ -632,7 +620,8 @@ sub noderange { @elems = split(/(@(?![^\(]*?\)))/,$range); # only split on @ when no , are present (inner recursion) } - while (my $atom = shift @elems) { + while (defined(my $atom = shift @elems)) { + if ($atom eq '') { next; } if ($atom eq ',') { next; } From 7ac9dae5af948c7799a5c9c3740caa0c8be758b2 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 20 Aug 2013 15:59:42 -0400 Subject: [PATCH 32/47] Attempt to fix bmcsetup problem where service processor changes after request to change too late --- xCAT-genesis-scripts/bin/bmcsetup | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/xCAT-genesis-scripts/bin/bmcsetup b/xCAT-genesis-scripts/bin/bmcsetup index 2cca4e2e9..758bb299d 100755 --- a/xCAT-genesis-scripts/bin/bmcsetup +++ b/xCAT-genesis-scripts/bin/bmcsetup @@ -54,6 +54,11 @@ if [ "$IPMIMFG" == 2 ]; then #IBM for p in $BMCPORT; do ipmitool -d $idev raw 0xc 1 1 0xc0 $p > /dev/null ipmitool -d $idev raw 0x04 0x12 0x09 0x01 0x18 0x${p}1 0x00 > /dev/null + CURBMCPORT=`ipmitool -d $idev raw 0xc 2 1 0xc0 0 0 | awk '{print $2}'` + while [ "$CURBMCPORT" -ne "$BMCPORT" ]; do + sleep 1 + CURBMCPORT=`ipmitool -d $idev raw 0xc 2 1 0xc0 0 0 | awk '{print $2}'` + done let idev=idev+1 done fi @@ -67,7 +72,12 @@ if [ "$IPMIMFG" == 2 ]; then #IBM let idev=0 for p in $BMCPORT; do ipmitool -d $idev raw 0xc 1 1 0xc0 $p > /dev/null - let idev=idev+1 + CURBMCPORT=`ipmitool -d $idev raw 0xc 2 1 0xc0 0 0 | awk '{print $2}'` + while [ "$CURBMCPORT" -ne "$BMCPORT" ]; do + sleep 1 + CURBMCPORT=`ipmitool -d $idev raw 0xc 2 1 0xc0 0 0 | awk '{print $2}'` + done + let idev=idev+1 done fi fi @@ -84,8 +94,17 @@ elif [ "$IPMIMFG" == 20301 ] ; then let idev=0 for p in $BMCPORT; do ipmitool -d $idev raw 0xc 1 1 0xc0 $p > /dev/null - NEWPORT=`ipmitool -d $idev raw 0xc 2 1 0xc0 0 0|awk '{print $2}'` - sleep 10 + # after this change, we need to watch and wait to see that it + # actually takes effect. On port change, the service processor + # does not migrate the network configuration over + # so we might be halfway through setting up when the net config + # reverts to dhcp then static, which setting a static ip for is + # considered invalid + CURBMCPORT=`ipmitool -d $idev raw 0xc 2 1 0xc0 0 0 | awk '{print $2}'` + while [ "$CURBMCPORT" -ne "$BMCPORT" ]; do + sleep 1 + CURBMCPORT=`ipmitool -d $idev raw 0xc 2 1 0xc0 0 0 | awk '{print $2}'` + done let idev=idev+1 done From 2275e87b6ff04927d1a28bdc8b1db0b0b9cc58f7 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 20 Aug 2013 16:31:53 -0400 Subject: [PATCH 33/47] Try to suppress scary warning at time of checking for bmc port activity --- xCAT-genesis-scripts/bin/bmcsetup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-genesis-scripts/bin/bmcsetup b/xCAT-genesis-scripts/bin/bmcsetup index 758bb299d..a3336706a 100755 --- a/xCAT-genesis-scripts/bin/bmcsetup +++ b/xCAT-genesis-scripts/bin/bmcsetup @@ -101,7 +101,7 @@ elif [ "$IPMIMFG" == 20301 ] ; then # reverts to dhcp then static, which setting a static ip for is # considered invalid CURBMCPORT=`ipmitool -d $idev raw 0xc 2 1 0xc0 0 0 | awk '{print $2}'` - while [ "$CURBMCPORT" -ne "$BMCPORT" ]; do + while [ -z "$CURBMCPORT" -o 0"$CURBMCPORT" -ne "$BMCPORT" ]; do sleep 1 CURBMCPORT=`ipmitool -d $idev raw 0xc 2 1 0xc0 0 0 | awk '{print $2}'` done From 65a2d3511233ce53d465cf471cd54dd8e5329fa5 Mon Sep 17 00:00:00 2001 From: xq2005 Date: Wed, 21 Aug 2013 03:05:59 -0700 Subject: [PATCH 34/47] modification for builing xcat on ubuntu --- build-ubunturepo | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/build-ubunturepo b/build-ubunturepo index d133d2af3..ff9a42d60 100755 --- a/build-ubunturepo +++ b/build-ubunturepo @@ -43,6 +43,10 @@ printusage() # Process cmd line variable assignments, assigning each attr=val pair to a variable of same name for i in $*; do + echo $i | grep '=' + if [ $? != 0 ];then + continue + fi # upper case the variable name varstring=`echo "$i"|cut -d '=' -f 1|tr '[a-z]' '[A-Z]'`=`echo "$i"|cut -d '=' -f 2` export $varstring @@ -167,6 +171,7 @@ then short_ver=`cat Version|cut -d. -f 1,2` short_short_ver=`cat Version|cut -d. -f 1` + package_dir_name=debs$short_short_ver #TODO: define the core path and tarball name tarball_name="core-debs-snap.tar.bz2" @@ -186,8 +191,8 @@ then cur_date=`date +%Y%m%d` pkg_version="${short_ver}-${pkg_type}${cur_date}" - if [ ! -d ../../debs ];then - mkdir -p "../../debs" + if [ ! -d ../../$package_dir_name ];then + mkdir -p "../../$package_dir_name" fi packages="xCAT-client xCAT-genesis-scripts perl-xCAT xCAT-server xCAT-UI xCAT xCATsn xCAT-test xCAT-OpenStack" @@ -195,9 +200,9 @@ then do file_low=`echo $file | tr '[A-Z]' '[a-z]'` if grep -q $file $update_log || [ "$BUILDALL" == 1 -o "$file" = "perl-xCAT" ]; then - rm -f ../../debs/${file_low}_*.deb + rm -f ../../$package_dir_name/${file_low}_*.deb #only for genesis package - rm -f ../../debs/${file_low}-amd64_*.deb + rm -f ../../$package_dir_name/${file_low}-amd64_*.deb cd $file dch -v $pkg_version -b -c debian/changelog $build_string dpkg-buildpackage -uc -us @@ -208,11 +213,11 @@ then cd - find $file -maxdepth 3 -type d -name "${file_low}*" | grep debian | xargs rm -rf find $file -maxdepth 3 -type f -name "files" | grep debian | xargs rm -rf - mv ${file_low}* ../../debs/ + mv ${file_low}* ../../$package_dir_name/ fi done - find ../../debs/* ! -name *.deb | xargs rm -f + find ../../$package_dir_name/* ! -name *.deb | xargs rm -f fi if [ "$PROMOTE" = 1 ]; then @@ -256,7 +261,7 @@ __EOF__ #import the deb packages into the repo for dist in $dists; do - for file in `ls ../debs/*.deb`; do + for file in `ls ../$package_dir_name/*.deb`; do reprepro -b ./ includedeb $dist $file; done done From 66700054a3b5af1c370350355e608dc9783bdd03 Mon Sep 17 00:00:00 2001 From: xq2005 Date: Wed, 21 Aug 2013 07:35:23 -0700 Subject: [PATCH 35/47] add kvm pkglist and template for ubuntu --- .../share/xcat/install/ubuntu/kvm.pkglist | 10 ++ .../share/xcat/install/ubuntu/kvm.tmpl | 114 ++++++++++++++++++ 2 files changed, 124 insertions(+) create mode 100644 xCAT-server/share/xcat/install/ubuntu/kvm.pkglist create mode 100644 xCAT-server/share/xcat/install/ubuntu/kvm.tmpl diff --git a/xCAT-server/share/xcat/install/ubuntu/kvm.pkglist b/xCAT-server/share/xcat/install/ubuntu/kvm.pkglist new file mode 100644 index 000000000..edad393e0 --- /dev/null +++ b/xCAT-server/share/xcat/install/ubuntu/kvm.pkglist @@ -0,0 +1,10 @@ +openssh-server +ntp +gawk +nfs-common +snmpd +qemu-kvm +libvirt-bin +bridge-utils +libcap2-bin +vlan diff --git a/xCAT-server/share/xcat/install/ubuntu/kvm.tmpl b/xCAT-server/share/xcat/install/ubuntu/kvm.tmpl new file mode 100644 index 000000000..76136115f --- /dev/null +++ b/xCAT-server/share/xcat/install/ubuntu/kvm.tmpl @@ -0,0 +1,114 @@ + +### Localization +d-i debian-installer/locale string en_US +d-i localechooser/supported-locales multiselect en_US.UTF-8 + +# Keyboard Selection +d-i console-setup/ask_detect boolean false +d-i console-setup/layoutcode string en + +### Network Configuration + +d-i netcfg/get_hostname string unassigned-hostname +d-i netcfg/get_domain string unassigned-domain +d-i netcfg/wireless_wep string + +### Mirror settings +# If you select ftp, the mirror/country string does not need to be set. + +d-i mirror/country string manual +d-i mirror/protocol string http +d-i mirror/http/directory string /install/#TABLE:nodetype:$NODE:os#/#TABLE:nodetype:$NODE:arch# +d-i mirror/http/proxy string + +# Suite to install. +#d-i mirror/suite string testing +# Suite to use for loading installer components (optional). +#d-i mirror/udeb/suite string testing + + +### Partitioning +# This creates a small /boot partition, suitable +# swap, and uses the rest of the space for the root partition: + +d-i partman-auto/method string regular +d-i partman-lvm/device_remove_lvm boolean true +d-i partman-md/device_remove_md boolean true + +#create the /tmp/partitioning based on the uefi or legacy bios +d-i partman-auto/expert_recipe_file string /tmp/partitioning + +# This makes partman automatically partition without confirmation, provided +# that you told it what to do using one of the methods above. + +d-i partman/confirm_write_new_label boolean true +d-i partman/choose_partition select finish +d-i partman/confirm boolean true +d-i partman/confirm_nooverwrite boolean true + + +### Account setup + +d-i passwd/root-login boolean true +d-i passwd/make-user boolean false + +d-i passwd/root-password-crypted password #CRYPT:passwd:key=system,username=root:password# + +### Clock and time zone setup + +d-i clock-setup/ntp boolean true +d-i clock-setup/ntp-server string #TABLE:site:key=master:value# +d-i clock-setup/utc boolean true +d-i time/zone string #TABLE:site:key=timezone:value# + +### Apt setup + +d-i apt-setup/multiverse boolean false +d-i apt-setup/universe boolean false +d-i apt-setup/backports boolean false +d-i apt-setup/updates boolean false + + +### Boot loader installation + +d-i grub-installer/only_debian boolean true + +### Package selection + +tasksel tasksel/first multiselect standard + +# gawk required for the xCAT scripts to work +# Otherwise it installs mawk, which doesn't work + +d-i pkgsel/include string #INCLUDE_DEFAULT_PKGLIST_PRESEED# + +d-i debian-installer/allow_unauthenticated string true +d-i pkgsel/update-policy select none +d-i pkgsel/updatedb boolean false + +### Finishing up the installation +d-i finish-install/reboot_in_progress note + +### X configuration +xserver-xorg xserver-xorg/autodetect_monitor boolean true + +xserver-xorg xserver-xorg/config/monitor/selection-method \ + select medium + +xserver-xorg xserver-xorg/config/monitor/mode-list \ + select 1024x768 @ 60 Hz + + +d-i preseed/early_command string wget http://`cat /tmp/xcatserver`/install/autoinst/#HOSTNAME#.pre; \ + chmod u+x #HOSTNAME#.pre; \ + ./#HOSTNAME#.pre + +d-i preseed/late_command string wget http://`cat /tmp/xcatserver`/install/autoinst/#HOSTNAME#.post; \ + chmod u+x #HOSTNAME#.post; \ + cp ./#HOSTNAME#.post /target/root/post.script; \ + mount -o bind /proc /target/proc -t proc; \ + mount -o bind /dev /target/dev; \ + mount -o bind /dev/pts /target/dev/pts -t devpts; \ + mount -o bind /sys /target/sys; \ + chroot /target /root/post.script + From 5aee2ceea814577f26cbb92ac0fe006dfeceedb6 Mon Sep 17 00:00:00 2001 From: xq2005 Date: Wed, 21 Aug 2013 09:07:48 -0700 Subject: [PATCH 36/47] add reiserfs into genesis to support sysclone for sels --- xCAT-genesis-builder/install | 2 +- xCAT-genesis-builder/installkernel | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/xCAT-genesis-builder/install b/xCAT-genesis-builder/install index a756ae655..0491c148b 100755 --- a/xCAT-genesis-builder/install +++ b/xCAT-genesis-builder/install @@ -623,4 +623,4 @@ dracut_install /lib64/rsyslog/lmnet.so dracut_install /lib64/rsyslog/lmstrmsrv.so dracut_install /lib64/rsyslog/imuxsock.so dracut_install /usr/lib64/libnfsidmap/nsswitch.so -dracut_install killall logger nc nslookup bc chown chroot dd expr kill mkdosfs parted rsync shutdown sort ssh-keygen tr blockdev findfs insmod kexec lvm mdadm mke2fs pivot_root sshd swapon tune2fs # for sysclone +dracut_install killall logger nc nslookup bc chown chroot dd expr kill mkdosfs parted rsync shutdown sort ssh-keygen tr blockdev findfs insmod kexec klogd lvm mdadm mke2fs pivot_root sshd swapon tune2fs mkreiserfs reiserfstune # for sysclone diff --git a/xCAT-genesis-builder/installkernel b/xCAT-genesis-builder/installkernel index 9e52ac794..4217d9988 100755 --- a/xCAT-genesis-builder/installkernel +++ b/xCAT-genesis-builder/installkernel @@ -4,3 +4,4 @@ instmods e1000 e1000e virtio_net igb ines sfc mlx4_en cxgb3 cxgb4 tg3 bnx2 bnx2x instmods macvlan macvtap 8021q bridge bonding vmxnet3 cpufreq_ondemand acpi-cpufreq powernow-k8 cdc_ether instmods mptctl #LSI firmware management requires this instmods mlx4_ib ib_umad #make the mellanox ib available enough to examine /sys +instmods reiserfs #reiserfs on sysclone From 0565563156d05266a54ce855e130405574f4a2ed Mon Sep 17 00:00:00 2001 From: xcat ubuntu build machine Date: Wed, 21 Aug 2013 16:31:02 +0000 Subject: [PATCH 37/47] build packages on ubuntu --- build-ubunturepo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-ubunturepo b/build-ubunturepo index ff9a42d60..2829edeb2 100755 --- a/build-ubunturepo +++ b/build-ubunturepo @@ -171,7 +171,7 @@ then short_ver=`cat Version|cut -d. -f 1,2` short_short_ver=`cat Version|cut -d. -f 1` - package_dir_name=debs$short_short_ver + package_dir_name=debs$REL #TODO: define the core path and tarball name tarball_name="core-debs-snap.tar.bz2" From 5d7072da135a9096c38ed18a4ace30ee253ecd82 Mon Sep 17 00:00:00 2001 From: lissav Date: Wed, 21 Aug 2013 12:55:39 -0400 Subject: [PATCH 38/47] defect 3754 --- perl-xCAT/xCAT/SINV.pm | 46 +++++++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/perl-xCAT/xCAT/SINV.pm b/perl-xCAT/xCAT/SINV.pm index 2b01f5cb3..2df6d6420 100644 --- a/perl-xCAT/xCAT/SINV.pm +++ b/perl-xCAT/xCAT/SINV.pm @@ -202,9 +202,11 @@ sub parse_and_run_sinv # my @nodelist = (); my @cmdparts = (); + my $devicecommand =0; if ($options{'devicetype'}) { # must split different because devices have commands with spaces @cmdparts = split(' ', $cmd,3); + $devicecommand =1; } else { @cmdparts = split(' ', $cmd); } @@ -503,7 +505,7 @@ sub parse_and_run_sinv ); # write the results to the tempfile after running through xdshcoll - $rc = &storeresults($callback); + $rc = &storeresults($callback,$devicecommand); } $processflg = "node"; @@ -534,7 +536,7 @@ sub parse_and_run_sinv # write the results to the tempfile after running through xdshcoll - $rc = &storeresults($callback); + $rc = &storeresults($callback,$devicecommand); # Build report and write to output file # if file exist and has something in it @@ -1451,12 +1453,11 @@ sub rinvoutput sub storeresults { my $callback = shift; - + my $devicecommand= shift; # open file to write results of xdsh or rinv command my $newtempfile = $tempfile; $newtempfile .= "temp"; - open(FILE, ">$newtempfile"); - if ($? > 0) + unless (open(NEWTMPFILE, ">$newtempfile")) { my $rsp = {}; $rsp->{data}->[0] = "Could not open $newtempfile\n"; @@ -1465,9 +1466,9 @@ sub storeresults } foreach my $line (@cmdresult) { - print FILE $line; + print NEWTMPFILE $line; } - close FILE; + close NEWTMPFILE; my $outputfile; if ($processflg eq "seednode") { # cmd to seednode @@ -1479,8 +1480,7 @@ sub storeresults } # open file to put results of xdshcoll - open(FILE, ">$outputfile"); - if ($? > 0) + unless (open(NEWOUTFILE, ">$outputfile")) { my $rsp = {}; $rsp->{data}->[0] = "Could not open $outputfile\n"; @@ -1489,8 +1489,7 @@ sub storeresults } my $cmd = " $::XCATROOT/sbin/xdshcoll <$newtempfile |"; - open(XCOLL, "$cmd"); - if ($? > 0) + unless (open(XCOLL, "$cmd")) { my $rsp = {}; $rsp->{data}->[0] = "Could not call xdshcoll \n"; @@ -1503,18 +1502,37 @@ sub storeresults while () { $line = $_; - print FILE $line + print NEWOUTFILE $line } close(XCOLL); - close FILE; + close NEWOUTFILE; system("/bin/rm $newtempfile"); + # is device command, we get false errors from the Switch, check for + # blank error output lines and remove them. If there is nothing left + # then there really were no errors + my @newerrresult=(); + my $processerrors =1; + if ($devicecommand==1) { + foreach my $line (@errresult) + { + my @newline = (split(/:/, $line)); + if ($newline[1] !~ /^\s*$/) { # Not blank, then save it + push @newerrresult,$line; + } + + } + my $arraysize=@newerrresult; + if ($arraysize < 1) { + $processerrors =0; + } + } # capture errors # - if (@errresult) + if ((@errresult) && ($processerrors ==1)) { # if errors my $rsp = {}; my $i = 0; From 6df017b6201264543b90093af26d3f575e8c6786 Mon Sep 17 00:00:00 2001 From: xq2005 Date: Wed, 21 Aug 2013 19:50:17 -0700 Subject: [PATCH 39/47] remove klogd from genesis base --- xCAT-genesis-builder/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-genesis-builder/install b/xCAT-genesis-builder/install index 0491c148b..1ee268a35 100755 --- a/xCAT-genesis-builder/install +++ b/xCAT-genesis-builder/install @@ -623,4 +623,4 @@ dracut_install /lib64/rsyslog/lmnet.so dracut_install /lib64/rsyslog/lmstrmsrv.so dracut_install /lib64/rsyslog/imuxsock.so dracut_install /usr/lib64/libnfsidmap/nsswitch.so -dracut_install killall logger nc nslookup bc chown chroot dd expr kill mkdosfs parted rsync shutdown sort ssh-keygen tr blockdev findfs insmod kexec klogd lvm mdadm mke2fs pivot_root sshd swapon tune2fs mkreiserfs reiserfstune # for sysclone +dracut_install killall logger nc nslookup bc chown chroot dd expr kill mkdosfs parted rsync shutdown sort ssh-keygen tr blockdev findfs insmod kexec lvm mdadm mke2fs pivot_root sshd swapon tune2fs mkreiserfs reiserfstune # for sysclone From 969f5355362f2eb40c02b0568d528bd17b89b3de Mon Sep 17 00:00:00 2001 From: daniceexi Date: Thu, 22 Aug 2013 06:34:15 -0400 Subject: [PATCH 40/47] Remove the validity checking base machine type so that any power machines can be run with renergy command --- xCAT-client/pods/man1/renergy.1.pod | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/xCAT-client/pods/man1/renergy.1.pod b/xCAT-client/pods/man1/renergy.1.pod index 36019e0bc..f12187487 100644 --- a/xCAT-client/pods/man1/renergy.1.pod +++ b/xCAT-client/pods/man1/renergy.1.pod @@ -192,7 +192,7 @@ cappingperc =back -B<9125-F2C> +B<9125-F2C>, B<9119-FHB> =over 4 @@ -208,6 +208,22 @@ cappingperc,fsavingstatus,ffovalue =back +B + +=over 4 + +For the machine type which is not in the above list, the following +attributes can be tried but not guaranteed: + +B: savingstatus,dsavingstatus,cappingstatus,cappingmin, +cappingmax,,cappingvalue,cappingsoftmin,averageAC,averageDC, +ambienttemp,exhausttemp,CPUspeed,syssbpower,sysIPLtime + +B: savingstatus,dsavingstatus,cappingstatus,cappingwatt, +cappingperc + +=back + =back Note: From 10a1973aae887b20ad3790991d99839f01cc70d0 Mon Sep 17 00:00:00 2001 From: daniceexi Date: Thu, 22 Aug 2013 07:05:41 -0400 Subject: [PATCH 41/47] make geninitrd could run against statelite image to generate initrd --- xCAT-server/lib/xcat/plugins/geninitrd.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/geninitrd.pm b/xCAT-server/lib/xcat/plugins/geninitrd.pm index 9a9fe45f1..18782cb99 100644 --- a/xCAT-server/lib/xcat/plugins/geninitrd.pm +++ b/xCAT-server/lib/xcat/plugins/geninitrd.pm @@ -116,7 +116,7 @@ sub geninitrd { $netdrivers = $lient->{'netdrivers'}; # if the provmethod equals 'netboot', call the genimage --onlyinitrd directly - if ($oient->{'provmethod'} && $oient->{'provmethod'} eq "netboot") { + if ($oient->{'provmethod'} && ($oient->{'provmethod'} eq "netboot" || $oient->{'provmethod'} eq "statelite")) { if ($lient->{'rootimgdir'}) { unless (-d $lient->{'rootimgdir'}."/rootimg/lib/modules") { xCAT::MsgUtils->message("E", {error=>["The genimage should be run before running geninitrd."], errorcode=>["1"]}, $callback); @@ -132,7 +132,7 @@ sub geninitrd { # arg => [$osimage, '--onlyinitrd'] }, $callback); return; } elsif (!$oient->{'provmethod'} || $oient->{'provmethod'} ne "install") { - xCAT::MsgUtils->message("E", {error=>["The attribute [provmethod] for osimage [$osimage] must be set to install or netboot."], errorcode=>["1"]}, $callback); + xCAT::MsgUtils->message("E", {error=>["The attribute [provmethod] for osimage [$osimage] must be set to install, netboot or statelite."], errorcode=>["1"]}, $callback); return; } From 84b36c29ab2127f52eac9bae06d447ce613165e7 Mon Sep 17 00:00:00 2001 From: lissav Date: Thu, 22 Aug 2013 12:03:14 -0400 Subject: [PATCH 42/47] fix schema definition --- perl-xCAT/xCAT/Schema.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/perl-xCAT/xCAT/Schema.pm b/perl-xCAT/xCAT/Schema.pm index 8a2ac5965..2434bbd55 100644 --- a/perl-xCAT/xCAT/Schema.pm +++ b/perl-xCAT/xCAT/Schema.pm @@ -3231,7 +3231,7 @@ push(@{$defspec{group}->{'attrs'}}, @nodeattrs); access_tabentry => 'firmware.file=attr:cfgfile', }, {attr_name => 'disable', - tabentry => 'auditlog.disable', + tabentry => 'firmware.disable', access_tabentry => 'firmware.file=attr:cfgfile', }, ); From 82e6644c85afba8039e29b981a012dc8d9a56143 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Thu, 22 Aug 2013 14:35:21 -0400 Subject: [PATCH 43/47] Correct more issues with noderange --- perl-xCAT/xCAT/NodeRange.pm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/perl-xCAT/xCAT/NodeRange.pm b/perl-xCAT/xCAT/NodeRange.pm index 3c01fb005..1a34b912b 100644 --- a/perl-xCAT/xCAT/NodeRange.pm +++ b/perl-xCAT/xCAT/NodeRange.pm @@ -602,12 +602,12 @@ sub noderange { my $op = ","; if ($start =~ m/-$/) { #subtract the parenthetical $op .= "-" - } elsif ($start =~ m/@$/) { + } elsif ($start =~ m/\@$/) { $op = "@" } $start =~ s/,-$//; $start =~ s/,$//; - $start =~ s/@$//; + $start =~ s/\@$//; %nodes = map { $_ => 1 } noderange($start,$verify,$exsitenode,%options); my %innernodes = map { $_ => 1 } noderange($middle,$verify,$exsitenode,%options); set_arith(\%nodes,$op,\%innernodes); @@ -628,7 +628,11 @@ sub noderange { if ($atom =~ /^-/) { # if this is an exclusion, strip off the minus, but remember it $atom = substr($atom,1); $op = $op."-"; + } elsif ($atom =~ /^\@/) { # if this is an exclusion, strip off the minus, but remember it + $atom = substr($atom,1); + $op = "@"; } + if ($atom eq '') { next; } if ($atom =~ /^\^(.*)$/) { # get a list of nodes from a file open(NRF,$1); From 56ed1f53d029797be8c48a91519dedf38dd5b6eb Mon Sep 17 00:00:00 2001 From: xq2005 Date: Thu, 22 Aug 2013 22:58:53 -0700 Subject: [PATCH 44/47] postscripts modification for sysclone on sles --- xCAT/postscripts/configefi | 47 ++++++++++++++++++++++++++++++++-- xCAT/postscripts/killsyslog | 4 --- xCAT/postscripts/updatenetwork | 6 ++--- 3 files changed, 48 insertions(+), 9 deletions(-) diff --git a/xCAT/postscripts/configefi b/xCAT/postscripts/configefi index 6067248ce..4db78507c 100644 --- a/xCAT/postscripts/configefi +++ b/xCAT/postscripts/configefi @@ -1,2 +1,45 @@ -echo "Setting Boot Manager for the next boot." -efibootmgr -c -l \\EFI\\redhat\\grub.efi -L Linux +if [ -d /sys/firmware/efi ]; then + echo "Setting Boot Manager for the next boot." + efibootmgr -c -l \\EFI\\redhat\\grub.efi -L Linux +else + echo "run grub-install to configure the MBR." + if [ -e /etc/mtab ];then + mv /etc/mtab /etc/mtab.bak + fi + grep -v rootfs /proc/mounts > /etc/mtab + boot_device='' + if [ -f "/etc/systemconfig/systemconfig.conf" ];then + boot_device=`cat /etc/systemconfig/systemconfig.conf | grep BOOTDEV | awk '{print $3}'` + else + str_temp=`mount | awk '{print $1","$3}'` + for line in $str_temp + do + mp=`echo $line | awk -F, '{print $2}'` + if [ "$mp" = "/" ];then + boot_device=`echo $line | awk -F, '{print $1}' | sed -e 's/[0-9]*$//'` + break + fi + done + fi + + if [ -n "$boot_device" ];then + echo "the boot device is $boot_device" + else + echo "Can not find the boot device, return error" + exit 1 + fi + + #for sles10, should run grub-install with parameters + echo "grub-install --no-floppy --recheck $boot_device" + grub-install --no-floppy --recheck $boot_device + if [ $? -ne 0 ];then + #sles11, run grub install directly + grub-install + fi + + if [ -e /etc/mtab.bak ];then + mv -f /etc/mtab.bak /etc/mtab + else + rm -f /etc/mtab + fi +fi diff --git a/xCAT/postscripts/killsyslog b/xCAT/postscripts/killsyslog index 47aa106b5..ba2395caa 100755 --- a/xCAT/postscripts/killsyslog +++ b/xCAT/postscripts/killsyslog @@ -1,7 +1,3 @@ -#!/bin/bash - -#only used in sysclone when the image os is sles - if [ -f "/etc/SuSE-release" ];then str_out=`ps -ef | grep -v grep | grep syslog-ng` if [ $? -eq 0 ];then diff --git a/xCAT/postscripts/updatenetwork b/xCAT/postscripts/updatenetwork index 4e7e9355d..fc82ab64d 100644 --- a/xCAT/postscripts/updatenetwork +++ b/xCAT/postscripts/updatenetwork @@ -7,21 +7,21 @@ if [ -n "$rule_file" ];then rm -f $rule_file fi -echo "Updating hostname to $HOSTNAME" -sed -i "s/HOSTNAME=.*/HOSTNAME=$HOSTNAME/g" /etc/sysconfig/network - hostname $HOSTNAME str_cfg_file='' if [ -d "/etc/sysconfig/network-scripts/" ];then #redhat str_cfg_file="/etc/sysconfig/network-scripts/ifcfg-$DEVICE" + sed -i "s/HOSTNAME=.*/HOSTNAME=$HOSTNAME/g" /etc/sysconfig/network elif [ -d "/etc/sysconfig/network/" ];then #suse str_cfg_file="/etc/sysconfig/network/ifcfg-$DEVICE" + echo "$HOSTNAME" > /etc/HOSTNAME else #ubuntu str_cfg_file="/etc/network/interfaces.d/$DEVICE" + echo "$HOSTNAME" > /etc/hostname fi echo "Old ifcfg-$DEVICE is:" From e87d5fa0743fc806f6fa7bb481637891d8697c74 Mon Sep 17 00:00:00 2001 From: xq2005 Date: Thu, 22 Aug 2013 23:32:02 -0700 Subject: [PATCH 45/47] add mksysclone in sles.pm --- xCAT-server/lib/xcat/plugins/sles.pm | 251 ++++++++++++++++++++++++++- 1 file changed, 250 insertions(+), 1 deletion(-) diff --git a/xCAT-server/lib/xcat/plugins/sles.pm b/xCAT-server/lib/xcat/plugins/sles.pm index 72677014a..7c76da347 100644 --- a/xCAT-server/lib/xcat/plugins/sles.pm +++ b/xCAT-server/lib/xcat/plugins/sles.pm @@ -37,7 +37,8 @@ sub handled_commands copycd => "sles", mknetboot => "nodetype:os=(sles.*)|(suse.*)", mkinstall => "nodetype:os=(sles.*)|(suse.*)", - mkstatelite => "nodetype:os=(sles.*)" + mkstatelite => "nodetype:os=(sles.*)", + mksysclone => "nodetype:os=(sles.*)|(suse.*)" }; } @@ -690,6 +691,10 @@ sub process_request { return mknetboot($request, $callback, $doreq); } + elsif ($request->{command}->[0] eq 'mksysclone') + { + return mksysclone($request, $callback, $doreq); + } } sub mkinstall @@ -1204,6 +1209,250 @@ sub mkinstall #} } +sub mksysclone +{ + my $request = shift; + my $callback = shift; + my $doreq = shift; + my @nodes = @{$request->{node}}; + my $osimagetab; + my %img_hash=(); + + my $installroot; + my $globaltftpdir; + $installroot = "/install"; + $globaltftpdir = "/tftpboot"; + + my @ents = xCAT::TableUtils->get_site_attribute("installdir"); + my $site_ent = $ents[0]; + if( defined($site_ent) ) + { + $installroot = $site_ent; + } + @ents = xCAT::TableUtils->get_site_attribute("tftpdir"); + $site_ent = $ents[0]; + if( defined($site_ent) ) + { + $globaltftpdir = $site_ent; + } + + my $node; + my $ostab = xCAT::Table->new('nodetype'); + my $restab = xCAT::Table->new('noderes'); + my $bptab = xCAT::Table->new('bootparams',-create=>1); + my $hmtab = xCAT::Table->new('nodehm'); + my %osents = %{$ostab->getNodesAttribs(\@nodes, ['os', 'arch', 'provmethod'])}; + my %rents = + %{$restab->getNodesAttribs(\@nodes, + ['xcatmaster', 'nfsserver', 'tftpdir', 'primarynic', 'installnic'])}; + my %hents = + %{$hmtab->getNodesAttribs(\@nodes, + ['serialport', 'serialspeed', 'serialflow'])}; + my $xcatdport="3001"; + my @entries = xCAT::TableUtils->get_site_attribute("xcatdport"); + if ( defined($entries[0])) { + $xcatdport = $entries[0]; + } + + my @entries = xCAT::TableUtils->get_site_attribute("master"); + my $master_entry = $entries[0]; + + require xCAT::Template; + + my $flag_return = 0; + # Warning message for nodeset install/netboot/statelite + foreach my $knode (keys %osents) + { + my $ent = $osents{$knode}->[0]; + if ($ent && $ent->{provmethod} && ($ent->{provmethod} eq 'sysclone')){ + $callback->( { error => ["$knode: The provmethod \"sysclone\" have been deprecated. use \"nodeset osimage=\" instead."], + errorcode => [1]}); + # Do not print this warning message multiple times + $flag_return = 1; + } + } + + if ( $flag_return == 1 ){ + return; + } + + # copy postscripts + my $pspath = "$installroot/sysclone/scripts/post-install/"; + my $clusterfile = "$installroot/sysclone/scripts/cluster.txt"; + + mkpath("$pspath"); + copy("$installroot/postscripts/configefi","$pspath/15all.configefi"); + copy("$installroot/postscripts/updatenetwork","$pspath/16all.updatenetwork"); + copy("$installroot/postscripts/runxcatpost","$pspath/17all.runxcatpost"); + copy("$installroot/postscripts/killsyslog","$pspath/17all.killsyslog"); + + unless (-r "$pspath/10all.fix_swap_uuids") + { + mkpath("$pspath"); + copy("/var/lib/systemimager/scripts/post-install/10all.fix_swap_uuids","$pspath"); + } + + unless (-r "$pspath/95all.monitord_rebooted") + { + mkpath("$pspath"); + copy("/var/lib/systemimager/scripts/post-install/95all.monitord_rebooted","$pspath"); + } + + # copy hosts + copy("/etc/hosts","$installroot/sysclone/scripts/"); + + foreach $node (@nodes) + { + my $os; + my $tftpdir; + my $arch; + my $imagename; # set it if running of 'nodeset osimage=xxx' + my $xcatmaster; + my $instserver; + + my $ient = $rents{$node}->[0]; + if ($ient and $ient->{xcatmaster}) + { + $xcatmaster = $ient->{xcatmaster}; + } else { + $xcatmaster = $master_entry; + } + + my $osinst; + if ($rents{$node}->[0] and $rents{$node}->[0]->{tftpdir}) { + $tftpdir = $rents{$node}->[0]->{tftpdir}; + } else { + $tftpdir = $globaltftpdir; + } + my $ent = $osents{$node}->[0]; + if ($ent and $ent->{provmethod} and ($ent->{provmethod} ne 'install') and ($ent->{provmethod} ne 'netboot') and ($ent->{provmethod} ne 'statelite') and ($ent->{provmethod} ne 'sysclone')) { + $imagename=$ent->{provmethod}; + #print "imagename=$imagename\n"; + if (!exists($img_hash{$imagename})) { + if (!$osimagetab) { + $osimagetab=xCAT::Table->new('osimage', -create=>1); + } + (my $ref) = $osimagetab->getAttribs({imagename => $imagename}, 'osvers', 'osarch', 'profile', 'provmethod'); + if ($ref) { + $img_hash{$imagename}->{osarch}=$ref->{'osarch'}; + } else { + $callback->( + {error => ["The os image $imagename does not exists on the osimage table for $node"], + errorcode => [1]}); + next; + } + } + my $ph=$img_hash{$imagename}; + $arch = $ph->{osarch}; + } + + # copy kernel and initrd from image dir to /tftpboot + my $ramdisk_size = 200000; + + if ( + -r "$tftpdir/xcat/genesis.kernel.$arch" + and -r "$tftpdir/xcat/genesis.fs.$arch.gz" + ) + { + #We have a shot... + my $ent = $rents{$node}->[0]; + my $sent = $hents{$node}->[0]; + + my $kcmdline = "ramdisk_size=$ramdisk_size"; + my $ksdev = ""; + if ($ent->{installnic}) + { + $ksdev = $ent->{installnic}; + } + elsif ($ent->{primarynic}) + { + $ksdev = $ent->{primarynic}; + } + else + { + $ksdev = "bootif"; #if not specified, fall back to bootif + } + + if ($ksdev eq "mac") + { + my $mactab = xCAT::Table->new("mac"); + my $macref = $mactab->getNodeAttribs($node, ['mac']); + $ksdev = $macref->{mac}; + } + + unless ( $ksdev eq "bootif" ) { + $kcmdline .= " netdevice=" . $ksdev; + } + + if ($arch =~ /ppc/) { + $kcmdline .= " dhcptimeout=150"; + } + + if (defined($sent->{serialport})) + { + unless ($sent->{serialspeed}) + { + $callback->( { error => [ "serialport defined, but no serialspeed for $node in nodehm table" ], + errorcode => [1] } ); + } + else { + #go cmdline if serial console is requested, the shiny ansi is just impractical + $kcmdline .= " cmdline console=tty0 console=ttyS" + . $sent->{serialport} . "," + . $sent->{serialspeed}; + if ($sent->{serialflow} =~ /(hard|cts|ctsrts)/) { + $kcmdline .= "n8r"; + } + } + } + $kcmdline .= " xcatd=$xcatmaster:$xcatdport SCRIPTNAME=$imagename"; + + $bptab->setNodeAttribs( + $node, + { + kernel => "xcat/genesis.kernel.$arch", + initrd => "xcat/genesis.fs.$arch.gz", + kcmdline => $kcmdline + } + ); + } + else + { + $callback->( { error => ["Kernel and initrd not found in $tftpdir/xcat"], + errorcode => [1] } ); + } + + # assign nodes to an image + if (-r "$clusterfile") + { + my $cmd = qq{cat $clusterfile | grep "$node"}; + my $out = xCAT::Utils->runcmd($cmd, -1); + if ($::RUNCMD_RC == 0) + { + my $out = `sed -i /$node./d $clusterfile`; + } + } + + my $cmd =qq{echo "$node:compute:$imagename:" >> $clusterfile}; + my $out = xCAT::Utils->runcmd($cmd, -1); + + unless (-r "$installroot/sysclone/images/$imagename/opt/xcat/xcatdsklspost") + { + mkpath("$installroot/sysclone/images/$imagename/opt/xcat/"); + copy("$installroot/postscripts/xcatdsklspost","$installroot/sysclone/images/$imagename/opt/xcat/"); + } + } + + # check systemimager-server-rsyncd to make sure it's running. + my $out = xCAT::Utils->runcmd("service systemimager-server-rsyncd status", -1); + if ($::RUNCMD_RC != 0) { # not running + my $rc = xCAT::Utils->startService("systemimager-server-rsyncd"); + if ($rc != 0) { + return 1; + } + } +} + sub copycd { my $request = shift; From afc950912db8ff36f283a341b21af3c19d26521f Mon Sep 17 00:00:00 2001 From: daniceexi Date: Fri, 23 Aug 2013 06:42:36 -0400 Subject: [PATCH 46/47] kill the child processes when create socket failed --- xCAT-server/share/xcat/tools/detect_dhcpd | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/xCAT-server/share/xcat/tools/detect_dhcpd b/xCAT-server/share/xcat/tools/detect_dhcpd index 10956e144..d696a66eb 100755 --- a/xCAT-server/share/xcat/tools/detect_dhcpd +++ b/xCAT-server/share/xcat/tools/detect_dhcpd @@ -88,7 +88,13 @@ my $sock = IO::Socket::INET->new(Proto => 'udp', #LocalAddr => 0, LocalAddr => $IP, LocalPort => '68', - PeerAddr => inet_ntoa(INADDR_BROADCAST)) or die "Create socket error: $@\n"; + PeerAddr => inet_ntoa(INADDR_BROADCAST)); + +unless ($sock) { + print "Create socket error: $@\n"; + kill_child(); + exit 1; +} my $timeout = 10; if ($::TIMEOUT) { @@ -104,6 +110,8 @@ while ($end - $start <= $timeout) { $end =~ s/(\d.*)\.(\d.*)/$1/; } + +kill_child(); #kill the child process kill 15, $pid; my @pidoftcpdump = `ps -ef | grep -E "[0-9]+:[0-9]+:[0-9]+ tcpdump -i $IF" | awk -F' ' '{print \$2}'`; @@ -297,4 +305,11 @@ sub packdhcppkg{ return $package; } - +sub kill_child { + kill 15, $pid; + my @pidoftcpdump = `ps -ef | grep -E "[0-9]+:[0-9]+:[0-9]+ tcpdump -i $IF" | awk -F' ' '{print \$2}'`; + foreach my $cpid (@pidoftcpdump) { + kill 15, $cpid; + #print "try to kill $cpid\n"; + } +} From a8c36721b0ff5951b84b7de5aaa31dfa54abcc89 Mon Sep 17 00:00:00 2001 From: lissav Date: Sat, 24 Aug 2013 06:32:33 -0400 Subject: [PATCH 47/47] add additonal ethernet setup --- xCAT-client/pods/man1/xdsh.1.pod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-client/pods/man1/xdsh.1.pod b/xCAT-client/pods/man1/xdsh.1.pod index a98eb07ab..e5ba3c110 100644 --- a/xCAT-client/pods/man1/xdsh.1.pod +++ b/xCAT-client/pods/man1/xdsh.1.pod @@ -565,7 +565,7 @@ To define a BNT Ethernet switch as a node and run a command to create a new vlan B I -B I +B I where I and I are the SSH user name and password for the switch. If it is for Telnet, add I in front of the user name: I. I