3448e9c7d3
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@518 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
119 lines
2.8 KiB
Perl
Executable File
119 lines
2.8 KiB
Perl
Executable File
#!/usr/bin/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 File::Basename;
|
|
use xCAT::MsgUtils;
|
|
use xCAT::Client submit_request;
|
|
|
|
my $bname = basename($0);
|
|
|
|
#########################################
|
|
# Main
|
|
#
|
|
# xcatDBcmds
|
|
#
|
|
# Build hash and submit request
|
|
#
|
|
# Handles: mkdef, chdef, lsdef, rmdef, and xcat2nim commands
|
|
#
|
|
# Note: The subroutines that implement these commands
|
|
# are, for the most part, in:
|
|
# /opt/xcat/lib/perl/xCAT_plugin/DBobjectdefs.pm
|
|
# /opt/xcat/lib/perl/xCAT_plugin/xcat2nim.pm
|
|
# /opt/xcat/lib/perl/xCAT/DBobjUtils.pm
|
|
# -on the xCAT management node
|
|
#
|
|
#########################################
|
|
|
|
my $cmdref;
|
|
|
|
# set the command name to pass to the plugin
|
|
if ($bname =~ /xcatDBcmds/)
|
|
{
|
|
$cmdref->{command}->[0] = shift @ARGV;
|
|
}
|
|
elsif ($bname =~ /^(.*$)/)
|
|
{
|
|
$cmdref->{command}->[0] = $1;
|
|
}
|
|
else
|
|
{
|
|
printf("Bad usage\n");
|
|
exit 1;
|
|
}
|
|
|
|
# get info from files piped in as stdin
|
|
if (-p STDIN) {
|
|
my $data;
|
|
while ( <STDIN> ) {
|
|
$data.=$_;
|
|
}
|
|
$cmdref->{stdin}->[0]=$data;
|
|
}
|
|
|
|
# add all the cmd line args to the hash - to pass to the plugin subroutine
|
|
foreach (@ARGV)
|
|
{
|
|
push(@{$cmdref->{arg}}, $_);
|
|
}
|
|
|
|
|
|
#
|
|
# We need to see if a noderange was provided on the command line
|
|
# - the command line could be flags(options) -> noderange -> attr=val pairs
|
|
# - the noderange is used by xCAT remote access support infrastructure
|
|
# so we need to set it now
|
|
#
|
|
|
|
use Getopt::Long;
|
|
|
|
# Allows opts to be grouped (e.g. -avx)
|
|
Getopt::Long::Configure("bundling");
|
|
|
|
# parse the options
|
|
if (
|
|
!GetOptions(
|
|
'all|a' => \$::opt_a,
|
|
'dynamic|d' => \$::opt_d,
|
|
'f|force' => \$::opt_f,
|
|
'i=s' => \$::opt_i,
|
|
'help|h' => \$::opt_h,
|
|
'long|l' => \$::opt_l,
|
|
'm|minus' => \$::opt_m,
|
|
'o=s' => \$::opt_o,
|
|
'r|replace' => \$::opt_r,
|
|
't=s' => \$::opt_t,
|
|
'update|u' => \$::opt_u,
|
|
'verbose|V' => \$::opt_V,
|
|
'version|v' => \$::opt_v,
|
|
'w=s' => \$::opt_w,
|
|
'x|xml' => \$::opt_x,
|
|
'z|stanza' => \$::opt_z
|
|
)
|
|
)
|
|
{
|
|
return 1;
|
|
}
|
|
|
|
# a node range would be the next arg - but not if it contains an "=" sign
|
|
# - then it would be an attr=val operand
|
|
my $arg = shift(@ARGV);
|
|
if (!($arg =~ /=/))
|
|
{
|
|
# 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;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
xCAT::Client::submit_request($cmdref,\&xCAT::Client::handle_response);
|
|
exit $xCAT::Client::EXITCODE;
|