add routine to generate nodegroup files directory for input to AIX dsh
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@4302 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
parent
5b959685d6
commit
327883edd6
124
xCAT-server/share/xcat/tools/groupfiles4dsh
Executable file
124
xCAT-server/share/xcat/tools/groupfiles4dsh
Executable file
@ -0,0 +1,124 @@
|
||||
#!/usr/bin/perl
|
||||
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
|
||||
#(C)IBM Corp
|
||||
#
|
||||
|
||||
BEGIN
|
||||
{
|
||||
$::XCATROOT =
|
||||
$ENV{'XCATROOT'} ? $ENV{'XCATROOT'}
|
||||
: -d '/opt/xcat' ? '/opt/xcat'
|
||||
: '/usr';
|
||||
}
|
||||
use lib "$::XCATROOT/lib/perl";
|
||||
use Getopt::Long;
|
||||
use xCAT::MsgUtils;
|
||||
use xCAT::Utils;
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
=head1 groupfiles4dsh
|
||||
|
||||
|
||||
This tool will build a directory of files for each defined
|
||||
nodegroup in xCAT. The file will be named the nodegroup name and
|
||||
contain a list of nodes that belong to the nodegroup.
|
||||
The file can be used as input to the AIX dsh command run in the DSH
|
||||
context.
|
||||
The purpose of this tool is to allow backward compatiblity with scripts
|
||||
that were created using the AIX or CSM dsh command.
|
||||
|
||||
|
||||
groupfiles4dsh -p <directory to place generated nodegroup files>
|
||||
example: groupfiles4dsh -p /tmp/dshnodegrpfiles
|
||||
|
||||
Use: export DSH_CONTEXT=DSH ( default unless CSM is installed)
|
||||
export DSH_NODE_RSH=/bin/ssh (default is rsh)
|
||||
export DSH_NODEGROUP_PATH= /tmp/dshnodegrpfiles
|
||||
|
||||
dsh -N /tmp/dshnodegrpfiles/allnodes date
|
||||
dsh -a date ( see man dsh, DSH context)
|
||||
|
||||
=cut
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Main
|
||||
my $rc = 0;
|
||||
&parse_args;
|
||||
my $cmd = "lsdef -t group";
|
||||
my @grpoutput = xCAT::Utils->runcmd($cmd, 0);
|
||||
if ($::RUNCMD_RC != 0)
|
||||
{ # error
|
||||
xCAT::MsgUtils->message("E", "Error running $cmd");
|
||||
exit 1;
|
||||
}
|
||||
foreach my $group (@grpoutput)
|
||||
{
|
||||
my $cmd = "nodels $group > $::PATH/$group";
|
||||
xCAT::Utils->runcmd($cmd, 0);
|
||||
if ($::RUNCMD_RC != 0)
|
||||
{ # error
|
||||
xCAT::MsgUtils->message("E", "Error running $cmd\n");
|
||||
exit 1;
|
||||
}
|
||||
|
||||
}
|
||||
exit $rc;
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
=head3 parse_args
|
||||
|
||||
Parses for input
|
||||
|
||||
=cut
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
sub parse_args
|
||||
{
|
||||
my $msg;
|
||||
my $usagemsg;
|
||||
$usagemsg =
|
||||
"groupfiles4dsh -h \ngroupfiles4dsh -v \ngroupfiles4dsh [-p] [path to group files directory]";
|
||||
Getopt::Long::Configure("posix_default");
|
||||
Getopt::Long::Configure("no_gnu_compat");
|
||||
Getopt::Long::Configure("bundling");
|
||||
if (
|
||||
!GetOptions(
|
||||
'p|path=s' => \$::PATH,
|
||||
'h|help' => \$::HELP,
|
||||
'v|version' => \$::VERSION
|
||||
|
||||
)
|
||||
)
|
||||
{
|
||||
xCAT::MsgUtils->message("E", $usagemsg);
|
||||
exit 1;
|
||||
}
|
||||
if ($::HELP)
|
||||
{
|
||||
xCAT::MsgUtils->message("I", $usagemsg);
|
||||
exit 0;
|
||||
}
|
||||
if ($::VERSION)
|
||||
{
|
||||
my $version = xCAT::Utils->Version();
|
||||
xCAT::MsgUtils->message("I", $version);
|
||||
exit 0;
|
||||
}
|
||||
if (!($::PATH))
|
||||
{
|
||||
my $msg =
|
||||
"Requires -p with path to existing directory to hold group files.";
|
||||
xCAT::MsgUtils->message("E", $msg);
|
||||
exit 1;
|
||||
}
|
||||
if (!(-d $::PATH))
|
||||
{
|
||||
my $msg = " Input directory must exist.";
|
||||
xCAT::MsgUtils->message("E", $msg);
|
||||
exit 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user