From cd81905b63bce90c5c86caaa23d9e88f8f164883 Mon Sep 17 00:00:00 2001 From: bp-sawyers Date: Tue, 18 Mar 2008 14:37:55 +0000 Subject: [PATCH] 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 --- perl-xCAT-2.0/xCAT/Schema.pm | 2 +- xCAT-client-2.0/bin/psh | 26 ++++++++----- xCAT-client-2.0/pods/man1/psh.1.pod | 59 +++++++++++++++++------------ 3 files changed, 53 insertions(+), 34 deletions(-) diff --git a/perl-xCAT-2.0/xCAT/Schema.pm b/perl-xCAT-2.0/xCAT/Schema.pm index d8214111d..8d04c0850 100644 --- a/perl-xCAT-2.0/xCAT/Schema.pm +++ b/perl-xCAT-2.0/xCAT/Schema.pm @@ -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.", diff --git a/xCAT-client-2.0/bin/psh b/xCAT-client-2.0/bin/psh index 1fa26d59a..ba6cf3177 100755 --- a/xCAT-client-2.0/bin/psh +++ b/xCAT-client-2.0/bin/psh @@ -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 ] [-l ] \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 \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 |"); } diff --git a/xCAT-client-2.0/pods/man1/psh.1.pod b/xCAT-client-2.0/pods/man1/psh.1.pod index 3720789c5..4f0947e15 100644 --- a/xCAT-client-2.0/pods/man1/psh.1.pod +++ b/xCAT-client-2.0/pods/man1/psh.1.pod @@ -4,7 +4,7 @@ psh - parallel remote shell =head1 B -B [I<-s>] {I|B|I} I +B [B<-i> I] [B<-l> I] I I B {B<-h>|B<--help>|B<-v>|B<--version>} @@ -14,30 +14,29 @@ B is a utility used to run a command across a list of nodes in parallel. B must be set up to allow no prompting for B 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 =over 7 -=item B<-s> +=item B<-i> I -Issues the commands serially. +The NIC on the node that psh should communicate with. For example, if I is B, +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 + +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 See L. -=item B - -Run against nodes owned by "me" as listed by PBS's B -command. - -=item B - -Run against nodes assigned to a PBS job as listed by PBS's -B command. - =item B Command to be run in parallel. If no command is give then B @@ -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 -B I I +=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 I I I<-f> I +Run uptime on 3 nodes: -B I I<'rm> I<-f> I + B I I + + 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 I I<'info -T mm[1]'> + +=item * + +Remove the tmp files on the nodes in the 1st frame: + +B I I<'rm -f /tmp/*'> Notice the use of '' to forward shell expansion. This is not necessary in interactive mode. +=back + =head1 B Egan Ford