diff --git a/docs/source/guides/admin-guides/references/man8/nodeset.8.rst b/docs/source/guides/admin-guides/references/man8/nodeset.8.rst index 50d12e87c..aeb8275c6 100644 --- a/docs/source/guides/admin-guides/references/man8/nodeset.8.rst +++ b/docs/source/guides/admin-guides/references/man8/nodeset.8.rst @@ -19,7 +19,7 @@ Name **************** -\ **nodeset**\ \ *noderange*\ [\ **boot**\ | \ **stat**\ [\ **-a**\ ]| \ **offline**\ | \ **runcmd=bmcsetup**\ | \ **osimage**\ [=\ *imagename*\ ] | \ **shell**\ | \ **shutdown**\ ] +\ **nodeset**\ \ *noderange*\ [\ **boot**\ | \ **stat**\ [\ **-a**\ ]| \ **offline**\ | \ **runcmd=bmcsetup**\ | \ **osimage**\ [=\ *imagename*\ ] | \ **shell**\ | \ **shutdown**\ ] [\ **-V | -**\ **-verbose**\ ] \ **nodeset**\ \ *noderange*\ \ **osimage**\ [=\ *imagename*\ ] [\ **-**\ **-noupdateinitrd**\ ] [\ **-**\ **-ignorekernelchk**\ ] @@ -40,10 +40,16 @@ changing the network boot files. Each xCAT node always boots from the network and downloads a boot file with instructions on what action to take next. -\ **nodeset**\ will manipulate the boot configuration files of yaboot and pxelinux.0. +\ **nodeset**\ will manipulate the boot configuration files of xnba, grub2, petitboot, yaboot and pxelinux.0. Assume that /tftpboot is the root for tftpd (set in site(5)|site.5). +\ **nodeset**\ for petitboot makes changes to /tftpboot/petitboot/{node name} + +\ **nodeset**\ for xnba makes changes to /tftpboot/xcat/xnba/nodes/{node name} + +\ **nodeset**\ for grub2 makes changes to /tftpboot/boot/grub2/{node name} + \ **nodeset**\ for pxe makes changes to /tftpboot/pxelinux.cfg/{node hex ip} \ **nodeset**\ for yaboot makes changes to /tftpboot/etc/{node hex ip} @@ -53,6 +59,8 @@ Assume that /tftpboot is the root for tftpd (set in site(5)|site.5). \ **nodeset**\ is called by \ **rinstall**\ and \ **winstall**\ and is also called by the installation process remotely to set the boot state back to "boot". +In a hierarchical cluster managed by service nodes, \ **nodeset**\ command is used to make sure compute node states are consistent on service and management nodes. When errors are reported, run the command with verbose mode. And the command will display additional service node information, which might be useful in identifying the problem. + A user can supply their own scripts to be run on the mn or on the service node (if a hierarchical cluster) for a node when the nodeset command is run. Such scripts are called \ **prescripts**\ . They should be copied to /install/prescripts directory. A table called \ *prescripts*\ is used to specify the scripts and their associated actions. The scripts to be run at the beginning of the nodeset command are stored in the 'begin' column of \ *prescripts*\ table. The scripts to be run at the end of the nodeset command are stored in the 'end' column of \ *prescripts*\ table. You can run 'tabdump -d prescripts' command for details. The following two environment variables will be passed to each script: NODES contains all the names of the nodes that need to run the script for and ACTION contains the current nodeset action. If \ *#xCAT setting:MAX_INSTANCE=number*\ is specified in the script, the script will get invoked for each node in parallel, but no more than \ *number*\ of instances will be invoked at a time. If it is not specified, the script will be invoked once for all the nodes. @@ -125,6 +133,12 @@ A user can supply their own scripts to be run on the mn or on the service node ( +\ **-V | -**\ **-verbose**\ + + Verbose mode. + + + \ **-h | -**\ **-help**\ Print help. diff --git a/perl-xCAT/xCAT/Client.pm b/perl-xCAT/xCAT/Client.pm index d7df0a9fc..ae0d19d98 100644 --- a/perl-xCAT/xCAT/Client.pm +++ b/perl-xCAT/xCAT/Client.pm @@ -1129,6 +1129,13 @@ sub handle_response { return; } + my $msgsource; + if ($ENV{'XCATSHOWSVR'}) { + unless ($rsp->{NoSvrPrefix}) { # some plugins could disable the prefix forcely by seting the flag in response. + $msgsource = $rsp->{xcatdsource}->[0] if ($rsp->{xcatdsource}); + } + } + #print "in handle_response\n"; # Handle errors if (defined($rsp->{errorcode})) { @@ -1141,24 +1148,23 @@ sub handle_response { $xCAT::Client::EXITCODE |= $rsp->{errorcode}; } # assume it is a non-reference scalar } + if ($rsp->{error}) { #print "printing error\n"; if (ref($rsp->{error}) eq 'ARRAY') { foreach my $text (@{ $rsp->{error} }) { - if ($rsp->{NoErrorPrefix}) { - print STDERR "$text\n"; - } else { - print STDERR "Error: $text\n"; - } + my $desc = "$text"; + $desc = "[$msgsource]: $desc" if ($msgsource && $desc); + $desc = "Error: $desc" unless ($rsp->{NoErrorPrefix}); + print STDERR "$desc\n"; } } else { - if ($rsp->{NoErrorPrefix}) { - print STDERR ($rsp->{error} . "\n"); - } else { - print STDERR ("Error: " . $rsp->{error} . "\n"); - } + my $desc = $rsp->{error}; + $desc = "[$msgsource]: $desc" if ($msgsource && $desc); + $desc = "Error: $desc" unless ($rsp->{NoErrorPrefix}); + print STDERR "$desc\n"; } } if ($rsp->{warning}) { @@ -1166,19 +1172,17 @@ sub handle_response { #print "printing warning\n"; if (ref($rsp->{warning}) eq 'ARRAY') { foreach my $text (@{ $rsp->{warning} }) { - if ($rsp->{NoWarnPrefix}) { - print STDERR "$text\n"; - } else { - print STDERR "Warning: $text\n"; - } + my $desc = "$text"; + $desc = "[$msgsource]: $desc" if ($msgsource && $desc); + $desc = "Warning: $desc" unless ($rsp->{NoWarnPrefix}); + print STDERR "$desc\n"; } } else { - if ($rsp->{NoWarnPrefix}) { - print STDERR ($rsp->{warning} . "\n"); - } else { - print STDERR ("Warning: " . $rsp->{warning} . "\n"); - } + my $desc = $rsp->{warning}; + $desc = "[$msgsource]: $desc" if ($msgsource && $desc); + $desc = "Warning: $desc" unless ($rsp->{NoWarnPrefix}); + print STDERR "$desc\n"; } } if ($rsp->{info}) { @@ -1186,11 +1190,15 @@ sub handle_response { #print "printing info\n"; if (ref($rsp->{info}) eq 'ARRAY') { foreach my $text (@{ $rsp->{info} }) { - print "$text\n"; + my $desc = "$text"; + $desc = "[$msgsource]: $desc" if ($msgsource && $desc); + print "$desc\n"; } } else { - print($rsp->{info} . "\n"); + my $desc = $rsp->{info}; + $desc = "[$msgsource]: $desc" if ($msgsource && $desc); + print "$desc\n"; } } @@ -1224,6 +1232,11 @@ sub handle_response { } else { $desc = $node->{name}; } + if ($desc) { + $desc = "$desc: [$msgsource]" if ($msgsource); + } else { + $desc = "[$msgsource]" if ($msgsource); + } if ($node->{errorcode}) { if (ref($node->{errorcode}) eq 'ARRAY') { foreach my $ecode (@{ $node->{errorcode} }) { @@ -1274,7 +1287,7 @@ sub handle_response { if ($node->{base64_data}) { $desc = $desc . ": " . decode_base64($node->{base64_data}->[0]); } - if ($desc) { + if ($desc && $desc ne "[$msgsource]") { if ($errflg == 1) { print STDERR ("$desc\n"); } else { @@ -1306,7 +1319,10 @@ sub handle_response { } } } - if ($desc) { print "$desc\n"; } + if ($desc) { + $desc = "[$msgsource]: $desc" if ($msgsource); + print "$desc\n"; + } } } } # end of handle_response diff --git a/xCAT-client/bin/rinstall b/xCAT-client/bin/rinstall index 789222ba3..d23b65f94 100755 --- a/xCAT-client/bin/rinstall +++ b/xCAT-client/bin/rinstall @@ -79,6 +79,14 @@ if($bname eq "rinstall" and $startconsole==1 and scalar @noderange!=1 ){ exit 1; } +# Allow to print server information when -V/--verbose +foreach (reverse(@ARGV)) { + if ($_ eq '-V' || $_ eq '--verbose') { + $ENV{'XCATSHOWSVR'} = 1; + last; + } +} + # 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 diff --git a/xCAT-client/bin/updatenode b/xCAT-client/bin/updatenode index 17e52db8e..ebfe392e2 100755 --- a/xCAT-client/bin/updatenode +++ b/xCAT-client/bin/updatenode @@ -200,5 +200,13 @@ foreach (keys %ENV) { } } +# Allow to print server information when -V/--verbose +foreach (reverse(@ARGV)) { + if ($_ eq '-V' || $_ eq '--verbose') { + $ENV{'XCATSHOWSVR'} = 1; + last; + } +} + xCAT::Client::submit_request($cmdref, \&xCAT::Client::handle_response); exit $xCAT::Client::EXITCODE; diff --git a/xCAT-client/bin/xcatclient b/xCAT-client/bin/xcatclient index 83a918941..7f68579c9 100755 --- a/xCAT-client/bin/xcatclient +++ b/xCAT-client/bin/xcatclient @@ -102,5 +102,13 @@ foreach (keys %ENV) { } } +# Allow to print server information when -V +foreach (reverse(@ARGV)) { + if ($_ eq '-V') { + $ENV{'XCATSHOWSVR'} = 1; + last; + } +} + xCAT::Client::submit_request($cmdref, \&xCAT::Client::handle_response); exit $xCAT::Client::EXITCODE; diff --git a/xCAT-client/bin/xcatclientnnr b/xCAT-client/bin/xcatclientnnr index e33b80408..566dec3b2 100755 --- a/xCAT-client/bin/xcatclientnnr +++ b/xCAT-client/bin/xcatclientnnr @@ -51,6 +51,14 @@ foreach (keys %ENV) { } } +# Allow to print server information when -V/--verbose +foreach (reverse(@ARGV)) { + if ($_ eq '-V' || $_ eq '--verbose') { + $ENV{'XCATSHOWSVR'} = 1; + last; + } +} + xCAT::Client::submit_request($cmdref, \&xCAT::Client::handle_response); exit $xCAT::Client::EXITCODE; diff --git a/xCAT-client/pods/man8/nodeset.8.pod b/xCAT-client/pods/man8/nodeset.8.pod index 2fd8bc957..bf6692de5 100644 --- a/xCAT-client/pods/man8/nodeset.8.pod +++ b/xCAT-client/pods/man8/nodeset.8.pod @@ -4,7 +4,7 @@ B - set the boot state for a noderange =head1 B -B I [B | B [B<-a>]| B | B | B[=I] | B | B] +B I [B | B [B<-a>]| B | B | B[=I] | B | B] [B<-V>|B<--verbose>] B I B[=I] [B<--noupdateinitrd>] [B<--ignorekernelchk>] @@ -21,10 +21,16 @@ changing the network boot files. Each xCAT node always boots from the network and downloads a boot file with instructions on what action to take next. -B will manipulate the boot configuration files of yaboot and pxelinux.0. +B will manipulate the boot configuration files of xnba, grub2, petitboot, yaboot and pxelinux.0. Assume that /tftpboot is the root for tftpd (set in L). +B for petitboot makes changes to /tftpboot/petitboot/{node name} + +B for xnba makes changes to /tftpboot/xcat/xnba/nodes/{node name} + +B for grub2 makes changes to /tftpboot/boot/grub2/{node name} + B for pxe makes changes to /tftpboot/pxelinux.cfg/{node hex ip} B for yaboot makes changes to /tftpboot/etc/{node hex ip} @@ -34,6 +40,8 @@ B only sets the next boot state, but does not reboot. B is called by B and B and is also called by the installation process remotely to set the boot state back to "boot". +In a hierarchical cluster managed by service nodes, B command is used to make sure compute node states are consistent on service and management nodes. When errors are reported, run the command with verbose mode. And the command will display additional service node information, which might be useful in identifying the problem. + A user can supply their own scripts to be run on the mn or on the service node (if a hierarchical cluster) for a node when the nodeset command is run. Such scripts are called B. They should be copied to /install/prescripts directory. A table called I is used to specify the scripts and their associated actions. The scripts to be run at the beginning of the nodeset command are stored in the 'begin' column of I table. The scripts to be run at the end of the nodeset command are stored in the 'end' column of I table. You can run 'tabdump -d prescripts' command for details. The following two environment variables will be passed to each script: NODES contains all the names of the nodes that need to run the script for and ACTION contains the current nodeset action. If I<#xCAT setting:MAX_INSTANCE=number> is specified in the script, the script will get invoked for each node in parallel, but no more than I of instances will be invoked at a time. If it is not specified, the script will be invoked once for all the nodes. @@ -84,6 +92,10 @@ The node will also be able to be sshed into and have utilities such as wget, tft To make the node to get into power off status. This status only can be used after B and B to power off the node after the performing of operations. +=item B<-V>|B<--verbose> + +Verbose mode. + =item B<-h>|B<--help> Print help. diff --git a/xCAT-server/sbin/xcatd b/xCAT-server/sbin/xcatd index cc8303261..dd34ccbed 100755 --- a/xCAT-server/sbin/xcatd +++ b/xCAT-server/sbin/xcatd @@ -940,6 +940,9 @@ unless ($foreground) { daemonize; } +# Cache the hostname, restart xcatd if hostname is changed after xcatd running +my $MYXCATSERVER = Sys::Hostname::hostname; + $dbmaster = xCAT::Table::init_dbworker; if ($enable_perf) { xCAT::MsgUtils->perf_log_process( "db", undef, "dbprocess", $dbmaster ); @@ -2585,8 +2588,21 @@ sub send_response { if ($encode eq "xml") { my $xml; if ($response->{xcatresponse}) { # it's an aggregate, keeproot + if ($MYXCATSERVER) { + my $rsp = $response->{xcatresponse}; + if ( (ref($rsp) eq 'ARRAY') && scalar(@$rsp) > 0 ) { + foreach (@$rsp) { + $_->{xcatdsource}->[0] = $MYXCATSERVER unless ($_->{xcatdsource}); + } + } + } $xml = XMLout($response, KeyAttr => [], NoAttr => 1, KeepRoot => 1); } else { + if ($MYXCATSERVER) { + unless (exists($response->{serverdone})) { + $response->{xcatdsource}->[0] = $MYXCATSERVER; + } + } $xml = XMLout($response, RootName => 'xcatresponse', NoAttr => 1); } $xml =~ tr/\011-\177/?/c;