From 5c946182b52897d5c38403461a1403c1bec0867a Mon Sep 17 00:00:00 2001 From: Jia Zhao Date: Wed, 18 Jun 2014 13:33:07 +0800 Subject: [PATCH 01/26] fix noderegenips generate conflict ips --- xCAT-server/lib/xcat/plugins/profilednodes.pm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/profilednodes.pm b/xCAT-server/lib/xcat/plugins/profilednodes.pm index 9f25a3b7a..218fd45c9 100644 --- a/xCAT-server/lib/xcat/plugins/profilednodes.pm +++ b/xCAT-server/lib/xcat/plugins/profilednodes.pm @@ -761,7 +761,7 @@ Usage: } # make sure there are something changed, otherwise we should quit without any changes. unless ($changeflag){ - setrsp_errormsg("No profile changes detect."); + setrsp_infostr("Warning: no profile changes detect."); return; } @@ -931,11 +931,15 @@ Usage: #6. Generate new free IPs for each network. my @allknownips = keys %allips; + my %netFreeIPsHash = (); foreach my $updnic (@updateNics){ #No need generate for removed nics. unless (grep {$_ eq $updnic} @removedNics){ my $netname = $netProfileNicsRef->{$netProfileName}->{$updnic}->{"network"}; - $freeIPsHash{$updnic} = xCAT::ProfiledNodeUtils->get_allocable_staticips_innet($netname, \@allknownips); + if ( not exists $netFreeIPsHash{$netname} ){ + $netFreeIPsHash{$netname} = xCAT::ProfiledNodeUtils->get_allocable_staticips_innet($netname, \@allknownips); + } + $freeIPsHash{$updnic} = $netFreeIPsHash{$netname}; } } From 147b7b2cedaa6a7256d37c5fa5e266dde112fddd Mon Sep 17 00:00:00 2001 From: immarvin Date: Wed, 18 Jun 2014 00:43:21 -0700 Subject: [PATCH 02/26] correct a typo --- xCAT/postscripts/enablekdump | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT/postscripts/enablekdump b/xCAT/postscripts/enablekdump index f713c69cf..40ceca219 100755 --- a/xCAT/postscripts/enablekdump +++ b/xCAT/postscripts/enablekdump @@ -32,7 +32,7 @@ for i in `/bin/cat /proc/cmdline`; do elif [ "$KEY" = "BOOTIF" ]; then MACX=`/bin/echo $i | /bin/awk -F= '{print $2}'|sed -e s/^01-// -e s/-/:/g` #ETHX=`/sbin/ifconfig | /bin/grep -i $MACX | /bin/awk '{print $1}'` - ETHX=`/sbin/ip -oneline link show ens33|/bin/grep -i $MACX |/bin/awk -F ":" '{print $2}'|/bin/grep -o "[^ ]\+\( \+[^ ]\+\)*"` + ETHX=`/sbin/ip -oneline link show |/bin/grep -i $MACX |/bin/awk -F ":" '{print $2}'|/bin/grep -o "[^ ]\+\( \+[^ ]\+\)*"` break fi done From d378feca9267def834e45bd2353a858111bab849 Mon Sep 17 00:00:00 2001 From: immarvin Date: Thu, 19 Jun 2014 00:34:18 -0700 Subject: [PATCH 03/26] add *.tmpl and *.pkglist files for rhel7 service node --- .../share/xcat/install/rh/service.rhel7.tmpl | 154 ++++++++++++++++++ .../install/rh/service.rhels7.ppc64.pkglist | 35 ++++ .../install/rh/service.rhels7.x86_64.pkglist | 26 +++ 3 files changed, 215 insertions(+) create mode 100644 xCAT-server/share/xcat/install/rh/service.rhel7.tmpl create mode 100644 xCAT-server/share/xcat/install/rh/service.rhels7.ppc64.pkglist create mode 100644 xCAT-server/share/xcat/install/rh/service.rhels7.x86_64.pkglist diff --git a/xCAT-server/share/xcat/install/rh/service.rhel7.tmpl b/xCAT-server/share/xcat/install/rh/service.rhel7.tmpl new file mode 100644 index 000000000..b32f1f01d --- /dev/null +++ b/xCAT-server/share/xcat/install/rh/service.rhel7.tmpl @@ -0,0 +1,154 @@ +# +#cmdline + +lang en_US +#KICKSTARTNET# + +# +# Where's the source? +# nfs --server hostname.of.server or IP --dir /path/to/RH/CD/image +# +#nfs --server #XCATVAR:INSTALL_NFS# --dir #XCATVAR:INSTALL_SRC_DIR# + +%include /tmp/repos + +#device ethernet e100 +keyboard "us" + +# +# Clear the MBR +# +zerombr + +# +# Wipe out the disk +# +clearpart --all --initlabel +#clearpart --linux +#key --skip + +# +# Customize to fit your needs +# + +#XCAT_PARTITION_START# +#No RAID +#/boot really significant for this sort of setup nowadays? +#part /boot --size 50 --fstype ext3 +%include /tmp/partitioning +#part swap --size 1024 +#part / --size 1 --grow --fstype ext4 +#XCAT_PARTITION_END# + +#RAID 0 /scr for performance +#part / --size 1024 --ondisk sda +#part swap --size 512 --ondisk sda +#part /var --size 1024 --ondisk sdb +#part swap --size 512 --ondisk sdb +#part raid.01 --size 1 --grow --ondisk sda +#part raid.02 --size 1 --grow --ondisk sdb +#raid /scr --level 0 --device md0 raid.01 raid.02 + +#Full RAID 1 Sample +#part raid.01 --size 50 --ondisk sda +#part raid.02 --size 50 --ondisk sdb +#raid /boot --level 1 --device md0 raid.01 raid.02 +# +#part raid.11 --size 1024 --ondisk sda +#part raid.12 --size 1024 --ondisk sdb +#raid / --level 1 --device md1 raid.11 raid.12 +# +#part raid.21 --size 1024 --ondisk sda +#part raid.22 --size 1024 --ondisk sdb +#raid /var --level 1 --device md2 raid.21 raid.22 +# +#part raid.31 --size 1024 --ondisk sda +#part raid.32 --size 1024 --ondisk sdb +#raid swap --level 1 --device md3 raid.31 raid.32 +# +#part raid.41 --size 1 --grow --ondisk sda +#part raid.42 --size 1 --grow --ondisk sdb +#raid /scr --level 1 --device md4 raid.41 raid.42 + +# +# bootloader config +# --append +# --useLilo +# --md5pass +# +bootloader + +# +# install or upgrade +# +install + +# +# text mode install (default is graphical) +# +text + +# +# firewall +# +firewall --disabled + +# +# Select a zone +# Add the --utc switch if your hardware clock is set to GMT +# +#timezone US/Hawaii +#timezone US/Pacific +#timezone US/Mountain +#timezone US/Central +#timezone US/Eastern +timezone --utc "#TABLE:site:key=timezone:value#" + +# +# Don't do X +# +skipx + + +# +# To generate an encrypted root password use: +# +# perl -e 'print crypt("blah","Xa") . "\n";'p +# openssl passwd -apr1 -salt xxxxxxxx password +# +# where "blah" is your root password. +# +#rootpw --iscrypted XaLGAVe1C41x2 +#rootpw XaLGAVe1C41x2 --iscrypted +rootpw --iscrypted #CRYPT:passwd:key=system,username=root:password# + +# +# NIS setup: auth --enablenis --nisdomain sensenet +# --nisserver neptune --useshadow --enablemd5 +# +# OR +auth --useshadow --enablemd5 + + +# +# SE Linux +# +selinux --disabled + +# +# Reboot after installation +# +reboot + +# +#end of section +# +%packages +#INCLUDE_DEFAULT_PKGLIST# +%end +%pre +#INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/pre.rh.rhel7# +%end +%post +#INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/post.xcat# +%end diff --git a/xCAT-server/share/xcat/install/rh/service.rhels7.ppc64.pkglist b/xCAT-server/share/xcat/install/rh/service.rhels7.ppc64.pkglist new file mode 100644 index 000000000..050985ba7 --- /dev/null +++ b/xCAT-server/share/xcat/install/rh/service.rhels7.ppc64.pkglist @@ -0,0 +1,35 @@ +#Please make sure there is a space between @ and group name +@ Network Infrastructure Server +@ System administration tools +@ System Management +@ X Window System +@ Development Tools +autofs +ksh +tcsh +ntp +tftp +xinetd +rsh +rsh-server +psacct +nfs-utils +net-snmp +rsync +yp-tools +ypserv +ypbind +m4 +sendmail-cf +gdb +binutils +openssh-server +openssl098e.ppc +openssl098e.ppc64 +util-linux +perl-DBD-MySQL +perl-Socket6 +unixODBC +perl-DBD-MySQL +mysql-connector-odbc +perl-DBD-Pg diff --git a/xCAT-server/share/xcat/install/rh/service.rhels7.x86_64.pkglist b/xCAT-server/share/xcat/install/rh/service.rhels7.x86_64.pkglist new file mode 100644 index 000000000..2e9da4d82 --- /dev/null +++ b/xCAT-server/share/xcat/install/rh/service.rhels7.x86_64.pkglist @@ -0,0 +1,26 @@ +#Please make sure there is a space between @ and group name +autofs +ksh +tcsh +ntp +tftp +xinetd +rsh +rsh-server +psacct +nfs-utils +net-snmp +rsync +yp-tools +ypserv +ypbind +m4 +sendmail-cf +gdb +binutils +openssh-server +util-linux +unixODBC +perl-DBD-MySQL +mysql-connector-odbc +perl-DBD-Pg From 481b70c330775156d163fe380940a3dcef138831 Mon Sep 17 00:00:00 2001 From: huweihua Date: Thu, 19 Jun 2014 03:50:46 -0400 Subject: [PATCH 04/26] add feature: update delta change from golden client to target node --- xCAT/postscripts/runxcatpost | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/xCAT/postscripts/runxcatpost b/xCAT/postscripts/runxcatpost index 508c13f14..44b0bdfaf 100644 --- a/xCAT/postscripts/runxcatpost +++ b/xCAT/postscripts/runxcatpost @@ -1,4 +1,5 @@ #!/bin/bash +#Used only by sysclone if [ ! -f "/opt/xcat/xcatdsklspost" ];then echo "sysclone require /opt/xcat/xcatdsklspost, but it can not be found. return error!" @@ -27,6 +28,11 @@ fi XCATSERVER="$XCATSERVER:3001" export XCATSERVER +if [ ! -d "/etc/xcat/" ];then + mkdir -p /etc/xcat +fi +echo "sysclone" > /etc/xcat/xcatinstallinfo + cd /xcatpost/ #save the postboot scripts to /xcatpost/mypostscript.post TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ d" /xcatpost/mypostscript` @@ -68,4 +74,6 @@ echo "$TMP" > /tmp/xcatenv . /tmp/xcatenv /xcatpost/addsiteyum -/xcatpost/updateflag.awk $MASTER 3002 +if [ -z "$NODESTATUS" ] || [ "$NODESTATUS" != "0" -a "$NODESTATUS" != "N" -a "$NODESTATUS" != "n" ]; then + /xcatpost/updateflag.awk $MASTER 3002 +fi From 3c0e4ebf570fd44eefe5b387b81e757f0d06ed08 Mon Sep 17 00:00:00 2001 From: huweihua Date: Thu, 19 Jun 2014 04:08:53 -0400 Subject: [PATCH 05/26] sysclone add feature: update delta change from golden client to target node --- xCAT/postscripts/syscloneimgupdate | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/xCAT/postscripts/syscloneimgupdate b/xCAT/postscripts/syscloneimgupdate index b785f7a8d..6a7b6ed41 100755 --- a/xCAT/postscripts/syscloneimgupdate +++ b/xCAT/postscripts/syscloneimgupdate @@ -1,11 +1,15 @@ #!/bin/bash +#Used only by sysclone -if [ "$NODESETSTATE" != "sysclone" ];then +installmethods=`cat /etc/xcat/xcatinstallinfo` +if [ "$installmethods" != "sysclone" ];then + echo "This node didn't be installed by sysclone" exit 0 fi + #update the exclude configuration file #do not sync the following files -for filename in /etc/fstab /boot/grub /etc/grub.conf /boot/efi /etc/elilo.conf /xcatpost +for filename in /etc/fstab /boot/grub /etc/grub.conf /boot/efi /etc/elilo.conf /xcatpost /etc/xcat do if [ ! -e $filename ];then continue @@ -33,5 +37,15 @@ fi str_server_ip=`echo $str_server_ip | sed "s/'//g"` #call system imager command to update the image -echo "si_updateclient --server $str_server_ip --no-bootloader --yes" -export PERL5LIB=/usr/lib/perl5/site_perl/;LANG=C si_updateclient --server $str_server_ip --no-bootloader --yes +echo "si_updateclient --server $str_server_ip --yes" +export PERL5LIB=/usr/lib/perl5/site_perl/;LANG=C si_updateclient --server $str_server_ip --yes + +if [[ -f /sbin/dracut ]]; then + #redhat or centos + echo "Running dracut to regenerate the initrd with the drivers needed by this node:" + dracut --force +else + # suse/sles + echo "Running mkinitrd to regenerate the initrd with the drivers needed by this node:" + mkinitrd +fi From 1068c2db5b508a81bf4dcef4c1a8af345e5e9fe5 Mon Sep 17 00:00:00 2001 From: huweihua Date: Thu, 19 Jun 2014 04:13:26 -0400 Subject: [PATCH 06/26] sysclone add feature: update delta change from golden client to target node --- xCAT/postscripts/makeinitrd | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 xCAT/postscripts/makeinitrd diff --git a/xCAT/postscripts/makeinitrd b/xCAT/postscripts/makeinitrd new file mode 100755 index 000000000..c4a33ddc9 --- /dev/null +++ b/xCAT/postscripts/makeinitrd @@ -0,0 +1,20 @@ +#!/bin/bash +#Used only by sysclone + +# This SI post-install script is needed because the initrd that autoyast/kickstart/ubuntu builds when installing +# sles/rh/ubuntu on the golden node may not have the drivers when that initrd runs on the node that is +# being deployed with this image (specifically, drivers to be able to mount the disk). +# So rebuild the initrd on the to-node after putting the image on the disk, but before rebooting. + +#todo: Make this script work on red hat by checking for dracut and using that if it exists. +# And do whatever is necessary on ubuntu. + +if [[ -f /sbin/dracut ]]; then + # redhat/centos + echo "Running dracut to regenerate the initrd with the drivers needed by this node:" + dracut --force +else + # suse/sles + echo "Running mkinitrd to regenerate the initrd with the drivers needed by this node:" + mkinitrd +fi From cba796dd8ddefcd75dbf0e6864a1d67c4bb0dcab Mon Sep 17 00:00:00 2001 From: huweihua Date: Thu, 19 Jun 2014 04:22:41 -0400 Subject: [PATCH 07/26] add some comment for sysclone --- xCAT/postscripts/configefi | 3 +++ xCAT/postscripts/updatenetwork | 2 ++ 2 files changed, 5 insertions(+) diff --git a/xCAT/postscripts/configefi b/xCAT/postscripts/configefi index da0e7face..0f355b436 100644 --- a/xCAT/postscripts/configefi +++ b/xCAT/postscripts/configefi @@ -1,3 +1,6 @@ +#!/bin/bash +#Used only by sysclone + if [ -d /sys/firmware/efi ]; then echo "Setting Boot Manager for the next boot." echo "delete all sysclone boot list" diff --git a/xCAT/postscripts/updatenetwork b/xCAT/postscripts/updatenetwork index 8da573914..de7db45c8 100644 --- a/xCAT/postscripts/updatenetwork +++ b/xCAT/postscripts/updatenetwork @@ -1,4 +1,6 @@ #!/bin/bash +#Used only by sysclone + . /tmp/post-install/variables.txt #delete the udev rule in the image From ae1fc3d297c860ad43b858297ce772f27657cfe0 Mon Sep 17 00:00:00 2001 From: huweihua Date: Thu, 19 Jun 2014 04:26:09 -0400 Subject: [PATCH 08/26] add some comment for sysclone --- xCAT/postscripts/killsyslog | 3 +++ 1 file changed, 3 insertions(+) diff --git a/xCAT/postscripts/killsyslog b/xCAT/postscripts/killsyslog index ba2395caa..c379245fc 100755 --- a/xCAT/postscripts/killsyslog +++ b/xCAT/postscripts/killsyslog @@ -1,3 +1,6 @@ +#!/bin/bash +#Used only by sysclone + if [ -f "/etc/SuSE-release" ];then str_out=`ps -ef | grep -v grep | grep syslog-ng` if [ $? -eq 0 ];then From bda289858d4755523936c8f9f5be29699d1b45a9 Mon Sep 17 00:00:00 2001 From: huweihua Date: Thu, 19 Jun 2014 04:31:58 -0400 Subject: [PATCH 09/26] sysclone add feature: update delta change from golden client to target node --- xCAT-server/lib/xcat/plugins/updatenode.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-server/lib/xcat/plugins/updatenode.pm b/xCAT-server/lib/xcat/plugins/updatenode.pm index 9adc0baeb..9868f33a5 100644 --- a/xCAT-server/lib/xcat/plugins/updatenode.pm +++ b/xCAT-server/lib/xcat/plugins/updatenode.pm @@ -1924,7 +1924,7 @@ sub updatenodesoftware my $cmd; my $args1; $cmd = - "$installdir/postscripts/xcatdsklspost 2 -m $snkey 'ospkgs,otherpkgs' --tftp $tftpdir --installdir $installdir --nfsv4 $nfsv4 -c"; + "$installdir/postscripts/xcatdsklspost 2 -m $snkey 'ospkgs,otherpkgs,syscloneimgupdate' --tftp $tftpdir --installdir $installdir --nfsv4 $nfsv4 -c"; # add flowcontrol flag if ($flowcontrol == 1){ $cmd .= " -F"; From 0fa1ebf7a8641c09d004bc8115c2f9205d6dff08 Mon Sep 17 00:00:00 2001 From: huweihua Date: Thu, 19 Jun 2014 04:38:20 -0400 Subject: [PATCH 10/26] sysclone add feature: update delta change from golden client to target node --- xCAT-server/lib/xcat/plugins/anaconda.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/xCAT-server/lib/xcat/plugins/anaconda.pm b/xCAT-server/lib/xcat/plugins/anaconda.pm index b21507023..0883286e6 100644 --- a/xCAT-server/lib/xcat/plugins/anaconda.pm +++ b/xCAT-server/lib/xcat/plugins/anaconda.pm @@ -1671,6 +1671,7 @@ sub mksysclone copy("$installroot/postscripts/$script1","$pspath/15all.$script1"); copy("$installroot/postscripts/$script2","$pspath/16all.$script2"); copy("$installroot/postscripts/runxcatpost","$pspath/17all.runxcatpost"); + copy("$installroot/postscripts/makeinitrd","$pspath/20all.makeinitrd"); unless (-r "$pspath/10all.fix_swap_uuids") { From 7a2c5dca1efe2af91a3af58c5b10842097e79646 Mon Sep 17 00:00:00 2001 From: huweihua Date: Thu, 19 Jun 2014 04:44:25 -0400 Subject: [PATCH 11/26] sysclone add feature: update delta change from golden client to target node --- xCAT-server/lib/xcat/plugins/sles.pm | 38 +++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/sles.pm b/xCAT-server/lib/xcat/plugins/sles.pm index 171415e7b..3339b2cec 100755 --- a/xCAT-server/lib/xcat/plugins/sles.pm +++ b/xCAT-server/lib/xcat/plugins/sles.pm @@ -1353,6 +1353,7 @@ sub mksysclone copy("$installroot/postscripts/configefi","$pspath/15all.configefi"); copy("$installroot/postscripts/updatenetwork","$pspath/16all.updatenetwork"); copy("$installroot/postscripts/runxcatpost","$pspath/17all.runxcatpost"); + copy("$installroot/postscripts/makeinitrd","$pspath/20all.makeinitrd"); copy("$installroot/postscripts/killsyslog","$pspath/99all.killsyslog"); unless (-r "$pspath/10all.fix_swap_uuids") @@ -1512,12 +1513,41 @@ sub mksysclone } my $cmd =qq{echo "$node:compute:$imagename:" >> $clusterfile}; - my $out = xCAT::Utils->runcmd($cmd, -1); + my $rc = xCAT::Utils->runcmd($cmd, -1); - unless (-r "$installroot/sysclone/images/$imagename/opt/xcat/xcatdsklspost") + my $imagedir; + my $osimagetab = xCAT::Table->new('linuximage'); + my $osimageentry = $osimagetab->getAttribs({imagename => $imagename}, 'rootimgdir'); + if($osimageentry){ + $imagedir = $osimageentry->{rootimgdir}; + $imagedir =~ s/^(\/.*)\/.+\/?$/$1/; + }else{ + $imagedir = "$installroot/sysclone/images"; + $cmd = "chdef -t osimage $imagename rootimgdir=$imagedir/$imagename"; + $rc = `$cmd`; + } + + my $cfgimagedir = `cat /etc/systemimager/rsync_stubs/40$imagename|grep path`; + chomp($cfgimagedir); + $cfgimagedir =~ s/^\s+path=(\/.*)\/.+$/$1/g; + + if($imagedir ne $cfgimagedir){ + my $oldstr = `cat /etc/systemimager/rsync_stubs/40$imagename|grep path`; + chomp($oldstr); + $oldstr =~ s/\//\\\\\//g; + + my $targetstr="\tpath=".$imagedir."/".$imagename; + $targetstr =~ s/\//\\\\\//g; + $cmd= "sed -i \"s/$oldstr/$targetstr/\" /etc/systemimager/rsync_stubs/40$imagename"; + $rc = `$cmd`; + } + + $rc = `export PERL5LIB=/usr/lib/perl5/site_perl/;LANG=C si_mkrsyncd_conf`; + + unless (-r "$imagedir/$imagename/opt/xcat/xcatdsklspost") { - mkpath("$installroot/sysclone/images/$imagename/opt/xcat/"); - copy("$installroot/postscripts/xcatdsklspost","$installroot/sysclone/images/$imagename/opt/xcat/"); + mkpath("$imagedir/$imagename/opt/xcat/"); + copy("$installroot/postscripts/xcatdsklspost","$imagedir/$imagename/opt/xcat/"); } } From 014b82f976f95d92eca1cd6a778c401189cf6d50 Mon Sep 17 00:00:00 2001 From: daniceexi Date: Thu, 19 Jun 2014 12:52:07 -0400 Subject: [PATCH 12/26] fix the issue that cannot handle the case that XX in #INCLUDE:XX# also replacable --- xCAT-server/lib/perl/xCAT/Template.pm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/xCAT-server/lib/perl/xCAT/Template.pm b/xCAT-server/lib/perl/xCAT/Template.pm index f77c5f06d..523644b04 100644 --- a/xCAT-server/lib/perl/xCAT/Template.pm +++ b/xCAT-server/lib/perl/xCAT/Template.pm @@ -178,19 +178,21 @@ sub subvars { while (not $doneincludes) { $doneincludes=1; $inc =~ s/#ENV:([^#]+)#/envvar($1)/eg; # handle the variable in #INCLUDE - if ($inc =~ /#INCLUDE_PKGLIST:[^#^\n]+#/) { + if ($inc =~ /#INCLUDE_PKGLIST:[^\n]+#/) { + # get in this section but might not do the replace since it needs wait + # for the replace of sting inside the #INCLUDE_PKGLIST:xx# $doneincludes=0; $inc =~ s/#INCLUDE_PKGLIST:([^#^\n]+)#/includefile($1, 0, 1)/eg; } - if ($inc =~ /#INCLUDE_PTRNLIST:[^#^\n]+#/) { + if ($inc =~ /#INCLUDE_PTRNLIST:[^\n]+#/) { $doneincludes=0; $inc =~ s/#INCLUDE_PTRNLIST:([^#^\n]+)#/includefile($1, 0, 2)/eg; } - if ($inc =~ /#INCLUDE_RMPKGLIST:[^#^\n]+#/) { + if ($inc =~ /#INCLUDE_RMPKGLIST:[^\n]+#/) { $doneincludes=0; $inc =~ s/#INCLUDE_RMPKGLIST:([^#^\n]+)#/includefile($1, 0, 3)/eg; } - if ($inc =~ /#INCLUDE:[^#^\n]+#/) { + if ($inc =~ /#INCLUDE:[^\n]+#/) { $doneincludes=0; $inc =~ s/#INCLUDE:([^#^\n]+)#/includefile($1, 0, 0)/eg; } From 43681ede4031225fab3a5095b5371bb187525e88 Mon Sep 17 00:00:00 2001 From: daniceexi Date: Fri, 20 Jun 2014 02:59:22 -0400 Subject: [PATCH 13/26] code drop for postscript configbond --- xCAT/postscripts/configbond | 257 ++++++++++++++++++++++++++++++++++++ 1 file changed, 257 insertions(+) create mode 100755 xCAT/postscripts/configbond diff --git a/xCAT/postscripts/configbond b/xCAT/postscripts/configbond new file mode 100755 index 000000000..8ba4cf2d9 --- /dev/null +++ b/xCAT/postscripts/configbond @@ -0,0 +1,257 @@ +#! /bin/bash +# IBM(c) 2014 EPL license http://www.eclipse.org/legal/epl-v10.html + +# Usage: +# configbond bondname nic1@nic2@... [opt1@opt2@...] +# +# Description: +# This script is used to configure bond interface base on the arguments from the +# command line and the network information from nics and networks tables. +# +# This script will create bond interface named with 'nic1','nic2'... as slave +# devices. The bonding options 'opt1','opt2'... will be configured to bond interface. +# +# The network information for the bond interface will be gotten from the nics.nicsip and +# nics.nicnetworks for interface . If cannot get for , try to +# search for nic1. If failed too, then nic2 ... +# +# It only supports to configure one bond device at each run. If you want to create +# multiple bond devices, call it multiple times. +# +# Note: +# This script only works for IPv4 so far. + + +# Following are examples of variables which are exported from mypostscript. Mostly, we need the nics and +# networks related varirables which are exported from xcat nics and networks tables. +# NICIPS=bond0!10.0.0.12 +# NICTYPES=bond0!Ethernet +# NICHOSTNAMESUFFIXES=bond0!-bond0 +# NICNETWORKS=bond0!10_0_0_0-255_255_255_0 +# NICCUSTOMSCRIPTS=bond0!configbond +# NETWORKS_LINES=2 +# NETWORKS_LINE1=netname=10_0_0_0-255_255_255_0||net=10.0.0.0||mask=255.255.255.0||mgtifname=eth1||gateway=||dhcpserver=||tftpserver=10.0.0.10||nameservers=||ntpservers=||logservers=||dynamicrange=||staticrange=||staticrangeincrement=||nodehostname=||ddnsdomain=||vlanid=||domain=||disable=||comments= +# NETWORKS_LINE2=netname=10_0_2_0-255_255_255_0||net=10.0.2.0||mask=255.255.255.0||mgtifname=eth0||gateway=10.0.2.2||dhcpserver=||tftpserver=10.0.2.15||nameservers=||ntpservers=||logservers=||dynamicrange=||staticrange=||staticrangeincrement=||nodehostname=||ddnsdomain=||vlanid=||domain=||disable=||comments= + + +# locd library for network caculation +str_dir_name=`dirname $0` +. $str_dir_name/xcatlib.sh + +# Subroutine to display message and pass it to syslog +# Usage: showmsg "message to putput" ["error"] +function showmsg() { + msg="configbond: $1" + error=$2 + + if [ -n "$error" ]; then + $(logger -t xcat -p local4.err $msg) + else + $(logger -t xcat -p local4.info $msg) + fi + + echo $msg +} + +# Check OS version and get the directory of network configuration file +str_bond_name='' +str_os_type=`uname | tr 'A-Z' 'a-z'` +str_cfg_dir='' +str_temp='' +if [ "$str_os_type" = "linux" ];then + str_temp=`echo $OSVER | grep -E '(sles|suse)'` + if [ -f "/etc/redhat-release" ];then + str_os_type="redhat" + str_cfg_dir="/etc/sysconfig/network-scripts" + elif [ -f "/etc/SuSE-release" -o -n "$str_temp" ];then + str_os_type="sles" + str_cfg_dir="/etc/sysconfig/network" + else + showmsg "Only supports RHEL and SLES" "error" + exit -1 + fi +else + showmsg "Does NOT support non-Linux Operating System" "error" + exit -1 +fi + + +# Parse arguments +old_ifs=$IFS +IFS=$'@' + +if [ $# -eq 2 ];then + array_bond_opts="mode=4 miimon=100 downdelay=0 updelay=0 lacp_rate=fast xmit_hash_policy=1" +elif [ $# -eq 3 ]; then + array_bond_opts=($3) +else + showmsg "Only supports 2 or 3 arguments. Usage: configbond bondname nic1@nic2@... [opt1@opt2@...]" + exit -1 +fi + +str_bond_name=$1 +array_bond_slaves=($2) +IFS=$old_ifs + +# examples of variables +# str_bond_name=bond0 +# array_bond_slaves=(eth1 eth2) +# array_bond_opts=(mode=1 miimon=100) + +# Check the existence of slave devices and remove the inactive ones +realdevs=$(ip addr show 2>&1 | grep -E '^[1-9]' | cut -d: -f2) +for slave in ${array_bond_slaves[*]}; do + active=0 + for rdev in $realdevs; do + if [ $rdev = $slave ]; then + active=1 + fi + done + if [ $active -eq 0 ]; then + showmsg "Warning: device $slave does not exist. It will not be configured as a slave device." + # remove the device from slave list + allslaves=${array_bond_slaves[*]} + allslaves=${allslaves/$slave/} + array_bond_slaves=($allslaves) + fi +done + +if [ ${#array_bond_slaves[*]} -eq 0 ]; then + showmsg "No available slave devices to use." "error" + exit -1 +fi + +showmsg "Create bond interface $str_bond_name with slaves=\"${array_bond_slaves[*]}\" opts=\"${array_bond_opts[*]}\"" + +# Get bond device's IP address +str_bond_ip="" +if [ -z "$NICIPS" ]; then + showmsg "Failed to get IP for bond interface: $str_bond_name. No IP is set in nics.nicips table." + exit 1 +else + for devname in $str_bond_name ${array_bond_slaves[*]}; do # for each "bondname nic1 nic2 ..." + for ifipinfo in ${NICIPS//,/ }; do # for each "ifname!ifip" + old_ifs=$IFS + IFS=$'!' + arrayifinfo=($ifipinfo) # [0] - ifname; [1] - if ip address + IFS=$old_ifs + + if [ "$devname" = "${arrayifinfo[0]}" ]; then + str_bond_ip=${arrayifinfo[1]} + break 2 + fi + done + done +fi + +# remove the left part from |. that means only keeping the first ip in the interface if there are alias ip +str_bond_ip=${str_bond_ip%%|*} + +if [ -z "str_bond_ip" ]; then + showmsg "Failed to get IP for $str_bond_name ${array_bond_slaves[*]} from $NICIPS" + exit 1 +fi + +# Get the network and netmask info for the $str_bond_ip from networks table +str_bond_net= +str_bond_mask= +num_i=1 +while [ $num_i -le $NETWORKS_LINES ];do + eval str_bond_network=\$NETWORKS_LINE$num_i + str_temp_net=${str_bond_network#*net=} # remove the left part from 'net=' + str_temp_net=${str_temp_net%%|*} # remove the right part from first '|' + str_temp_mask=${str_bond_network#*mask=} # remove the left part from 'mask=' + str_temp_mask=${str_temp_mask%%|*} # remove the right part from first '|' + + str_temp_net1=$(v4calcnet $str_bond_ip $str_temp_mask) + str_temp_net2=$(v4calcnet $str_temp_net $str_temp_mask) + if [ "$str_temp_net1" = "$str_temp_net2" ];then + str_bond_net=$str_temp_net + str_bond_mask=$str_temp_mask + break + fi + num_i=$((num_i+1)) +done + +if [ -z "$str_bond_net" ] || [ -z "$str_bond_mask" ]; then + showmsg "Cannot find network information for bond IP $str_bond_ip from networks table." "error" + exit 1 +fi + +showmsg "IP information for $str_bond_name: IP=$str_bond_ip; network=$str_bond_net; netmask=$str_bond_mask" + +# Create bond config file + +str_master_file="${str_cfg_dir}/ifcfg-${str_bond_name}" + +if [ "$str_os_type" = "redhat" ];then + # Create the master file + cat > $str_master_file < $str_slave_file < $str_master_file <> $str_master_file + num_index=$((num_index+1)) + + str_slave_file="${str_cfg_dir}/ifcfg-${slave}" + echo "BOOTPROTO=none" > $str_slave_file + echo "STARTMODE=hotplug" >> $str_slave_file + done +fi + +# add bonding driver alias for +echo "alias $str_bond_name bonding" > /etc/modprobe.d/$str_bond_name.conf + +# Bring down the salve devices first +for slave in ${array_bond_slaves[*]}; do + $(ifdown $slave &>/dev/null) +done + +# Bring up bond device +$(ifup ${str_bond_name} &>/dev/null) + +if [ $? -ne 0 ]; then + showmsg "Failed to bring up $str_bond_name" "error" + exit 1 +fi + +showmsg "Finished the configuration for bond interface $str_bond_name" +exit 0 + + From b701bed5f1d974cc53563fd9c5cb939d5bc3e153 Mon Sep 17 00:00:00 2001 From: immarvin Date: Thu, 19 Jun 2014 20:42:33 -0700 Subject: [PATCH 14/26] add some packages to service node pkglist for rhel7 --- xCAT-server/share/xcat/install/rh/service.rhels7.ppc64.pkglist | 2 ++ xCAT-server/share/xcat/install/rh/service.rhels7.x86_64.pkglist | 2 ++ 2 files changed, 4 insertions(+) diff --git a/xCAT-server/share/xcat/install/rh/service.rhels7.ppc64.pkglist b/xCAT-server/share/xcat/install/rh/service.rhels7.ppc64.pkglist index 050985ba7..ec753351c 100644 --- a/xCAT-server/share/xcat/install/rh/service.rhels7.ppc64.pkglist +++ b/xCAT-server/share/xcat/install/rh/service.rhels7.ppc64.pkglist @@ -33,3 +33,5 @@ unixODBC perl-DBD-MySQL mysql-connector-odbc perl-DBD-Pg +wget +util-linux-ng diff --git a/xCAT-server/share/xcat/install/rh/service.rhels7.x86_64.pkglist b/xCAT-server/share/xcat/install/rh/service.rhels7.x86_64.pkglist index 2e9da4d82..4e3da0946 100644 --- a/xCAT-server/share/xcat/install/rh/service.rhels7.x86_64.pkglist +++ b/xCAT-server/share/xcat/install/rh/service.rhels7.x86_64.pkglist @@ -24,3 +24,5 @@ unixODBC perl-DBD-MySQL mysql-connector-odbc perl-DBD-Pg +wget +util-linux-ng From bbefb20cb75cdb0cc1e1ab6572644d79bfdaa51c Mon Sep 17 00:00:00 2001 From: daniceexi Date: Fri, 20 Jun 2014 04:35:41 -0400 Subject: [PATCH 15/26] configbond: ifdown the bond before ifup it for the case it has been configured --- xCAT/postscripts/configbond | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT/postscripts/configbond b/xCAT/postscripts/configbond index 8ba4cf2d9..9d55e5318 100755 --- a/xCAT/postscripts/configbond +++ b/xCAT/postscripts/configbond @@ -239,7 +239,7 @@ fi echo "alias $str_bond_name bonding" > /etc/modprobe.d/$str_bond_name.conf # Bring down the salve devices first -for slave in ${array_bond_slaves[*]}; do +for slave in ${str_bond_name} ${array_bond_slaves[*]}; do $(ifdown $slave &>/dev/null) done From 4b4ffe1441a319c51a3f20a5ce3d1d233aa77571 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Mon, 14 Apr 2014 15:46:44 -0400 Subject: [PATCH 16/26] Implement auto-downgrade to operator in IPMI In some circumstances, xCAT can only have Operator privilege in an IPMI environment. In such a scenario, auto-degrade to operator and try again before giving up. --- xCAT-server/lib/perl/xCAT/IPMI.pm | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/xCAT-server/lib/perl/xCAT/IPMI.pm b/xCAT-server/lib/perl/xCAT/IPMI.pm index 3afb337cc..1af8ce35a 100644 --- a/xCAT-server/lib/perl/xCAT/IPMI.pm +++ b/xCAT-server/lib/perl/xCAT/IPMI.pm @@ -121,6 +121,7 @@ sub new { unless ($ipmi2support) { $self->{ipmi15only} = 1; } + $self->{privlevel} = 4; unless ($args{'bmc'} and defined $args{'userid'} and defined $args{'password'}) { $self->{error}="bmc, userid, and password must be specified"; return $self; @@ -308,7 +309,7 @@ sub session_activated { sub set_admin_level { my $self= shift; - $self->subcmd(netfn=>0x6,command=>0x3b,data=>[4],callback=>\&admin_level_set,callback_args=>$self); + $self->subcmd(netfn=>0x6,command=>0x3b,data=>[$self->{privlevel}],callback=>\&admin_level_set,callback_args=>$self); } sub admin_level_set { my $rsp = shift; @@ -686,7 +687,7 @@ sub send_rakp3 { $self->{rmcptag}+=1; my @payload = ($self->{rmcptag},0,0,0,@{$self->{pendingsessionid}}); my @user = unpack("C*",$self->{userid}); - push @payload,unpack("C*",hmac_sha1(pack("C*",@{$self->{remoterandomnumber}},@{$self->{sidm}},4,scalar @user,@user),$self->{password})); + push @payload,unpack("C*",hmac_sha1(pack("C*",@{$self->{remoterandomnumber}},@{$self->{sidm}},$self->{privlevel},scalar @user,@user),$self->{password})); $self->sendpayload(payload=>\@payload,type=>$payload_types{'rakp3'}); } @@ -700,7 +701,7 @@ sub send_rakp1 { push @{$self->{randomnumber}},$randomnumber; } push @payload, @{$self->{randomnumber}}; - push @payload,(4,0,0); # request admin + push @payload,($self->{privlevel},0,0); # request priv my @user = unpack("C*",$self->{userid}); push @payload,scalar @user; push @payload,@user; @@ -816,6 +817,13 @@ sub got_rakp2 { } $byte = shift @data; unless ($byte == 0x00) { + if ($byte == 0x9 and $self->{privlevel} == 4) { + # this is probably an environment that wants to give us only operator + # try to connect again at 3. + $self->{privlevel} = 3; + $self->relog(); + return; + } if ($byte == 0x02) { #invalid session id is almost certainly because a retry on rmcp+ open session response rendered our session id invalid, ignore this in the hope that we'll get an answer for our retry that invalidated us.. #$self->relog(); #TODO: probably should disable RAKP1 retry here... high likelihood that we'll just spew a bad RAKP1 and Open Session Request retry would be more appropriate to try to discern a valid session id @@ -840,7 +848,7 @@ sub got_rakp2 { #Data now represents authcode.. sha1 only.. my @user = unpack("C*",$self->{userid}); my $ulength = scalar @user; - my $hmacdata = pack("C*",(@{$self->{sidm}},@{$self->{pendingsessionid}},@{$self->{randomnumber}},@{$self->{remoterandomnumber}},@{$self->{remoteguid}},4,$ulength,@user)); + my $hmacdata = pack("C*",(@{$self->{sidm}},@{$self->{pendingsessionid}},@{$self->{randomnumber}},@{$self->{remoterandomnumber}},@{$self->{remoteguid}},$self->{privlevel},$ulength,@user)); my @expectedhash = (unpack("C*",hmac_sha1($hmacdata,$self->{password}))); foreach (0..(scalar(@expectedhash)-1)) { if ($expectedhash[$_] != $data[$_]) { @@ -849,7 +857,7 @@ sub got_rakp2 { return 9; } } - $self->{sik} = hmac_sha1(pack("C*",@{$self->{randomnumber}},@{$self->{remoterandomnumber}},4,$ulength,@user),$self->{password}); + $self->{sik} = hmac_sha1(pack("C*",@{$self->{randomnumber}},@{$self->{remoterandomnumber}},$self->{privlevel},$ulength,@user),$self->{password}); $self->{k1} = hmac_sha1(pack("C*",1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),$self->{sik}); $self->{k2} = hmac_sha1(pack("C*",2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2),$self->{sik}); my @aeskey = unpack("C*",$self->{k2}); From 15f6241aeba158bb735539e707e7af5f2ba27f42 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 20 Jun 2014 14:43:46 -0400 Subject: [PATCH 17/26] Improve robustness in downgrade of session privilege --- xCAT-server/lib/perl/xCAT/IPMI.pm | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/xCAT-server/lib/perl/xCAT/IPMI.pm b/xCAT-server/lib/perl/xCAT/IPMI.pm index 1af8ce35a..7abd6d738 100644 --- a/xCAT-server/lib/perl/xCAT/IPMI.pm +++ b/xCAT-server/lib/perl/xCAT/IPMI.pm @@ -320,6 +320,14 @@ sub admin_level_set { 0x82 => "Cannot disable User Level authentication", ); my $code = $rsp->{code}; + if (($code == 0x80 or $code == 0x81) and $self->{privlevel} == 4) { + $self->{privlevel} = 3; + $self->{logged}=1; + $self->logout(); + $self->relog(); + return; + } + if ($code) { my $errtxt = sprintf("ERROR: Failed requesting administrator privilege %02xh",$code); if ($localcodes{$code}) { @@ -710,6 +718,8 @@ sub send_rakp1 { } sub init { my $self = shift; + $self->{confalgo} = undef; + $self->{integrityalgo}=undef; $self->{sessionestablishmentcontext} = 0; $self->{'sequencenumber'} = 0; #init sequence number $self->{'sequencenumberbytes'} = [0,0,0,0]; #init sequence number @@ -817,7 +827,7 @@ sub got_rakp2 { } $byte = shift @data; unless ($byte == 0x00) { - if ($byte == 0x9 and $self->{privlevel} == 4) { + if (($byte == 0x9 or $byte == 0xd) and $self->{privlevel} == 4) { # this is probably an environment that wants to give us only operator # try to connect again at 3. $self->{privlevel} = 3; From a8e96b90e65f7a394a18652bdf3d7d85878a55f3 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 20 Jun 2014 14:53:16 -0400 Subject: [PATCH 18/26] Correct mistake in the FRU parsing code in the product area --- xCAT-server/lib/xcat/plugins/ipmi.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-server/lib/xcat/plugins/ipmi.pm b/xCAT-server/lib/xcat/plugins/ipmi.pm index 4717a57e1..3a41a1f52 100644 --- a/xCAT-server/lib/xcat/plugins/ipmi.pm +++ b/xCAT-server/lib/xcat/plugins/ipmi.pm @@ -2225,7 +2225,7 @@ sub initfru_zero { $fru = FRU->new(); $fru->rec_type("misc"); $fru->desc("System Manufacturer"); - if ($fruhash->{product}->{product}->{encoding}==3) { + if ($fruhash->{product}->{manufacturer}->{encoding}==3) { $fru->value($fruhash->{product}->{manufacturer}->{value}); } else { $fru->value(phex($fruhash->{product}->{manufacturer}->{value})); From 54c28704083807a8b1fdf97921964e74fb0b1de3 Mon Sep 17 00:00:00 2001 From: huweihua Date: Mon, 23 Jun 2014 05:00:26 -0400 Subject: [PATCH 19/26] sysclone: fix some bug in Softlayer environment --- xCAT/postscripts/configefi | 51 +++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 15 deletions(-) diff --git a/xCAT/postscripts/configefi b/xCAT/postscripts/configefi index 0f355b436..41a30a498 100644 --- a/xCAT/postscripts/configefi +++ b/xCAT/postscripts/configefi @@ -1,6 +1,9 @@ #!/bin/bash #Used only by sysclone +# SI post-install script to configure the efi boot mgr or grub after SI has installed the OS +# SI post-install scripts run in a chroot environment of the final OS image + if [ -d /sys/firmware/efi ]; then echo "Setting Boot Manager for the next boot." echo "delete all sysclone boot list" @@ -28,32 +31,50 @@ else 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 + boot_root=`mount | grep -E ' on\s+/ type ' | awk '{print $1}'` + boot_device=`echo $boot_root | sed -e 's/[0-9]*$//'` + + #str_temp=`mount | awk '{print $1","$3}'` + #for line in $str_temp + #do + # mp=`echo $line | awk -F, '{print $2}'` + # if [ "$mp" = "/" ];then + # boot_device=`echo $line | awk -F, '{print $1}' | sed -e 's/[0-9]*$//'` + # break + # fi + #done fi if [ -n "$boot_device" ];then - echo "the boot device is $boot_device" + echo "The boot device is $boot_device" + echo "The boot root device is $boot_root" else echo "Can not find the boot device, return error" exit 1 fi - #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 + # set grub to use this boot device + if grep -qe '^VERSION\s*=\s*11' /etc/SuSE-release; then #sles11, run grub-install.unsupported directly + echo "grub-install.unsupported --no-floppy --recheck $boot_device" grub-install.unsupported --no-floppy --recheck $boot_device + # note: the error about grub-set-default not existing is harmless, because we want the default to be 0 anyway + else + #for sles10, should run grub-install with parameters + echo "grub-install --no-floppy --recheck $boot_device" + grub-install --no-floppy --recheck $boot_device fi - + + # change the entries in the grub conf file to use the correct boot root device + # (not the one leftover from the golden image) + if [ -f "/boot/grub/grub.conf" ];then + conffile="/boot/grub/grub.conf" + else + conffile="/boot/grub/menu.lst" + fi + sed -i 's| root=\S*| root='$boot_root'|' $conffile + sed -i 's| resume=\S*| noresume|' $conffile + if [ -e /etc/mtab.bak ];then mv -f /etc/mtab.bak /etc/mtab else From 908fdf842947934ed08b6461f99dd0c0a74516ae Mon Sep 17 00:00:00 2001 From: huweihua Date: Mon, 23 Jun 2014 05:05:30 -0400 Subject: [PATCH 20/26] sysclone: fix some bug in Softlayer environment --- xCAT/postscripts/killsyslog | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/xCAT/postscripts/killsyslog b/xCAT/postscripts/killsyslog index c379245fc..e6f6d4545 100755 --- a/xCAT/postscripts/killsyslog +++ b/xCAT/postscripts/killsyslog @@ -1,6 +1,10 @@ #!/bin/bash #Used only by sysclone +# SI post-install script, run after SI has installed the OS, to kill processes SI does not kill +# (so /a can be umounted cleanly) +# SI post-install scripts run in a chroot environment of the final OS image + if [ -f "/etc/SuSE-release" ];then str_out=`ps -ef | grep -v grep | grep syslog-ng` if [ $? -eq 0 ];then @@ -8,3 +12,15 @@ if [ -f "/etc/SuSE-release" ];then kill -9 $str_id fi fi + +# SI starts klogd in the chroot, but does not kill it. Remove this line when SI fixes their bug. +killall klogd + +# flush all write buffers, just in case SI can not umount /a +echo "Syncing file systems" +sync + +#todo: remove +#echo "Processes still using /:" +#fuser -v / +#sleep 30 From 3c327578e4c33bc468f970adadb177acb9036d10 Mon Sep 17 00:00:00 2001 From: lissav Date: Tue, 24 Jun 2014 07:41:06 -0400 Subject: [PATCH 21/26] Defect 4164, change rinstall to a plugin --- perl-xCAT/xCAT/Utils.pm | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/perl-xCAT/xCAT/Utils.pm b/perl-xCAT/xCAT/Utils.pm index 12fb29ff0..bd3b51bbd 100644 --- a/perl-xCAT/xCAT/Utils.pm +++ b/perl-xCAT/xCAT/Utils.pm @@ -1339,11 +1339,30 @@ sub runxcmd_output } } } + if (defined($node->{error})) + { + if (ref(\($node->{error}->[0])) eq 'SCALAR') + { + $desc = $desc . ": " . $node->{error}->[0]; + } + } + if (defined($node->{errorcode})) + { + if (ref(\($node->{errorcode}->[0])) eq 'SCALAR') + { + $::RUNCMD_RC |= $node->{errorcode}->[0]; + } + } push @$::xcmd_outref, $desc; } if (defined($resp->{error})) { - push @$::xcmd_outref, @{$resp->{error}}; + if (ref($resp->{error}) eq 'ARRAY') + { + push @$::xcmd_outref, @{$resp->{error}}; + } else { + push @$::xcmd_outref, $resp->{error}; + } } if (defined($resp->{errorcode})) { From b24d5bdda45bcb5b96e0e1fbe4277b3415f0e463 Mon Sep 17 00:00:00 2001 From: lissav Date: Tue, 24 Jun 2014 07:50:36 -0400 Subject: [PATCH 22/26] add rinstall plugin --- xCAT-server/lib/xcat/plugins/rinstall.pm | 481 +++++++++++++++++++++++ 1 file changed, 481 insertions(+) create mode 100644 xCAT-server/lib/xcat/plugins/rinstall.pm diff --git a/xCAT-server/lib/xcat/plugins/rinstall.pm b/xCAT-server/lib/xcat/plugins/rinstall.pm new file mode 100644 index 000000000..62fd73c48 --- /dev/null +++ b/xCAT-server/lib/xcat/plugins/rinstall.pm @@ -0,0 +1,481 @@ +# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html +#------------------------------------------------------- + +=head1 + xCAT plugin package to handle rinstall and winstall + + Supported command: + rinstall - runs nodeset, rsetboot,rpower commands + winstall - also opens the console + +=cut + +#------------------------------------------------------- +package xCAT_plugin::rinstall; +use strict; + +require xCAT::Utils; +require xCAT::MsgUtils; +use xCAT::NodeRange; +use xCAT::Table; + +use Data::Dumper; +use Getopt::Long; + +#------------------------------------------------------- + +=head3 handled_commands + +Return list of commands handled by this plugin + +=cut + +#------------------------------------------------------- + +sub handled_commands +{ + return { + rinstall => "rinstall", + winstall => "rinstall", + }; +} + +#------------------------------------------------------- + +=head3 Process the command + +=cut + +#------------------------------------------------------- +sub process_request +{ + + my $request = shift; + my $callback = shift; + my $subreq = shift; + + rinstall($request, $callback, $subreq); +} + +#------------------------------------------------------- + +=head3 rinstall + + Wrapper around nodeset, rsetboot, rpower for the admin convenience + + +=cut + +#------------------------------------------------------- +sub rinstall +{ + my ($req, $callback, $subreq) = @_; + $::CALLBACK=$callback; + my $OSVER; + my $PROFILE; + my $ARCH; + my $CONSOLE; + my $OSIMAGE; + my $HELP; + my $VERSION; + my $command = $req->{command}->[0]; # could be rinstall on winstall + my $args; + if (defined($req->{arg}) ) { # there are arguments + $args=$req->{arg}; # argument + @ARGV = @{$args}; + } + my $nodes; + my @nodes; + if (defined ($req->{node})) { # there are nodes + $nodes = $req->{node}; + @nodes=@$nodes; + } + # no arguments, no nodes then input wrong + if ((scalar(@nodes) == 0) && (scalar(@ARGV) == 0)){ + &usage($command,$callback); + return 1; + } + #print Dumper($req); + Getopt::Long::Configure("bundling"); + + unless ( + GetOptions( + 'o|osver=s' => \$OSVER, + 'p|profile=s' => \$PROFILE, + 'a|arch=s' => \$ARCH, + 'O|osimage=s' => \$OSIMAGE, + 'h|help' => \$HELP, + 'v|version' => \$VERSION, + 'c|console' => \$CONSOLE + ) + ) + { + &usage($command,$callback); + return 1; + } + if ($HELP) + { + &usage($command,$callback); + return 0; + } + if ($VERSION) + { + my $version = xCAT::Utils->Version(); + my $rsp = {}; + $rsp->{data}->[0] = "$version"; + xCAT::MsgUtils->message("I", $rsp, $callback); + return (0); + } + + if (scalar @$nodes eq 0) + { + my $rsp = {}; + $rsp->{error}->[0] ="noderange not supplied"; + xCAT::MsgUtils->message("E", $rsp, $callback); + return 1; + } + + my $rc = 0; + my %pnhash; + + + if ($OSIMAGE) + { + + # -O|--osimage is specified, ignore any -a,-p,-o options, + # call "nodeset ... osimage= ..." to set the boot state of the noderange to the specified osimage, + # "nodeset" will handle the updating of node attributes such as os,arch,profile,provmethod + # verify input + &checkoption("[-O|--osimage] $OSIMAGE",$OSVER,$PROFILE,$ARCH,$callback); + + # run nodeset $noderange osimage=$OSIMAGE + my @osimageargs; + push @osimageargs,"osimage=$OSIMAGE" ; + my $res = + xCAT::Utils->runxcmd( + { + command => ["nodeset"], + node => \@nodes, + arg => \@osimageargs + }, + $subreq, -1, 1); + + my $rsp = {}; + if ($::RUNCMD_RC ==0 ) { + foreach my $line (@$res) { + $rsp->{data} ->[0] = $line; + xCAT::MsgUtils->message("I", $rsp, $callback); + } + } else { + foreach my $line (@$res) { + $rsp->{error} ->[0] = $line; + xCAT::MsgUtils->message("E", $rsp, $callback); + } + return 1; + } + } + else + { + + # no osimage specified, update the node attributes specified by -a,-p,-o options thru "nodech", + # then set the boot state of each node based on the nodetype.provmethod: + # 1) if nodetype.provmethod = , ignore any -p,-o,-a option, + # then call "nodeset ... osimage" + # 2) if nodetype.provmethod = [install/netboot/statelite], + # update the node attributes specified by -a,-p,-o options thru "nodech", + # call "nodeset ... [install/netboot/statelite]" + # 3) if nodetype.provmethod is not set, use 'install' as the default value + + # group the nodes according to the nodetype.provmethod + + foreach (@$nodes) + { + my $tab = xCAT::Table->new("nodetype"); + my $nthash = $tab->getNodeAttribs($_, ['provmethod']); + $tab->close(); + if (defined($nthash) and defined($nthash->{'provmethod'})) + { + push(@{$pnhash{$nthash->{'provmethod'}}}, $_); + } + else + { + + #if nodetype.provmethod is not specified, + push(@{$pnhash{'install'}}, $_); + } + } + # Now for each group based on provmethod + foreach my $key (keys %pnhash) + { + $::RUNCMD_RC =0; + my $nodes = join(',', @{$pnhash{$key}}); + if ($key =~ /^(install|netboot|statelite)$/) + { + + # nodetype.provmethod = [install|netboot|statelite] + my @nodechline; + if ($OSVER) + { + push @nodechline, "nodetype.os=$OSVER"; + } + if ($PROFILE) + { + push @nodechline, "nodetype.profile=$PROFILE"; + } + if ($ARCH) + { + push @nodechline, "nodetype.arch=$ARCH"; + } + if (@nodechline) + { + # run nodech $nodes $nodechline + my $res = + xCAT::Utils->runxcmd( + { + command => ["nodech"], + node => \@nodes, + arg => \@nodechline + }, + $subreq, -1, 1); + + my $rsp = {}; + $rc=$::RUNCMD_RC; + if ($rc == 0 ) { + foreach my $line (@$res) { + $rsp->{data} ->[0] = $line; + xCAT::MsgUtils->message("I", $rsp, $callback); + } + } else { # error + $rsp->{error} ->[0] = "nodech error"; + xCAT::MsgUtils->message("E", $rsp, $callback); + foreach my $line (@$res) { + $rsp->{error} ->[0] = $line; + xCAT::MsgUtils->message("E", $rsp, $callback); + } + } + } # end nodechline + + if ($rc == 0) # if no error from nodech then run nodeset + { + # run nodeset $nodes $key ( where key is install/netboot/statelite) + my @nodesetarg; + push @nodesetarg, "$key"; + my $res = + xCAT::Utils->runxcmd( + { + command => ["nodeset"], + node => \@nodes, + arg => \@nodesetarg + }, + $subreq, -1, 1); + + my $rsp = {}; + $rc=$::RUNCMD_RC; + if ($rc ==0 ) { + foreach my $line (@$res) { + $rsp->{data} ->[0] = $line; + xCAT::MsgUtils->message("I", $rsp, $callback); + } + } else { # error + foreach my $line (@$res) { + $rsp->{error} ->[0] = $line; + xCAT::MsgUtils->message("E", $rsp, $callback); + } + } + } + } + else # if not install/netboot/statelite + { + + # nodetype.provmethod = + &checkoption("nodetype.provmethod=$key",$OSVER,$PROFILE,$ARCH,$callback); + # run nodeset $nodes osimage + my @nodesetarg; + push @nodesetarg, "osimage"; + my $res = + xCAT::Utils->runxcmd( + { + command => ["nodeset"], + node => \@nodes, + arg => \@nodesetarg + }, + $subreq, -1, 1); + + my $rsp = {}; + $rc=$::RUNCMD_RC; + if ($rc ==0 ) { + foreach my $line (@$res) { + $rsp->{data} ->[0] = $line; + xCAT::MsgUtils->message("I", $rsp, $callback); + } + } else { # error + foreach my $line (@$res) { + $rsp->{error} ->[0] = $line; + xCAT::MsgUtils->message("E", $rsp, $callback); + } + } + } + + } + } # end nodech/nodeset for each group + + if ($rc != 0) # we got an error with the nodeset + { + my $rsp = {}; + $rsp->{error}->[0] = "nodeset failure will not continue "; + xCAT::MsgUtils->message("E", $rsp, $callback); + return 1; + } + + # call "rsetboot" to set the boot order of the nodehm.mgt=ipmi nodes,for others, + # assume user has set the correct boot order before "rinstall" + + # run rsetboot $noderange net + + my @rsetbootarg; + push @rsetbootarg, "net"; + my $res = + xCAT::Utils->runxcmd( + { + command => ["rsetboot"], + node => \@nodes, + arg => \@rsetbootarg + }, + $subreq, -1, 1); + # fix output it is a hash and you must get error out of the hash. + my $rsp = {}; + $rc=$::RUNCMD_RC; + if ($rc ==0 ) { + foreach my $line (@$res) { + $rsp->{data} ->[0] = $line; + xCAT::MsgUtils->message("I", $rsp, $callback); + } + } else { # error + foreach my $line (@$res) { + $rsp->{error} ->[0] = $line; + xCAT::MsgUtils->message("E", $rsp, $callback); + } + } + if ($rc != 0) # we got an error with the rsetboot + { + my $rsp = {}; + $rsp->{error}->[0] = "rsetboot failure will not continue "; + xCAT::MsgUtils->message("E", $rsp, $callback); + return 1; + } + + # call "rpower" to start the node provision process + + #run rpower $noderange boot + my @rpowerarg; + push @rpowerarg, "boot"; + my $res = + xCAT::Utils->runxcmd( + { + command => ["rpower"], + node => \@nodes, + arg => \@rpowerarg + }, + $subreq, -1, 1); + + my $rsp = {}; + $rc=$::RUNCMD_RC; + if ($rc ==0 ) { + foreach my $line (@$res) { + $rsp->{data} ->[0] = $line; + xCAT::MsgUtils->message("I", $rsp, $callback); + } + } else { # error + foreach my $line (@$res) { + $rsp->{error} ->[0] = $line; + xCAT::MsgUtils->message("E", $rsp, $callback); + } + } + # Check if they asked to bring up a console ( -c) from rinstall always for winstall + $req->{startconsole}->[0] =0; + if ($command =~ /rinstall/) + { + + # for rinstall, the -c|--console option can provide the remote console for only 1 node + if ($CONSOLE) + { + if (scalar @$nodes ne 1) + { + my $rsp = {}; + $rsp->{error}->[0] = "rinstall -c only accepts one node in the noderange. See winstall for support for support of consoles on multiple nodes."; + xCAT::MsgUtils->message("E", $rsp, $callback); + return 1; + } else { # tell rinstall client ok to start rcons + $req->{startconsole}->[0] =1; + } + + } + } + elsif ($command =~ /winstall/) + { + + # winstall can start a wcons command to multiple nodes for monitoring the provision cycle + $req->{startconsole}->[0] =1; + + } + + return 0; +} + +#------------------------------------------------------- + +=head3 Usage + + +=cut + +#------------------------------------------------------- + +sub usage +{ + my $command = shift; + my $callback = shift; + my $rsp = {}; + $rsp->{data}->[0] = "$command usage:"; + if ($command =~ /rinstall/) { + $rsp->{data}->[1] = " [-o|--osver] [-p|--profile] [-a|--arch] [-c|--console] "; + } else { # winstall + $rsp->{data}->[1] = " [-o|--osver] [-p|--profile] [-a|--arch] "; + } + if ($command =~ /rinstall/) { + $rsp->{data}->[2] = " [-O|--osimage] [-c|--console] "; + } else { # wininstall + $rsp->{data}->[2] = " [-O|--osimage] "; + } + + $rsp->{data}->[3] = " [-h|--help]"; + $rsp->{data}->[4] = " [-v|--version]"; + xCAT::MsgUtils->message("I", $rsp, $callback); +} + +# check and complain about the invalid combination of the options, +# ignore -o,-p and -a options and prompt a warning message when provmethod=osimagename +sub checkoption{ + my $optstring=shift; + my $OSVER=shift; + my $PROFILE=shift; + my $ARCH=shift; + my $callback=shift; + my $rsp = {}; + if($OSVER) { + $rsp->{data}->[0] = "-o option not valid with $optstring. It is ignored."; + xCAT::MsgUtils->message("I", $rsp, $callback); + } + if($PROFILE) { + $rsp->{data}->[0] = "-p option not valid with $optstring. It is ignored."; + xCAT::MsgUtils->message("I", $rsp, $callback); + } + if($ARCH) { + $rsp->{data}->[0] = "-a option not valid with $optstring. It is ignored."; + xCAT::MsgUtils->message("I", $rsp, $callback); + } +} + + + +1; From 4691f35799bc94b7b68c49582ed48d03ce32ac97 Mon Sep 17 00:00:00 2001 From: immarvin Date: Tue, 24 Jun 2014 07:58:13 -0700 Subject: [PATCH 23/26] fix defect#4171 [FVT]:xcatd is not running after rh7 sn is setup --- perl-xCAT/xCAT/NetworkUtils.pm | 156 +++++++++++++++++++++++---------- 1 file changed, 111 insertions(+), 45 deletions(-) diff --git a/perl-xCAT/xCAT/NetworkUtils.pm b/perl-xCAT/xCAT/NetworkUtils.pm index 3bcc6383f..92e278cfe 100755 --- a/perl-xCAT/xCAT/NetworkUtils.pm +++ b/perl-xCAT/xCAT/NetworkUtils.pm @@ -19,7 +19,7 @@ use File::Path; use Math::BigInt; use Socket; use xCAT::GlobalDef; -use Data::Dumper; +#use Data::Dumper; use strict; use warnings "all"; my $socket6support = eval { require Socket6 }; @@ -1601,58 +1601,124 @@ sub thishostisnot =cut #----------------------------------------------------------------------------- +#sub gethost_ips1 +#{ +# my ($class) = @_; +# my $cmd; +# my @ipaddress; +# $cmd = "ifconfig" . " -a"; +# $cmd = $cmd . "| grep \"inet\""; +# my @result = xCAT::Utils->runcmd($cmd, 0); +# if ($::RUNCMD_RC != 0) +# { +# xCAT::MsgUtils->message("S", "Error from $cmd\n"); +# exit $::RUNCMD_RC; +# } +# foreach my $addr (@result) +# { +# my @ip; +# if (xCAT::Utils->isLinux()) +# { +# if ($addr =~ /inet6/) +# { +# #TODO, Linux ipv6 +# } +# else +# { +# my ($inet, $addr1, $Bcast, $Mask) = split(" ", $addr); +# #@ip = split(":", $addr1); +# #push @ipaddress, $ip[1]; +# $addr1 =~ s/.*://; +# push @ipaddress, $addr1; +# } +# } +# else +# { #AIX +# if ($addr =~ /inet6/) +# { +# $addr =~ /\s*inet6\s+([\da-fA-F:]+).*\/(\d+)/; +# my $v6ip = $1; +# my $v6mask = $2; +# if ($v6ip) +# { +# push @ipaddress, $v6ip; +# } +# } +# else +# { +# my ($inet, $addr1, $netmask, $mask1, $Bcast, $bcastaddr) = +# split(" ", $addr); +# push @ipaddress, $addr1; +# } +# +# } +# } +# my @names = @ipaddress; +# foreach my $ipaddr (@names) +# { +# my $hostname = xCAT::NetworkUtils->gethostname($ipaddr); +# if ($hostname) +# { +# my @shorthost = split(/\./, $hostname); +# push @ipaddress, $shorthost[0]; +# } +# } +# +# return @ipaddress; +#} + + sub gethost_ips { my ($class) = @_; my $cmd; my @ipaddress; - $cmd = "ifconfig" . " -a"; - $cmd = $cmd . "| grep \"inet\""; - my @result = xCAT::Utils->runcmd($cmd, 0); - if ($::RUNCMD_RC != 0) + if (xCAT::Utils->isLinux()) { - xCAT::MsgUtils->message("S", "Error from $cmd\n"); - exit $::RUNCMD_RC; + $cmd="ip -4 --oneline addr show |awk -F ' ' '{print \$4}'|awk -F '/' '{print \$1}'"; + my @result =xCAT::Utils->runcmd($cmd); + if ($::RUNCMD_RC != 0) + { + xCAT::MsgUtils->message("S", "Error from $cmd\n"); + exit $::RUNCMD_RC; + } + + push @ipaddress, @result; } - foreach my $addr (@result) - { - my @ip; - if (xCAT::Utils->isLinux()) - { - if ($addr =~ /inet6/) - { - #TODO, Linux ipv6 - } - else - { - my ($inet, $addr1, $Bcast, $Mask) = split(" ", $addr); - #@ip = split(":", $addr1); - #push @ipaddress, $ip[1]; - $addr1 =~ s/.*://; - push @ipaddress, $addr1; - } - } - else - { #AIX - if ($addr =~ /inet6/) - { - $addr =~ /\s*inet6\s+([\da-fA-F:]+).*\/(\d+)/; - my $v6ip = $1; - my $v6mask = $2; - if ($v6ip) - { - push @ipaddress, $v6ip; - } - } - else - { - my ($inet, $addr1, $netmask, $mask1, $Bcast, $bcastaddr) = - split(" ", $addr); - push @ipaddress, $addr1; - } + else + { #AIX + + $cmd = "ifconfig" . " -a"; + $cmd = $cmd . "| grep \"inet\""; + my @result = xCAT::Utils->runcmd($cmd, 0); + if ($::RUNCMD_RC != 0) + { + xCAT::MsgUtils->message("S", "Error from $cmd\n"); + exit $::RUNCMD_RC; + } + + foreach my $addr (@result) + { + if ($addr =~ /inet6/) + { + $addr =~ /\s*inet6\s+([\da-fA-F:]+).*\/(\d+)/; + my $v6ip = $1; + my $v6mask = $2; + if ($v6ip) + { + push @ipaddress, $v6ip; + } + } + else + { + my ($inet, $addr1, $netmask, $mask1, $Bcast, $bcastaddr) = + split(" ", $addr); + push @ipaddress, $addr1; + } - } + } } + my @names = @ipaddress; foreach my $ipaddr (@names) { @@ -1663,9 +1729,9 @@ sub gethost_ips push @ipaddress, $shorthost[0]; } } - return @ipaddress; } + #------------------------------------------------------------------------------- =head3 get_subnet_aix From a3b3656ed873f8181e9c3da6d776194287f3b646 Mon Sep 17 00:00:00 2001 From: lissav Date: Tue, 24 Jun 2014 12:15:39 -0400 Subject: [PATCH 24/26] defect 4164 --- xCAT-client/bin/rinstall | 224 ++++++++++----------------------------- 1 file changed, 56 insertions(+), 168 deletions(-) diff --git a/xCAT-client/bin/rinstall b/xCAT-client/bin/rinstall index fad798fdb..48ce9b1a1 100755 --- a/xCAT-client/bin/rinstall +++ b/xCAT-client/bin/rinstall @@ -1,12 +1,11 @@ #!/usr/bin/env perl # IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html -# Used as a convience command combined of [nodech]-nodeset-rpower-[rcons/wcons] +# Used as a convience command combined of [nodech]-nodeset-rsetboot-rpower-[rcons/wcons] # to make ease of node OS provision -# To use this, sym link your cmd name to this script. +# This is the client front-end to rinstall/winstall commands -use strict; BEGIN { @@ -20,180 +19,69 @@ use lib "$::XCATROOT/lib/perl"; use File::Basename; use Getopt::Long; use xCAT::MsgUtils; -use xCAT::Table; -use xCAT::NodeRange; +use xCAT::Utils; +use xCAT::Client; +use Cwd; +use strict; - -sub usage { - print basename($0)." usage:\n"; - print " ".basename($0)." [-o|--osver] [-p|--profile] [-a|--arch] [-O|--osimage] [-c|--console] \n" -} - - - -my $OSVER; -my $PROFILE; -my $ARCH; -my $CONSOLE; -my $OSIMAGE; - -Getopt::Long::Configure("bundling"); -unless (GetOptions( - 'o|osver=s' => \$OSVER, - 'p|profile=s' => \$PROFILE, - 'a|arch=s' => \$ARCH, - 'O|osimage=s' => \$OSIMAGE, - 'c|console' => \$CONSOLE - )) { - usage; - exit 1; -} -my $arraysize=@ARGV; -if ($arraysize > 1) { - print "noderange invalid\n"; - usage; - exit 1; -} -if ($arraysize == 0) { - print "noderange not supplied\n"; - usage; - exit 1; -} - -my $noderange=@ARGV[0]; -my $rc=0; -my %pnhash; -my @allnodes; -#use Data::Dumper; - -# check and complain about the invalid combination of the options, -# called when -O is specified or nodetype.provmethod=, -# ignore -o,-p and -a options and prompt a warning message -sub checkoption{ - my $optstring=shift; - if($OSVER) {print 'warning: "'.$optstring.'" specified, "[-o|--osver] '.$OSVER."\" ignored\n"}; - if($PROFILE) {print 'warning: "'.$optstring.'" specified, "[-p|--profile] '.$PROFILE."\" ignored\n"}; - if($ARCH) {print 'warning: "'.$optstring.'" specified, "[-a|--arch] '.$OSVER."\" ignored\n"}; -} - - -@allnodes=noderange($noderange); -if($OSIMAGE){ - -# -O|--osimage is specified, ignore any -a,-p,-o options, -# call "nodeset ... osimage= ..." to set the boot state of the noderange to the specified osimage, -# "nodeset" will handle the updating of node attributes such as os,arch,profile,provmethod - - &checkoption("[-O|--osimage] $OSIMAGE"); - $rc=system("nodeset $noderange osimage=$OSIMAGE"); - if ($rc) { - xCAT::MsgUtils->message("E","nodeset failure"); - exit 1; - }; -}else +# build a request to go the rinstall plugin +my $bname = basename($0); +my $cmdref; +$cmdref->{command}->[0] = $bname; +$cmdref->{cwd}->[0] = cwd(); +# allows our plugins to get the stdin of the cmd that invoked the plugin +my $data; +if ( (($^O =~ /^linux/i) && ($ENV{'SHELL'} =~ /\/ksh$/)) || !defined($ENV{'TERM'}) ) { - -# no osimage specified, update the node attributes specified by -a,-p,-o options thru "nodech", -# then set the boot state of each node based on the nodetype.provmethod: -# 1) if nodetype.provmethod = , ignore any -p,-o,-a option, then call "nodeset ... osimage" -# 2) if nodetype.provmethod = [install/netboot/statelite], update the node attributes specified by -a,-p,-o options thru "nodech", call "nodeset ... [install/netboot/statelite]" -# 3) if nodetype.provmethod is not set, use 'install' as the default value - -# group the nodes according to the nodetype.provmethod - - foreach(@allnodes){ - my $tab=xCAT::Table->new("nodetype"); - my $nthash=$tab->getNodeAttribs($_,['provmethod']); - $tab->close(); - if(defined($nthash) and defined($nthash->{'provmethod'})) - { - push(@{$pnhash{$nthash->{'provmethod'}}},$_); - } - else - { - #if nodetype.provmethod is not specified, - push(@{$pnhash{'install'}},$_); - } - } - - - foreach my $key (keys %pnhash) - { - my $rclocal=0; - my $nodes=join(',',@{$pnhash{$key}}); - if($key =~ /^(install|netboot|statelite)$/) - { - - # nodetype.provmethod = [install|netboot|statelite] - my $nodechline = ""; - if ($OSVER) { - $nodechline = "nodetype.os=$OSVER"; - } - if ($PROFILE) { - $nodechline .= " nodetype.profile=$PROFILE"; - } - if ($ARCH) { - $nodechline .= " nodetype.arch=$ARCH"; - } - if ($nodechline) { - $rclocal=system("nodech $nodes $nodechline"); - if ($rclocal) { - print "nodech failure\n"; - $rc=$rclocal; - } - } - - unless($rc){ - $rclocal=system("nodeset $nodes $key"); - if ($rclocal) { - print "nodeset $nodes failure\n"; - $rc=$rclocal; - } - } - } - else - { - - # nodetype.provmethod = - &checkoption("nodetype.provmethod=$key"); - $rclocal=system("nodeset $nodes osimage"); - if ($rclocal) { - print "nodeset $nodes failure\n"; - $rc=$rclocal; - } - } - - } + my $rin=""; + my $rout; + vec($rin,fileno(STDIN),1)=1; + my $nfound=select($rout=$rin,"","",1); + if ($nfound) + { + while ( ) { $data.=$_; } + $cmdref->{stdin}->[0]=$data; + } } - -if($rc){ - xCAT::MsgUtils->message("E","nodeset failure"); - exit 1; +else +{ + if (-p STDIN) { + while ( ) { $data.=$_; } + $cmdref->{stdin}->[0]=$data; + } } +my $arg; +my @tmpargv = @ARGV; +# first +$arg=shift(@ARGV); +# first 1st non-hyphen arg is the noderange +while ($arg =~ /^-/) { + push (@{$cmdref->{arg}}, $arg); + $arg=shift(@ARGV); +} +$cmdref->{noderange}->[0]=$arg; +push (@{$cmdref->{arg}}, @ARGV); -# call "rsetboot" to set the boot order of the nodehm.mgt=ipmi nodes,for others, assume user has set the correct boot order before "rinstall" -system("rsetboot $noderange net"); +my $noderange=$cmdref->{noderange}->[0]; # save the noderange -# call "rpower" to start the node provision process -$rc=system("rpower $noderange boot"); -if ($rc) { - xCAT::MsgUtils->message("E","rpower failure"); - exit 1; -}; +# ok call Client to run the plugin rinstall.pm +xCAT::Client::submit_request($cmdref,\&xCAT::Client::handle_response); +if ($xCAT::Client::EXITCODE == 0) # no errors +{ + my $startconsole=$cmdref->{startconsole}->[0]; + # if startconsole requested ( -c flag) for rinstall always for winstall + # This is set in the rinstall plugin + if ($startconsole == 1) { + if (basename($0) =~ /rinstall/) { -if (basename($0) =~ /rinstall/) { - -# for rinstall, the -c|--console option can provide the remote console for only 1 node - if ($CONSOLE) { - if(scalar @allnodes ne 1){ - xCAT::MsgUtils->message("E","rinstall [-c|--console] will only work if there is only one node in the noderange. See winstall(8) for consoles on multiple systems"); - exit 1; - } exec("rcons $noderange"); } -} elsif (basename($0) =~ /winstall/) { -# winstall can commence a wcons command to the noderange for monitoring the provision cycle + elsif (basename($0) =~ /winstall/) { + # winstall can commence a wcons command to the noderange for monitoring the provision cycle - exec("wcons $noderange"); + exec("wcons $noderange"); + } + } } +exit $xCAT::Client::EXITCODE; From 0d4e736b6d71708b28a925f55fa3b4b4052566df Mon Sep 17 00:00:00 2001 From: lissav Date: Tue, 24 Jun 2014 12:17:54 -0400 Subject: [PATCH 25/26] defect 4164 --- xCAT-client/pods/man8/rinstall.8.pod | 32 +++++++++++++++--------- xCAT-client/pods/man8/winstall.8.pod | 37 ++++++++++++++++++---------- 2 files changed, 45 insertions(+), 24 deletions(-) diff --git a/xCAT-client/pods/man8/rinstall.8.pod b/xCAT-client/pods/man8/rinstall.8.pod index 1988ace26..1923a8f9f 100644 --- a/xCAT-client/pods/man8/rinstall.8.pod +++ b/xCAT-client/pods/man8/rinstall.8.pod @@ -4,32 +4,42 @@ B - Begin OS provision on a noderange =head1 B -B [I<-o>|I<--osver>] [I<-p>|I<--profile>] [I<-a>|I<--arch>] [I<-O>|I<--osimage>] [I<-c>|I<--console>] [I] +B [I<-o>|I<--osver>] [I<-p>|I<--profile>] [I<-a>|I<--arch>] [I<-c>|I<--console>] [I] + +B [I<-O>|I<--osimage>] [I<-c>|I<--console>] [I] =head1 B -B is a convience command that will change tables as requested for operating system version, profile, and architecture, call B to modify the network boot configuration, call B net to set the next boot over network (only support nodes with "nodetype.mgt=ipmi", for other nodes, make sure the correct boot order has been set before B), and B to begin a boot cycle. +B is a convenience command that will change tables as requested for operating system version, profile, and architecture, call B to modify the network boot configuration, call B net to set the next boot over network (only support nodes with "nodetype.mgt=ipmi", for other nodes, make sure the correct boot order has been set before B), and B to begin a boot cycle. If [I<-O>|I<--osimage>] is specified or nodetype.provmethod=I is set, provision the noderange with the osimage specified/configured, ignore the table change options if specified. -If -c is specified, it will then become the text console of the node. If wanting consoles on multiple nodes with a similar command, see L. +If -c is specified, it will then run rcons on the node. This is allowed only if one node in the noderange. If need consoles on multiple nodes , see L. =head1 B =over 7 +=item B<-h>|B<--help> + +Display usage message. + +=item B<-v>|B<--version> + +Display version. + =item B<-o>|B<--osver> -Specifies which os version to provision. If unspecified, the current table values are used. Will be ignored if [I<-O>|I<--osimage>] is specified or nodetype.provmethod=I. +Specifies which os version to provision. If unspecified, the current node os setting is used. Will be ignored if [I<-O>|I<--osimage>] is specified or nodetype.provmethod=I. =item B<-p>|B<--profile> -Specifies what profile should be used of the operating system. If not specified the tables are used as is. Will be ignored if [I<-O>|I<--osimage>] is specified or nodetype.provmethod=I. +Specifies what profile should be used of the operating system. If not specified the current node profile setting is used. Will be ignored if [I<-O>|I<--osimage>] is specified or nodetype.provmethod=I. =item B<-a>|B<--arch> -Specifies what architecture of the OS to provision. Typically this is unneeded, but if provisioning betweer x86_64 and x86 frequently, this may be a useful flag. Will be ignored if [I<-O>|I<--osimage>] is specified or nodetype.provmethod=I. +Specifies what architecture of the OS to provision. Typically this is unneeded, but if provisioning between x86_64 and x86 frequently, this may be a useful flag. Will be ignored if [I<-O>|I<--osimage>] is specified or nodetype.provmethod=I. =item B<-O>|B<--osimage> @@ -37,7 +47,7 @@ Specifies the osimage to provision. =item B<-c>|B<--console> -Requests that rinstall become rcons once the provision commences. This will only work if there is only one node in the noderange. See L for consoles on multiple systems. +Requests that rinstall runs rcons once the provision starts. This will only work if there is only one node in the noderange. See L for starting nsoles on multiple nodes. =back @@ -46,17 +56,17 @@ Requests that rinstall become rcons once the provision commences. This will onl B I -Provison nodes 1 through 20, using configuration as is from tables. +Provison nodes 1 through 20, using their current configuration. -B -o rhels5.1 -p compute I +B I -o rhels5.1 -p compute Provision nodes 1 through 20, forcing rhels5.1 and compute profile. -B -O rhels6.4-ppc64-netboot-compute I +B I -O rhels6.4-ppc64-netboot-compute Provision nodes 1 through 20 with the osimage rhels6.4-ppc64-netboot-compute. -B -c I +B I -c Provisoon node1 and start a console to monitor the process. diff --git a/xCAT-client/pods/man8/winstall.8.pod b/xCAT-client/pods/man8/winstall.8.pod index 464b22de2..303256b18 100644 --- a/xCAT-client/pods/man8/winstall.8.pod +++ b/xCAT-client/pods/man8/winstall.8.pod @@ -1,53 +1,64 @@ =head1 Name -B - Begin OS provision on a noderange and display in wcons +B - Begin OS provision on a noderange =head1 B -B [I<-o>|I<--osver>] [I<-p>|I<--profile>] [I<-a>|I<--arch>] [I<-O>|I<--osimage>] [I] +B [I<-o>|I<--osver>] [I<-p>|I<--profile>] [I<-a>|I<--arch>] [I] + +B [I<-O>|I<--osimage>] [I] =head1 B -B is a convience command that will change tables as requested for operating system version, profile, and architecture, call nodeset to modify the network boot configuration, and rpower to begin a boot cycle. +B is a convenience tool that will change attributes as requested for operating system version, profile, and architecture, call B to modify the network boot configuration, call B net to set the next boot over network (only support nodes +with "nodetype.mgt=ipmi", for other nodes, make sure the correct boot order has been set before B), and B to begin a boot cycle. -If [I<-O>|I<--osimage>] is specified or nodetype.provmethod=I is set, provision the noderange with the osimage specified/configured, ignore the table change options if specified +If [I<-O>|I<--osimage>] is specified or nodetype.provmethod=I is set, provision the noderange with the osimage specified/configured, ignore the table change options if specified. -It will then commence a wcons command to the noderange for monitoring. +It will then run wcons on the nodes. =head1 B =over 7 +=item B<-h>|B<--help> + +Display usage message. + +=item B<-v>|B<--version> + +Display version. + =item B<-o>|B<--osver> -Specifies which os version to provision. If unspecified, the current table values are used. Will be ignored if [I<-O>|I<--osimage>] is specified or nodetype.provmethod=I. +Specifies which os version to provision. If unspecified, the current node os setting is used. Will be ignored if [I<-O>|I<--osimage>] is specified or nodetype.provmethod=I. =item B<-p>|B<--profile> -Specifies what profile should be used of the operating system. If not specified the tables are used as is. Will be ignored if [I<-O>|I<--osimage>] is specified or nodetype.provmethod=I. +Specifies what profile should be used of the operating system. If not specified the current node profile setting is used. Will be ignored if [I<-O>|I<--osimage>] is specified or nodetype.provmethod=I. =item B<-a>|B<--arch> -Specifies what architecture of the OS to provision. Typically this is unneeded, but if provisioning betweer x86_64 and x86 frequently, this may be a useful flag. Will be ignored if [I<-O>|I<--osimage>] is specified or nodetype.provmethod=I. +Specifies what architecture of the OS to provision. Typically this is unneeded, but if provisioning between x86_64 and x86 frequently, this may be a useful flag. Will be ignored if [I<-O>|I<--osimage>] is specified or nodetype.provmethod=I. =item B<-O>|B<--osimage> -Specifies the osimage to provision. +Specifies the osimage to provision. =back =head1 B -B I +B I -Provison nodes 1 through 20, using configuration as is from tables. +Provison nodes 1 through 20, using their current configuration. -B -o rhels5.1 -p compute I +B I -o rhels5.1 -p compute Provision nodes 1 through 20, forcing rhels5.1 and compute profile. -B -O rhels6.4-ppc64-netboot-compute I +B I -O rhels6.4-ppc64-netboot-compute Provision nodes 1 through 20 with the osimage rhels6.4-ppc64-netboot-compute. From 417606b01a84d146fdccaf934115493d491459bc Mon Sep 17 00:00:00 2001 From: Bruce Potter Date: Tue, 24 Jun 2014 16:39:05 -0400 Subject: [PATCH 26/26] adapter xcat softlayer rpm for 2.8.5 --- xCAT-SoftLayer/postscripts/configbond | 2 +- xCAT-SoftLayer/si-post-install/20all.makeinitrd | 12 +++++++----- xCAT-SoftLayer/xCAT-SoftLayer.spec | 7 ++++++- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/xCAT-SoftLayer/postscripts/configbond b/xCAT-SoftLayer/postscripts/configbond index 537ed5df4..5d43c3a8a 100755 --- a/xCAT-SoftLayer/postscripts/configbond +++ b/xCAT-SoftLayer/postscripts/configbond @@ -19,7 +19,7 @@ if (scalar(@ARGV) < 2 || scalar(@ARGV) > 3) { my $bond = shift(@ARGV); my $nic = $ARGV[0]; my @devs; -push(@devs,@ARGV); +foreach my $a (@ARGV) { push(@devs,split('@',$a)); } # support the new syntax in the xcat configbond postscript my $nicips = $ENV{NICIPS}; my $nicnetworks = $ENV{NICNETWORKS}; my $net_cnt = $ENV{NETWORKS_LINES}; diff --git a/xCAT-SoftLayer/si-post-install/20all.makeinitrd b/xCAT-SoftLayer/si-post-install/20all.makeinitrd index 761890045..c4a33ddc9 100755 --- a/xCAT-SoftLayer/si-post-install/20all.makeinitrd +++ b/xCAT-SoftLayer/si-post-install/20all.makeinitrd @@ -1,4 +1,5 @@ #!/bin/bash +#Used only by sysclone # This SI post-install script is needed because the initrd that autoyast/kickstart/ubuntu builds when installing # sles/rh/ubuntu on the golden node may not have the drivers when that initrd runs on the node that is @@ -9,10 +10,11 @@ # And do whatever is necessary on ubuntu. if [[ -f /sbin/dracut ]]; then - #todo: implement rh case using dracut - echo "Note: not regenerating the initrd, because dracut is not supported by this node yet." + # redhat/centos + echo "Running dracut to regenerate the initrd with the drivers needed by this node:" + dracut --force else - # suse/sles - echo "Running mkinitrd to regenerate the initrd with the drivers needed by this node:" - mkinitrd + # suse/sles + echo "Running mkinitrd to regenerate the initrd with the drivers needed by this node:" + mkinitrd fi diff --git a/xCAT-SoftLayer/xCAT-SoftLayer.spec b/xCAT-SoftLayer/xCAT-SoftLayer.spec index 7ee7e06d1..c5886c787 100644 --- a/xCAT-SoftLayer/xCAT-SoftLayer.spec +++ b/xCAT-SoftLayer/xCAT-SoftLayer.spec @@ -84,4 +84,9 @@ rm -rf $RPM_BUILD_ROOT %post # We are shipping the postscripts in a sysclone dir and then copying them to /install/postscripts here, # because we want to allow base xcat to eventually ship them and not conflict on the file name/path -cp -f /%{prefix}/share/xcat/sysclone/postscripts/* /install/postscripts +# But base xcat now has a newer/better configbond written in bash, so if that is there do not overwrite it. +head /install/postscripts/configbond | grep -q -E '^#! */bin/bash' +if [[ $? != 0 ]]; then + # the new configbond from xcat 2.8.5 is not there, so copy ours + cp -f /%{prefix}/share/xcat/sysclone/postscripts/* /install/postscripts +fi