Add a -l user option to psh so it could work with amm
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@805 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
parent
d9c34c49e1
commit
cd81905b63
@ -199,7 +199,7 @@ nodelist => {
|
||||
descriptions => {
|
||||
node => 'The hostname of a node in the cluster.',
|
||||
nodetype => 'A comma-delimited list of characteristics of this node. Valid values: blade, vm (virtual machine), lpar, osi (OS image), hmc, fsp, ivm, bpa, mm, rsa, switch.',
|
||||
groups => "A comma-delimited list of groups this node is a member of. Group names are arbitrary, except all nodes should be part of the 'all' group.",
|
||||
groups => "A comma-delimited list of groups this node is a member of. Group names are arbitrary, except all nodes should be part of the 'all' group. Suggested group names include: ipmi, blade, lpar, hmc, fsp, ivm, bpa, mm, rsa, switch, service, compute. (Use as many as apply.)",
|
||||
status => 'The current status of this node. This attribute will be set by xCAT software. Valid values: defined, booting, discovering, installing, installed, alive, off.',
|
||||
comments => 'Any user-written notes.',
|
||||
disable => "Set to 'yes' or '1' to comment out this row.",
|
||||
|
@ -1,3 +1,4 @@
|
||||
#!/usr/bin/perl
|
||||
#!/usr/bin/env perl
|
||||
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
|
||||
BEGIN
|
||||
@ -14,11 +15,19 @@ use xCAT::Utils;
|
||||
use Getopt::Long;
|
||||
use POSIX qw(:signal_h :errno_h :sys_wait_h);
|
||||
my $interface;
|
||||
my $username;
|
||||
my $help;
|
||||
Getopt::Long::Configure("require_order");
|
||||
GetOptions(
|
||||
"interface=s" => \$interface,
|
||||
Getopt::Long::Configure("no_pass_through");
|
||||
if (!GetOptions(
|
||||
"i|interface=s" => \$interface,
|
||||
'l|loginname=s' => \$username,
|
||||
"nonodecheck" => \$::NONODECHECK, #does not check the noderange, in this case, noderange need to be a list of nodes.
|
||||
);
|
||||
'h|help' => \$help,
|
||||
) || $help || scalar(@ARGV)<2 ) {
|
||||
print "Usage: psh [-i <interface>] [-l <user>] <noderange> <command>\n";
|
||||
exit;
|
||||
}
|
||||
my %nodehdl;
|
||||
my $xcathost='localhost:3001';
|
||||
if ($ENV{XCATHOST}) {
|
||||
@ -26,9 +35,6 @@ if ($ENV{XCATHOST}) {
|
||||
}
|
||||
|
||||
my $pshmaxp = 64; #TODO: should this be server dictated or local conf?
|
||||
unless (@ARGV) {
|
||||
print "Usage: psh [-i <suffix] <noderange> <command>\n";
|
||||
}
|
||||
my $noderange = $ARGV[0];
|
||||
my @nodes=();
|
||||
|
||||
@ -87,7 +93,7 @@ foreach (@nodes) {
|
||||
while ($children > $pshmaxp) { processoutput($inputs); }
|
||||
my $child;
|
||||
$children++;
|
||||
sshnode(\$child,$node,@ARGV[1 .. $#ARGV]);
|
||||
sshnode(\$child,$node,$username,@ARGV[1 .. $#ARGV]);
|
||||
$inputs->add($child);
|
||||
$nodehdl{$child} = $node;
|
||||
}
|
||||
@ -118,9 +124,11 @@ sub processoutput { #This way, one arbiter handles output, no interrupting
|
||||
sub sshnode {
|
||||
my $out = shift;
|
||||
my $node = shift;
|
||||
my $username = shift;
|
||||
if (length($username)) { $username = "-l $username"; }
|
||||
my $in;
|
||||
my $args = join(" ",@_);
|
||||
#print "ssh -o BatchMode=yes $node " . xCAT::Utils->quote($args) . " 2>&1 |\n";
|
||||
open($$out,"ssh -o BatchMode=yes $node " . xCAT::Utils->quote($args) . " 2>&1 |");
|
||||
#print "ssh -o BatchMode=yes $username $node " . xCAT::Utils->quote($args) . " 2>&1 |\n";
|
||||
open($$out,"ssh -o BatchMode=yes $username $node " . xCAT::Utils->quote($args) . " 2>&1 |");
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@ psh - parallel remote shell
|
||||
|
||||
=head1 B<Synopsis>
|
||||
|
||||
B<psh> [I<-s>] {I<noderange>|B<me>|I<pbs-job-id>} I<command>
|
||||
B<psh> [B<-i> I<interface>] [B<-l> I<user>] I<noderange> I<command>
|
||||
|
||||
B<psh> {B<-h>|B<--help>|B<-v>|B<--version>}
|
||||
|
||||
@ -14,30 +14,29 @@ B<psh> is a utility used to run a command across a list of nodes in parallel.
|
||||
|
||||
B<ssh> must be set up to allow no prompting for B<psh> to work.
|
||||
|
||||
Note: this command does not support the xcatd client/server communication and therefore must be run on the management node.
|
||||
Note: this command does not run through xcatd like most xCAT commands do.
|
||||
This means you must either run it on the management node, or have a network connection between
|
||||
your machine and the nodes.
|
||||
|
||||
=head1 B<Options>
|
||||
|
||||
=over 7
|
||||
|
||||
=item B<-s>
|
||||
=item B<-i> I<interface>
|
||||
|
||||
Issues the commands serially.
|
||||
The NIC on the node that psh should communicate with. For example, if I<interface> is B<eth1>,
|
||||
then psh will concatenate B<-eth1> to the end of every node name before ssh'ing to it. This
|
||||
assumes those host names have been set up to resolve to the IP address of each of the eth1 NICs.
|
||||
|
||||
=item B<-l> I<user>
|
||||
|
||||
Log into the nodes as the specified username. The default is to use the same username as you
|
||||
are running the psh command as.
|
||||
|
||||
=item B<noderange>
|
||||
|
||||
See L<noderange(3)|noderange.3>.
|
||||
|
||||
=item B<me>
|
||||
|
||||
Run against nodes owned by "me" as listed by PBS's B<qstat(1B)>
|
||||
command.
|
||||
|
||||
=item B<pbs>
|
||||
|
||||
Run against nodes assigned to a PBS job as listed by PBS's
|
||||
B<qstat(1B)> command.
|
||||
|
||||
=item B<command>
|
||||
|
||||
Command to be run in parallel. If no command is give then B<psh>
|
||||
@ -49,28 +48,40 @@ nodes in the noderange. Use "exit" or "Ctrl-D" to end the interactive session.
|
||||
|
||||
Print help.
|
||||
|
||||
=item B<-v>|B<--version>
|
||||
|
||||
Print version.
|
||||
|
||||
=back
|
||||
|
||||
|
||||
=head1 B<Examples>
|
||||
|
||||
B<psh> I<node4-node6> I<uptime>
|
||||
=over 3
|
||||
|
||||
node4: Sun Aug 5 17:42:06 MDT 2001
|
||||
node5: Sun Aug 5 17:42:06 MDT 2001
|
||||
node6: Sun Aug 5 17:42:06 MDT 2001
|
||||
=item *
|
||||
|
||||
B<psh> I<node1-node10> I<rm> I<-f> I</tmp/blah>
|
||||
Run uptime on 3 nodes:
|
||||
|
||||
B<psh> I<rack01> I<'rm> I<-f> I</tmp/*'>
|
||||
B<psh> I<node4-node6> I<uptime>
|
||||
|
||||
node4: Sun Aug 5 17:42:06 MDT 2001
|
||||
node5: Sun Aug 5 17:42:06 MDT 2001
|
||||
node6: Sun Aug 5 17:42:06 MDT 2001
|
||||
|
||||
=item *
|
||||
|
||||
Run a command on some BladeCenter management modules:
|
||||
|
||||
B<psh> I<amm1-amm5> I<'info -T mm[1]'>
|
||||
|
||||
=item *
|
||||
|
||||
Remove the tmp files on the nodes in the 1st frame:
|
||||
|
||||
B<psh> I<rack01> I<'rm -f /tmp/*'>
|
||||
|
||||
Notice the use of '' to forward shell expansion. This is not necessary
|
||||
in interactive mode.
|
||||
|
||||
=back
|
||||
|
||||
=head1 B<Author>
|
||||
|
||||
Egan Ford <egan@us.ibm.com>
|
||||
|
Loading…
Reference in New Issue
Block a user