Fixed errors in the client/server communication for xdsh and db-cmds and MsgUtils

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@505 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
bp-sawyers 2008-02-18 15:57:25 +00:00
parent 7a8922ce92
commit aceb17bc7f
10 changed files with 395 additions and 667 deletions

View File

@ -484,22 +484,31 @@ sub build_response {
##########################################
sub handle_response {
my $rsp = shift;
#print "in handle_response\n";
# Handle errors
if ($rsp->{errorcode}) {
if (ref($rsp->{errorcode}) eq 'ARRAY') { foreach my $ecode (@{$rsp->{errorcode}}) { $xCAT::Client::EXITCODE |= $ecode; } }
else { $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}}) { print "Error: $text\n"; } }
else { print ("Error: ".$rsp->{error}."\n"); }
}
if ($rsp->{warning}) {
if (ref($rsp->{warning}) eq 'ARRAY') { print ("Warning: " . $rsp->{warning}->[0] . "\n"); }
#print "printing warning\n";
if (ref($rsp->{warning}) eq 'ARRAY') { foreach my $text (@{$rsp->{warning}}) { print "Warning: $text\n"; } }
else { print ("Warning: ".$rsp->{warning}."\n"); }
}
if ($rsp->{error}) {
if (ref($rsp->{error}) eq 'ARRAY') { print ("Error: " . $rsp->{error}->[0] . "\n"); }
else { print ("Error: ".$rsp->{error}."\n"); }
if ($rsp->{info}) {
#print "printing info\n";
if (ref($rsp->{info}) eq 'ARRAY') { foreach my $text (@{$rsp->{info}}) { print "$text\n"; } }
else { print ($rsp->{info}."\n"); }
}
# Handle {node} structure
if ($rsp->{node}) {
if (scalar @{$rsp->{node}}) {
#print "printing node\n";
my $nodes=($rsp->{node});
my $node;
foreach $node (@$nodes) {
@ -527,7 +536,8 @@ sub handle_response {
}
# Handle {data} structure with no nodes
if ($rsp->{data}) {
if (scalar @{$rsp->{data}}) {
#print "printing data\n";
my $data=($rsp->{data});
my $data_entry;
foreach $data_entry (@$data) {

File diff suppressed because it is too large Load Diff

View File

@ -20,7 +20,7 @@ $::OK = 0;
=head2 Package Description
This program module file, supports the xcat messaging and logging
This program module file, supports the xcat messaging and logging
@ -41,43 +41,43 @@ This program module file, supports the xcat messaging and logging
#--------------------------------------------------------------------------------
=head1 Subroutines
=head1 Subroutines
=cut
=head3 message
Display a msg STDOUT,STDERR or return to callback function.
Display a msg STDOUT,STDERR or return to callback function.
If callback routine is provide, the message will be returned to the callback
routine.
If callback routime is not provide, the message is displayed to STDOUT or
STDERR.
Arguments:
The arguments of the message() function are:
If address of the callback is provided,
then the message will be returned either
then the message will be returned either
as data to the client's callback routine or to the
xcat daemon or Client.pm ( bypass) for display/logging.
See flags below.
See flags below.
If address of the callback is not provide, then
the message will be displayed to STDERR or STDOUT or
the message will be displayed to STDERR or STDOUT or
added to SYSLOG. See flags below.
For compatibility with existing code, the message routine will
move the data into the appropriate callback structure, if required.
See example below, if the input to the message routine
has the "data" structure filled in for an error message, then
the message routine will move the $rsp->{data}->[0] to
has the "data" structure filled in for an error message, then
the message routine will move the $rsp->{data}->[0] to
$rsp->{error}->[0]. This will allow xcatd/Client.pm will process
all but "data" messages.
The current client code should not have to change.
The current client code should not have to change.
my %rsp;
$rsp->{data}->[0] = "Job did not run. \n";
@ -86,41 +86,41 @@ This program module file, supports the xcat messaging and logging
Here the message routine will move $rsp->{data}->[0] to
$rsp->{error}->[0], to match the "E"message code.
Note the message
routine will only check for the data to either exist in
$rsp->{error}->[0] already, or to exist in $rsp->{data}->[0].
routine will only check for the data to either exist in
$rsp->{error}->[0] already, or to exist in $rsp->{data}->[0].
Here's the meaning of the 1st character, if a callback specified:
D - DATA this is returned to the client callback routine
E - error this is displayed/logged by daemon/Client.pm.
D - DATA this is returned to the client callback routine
E - error this is displayed/logged by daemon/Client.pm.
I - informational this is displayed/logged by daemon/Client.pm.
S - Message will be logged to syslog ( severe error)
S - Message will be logged to syslog ( severe error)
syslog facily (local4) and priority (err) will be used.
See /etc/syslog.conf file for the destination of the
messages.
Note S can be combined with other flags for example
SE logs message to syslog to also display the
message by daemon/ Client.pm.
message by daemon/ Client.pm.
V - verbose. This flag is not valid, the calling routine
should check for verbose mode before calling the message
routine and only use the I flag for the message.
If V flag is detected, it will be changed to an I flag.
W - warning this is displayed/logged by daemon/Client.pm.
If V flag is detected, it will be changed to an I flag.
W - warning this is displayed/logged by daemon/Client.pm.
Here's the meaning of the 1st character, if no callback specified:
D - DATA goes to STDOUT
D - DATA goes to STDOUT
E - error. This type of message will be sent to STDERR.
I - informational goes to STDOUT
S - Message will be logged to syslog ( severe error)
I - informational goes to STDOUT
S - Message will be logged to syslog ( severe error)
Note S can be combined with other flags for example
SE logs message to syslog and is sent to STDERR.
SE logs message to syslog and is sent to STDERR.
V - verbose. This flag is not valid, the calling routine
should check for verbose mode before calling the message
routine and only use the I flag for the message.
If V flag is detected, it will be changed to an I flag.
W - warning goes to STDOUT.
If V flag is detected, it will be changed to an I flag.
W - warning goes to STDOUT.
Returns:
none
@ -130,12 +130,12 @@ This program module file, supports the xcat messaging and logging
Example:
Use with no callback
Use with no callback
xCAT::MsgUtils->message('E', "Operation $value1 failed\n");
xCAT::MsgUtils->message('S', "Host $host not responding\n");
xCAT::MsgUtils->message('SI', "Host $host not responding\n");
Use with callback
Use with callback
my %rsp;
$rsp->{data}->[0] = "Job did not run. \n";
xCAT::MsgUtils->message("D", $rsp, $::CALLBACK);
@ -169,7 +169,7 @@ This program module file, supports the xcat messaging and logging
Comments:
Returns:
none
@ -188,6 +188,7 @@ sub message
my $sev = shift;
my $rsp = shift;
my $call_back = shift; # optional
my $exitcode = shift; # optional
# should be I, D, E, S, W
# or S(I, D, E, S, W)
@ -209,44 +210,36 @@ sub message
$sev = "SI";
}
# check that correct structure is filled in
# and move to correct structure. If the data is not in the
# Check that correct structure is filled in. If the data is not in the
# structure corresponding to the $sev, then look for it in "data"
if ($call_back)
{ # callback routine provided
if (($sev eq 'I') || ($sev eq 'SI'))
{
if (!($rsp->{info}->[0])) # no info data
{ # no error data
$rsp->{info}->[0] = $rsp->{data}->[0];
# $rsp->{data}->[0] = "";
#TODO: this is not really right for a couple reasons: 1) all the fields in the
# response structure are arrays, so can handle multiple lines of text. We
# should not just be check the 0th element. 2) a cmd may have both error
# text and data text. 3) this message() function should just take in a plain
# string and put it in the correct place based on the severity.
if ($call_back) { # callback routine provided
my $sevkey;
if ($sev =~ /I/) { $sevkey = 'info'; }
if ($sev =~ /W/) { $sevkey = 'warning'; }
if ($sev =~ /E/) {
$sevkey = 'error';
if (!defined($exitcode)) { $exitcode = 1; } # default to something non-zero
}
if (defined($sevkey)) {
if (!defined ($rsp->{$sevkey}) || !scalar(@{$rsp->{$sevkey}})) { # did not pass the text in in the severity-specific field
if (defined ($rsp->{data}) && scalar(@{$rsp->{data}})) {
push @{$rsp->{$sevkey}}, shift @{$rsp->{data}}; # assume they passed in the text in the data field instead
}
}
}
if (($sev eq 'E') || ($sev eq 'S') || ($sev eq 'SE'))
{
if (!($rsp->{error}->[0])) # no error data
{ # no error data
$rsp->{error}->[0] = $rsp->{data}->[0];
}
if (!defined ($rsp->{$sevkey}) || !scalar(@{$rsp->{$sevkey}})) { return; } # if still nothing in the array, there is nothing to print out
# $rsp->{data}->[0] = "";
}
}
if (($sev eq 'W') || ($sev eq 'SW'))
{
if (!($rsp->{warning}->[0])) # no warning data
{ # no error data
$rsp->{warning}->[0] = $rsp->{data}->[0];
# $rsp->{data}->[0] = "";
}
}
if ($sev ne 'S')
if ($sev ne 'S') # if sev is anything but only-syslog, print the msg
{ # not just syslog
$call_back->($rsp); # send message to daemon/Client.pm unless
# data structure which is output by the commands
# callback routine.
if ($exitcode) { $rsp->{errorcode}->[0] = $exitcode; }
$call_back->($rsp); # send message to daemon/Client.pm
shift @{$rsp->{$sevkey}}; # clear out the rsp structure in case they use it again
if ($exitcode) { shift @{$rsp->{errorcode}}; }
}
}
else # no callback provided

View File

@ -1,4 +1,5 @@
#!/usr/bin/env perl
#!/usr/bin/perl
# !/usr/bin/env perl
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
BEGIN
{
@ -59,15 +60,15 @@ foreach (@ARGV)
push(@{$cmdref->{arg}}, $_);
}
# Is it necessary to pass the node range through the client-server path ??
# Is it necessary to pass the node range through the client-server path ??
#
# !!!!!
# !!!!!
#
# BUT - also want to pass in a list of object definitions that are
# BUT - also want to pass in a list of object definitions that are
# not noderanges
#
#
# In any case - this doesn't work for mkdef & chdef because we may be
#
#
# In any case - this doesn't work for mkdef & chdef because we may be
# creating the node definition for the first time
#
#if (!($bname =~ /mkdef/))
@ -115,7 +116,7 @@ if (0)
my $arg = shift(@ARGV);
if (!($arg =~ /=/))
{
# only set the noderange if it was a type of node or the type
# only set the noderange if it was a type of node or the type
# wasn't specified.
if (!$::opt_t || ($::opt_t eq 'node')) {
$cmdref->{noderange}->[0] = $arg;
@ -125,141 +126,5 @@ if (0)
}
xCAT::Client::submit_request($cmdref, \&handle_response);
exit 0;
# may want to modify handle_response at some point!!!!!!!
##########################################
# handle_response is the callback that is
# invoked to print out the data returned by
# the plugin.
#
# Format of the response hash:
# {data => [ 'data str1', 'data str2', '...' ] }
#
# Results are printed as:
# data str1
# data str2
#
# or:
# {data => [ {desc => [ 'desc1' ],
# contents => [ 'contents1' ] },
# {desc => [ 'desc2 ],
# contents => [ 'contents2' ] }
# :
# ] }
# NOTE: In this format, only the data array can have more than one
# element. All other arrays are assumed to be a single element.
# Results are printed as:
# desc1: contents1
# desc2: contents2
#
# or:
# {node => [ {name => ['node1'],
# data => [ {desc => [ 'node1 desc' ],
# contents => [ 'node1 contents' ] } ] },
# {name => ['node2'],
# data => [ {desc => [ 'node2 desc' ],
# contents => [ 'node2 contents' ] } ] },
# :
# ] }
# NOTE: Only the node array can have more than one element.
# All other arrays are assumed to be a single element.
#
# This was generated from the corresponding HTML:
# <xcatrequest>
# <node>
# <name>node1</name>
# <data>
# <desc>node1 desc</desc>
# <contents>node1 contents</contents>
# </data>
# </node>
# <node>
# <name>node2</name>
# <data>
# <desc>node2 desc</desc>
# <contents>node2 contents</contents>
# </data>
# </node>
# </xcatrequest>
#
# Results are printed as:
# node_name: desc: contents
##########################################
sub handle_response
{
my $rsp = shift;
# Handle {node} structure
if ($rsp->{node})
{
my $nodes = ($rsp->{node});
my $node;
foreach $node (@$nodes)
{
my $desc = $node->{name}->[0];
if ($node->{data})
{
if (ref(\($node->{data}->[0])) eq 'SCALAR')
{
$desc = $desc . ": " . $node->{data}->[0];
}
else
{
if ($node->{data}->[0]->{desc})
{
$desc = $desc . ": " . $node->{data}->[0]->{desc}->[0];
}
if ($node->{data}->[0]->{contents})
{
$desc = "$desc: " . $node->{data}->[0]->{contents}->[0];
}
}
}
if ($desc)
{
print "$desc\n";
}
}
}
# Handle {data} structure with no nodes
if ($rsp->{data})
{
my $data = ($rsp->{data});
my $data_entry;
foreach $data_entry (@$data)
{
my $desc;
if (ref(\($data_entry)) eq 'SCALAR')
{
$desc = $data_entry;
}
else
{
if ($data_entry->{desc})
{
$desc = $data_entry->{desc}->[0];
}
if ($data_entry->{contents})
{
if ($desc)
{
$desc = "$desc: " . $data_entry->{contents}->[0];
}
else
{
$desc = $data_entry->{contents}->[0];
}
}
}
if ($desc)
{
print "$desc\n";
}
}
}
}
xCAT::Client::submit_request($cmdref,\&xCAT::Client::handle_response);
exit $xCAT::Client::EXITCODE;

View File

@ -1,18 +1,17 @@
#!/usr/bin/env perl
#!/usr/bin/perl
# !/usr/bin/env perl
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
BEGIN
{
$::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : -d '/opt/xcat' ? '/opt/xcat' : '/usr';
}
use lib "$::XCATROOT/lib/perl";
use IO::Socket::SSL;
use IO::Socket::INET;
use File::Basename;
use Data::Dumper;
#use Data::Dumper;
use Getopt::Long;
use xCAT::MsgUtils;
use xCAT::DSHCLI;
use xCAT::Client submit_request;
use xCAT::Client;
my $bname = basename($0);
#-----------------------------------------------------------------------------
@ -26,11 +25,11 @@ This program is the client interface for xdsh/xdcp.
This is the interface to for xdsh/xdsp
The command can run in client/server mode (default) or in bypass mode
where it does not use the xcat daemon xcatd.
where it does not use the xcat daemon xcatd.
Bypass mode is useful, when executing the command on the Management Server
and in particular if you want to run as a non-root id.
and in particular if you want to run as a non-root id.
Call parse_args to verify mode (client/server or bypass)
and whether to use Env Variables
and whether to use Env Variables
Build hash and submit request
See man page for options
@ -39,8 +38,6 @@ This program is the client interface for xdsh/xdcp.
#-----------------------------------------------------------------------------
# Main
my $rc = 0;
# report unsupported dsh exports
&check_invalid_exports;
@ -123,17 +120,17 @@ if (!($::CONTEXT_SET))
}
}
xCAT::Client::submit_request($cmdref, \&handle_response);
exit $rc;
xCAT::Client::submit_request($cmdref,\&xCAT::Client::handle_response);
exit $xCAT::Client::EXITCODE;
#-----------------------------------------------------------------------------
=head3 parse_args_xdsh
Parses for dsh input
Check if the command ask for help and display usage
Need to check only for the -X flag
Need to check -B flag to determine mode
Need to check -B flag to determine mode
=cut
@ -187,7 +184,7 @@ sub parse_args_xdsh
xCAT::DSHCLI->usage_dsh;
exit 0;
}
if ($options{'bypass'})
if ($options{'bypass'} || $options{'ssh-setup'}) # must force bypass mode for -K, so it can prompt user for node pw
{
$ENV{XCATBYPASS} = "yes"; # bypass xcatd
}
@ -226,11 +223,11 @@ sub parse_args_xdsh
#-----------------------------------------------------------------------------
=head3 parse_args_xdcp
Parses for dcp input
Check if the command ask for help and display usage
Need to check -X flag to determine how to set Environment Variables
Need to check -B flag to determine mode
Need to check -B flag to determine mode
=cut
@ -370,149 +367,3 @@ sub check_invalid_exports
" DSH_REPORT is set but is not supported. It will be ignored.\n");
}
}
#-----------------------------------------------------------------------------
=head3 handle_response
handle_response is the callback that is
invoked to print out the data returned by
the plugin.
Format of the response hash:
{data => [ 'data str1', 'data str2', '...' ] }
Results are printed as:
data str1
data str2
or:
{data => [ {desc => [ 'desc1' ],
contents => [ 'contents1' ] },
{desc => [ 'desc2 ],
contents => [ 'contents2' ] }
:
] }
NOTE: In this format, only the data array can have more than one
element. All other arrays are assumed to be a single element.
Results are printed as:
desc1: contents1
desc2: contents2
or:
{node => [ {name => ['node1'],
data => [ {desc => [ 'node1 desc' ],
contents => [ 'node1 contents' ] } ] },
{name => ['node2'],
data => [ {desc => [ 'node2 desc' ],
contents => [ 'node2 contents' ] } ] },
:
] }
NOTE: Only the node array can have more than one element.
All other arrays are assumed to be a single element.
This was generated from the corresponding HTML:
<xcatrequest>
<node>
<name>node1</name>
<data>
<desc>node1 desc</desc>
<contents>node1 contents</contents>
</data>
</node>
<node>
<name>node2</name>
<data>
<desc>node2 desc</desc>
<contents>node2 contents</contents>
</data>
</node>
</xcatrequest>
Results are printed as:
node_name: desc: contents
=cut
#-----------------------------------------------------------------------------
sub handle_response
{
my $rsp = shift;
# Handle {node} structure
if ($rsp->{errorcode})
{
foreach my $ecode (@{$rsp->{errorcode}})
{
$exitcode |= $ecode;
}
}
# Handle {node} structure
if ($rsp->{node})
{
my $nodes = ($rsp->{node});
my $node;
foreach $node (@$nodes)
{
my $desc = $node->{name}->[0];
if ($node->{data})
{
if (ref(\($node->{data}->[0])) eq 'SCALAR')
{
$desc = $desc . ": " . $node->{data}->[0];
}
else
{
if ($node->{data}->[0]->{desc})
{
$desc = $desc . ": " . $node->{data}->[0]->{desc}->[0];
}
if ($node->{data}->[0]->{contents})
{
$desc = "$desc: " . $node->{data}->[0]->{contents}->[0];
}
}
}
if ($desc)
{
print "$desc\n";
}
}
}
# Handle {data} structure with no nodes
if ($rsp->{data})
{
my $data = ($rsp->{data});
my $data_entry;
foreach $data_entry (@$data)
{
my $desc;
if (ref(\($data_entry)) eq 'SCALAR')
{
$desc = $data_entry;
}
else
{
if ($data_entry->{desc})
{
$desc = $data_entry->{desc}->[0];
}
if ($data_entry->{contents})
{
if ($desc)
{
$desc = "$desc: " . $data_entry->{contents}->[0];
}
else
{
$desc = $data_entry->{contents}->[0];
}
}
}
if ($desc)
{
print "$desc\n";
}
}
}
}

View File

@ -28,11 +28,16 @@ B<-?|-h|--help> Display usage message.
1. To display the contents of the site table:
I<tabdump site>
tabdump site
2. To see what tables exist in the xCAT database:
I<tabdump>
tabdump
3. To see what tables exist in the xCAT database:
mkdir -p /tmp/xcatdb.backup
for i in `tabdump`;do echo "Dumping $i..."; tabdump $i > /tmp/xcatdb.backup/$i.csv; done
=head1 FILES
@ -40,6 +45,4 @@ I<tabdump>
=head1 NOTES
This command is part of the xCAT software product.
This command is part of the xCAT software product.

View File

@ -32,12 +32,17 @@ B<-?|-h|--help> Display usage message.
1. To put rows into the mp table:
I<tabrestore mp.csv>
tabrestore mp.csv
The file mp.csv could contain something like:
#node,mpa,id,comments,disable
"blade","|\D+(\d+)|amm(($1-1)/14+1)|","|\D+(\d+)|(($1-1)%14+1)|",,
#node,mpa,id,comments,disable
"blade","|\D+(\d+)|amm(($1-1)/14+1)|","|\D+(\d+)|(($1-1)%14+1)|",,
2. To restore database tables that were dumped with tabdump:
cd /tmp/xcatdb.backup
for i in *.csv;do echo "Restoring $i..."; tabrestore $i; done
=head1 FILES
@ -45,6 +50,4 @@ The file mp.csv could contain something like:
=head1 NOTES
This command is part of the xCAT software product.
This command is part of the xCAT software product.

View File

@ -129,7 +129,7 @@
.\" ========================================================================
.\"
.IX Title "TABDUMP.1 1"
.TH TABDUMP.1 1 "2008-02-13" "perl v5.8.8" "User Contributed Perl Documentation"
.TH TABDUMP.1 1 "2008-02-18" "perl v5.8.8" "User Contributed Perl Documentation"
.SH "NAME"
\&\fBtabdump\fR \- display a database table in csv format.
.SH "SYNOPSIS"
@ -154,14 +154,25 @@ tables will be displayed.
.IX Header "EXAMPLES"
1. To display the contents of the site table:
.PP
\&\fItabdump site\fR
.Vb 1
\& tabdump site
.Ve
.PP
2. To see what tables exist in the xCAT database:
.PP
\&\fItabdump\fR
.Vb 1
\& tabdump
.Ve
.PP
3. To see what tables exist in the xCAT database:
.PP
.Vb 2
\& mkdir -p /tmp/xcatdb.backup
\& for i in `tabdump`;do echo "Dumping $i..."; tabdump $i > /tmp/xcatdb.backup/$i.csv; done
.Ve
.SH "FILES"
.IX Header "FILES"
/opt/xcat/sbin/tabdump
.SH "NOTES"
.IX Header "NOTES"
This command is part of the xCAT software product.
This command is part of the xCAT software product.

View File

@ -129,7 +129,7 @@
.\" ========================================================================
.\"
.IX Title "TABRESTORE.1 1"
.TH TABRESTORE.1 1 "2008-02-14" "perl v5.8.8" "User Contributed Perl Documentation"
.TH TABRESTORE.1 1 "2008-02-18" "perl v5.8.8" "User Contributed Perl Documentation"
.SH "NAME"
\&\fBtabrestore\fR \- replaces the contents of an xCAT database table with the contents in a csv file.
.SH "SYNOPSIS"
@ -158,15 +158,26 @@ into the xCAT database.
.IX Header "EXAMPLES"
1. To put rows into the mp table:
.PP
\&\fItabrestore mp.csv\fR
.Vb 1
\& tabrestore mp.csv
.Ve
.PP
The file mp.csv could contain something like:
.PP
#node,mpa,id,comments,disable
\&\*(L"blade\*(R",\*(L"|\eD+(\ed+)|amm(($1\-1)/14+1)|\*(R",\*(L"|\eD+(\ed+)|(($1\-1)%14+1)|\*(R",,
.Vb 2
\& #node,mpa,id,comments,disable
\& "blade","|\eD+(\ed+)|amm(($1-1)/14+1)|","|\eD+(\ed+)|(($1-1)%14+1)|",,
.Ve
.PP
2. To restore database tables that were dumped with tabdump:
.PP
.Vb 2
\& cd /tmp/xcatdb.backup
\& for i in *.csv;do echo "Restoring $i..."; tabrestore $i; done
.Ve
.SH "FILES"
.IX Header "FILES"
/opt/xcat/sbin/tabrestore
.SH "NOTES"
.IX Header "NOTES"
This command is part of the xCAT software product.
This command is part of the xCAT software product.

View File

@ -1,7 +1,7 @@
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
#-------------------------------------------------------
=head1
=head1
xCAT plugin package to handle xdsh
Supported command:
@ -23,7 +23,7 @@ require xCAT::DSHCLI;
#-------------------------------------------------------
=head3 handled_commands
=head3 handled_commands
Return list of commands handled by this plugin
@ -41,7 +41,7 @@ sub handled_commands
#-------------------------------------------------------
=head3 process_request
=head3 process_request
Process the command
@ -59,22 +59,10 @@ sub process_request
my $envs = $request->{env};
my %rsp;
# get Environment Variables
my $outref = [];
foreach my $envar (@{$request->{env}})
{
my $cmd = "export ";
$cmd .= $envar;
$cmd .= ";";
@$outref = `$cmd`;
if ($? > 0)
{
my %rsp;
$rsp->{data}->[0] = "Error running command: $cmd\n";
xCAT::MsgUtils->message("E", $rsp, $callback);
return 1;
}
# get the Environment Variables and set them in the current environment
foreach my $envar (@{$request->{env}}) {
my ($var, $value) = split(/=/, $envar, 2);
$ENV{$var} = $value;
}
if ($command eq "xdsh")
{
@ -91,18 +79,18 @@ sub process_request
{
my %rsp;
$rsp->{data}->[0] =
"Unknown command $command. Cannot process the command\n";
xCAT::MsgUtils->message("E", $rsp, $callback);
return 1;
"Unknown command $command. Cannot process the command.";
xCAT::MsgUtils->message("E", $rsp, $callback, 1);
return;
}
}
}
#-------------------------------------------------------
=head3 xdsh
=head3 xdsh
Parses Builds and runs the dsh
Parses Builds and runs the dsh
=cut
@ -116,25 +104,18 @@ sub xdsh
@local_results =
xCAT::DSHCLI->parse_and_run_dsh($nodes, $args, $callback,
$command, $noderange);
my %rsp;
my $i = 0;
## process return data
foreach my $line (@local_results)
{
$rsp->{data}->[$i] = $line;
$i++;
}
push @{$rsp->{data}}, @local_results;
xCAT::MsgUtils->message("I", $rsp, $callback);
return 0;
return;
}
#-------------------------------------------------------
=head3 xdcp
=head3 xdcp
Parses, Builds and runs the dcp command
Parses, Builds and runs the dcp command
=cut
@ -159,6 +140,6 @@ sub xdcp
xCAT::MsgUtils->message("I", $rsp, $callback);
return 0;
return;
}