From 003152611209f55383d84a5a99093bb1acf25328 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Thu, 24 Mar 2022 14:32:36 -0400 Subject: [PATCH 1/3] Allow SLES15 node on Power to reboot in standby mode --- xCAT-server/lib/xcat/plugins/grub2.pm | 8 ++++++-- .../installation/reg_linux_diskfull_installation_flat | 9 ++++++--- .../reg_linux_diskfull_installation_hierarchy | 9 ++++++--- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/grub2.pm b/xCAT-server/lib/xcat/plugins/grub2.pm index f9c133acd..2dcd5ea2f 100644 --- a/xCAT-server/lib/xcat/plugins/grub2.pm +++ b/xCAT-server/lib/xcat/plugins/grub2.pm @@ -100,7 +100,8 @@ sub setstate { my $tftpdir = shift; my %nrhash = %{ shift() }; my $linuximghash = shift(); - my $nodearch = shift; + my $nodearch = shift; + my $nodeos = shift; my $kern = $bphash{$node}->[0]; #$bptab->getNodeAttribs($node,['kernel','initrd','kcmdline']); if ($kern->{kcmdline} =~ /!myipfn!/) { my $ipfn; @@ -284,6 +285,8 @@ sub setstate { chdir("$bootloader_root"); if ($cref->{currstate} eq "offline" or $cref->{currstate} eq "boot") { unlink("grub2-$node"); + } elsif ($cref->{currstate} eq "standby" and $nodeos =~ /^sle15/i) { + unlink("grub2-$node"); #Make sure SLES15 can still boot from disk in "standby" state } elsif (! -e "grub2-$node") { symlink("grub2." . $nodearch, "grub2-$node"); } @@ -751,13 +754,14 @@ sub process_request { if ($args[0]) { # Send it on to the destiny plugin, then setstate my $ent = $typehash->{$_}->[0]; my $nodearch = $ent->{'arch'}; + my $nodeos = $ent->{'os'}; my $osimgname = $ent->{'provmethod'}; my $linuximghash = undef; unless ($osimgname =~ /^(install|netboot|statelite)$/) { $linuximghash = $linuximgtab->getAttribs({ imagename => $osimgname }, 'boottarget', 'addkcmdline'); } - ($rc, $errstr) = setstate($_, \%bphash, $chainhash, $machash, $tftpdir, $nrhash, $linuximghash, $nodearch); + ($rc, $errstr) = setstate($_, \%bphash, $chainhash, $machash, $tftpdir, $nrhash, $linuximghash, $nodearch, $nodeos); if ($rc) { $response{node}->[0]->{errorcode}->[0] = $rc; $response{node}->[0]->{error}->[0] = $errstr; diff --git a/xCAT-test/autotest/testcase/installation/reg_linux_diskfull_installation_flat b/xCAT-test/autotest/testcase/installation/reg_linux_diskfull_installation_flat index 4681fcb84..5af24a21c 100644 --- a/xCAT-test/autotest/testcase/installation/reg_linux_diskfull_installation_flat +++ b/xCAT-test/autotest/testcase/installation/reg_linux_diskfull_installation_flat @@ -71,12 +71,15 @@ cmd:lsdef -l $$CN cmd:ping $$CN -c 3 check:rc==0 check:output=~64 bytes from $$CN -# Check node ends up in boot state -cmd:lsdef $$CN -i currstate -c -check:output==boot cmd:xdsh $$CN "cat /var/log/xcat/xcat.log" cmd:xdsh $$CN "cat /test.synclist" check:rc==0 +# Check node can be rebooted from disk +cmd:xdsh $$CN shutdown -r now +cmd:sleep 300 +cmd:xdsh $$CN uptime +check:rc==0 +check:output=~up cmd:if [ -x /usr/bin/goconserver ]; then makegocons -d $$CN; else makeconservercf -d $$CN; fi cmd:if [[ -f /test.synclist.bak ]] ;then mv -f /test.synclist.bak /tmp/test.synclist;else rm -rf /test.synclist;fi cmd:chdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-compute synclists= diff --git a/xCAT-test/autotest/testcase/installation/reg_linux_diskfull_installation_hierarchy b/xCAT-test/autotest/testcase/installation/reg_linux_diskfull_installation_hierarchy index f82d40082..5a60ea588 100644 --- a/xCAT-test/autotest/testcase/installation/reg_linux_diskfull_installation_hierarchy +++ b/xCAT-test/autotest/testcase/installation/reg_linux_diskfull_installation_hierarchy @@ -107,7 +107,10 @@ check:rc==0 cmd:sitetz=`lsdef -t site -i timezone | awk -F= '{print $2}'`;nodetz=`xdsh $$CN "timedatectl | grep 'Time zone'" | awk -F: '{print $3}' | awk '{print $1}'`; test $sitetz = $nodetz check:rc==0 -# Check node ends up in boot state -cmd:lsdef $$CN -i currstate -c -check:output==boot +# Check node can be rebooted from disk +cmd:xdsh $$CN shutdown -r now +cmd:sleep 300 +cmd:xdsh $$CN uptime +check:rc==0 +check:output=~up end From acf7dac1aa5fdcf76ffa7ebd4a8c8872125cafba Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Mon, 4 Apr 2022 16:34:26 -0400 Subject: [PATCH 2/3] For SLES15 or higher --- xCAT-server/lib/xcat/plugins/grub2.pm | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/grub2.pm b/xCAT-server/lib/xcat/plugins/grub2.pm index 2dcd5ea2f..c98679b05 100644 --- a/xCAT-server/lib/xcat/plugins/grub2.pm +++ b/xCAT-server/lib/xcat/plugins/grub2.pm @@ -285,8 +285,15 @@ sub setstate { chdir("$bootloader_root"); if ($cref->{currstate} eq "offline" or $cref->{currstate} eq "boot") { unlink("grub2-$node"); - } elsif ($cref->{currstate} eq "standby" and $nodeos =~ /^sle15/i) { - unlink("grub2-$node"); #Make sure SLES15 can still boot from disk in "standby" state + } elsif ($cref->{currstate} eq "standby" and $nodeos =~ /^sle/i) { + my $os_version = $nodeos; + $os_version =~ s/sles//i; # Strip sles if there + $os_version =~ s/sle//i; # String sle if there + if ($os_version ge "15") { + # Make sure for SLES15 or higher can still boot + # from disk in "standby" state + unlink("grub2-$node"); + } } elsif (! -e "grub2-$node") { symlink("grub2." . $nodearch, "grub2-$node"); } From e7b43c6edd5e3254d2bf7e6749148ec0d1dcb514 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Mon, 4 Apr 2022 17:01:48 -0400 Subject: [PATCH 3/3] Improve version test operator --- xCAT-server/lib/xcat/plugins/grub2.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-server/lib/xcat/plugins/grub2.pm b/xCAT-server/lib/xcat/plugins/grub2.pm index c98679b05..b1e5becdc 100644 --- a/xCAT-server/lib/xcat/plugins/grub2.pm +++ b/xCAT-server/lib/xcat/plugins/grub2.pm @@ -289,7 +289,7 @@ sub setstate { my $os_version = $nodeos; $os_version =~ s/sles//i; # Strip sles if there $os_version =~ s/sle//i; # String sle if there - if ($os_version ge "15") { + if ($os_version >= "15") { # Make sure for SLES15 or higher can still boot # from disk in "standby" state unlink("grub2-$node");