Merge branch '2.8' of ssh://git.code.sf.net/p/xcat/xcat-core into 2.8

This commit is contained in:
Bruce Potter 2014-06-24 16:40:26 -04:00
commit 918f0b520c
3 changed files with 101 additions and 192 deletions

View File

@ -1,12 +1,11 @@
#!/usr/bin/env perl
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
# Used as a convience command combined of [nodech]-nodeset-rpower-[rcons/wcons]
# Used as a convience command combined of [nodech]-nodeset-rsetboot-rpower-[rcons/wcons]
# to make ease of node OS provision
# To use this, sym link your cmd name to this script.
# This is the client front-end to rinstall/winstall commands
use strict;
BEGIN
{
@ -20,180 +19,69 @@ use lib "$::XCATROOT/lib/perl";
use File::Basename;
use Getopt::Long;
use xCAT::MsgUtils;
use xCAT::Table;
use xCAT::NodeRange;
use xCAT::Utils;
use xCAT::Client;
use Cwd;
use strict;
sub usage {
print basename($0)." usage:\n";
print " ".basename($0)." [-o|--osver] [-p|--profile] [-a|--arch] [-O|--osimage] [-c|--console] <noderange>\n"
}
my $OSVER;
my $PROFILE;
my $ARCH;
my $CONSOLE;
my $OSIMAGE;
Getopt::Long::Configure("bundling");
unless (GetOptions(
'o|osver=s' => \$OSVER,
'p|profile=s' => \$PROFILE,
'a|arch=s' => \$ARCH,
'O|osimage=s' => \$OSIMAGE,
'c|console' => \$CONSOLE
)) {
usage;
exit 1;
}
my $arraysize=@ARGV;
if ($arraysize > 1) {
print "noderange invalid\n";
usage;
exit 1;
}
if ($arraysize == 0) {
print "noderange not supplied\n";
usage;
exit 1;
}
my $noderange=@ARGV[0];
my $rc=0;
my %pnhash;
my @allnodes;
#use Data::Dumper;
# check and complain about the invalid combination of the options,
# called when -O is specified or nodetype.provmethod=<osimage>,
# ignore -o,-p and -a options and prompt a warning message
sub checkoption{
my $optstring=shift;
if($OSVER) {print 'warning: "'.$optstring.'" specified, "[-o|--osver] '.$OSVER."\" ignored\n"};
if($PROFILE) {print 'warning: "'.$optstring.'" specified, "[-p|--profile] '.$PROFILE."\" ignored\n"};
if($ARCH) {print 'warning: "'.$optstring.'" specified, "[-a|--arch] '.$OSVER."\" ignored\n"};
}
@allnodes=noderange($noderange);
if($OSIMAGE){
# -O|--osimage is specified, ignore any -a,-p,-o options,
# call "nodeset ... osimage= ..." to set the boot state of the noderange to the specified osimage,
# "nodeset" will handle the updating of node attributes such as os,arch,profile,provmethod
&checkoption("[-O|--osimage] $OSIMAGE");
$rc=system("nodeset $noderange osimage=$OSIMAGE");
if ($rc) {
xCAT::MsgUtils->message("E","nodeset failure");
exit 1;
};
}else
# 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'}) )
{
# no osimage specified, update the node attributes specified by -a,-p,-o options thru "nodech",
# then set the boot state of each node based on the nodetype.provmethod:
# 1) if nodetype.provmethod = <osimage>, ignore any -p,-o,-a option, then call "nodeset ... osimage"
# 2) if nodetype.provmethod = [install/netboot/statelite], update the node attributes specified by -a,-p,-o options thru "nodech", call "nodeset ... [install/netboot/statelite]"
# 3) if nodetype.provmethod is not set, use 'install' as the default value
# group the nodes according to the nodetype.provmethod
foreach(@allnodes){
my $tab=xCAT::Table->new("nodetype");
my $nthash=$tab->getNodeAttribs($_,['provmethod']);
$tab->close();
if(defined($nthash) and defined($nthash->{'provmethod'}))
{
push(@{$pnhash{$nthash->{'provmethod'}}},$_);
}
else
{
#if nodetype.provmethod is not specified,
push(@{$pnhash{'install'}},$_);
}
}
foreach my $key (keys %pnhash)
{
my $rclocal=0;
my $nodes=join(',',@{$pnhash{$key}});
if($key =~ /^(install|netboot|statelite)$/)
{
# nodetype.provmethod = [install|netboot|statelite]
my $nodechline = "";
if ($OSVER) {
$nodechline = "nodetype.os=$OSVER";
}
if ($PROFILE) {
$nodechline .= " nodetype.profile=$PROFILE";
}
if ($ARCH) {
$nodechline .= " nodetype.arch=$ARCH";
}
if ($nodechline) {
$rclocal=system("nodech $nodes $nodechline");
if ($rclocal) {
print "nodech failure\n";
$rc=$rclocal;
}
}
unless($rc){
$rclocal=system("nodeset $nodes $key");
if ($rclocal) {
print "nodeset $nodes failure\n";
$rc=$rclocal;
}
}
}
else
{
# nodetype.provmethod = <osimage>
&checkoption("nodetype.provmethod=$key");
$rclocal=system("nodeset $nodes osimage");
if ($rclocal) {
print "nodeset $nodes failure\n";
$rc=$rclocal;
}
}
}
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;
}
}
if($rc){
xCAT::MsgUtils->message("E","nodeset failure");
exit 1;
else
{
if (-p STDIN) {
while ( <STDIN> ) { $data.=$_; }
$cmdref->{stdin}->[0]=$data;
}
}
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);
}
$cmdref->{noderange}->[0]=$arg;
push (@{$cmdref->{arg}}, @ARGV);
# call "rsetboot" to set the boot order of the nodehm.mgt=ipmi nodes,for others, assume user has set the correct boot order before "rinstall"
system("rsetboot $noderange net");
my $noderange=$cmdref->{noderange}->[0]; # save the noderange
# call "rpower" to start the node provision process
$rc=system("rpower $noderange boot");
if ($rc) {
xCAT::MsgUtils->message("E","rpower failure");
exit 1;
};
# ok call Client to run the plugin rinstall.pm
xCAT::Client::submit_request($cmdref,\&xCAT::Client::handle_response);
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/) {
if (basename($0) =~ /rinstall/) {
# for rinstall, the -c|--console option can provide the remote console for only 1 node
if ($CONSOLE) {
if(scalar @allnodes ne 1){
xCAT::MsgUtils->message("E","rinstall [-c|--console] will only work if there is only one node in the noderange. See winstall(8) for consoles on multiple systems");
exit 1;
}
exec("rcons $noderange");
}
} elsif (basename($0) =~ /winstall/) {
# winstall can commence a wcons command to the noderange for monitoring the provision cycle
elsif (basename($0) =~ /winstall/) {
# winstall can commence a wcons command to the noderange for monitoring the provision cycle
exec("wcons $noderange");
exec("wcons $noderange");
}
}
}
exit $xCAT::Client::EXITCODE;

