2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-05-22 11:42:05 +00:00

Log Number of Nodes for xCAT command to command.log (#5729)

* Log Number of Nodes for chdef/mkdef/rmdef/lsdef/nodels command to
command.log

* Create a new tag for reponse object
This commit is contained in:
cxhong 2018-10-29 05:12:20 -04:00 committed by Bin Xu
parent 6c77456fed
commit fe33d7d98f
3 changed files with 25 additions and 1 deletions

View File

@ -2080,6 +2080,7 @@ sub defmk
$rsp->{data}->[0] = "$nodenum object definitions have been created or modified.";
if ($nodenum > 0) {
# Some objects were created, report as success
$rsp->{numofnodes}->[0] = $nodenum;
xCAT::MsgUtils->message("I", $rsp, $::callback);
}
else {
@ -2962,6 +2963,7 @@ sub defch
if ($nodenum) {
$rsp->{data}->[0] = "$nodenum object definitions have been created or modified.";
$rsp->{numofnodes}->[0] = $nodenum;
} else {
$rsp->{data}->[0] = "No object definitions have been created or modified.";
}
@ -4155,6 +4157,7 @@ sub defls
# Display the definition of objects
if (defined($rsp_info->{data}) && scalar(@{ $rsp_info->{data} }) > 0) {
$rsp_info->{numofnodes}->[0] = $numobjects;
xCAT::MsgUtils->message("I", $rsp_info, $::callback);
}
@ -4522,6 +4525,7 @@ sub defrm
my $rsp;
my $nodenum = scalar(keys %objhash);
$rsp->{data}->[0] = "$nodenum object definitions have been removed.";
$rsp->{numofnodes}->[0] = $nodenum;
xCAT::MsgUtils->message("I", $rsp, $::callback);
}

View File

@ -1882,6 +1882,8 @@ sub nodels
my $VERSION;
my $HELP;
my $nodenum;
my $nodels_usage = sub
{
my $exitcode = shift @_;
@ -2154,6 +2156,7 @@ sub nodels
}
}
$callback->($rsp);
$nodenum = scalar (@$nodes);
}
else
{
@ -2205,8 +2208,12 @@ sub nodels
#}
}
$nodenum = scalar (@nodes);
}
}
my $rsp_info;
$rsp_info->{numofnodes}->[0] = $nodenum;
$callback->($rsp_info);
return 0;
}
@ -2328,7 +2335,7 @@ sub tabch {
{
my $tab = xCAT::Table->new($_, -create => 1, -autocommit => 0);
unless ($tab) {
my %rsp;
my %rsp;
$rsp{data}->[0] = "Table $_ does not exist.";
$rsp{errorcode}->[0] = 1;
$callback->(\%rsp);

View File

@ -30,6 +30,8 @@ my $udpctl;
my $pid_UDP;
my $pid_MON;
my $numofnodes=0;
# ----used for command log start---------
my $cmdlog_svrpid;
@ -2165,6 +2167,7 @@ sub plugin_command {
}
}
}
}
my $dispatch_parentfd;
@ -2661,6 +2664,9 @@ sub send_response {
if ( (ref($rsp) eq 'ARRAY') && scalar(@$rsp) > 0 ) {
foreach (@$rsp) {
$_->{xcatdsource}->[0] = $MYXCATSERVER unless ($_->{xcatdsource});
if ($_->{numofnodes}) {
$numofnodes = $_->{numofnodes}->[0];
}
}
}
}
@ -2803,6 +2809,12 @@ sub service_connection {
if ($enable_perf) {
xCAT::MsgUtils->perf_log_process('immediate', $req);
}
if (exists($req->{noderange}) && defined($req->{noderange}->[0])) {
my @nnodes = xCAT::NodeRange::noderange($req->{noderange}->[0]);
$numofnodes = (scalar(@nnodes));
}
# ----used for command log start----------
$cmdlog_starttime = time();
my ($sec, $min, $hour, $mday, $mon, $year) = localtime($cmdlog_starttime);
@ -3018,6 +3030,7 @@ sub service_connection {
}
# ----used for command log start-------
$cmdlog_alllog .= "[NumberNodes] $numofnodes \n";
my $reqhandletime = sprintf("%.3f", time()-$cmdlog_starttime);
$cmdlog_alllog .= "[ElapsedTime] $reqhandletime s\n";
cmdlog_submitlog();