2008-02-18 15:57:25 +00:00
|
|
|
#!/usr/bin/perl
|
2007-10-26 22:44:33 +00:00
|
|
|
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
|
2007-12-11 19:15:28 +00:00
|
|
|
BEGIN
|
|
|
|
{
|
2008-01-14 17:04:41 +00:00
|
|
|
$::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : -d '/opt/xcat' ? '/opt/xcat' : '/usr';
|
2007-12-11 19:15:28 +00:00
|
|
|
}
|
|
|
|
use lib "$::XCATROOT/lib/perl";
|
2007-10-26 22:44:33 +00:00
|
|
|
|
|
|
|
use File::Basename;
|
2007-11-26 19:59:04 +00:00
|
|
|
use xCAT::MsgUtils;
|
2007-10-26 22:44:33 +00:00
|
|
|
use xCAT::Client submit_request;
|
|
|
|
|
|
|
|
my $bname = basename($0);
|
|
|
|
|
|
|
|
#########################################
|
|
|
|
# Main
|
|
|
|
#
|
|
|
|
# xcatDBcmds
|
|
|
|
#
|
2007-11-26 19:59:04 +00:00
|
|
|
# Build hash and submit request
|
2007-10-26 22:44:33 +00:00
|
|
|
#
|
2008-02-18 20:44:29 +00:00
|
|
|
# Handles: mkdef, chdef, lsdef, rmdef, and xcat2nim commands
|
2007-10-26 22:44:33 +00:00
|
|
|
#
|
2007-11-26 19:59:04 +00:00
|
|
|
# Note: The subroutines that implement these commands
|
2008-02-18 20:44:29 +00:00
|
|
|
# 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
|
2007-10-26 22:44:33 +00:00
|
|
|
#
|
|
|
|
#########################################
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2007-11-26 19:59:04 +00:00
|
|
|
# get info from files piped in as stdin
|
|
|
|
if (-p STDIN) {
|
|
|
|
my $data;
|
|
|
|
while ( <STDIN> ) {
|
|
|
|
$data.=$_;
|
|
|
|
}
|
|
|
|
$cmdref->{stdin}->[0]=$data;
|
|
|
|
}
|
2007-10-26 22:44:33 +00:00
|
|
|
|
|
|
|
# add all the cmd line args to the hash - to pass to the plugin subroutine
|
|
|
|
foreach (@ARGV)
|
|
|
|
{
|
|
|
|
push(@{$cmdref->{arg}}, $_);
|
|
|
|
}
|
|
|
|
|
2008-02-18 15:57:25 +00:00
|
|
|
xCAT::Client::submit_request($cmdref,\&xCAT::Client::handle_response);
|
|
|
|
exit $xCAT::Client::EXITCODE;
|