View File

@ -4,32 +4,42 @@ B<rinstall> - Begin OS provision on a noderange
=head1 B<Synopsis>
B<rinstall> [I<-o>|I<--osver>] [I<-p>|I<--profile>] [I<-a>|I<--arch>] [I<-O>|I<--osimage>] [I<-c>|I<--console>] [I<noderange>]
B<rinstall> [I<-o>|I<--osver>] [I<-p>|I<--profile>] [I<-a>|I<--arch>] [I<-c>|I<--console>] [I<noderange>]
B<rinstall> [I<-O>|I<--osimage>] [I<-c>|I<--console>] [I<noderange>]
=head1 B<Description>
B<rinstall> is a convience command that will change tables as requested for operating system version, profile, and architecture, call B<nodeset> to modify the network boot configuration, call B<rsetboot> net to set the next boot over network (only support nodes with "nodetype.mgt=ipmi", for other nodes, make sure the correct boot order has been set before B<rinstall>), and B<rpower> to begin a boot cycle.
B<rinstall> is a convenience command that will change tables as requested for operating system version, profile, and architecture, call B<nodeset> to modify the network boot configuration, call B<rsetboot> net to set the next boot over network (only support nodes with "nodetype.mgt=ipmi", for other nodes, make sure the correct boot order has been set before B<rinstall>), and B<rpower> to begin a boot cycle.
If [I<-O>|I<--osimage>] is specified or nodetype.provmethod=I<osimage> is set, provision the noderange with the osimage specified/configured, ignore the table change options if specified.
If -c is specified, it will then become the text console of the node. If wanting consoles on multiple nodes with a similar command, see L<winstall(8)|winstall.8>.
If -c is specified, it will then run rcons on the node. This is allowed only if one node in the noderange. If need consoles on multiple nodes , see L<winstall(8)|winstall.8>.
=head1 B<Options>
=over 7
=item B<-h>|B<--help>
Display usage message.
=item B<-v>|B<--version>
Display version.
=item B<-o>|B<--osver>
Specifies which os version to provision. If unspecified, the current table values are used. Will be ignored if [I<-O>|I<--osimage>] is specified or nodetype.provmethod=I<osimage>.
Specifies which os version to provision. If unspecified, the current node os setting is used. Will be ignored if [I<-O>|I<--osimage>] is specified or nodetype.provmethod=I<osimage>.
=item B<-p>|B<--profile>
Specifies what profile should be used of the operating system. If not specified the tables are used as is. Will be ignored if [I<-O>|I<--osimage>] is specified or nodetype.provmethod=I<osimage>.
Specifies what profile should be used of the operating system. If not specified the current node profile setting is used. Will be ignored if [I<-O>|I<--osimage>] is specified or nodetype.provmethod=I<osimage>.
=item B<-a>|B<--arch>
Specifies what architecture of the OS to provision. Typically this is unneeded, but if provisioning betweer x86_64 and x86 frequently, this may be a useful flag. Will be ignored if [I<-O>|I<--osimage>] is specified or nodetype.provmethod=I<osimage>.
Specifies what architecture of the OS to provision. Typically this is unneeded, but if provisioning between x86_64 and x86 frequently, this may be a useful flag. Will be ignored if [I<-O>|I<--osimage>] is specified or nodetype.provmethod=I<osimage>.
=item B<-O>|B<--osimage>
@ -37,7 +47,7 @@ Specifies the osimage to provision.
=item B<-c>|B<--console>
Requests that rinstall become rcons once the provision commences. This will only work if there is only one node in the noderange. See L<winstall(8)|winstall.8> for consoles on multiple systems.
Requests that rinstall runs rcons once the provision starts. This will only work if there is only one node in the noderange. See L<winstall(8)|winstall.8> for starting nsoles on multiple nodes.
=back
@ -46,17 +56,17 @@ Requests that rinstall become rcons once the provision commences. This will onl
B<rinstall> I<node1-node20>
Provison nodes 1 through 20, using configuration as is from tables.
Provison nodes 1 through 20, using their current configuration.
B<rinstall> -o rhels5.1 -p compute I<node1-node20>
B<rinstall> I<node1-node20> -o rhels5.1 -p compute
Provision nodes 1 through 20, forcing rhels5.1 and compute profile.
B<rinstall> -O rhels6.4-ppc64-netboot-compute I<node1-node20>
B<rinstall> I<node1-node20> -O rhels6.4-ppc64-netboot-compute
Provision nodes 1 through 20 with the osimage rhels6.4-ppc64-netboot-compute.
B<rinstall> -c I<node1>
B<rinstall> I<node1> -c
Provisoon node1 and start a console to monitor the process.

