2008-05-19 19:05:54 +00:00
|
|
|
#!/usr/bin/env perl
|
2013-06-01 12:13:14 +00:00
|
|
|
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
|
|
|
|
|
2014-06-24 16:15:39 +00:00
|
|
|
# Used as a convience command combined of [nodech]-nodeset-rsetboot-rpower-[rcons/wcons]
|
2013-06-01 12:13:14 +00:00
|
|
|
# to make ease of node OS provision
|
|
|
|
|
2014-06-24 16:15:39 +00:00
|
|
|
# This is the client front-end to rinstall/winstall commands
|
2013-06-01 12:13:14 +00:00
|
|
|
|
2013-05-31 10:33:15 +00:00
|
|
|
|
|
|
|
BEGIN
|
|
|
|
{
|
|
|
|
$::XCATROOT =
|
|
|
|
$ENV{'XCATROOT'} ? $ENV{'XCATROOT'}
|
|
|
|
: -d '/opt/xcat' ? '/opt/xcat'
|
|
|
|
: '/usr';
|
|
|
|
}
|
|
|
|
|
|
|
|
use lib "$::XCATROOT/lib/perl";
|
2008-05-19 19:05:54 +00:00
|
|
|
use File::Basename;
|
2013-05-31 10:33:15 +00:00
|
|
|
use Getopt::Long;
|
2013-08-02 02:26:14 +00:00
|
|
|
use xCAT::MsgUtils;
|
2014-06-24 16:15:39 +00:00
|
|
|
use xCAT::Utils;
|
|
|
|
use xCAT::Client;
|
|
|
|
use Cwd;
|
|
|
|
use strict;
|
2010-04-26 17:53:32 +00:00
|
|
|
|
2014-06-24 16:15:39 +00:00
|
|
|
# build a request to go the rinstall plugin
|
|
|
|
my $bname = basename($0);
|
|
|
|
my $cmdref;
|
|
|
|
$cmdref->{command}->[0] = $bname;
|
|
|
|
$cmdref->{cwd}->[0] = cwd();
|
|
|
|
# allows our plugins to get the stdin of the cmd that invoked the plugin
|
|
|
|
my $data;
|
|
|
|
if ( (($^O =~ /^linux/i) && ($ENV{'SHELL'} =~ /\/ksh$/)) || !defined($ENV{'TERM'}) )
|
|
|
|
{
|
|
|
|
my $rin="";
|
|
|
|
my $rout;
|
|
|
|
vec($rin,fileno(STDIN),1)=1;
|
|
|
|
my $nfound=select($rout=$rin,"","",1);
|
|
|
|
if ($nfound)
|
|
|
|
{
|
|
|
|
while ( <STDIN> ) { $data.=$_; }
|
|
|
|
$cmdref->{stdin}->[0]=$data;
|
|
|
|
}
|
2008-05-19 19:05:54 +00:00
|
|
|
}
|
2014-06-24 16:15:39 +00:00
|
|
|
else
|
2013-05-31 10:33:15 +00:00
|
|
|
{
|
2014-06-24 16:15:39 +00:00
|
|
|
if (-p STDIN) {
|
|
|
|
while ( <STDIN> ) { $data.=$_; }
|
|
|
|
$cmdref->{stdin}->[0]=$data;
|
|
|
|
}
|
2008-05-19 19:05:54 +00:00
|
|
|
}
|
2014-06-24 16:15:39 +00:00
|
|
|
my $arg;
|
|
|
|
my @tmpargv = @ARGV;
|
|
|
|
# first
|
|
|
|
$arg=shift(@ARGV);
|
|
|
|
# first 1st non-hyphen arg is the noderange
|
|
|
|
while ($arg =~ /^-/) {
|
|
|
|
push (@{$cmdref->{arg}}, $arg);
|
|
|
|
$arg=shift(@ARGV);
|
2008-05-19 19:05:54 +00:00
|
|
|
}
|
2014-06-24 16:15:39 +00:00
|
|
|
$cmdref->{noderange}->[0]=$arg;
|
|
|
|
push (@{$cmdref->{arg}}, @ARGV);
|
2013-05-31 10:33:15 +00:00
|
|
|
|
2014-06-24 16:15:39 +00:00
|
|
|
my $noderange=$cmdref->{noderange}->[0]; # save the noderange
|
2013-06-06 03:14:34 +00:00
|
|
|
|
2014-06-24 16:15:39 +00:00
|
|
|
# ok call Client to run the plugin rinstall.pm
|
|
|
|
xCAT::Client::submit_request($cmdref,\&xCAT::Client::handle_response);
|
2013-05-31 10:33:15 +00:00
|
|
|
|
2014-06-24 16:15:39 +00:00
|
|
|
if ($xCAT::Client::EXITCODE == 0) # no errors
|
|
|
|
{
|
|
|
|
my $startconsole=$cmdref->{startconsole}->[0];
|
|
|
|
# if startconsole requested ( -c flag) for rinstall always for winstall
|
|
|
|
# This is set in the rinstall plugin
|
|
|
|
if ($startconsole == 1) {
|
|
|
|
if (basename($0) =~ /rinstall/) {
|
2013-06-01 12:13:14 +00:00
|
|
|
|
2008-05-19 19:05:54 +00:00
|
|
|
exec("rcons $noderange");
|
|
|
|
}
|
2014-06-24 16:15:39 +00:00
|
|
|
elsif (basename($0) =~ /winstall/) {
|
|
|
|
# winstall can commence a wcons command to the noderange for monitoring the provision cycle
|
2013-06-01 12:13:14 +00:00
|
|
|
|
2014-06-24 16:15:39 +00:00
|
|
|
exec("wcons $noderange");
|
|
|
|
}
|
|
|
|
}
|
2008-05-19 19:05:54 +00:00
|
|
|
}
|
2014-06-24 16:15:39 +00:00
|
|
|
exit $xCAT::Client::EXITCODE;
|