2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-05-30 09:36:41 +00:00

Merge pull request #3547 from robin2008/xcatshowsvr

Fix 3474, [Usability] The nodeset output cannot tell where the message it coming from
This commit is contained in:
chenglch 2017-08-02 17:09:51 +08:00 committed by GitHub
commit 192ce780bc
8 changed files with 118 additions and 28 deletions

View File

@ -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.

View File

@ -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

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -4,7 +4,7 @@ B<nodeset> - set the boot state for a noderange
=head1 B<Synopsis>
B<nodeset> I<noderange> [B<boot> | B<stat> [B<-a>]| B<offline> | B<runcmd=bmcsetup> | B<osimage>[=I<imagename>] | B<shell> | B<shutdown>]
B<nodeset> I<noderange> [B<boot> | B<stat> [B<-a>]| B<offline> | B<runcmd=bmcsetup> | B<osimage>[=I<imagename>] | B<shell> | B<shutdown>] [B<-V>|B<--verbose>]
B<nodeset> I<noderange> B<osimage>[=I<imagename>] [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<nodeset> will manipulate the boot configuration files of yaboot and pxelinux.0.
B<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 L<site(5)|site.5>).
B<nodeset> for petitboot makes changes to /tftpboot/petitboot/{node name}
B<nodeset> for xnba makes changes to /tftpboot/xcat/xnba/nodes/{node name}
B<nodeset> for grub2 makes changes to /tftpboot/boot/grub2/{node name}
B<nodeset> for pxe makes changes to /tftpboot/pxelinux.cfg/{node hex ip}
B<nodeset> for yaboot makes changes to /tftpboot/etc/{node hex ip}
@ -34,6 +40,8 @@ B<nodeset> only sets the next boot state, but does not reboot.
B<nodeset> is called by B<rinstall> and B<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, B<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 B<prescripts>. They should be copied to /install/prescripts directory. A table called I<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 I<prescripts> table. The scripts to be run at the end of the nodeset command are stored in the 'end' column of I<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 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<number> 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<runcmd> and B<runimage> to power off the node after the performing of operations.
=item B<-V>|B<--verbose>
Verbose mode.
=item B<-h>|B<--help>
Print help.

View File

@ -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;