View File

@ -1,53 +1,64 @@
=head1 Name
B<winstall> - Begin OS provision on a noderange and display in wcons
B<winstall> - Begin OS provision on a noderange
=head1 B<Synopsis>
B<winstall> [I<-o>|I<--osver>] [I<-p>|I<--profile>] [I<-a>|I<--arch>] [I<-O>|I<--osimage>] [I<noderange>]
B<winstall> [I<-o>|I<--osver>] [I<-p>|I<--profile>] [I<-a>|I<--arch>] [I<noderange>]
B<winstall> [I<-O>|I<--osimage>] [I<noderange>]
=head1 B<Description>
B<winstall> is a convience command that will change tables as requested for operating system version, profile, and architecture, call nodeset to modify the network boot configuration, and rpower to begin a boot cycle.
B<winstall> is a convenience tool that will change attributes as requested for operating system version, profile, and architecture, call B<nodeset> to modify the network boot configuration, call B<rsetboot> net to set the next boot over network (only support nodes
with "nodetype.mgt=ipmi", for other nodes, make sure the correct boot order has been set before B<winstall>), and B<rpower> to begin a boot cycle.
If [I<-O>|I<--osimage>] is specified or nodetype.provmethod=I<osimage> is set, provision the noderange with the osimage specified/configured, ignore the table change options if specified
If [I<-O>|I<--osimage>] is specified or nodetype.provmethod=I<osimage> is set, provision the noderange with the osimage specified/configured, ignore the table change options if specified.
It will then commence a wcons command to the noderange for monitoring.
It will then run wcons on the nodes.
=head1 B<Options>
=over 7
=item B<-h>|B<--help>
Display usage message.
=item B<-v>|B<--version>
Display version.
=item B<-o>|B<--osver>
Specifies which os version to provision. If unspecified, the current table values are used. Will be ignored if [I<-O>|I<--osimage>] is specified or nodetype.provmethod=I<osimage>.
Specifies which os version to provision. If unspecified, the current node os setting is used. Will be ignored if [I<-O>|I<--osimage>] is specified or nodetype.provmethod=I<osimage>.
=item B<-p>|B<--profile>
Specifies what profile should be used of the operating system. If not specified the tables are used as is. Will be ignored if [I<-O>|I<--osimage>] is specified or nodetype.provmethod=I<osimage>.
Specifies what profile should be used of the operating system. If not specified the current node profile setting is used. Will be ignored if [I<-O>|I<--osimage>] is specified or nodetype.provmethod=I<osimage>.
=item B<-a>|B<--arch>
Specifies what architecture of the OS to provision. Typically this is unneeded, but if provisioning betweer x86_64 and x86 frequently, this may be a useful flag. Will be ignored if [I<-O>|I<--osimage>] is specified or nodetype.provmethod=I<osimage>.
Specifies what architecture of the OS to provision. Typically this is unneeded, but if provisioning between x86_64 and x86 frequently, this may be a useful flag. Will be ignored if [I<-O>|I<--osimage>] is specified or nodetype.provmethod=I<osimage>.
=item B<-O>|B<--osimage>
Specifies the osimage to provision.
Specifies the osimage to provision.
=back
=head1 B<Examples>
B<rinstall> I<node1-node20>
B<winstall> I<node1-node20>
Provison nodes 1 through 20, using configuration as is from tables.
Provison nodes 1 through 20, using their current configuration.
B<rinstall> -o rhels5.1 -p compute I<node1-node20>
B<winstall> I<node1-node20> -o rhels5.1 -p compute
Provision nodes 1 through 20, forcing rhels5.1 and compute profile.
B<rinstall> -O rhels6.4-ppc64-netboot-compute I<node1-node20>
B<winstall> I<node1-node20> -O rhels6.4-ppc64-netboot-compute
Provision nodes 1 through 20 with the osimage rhels6.4-ppc64-netboot-compute.