fix defect #3463 rinstall does not support provmethod=osimagename
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/branches/2.8@16501 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
parent
268d20215e
commit
4e9d9d0b7a
@ -1,20 +1,39 @@
|
||||
#!/usr/bin/env perl
|
||||
use strict;
|
||||
use Getopt::Long;
|
||||
|
||||
BEGIN
|
||||
{
|
||||
$::XCATROOT =
|
||||
$ENV{'XCATROOT'} ? $ENV{'XCATROOT'}
|
||||
: -d '/opt/xcat' ? '/opt/xcat'
|
||||
: '/usr';
|
||||
}
|
||||
|
||||
use lib "$::XCATROOT/lib/perl";
|
||||
use File::Basename;
|
||||
use Getopt::Long;
|
||||
use xCAT::Table;
|
||||
use xCAT::NodeRange;
|
||||
|
||||
sub usage {
|
||||
print basename($0)." usage:\n";
|
||||
print " ".basename($0)." [-o|--osver [-p|--profile] [-a|--arch] [-c|--console] <noderange>\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;
|
||||
@ -31,30 +50,106 @@ if ($arraysize == 0) {
|
||||
usage;
|
||||
exit 1;
|
||||
}
|
||||
|
||||
my $noderange=@ARGV[0];
|
||||
my $rc=0;
|
||||
my %pnhash;
|
||||
my @allnodes;
|
||||
#use Data::Dumper;
|
||||
|
||||
my $nodechline = "";
|
||||
if ($OSVER) {
|
||||
$nodechline = "nodetype.os=$OSVER";
|
||||
}
|
||||
if ($PROFILE) {
|
||||
$nodechline .= " nodetype.profile=$PROFILE";
|
||||
}
|
||||
if ($ARCH) {
|
||||
$nodechline .= " nodetype.arch=$ARCH";
|
||||
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"};
|
||||
}
|
||||
|
||||
my $rc;
|
||||
if ($nodechline) {
|
||||
$rc=system("nodech $noderange $nodechline");
|
||||
|
||||
if($OSIMAGE){
|
||||
&checkoption("[-O|--osimage] $OSIMAGE");
|
||||
$rc=system("nodeset $noderange osimage=$OSIMAGE");
|
||||
if ($rc) { die "nodeset failure" };
|
||||
}else
|
||||
{
|
||||
@allnodes=noderange($noderange);
|
||||
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
|
||||
{
|
||||
push(@{$pnhash{'BLANK###'}},$_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
foreach my $key (keys %pnhash)
|
||||
{
|
||||
my $rclocal=0;
|
||||
my $nodes=join(',',@{$pnhash{$key}});
|
||||
if($key =~ /^(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;
|
||||
}
|
||||
}
|
||||
}
|
||||
elsif($key eq 'BLANK###')
|
||||
{
|
||||
print "nodetype.provmethod must be specified for nodes: $nodes\n";
|
||||
$rc=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
&checkoption("nodetype.provmethod=$key");
|
||||
$rclocal=system("nodeset $nodes osimage");
|
||||
if ($rclocal) {
|
||||
print "nodeset $nodes failure\n";
|
||||
$rc=$rclocal;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if ($rc) { die "nodech failure" };
|
||||
$rc=system("nodeset $noderange install");
|
||||
if ($rc) { die "nodeset failure" };
|
||||
|
||||
if($rc){
|
||||
die "nodeset failure";
|
||||
}
|
||||
|
||||
|
||||
$rc=system("rpower $noderange boot");
|
||||
if ($rc) { die "rpower failure" };
|
||||
|
||||
if (basename($0) =~ /rinstall/) {
|
||||
if ($CONSOLE) {
|
||||
if(scalar @allnodes ne 1){
|
||||
die "rinstall [-c|--console] will only work if there is only one node in the noderange. See winstall(8) for consoles on multiple systems";
|
||||
}
|
||||
exec("rcons $noderange");
|
||||
}
|
||||
} elsif (basename($0) =~ /winstall/) {
|
||||
|
@ -1,15 +1,18 @@
|
||||
=head1 Name
|
||||
|
||||
B<rinstall> - Begin installation on a noderange
|
||||
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<-c>|I<--console>] [I<noderange>]
|
||||
B<rinstall> [I<-o>|I<--osver>] [I<-p>|I<--profile>] [I<-a>|I<--arch>] [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 nodeset to modify the network boot configuration, and rpower to begin a boot cycle. 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>.
|
||||
B<rinstall> 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.
|
||||
|
||||
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>.
|
||||
|
||||
=head1 B<Options>
|
||||
|
||||
@ -17,21 +20,24 @@ text console of the node. If wanting consoles on multiple nodes with a similar
|
||||
|
||||
=item B<-o>|B<--osver>
|
||||
|
||||
Specifies which os version to install. If unspecified, the current table values are used.
|
||||
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>.
|
||||
|
||||
=item B<-p>|B<--profile>
|
||||
|
||||
Specifies what profile should be used of the operating system. If not specified the tables are used as is.
|
||||
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>.
|
||||
|
||||
|
||||
=item B<-a>|B<--arch>
|
||||
|
||||
Specifies what architecture of the OS to install. Typically this is unneeded, but if provisioning betweer x86_64 and x86 frequently, this may be a useful flag.
|
||||
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>.
|
||||
|
||||
=item B<-O>|B<--osimage>
|
||||
|
||||
Specifies the osimage to provision.
|
||||
|
||||
=item B<-c>|B<--console>
|
||||
|
||||
|
||||
Requests that rinstall become rcons once the install 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 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.
|
||||
|
||||
=back
|
||||
|
||||
@ -40,15 +46,19 @@ Requests that rinstall become rcons once the install commences. This will only
|
||||
|
||||
B<rinstall> I<node1-node20>
|
||||
|
||||
Install nodes 1 through 20, using configuration as is from tables.
|
||||
Provison nodes 1 through 20, using configuration as is from tables.
|
||||
|
||||
B<rinstall> -o rhels5.1 -p compute I<node1-node20>
|
||||
|
||||
Install nodes 1 through 20, forcing rhels5.1 and compute profile.
|
||||
Provision nodes 1 through 20, forcing rhels5.1 and compute profile.
|
||||
|
||||
B<rinstall> -O rhels6.4-ppc64-netboot-compute I<node1-node20>
|
||||
|
||||
Provision nodes 1 through 20 with the osimage rhels6.4-ppc64-netboot-compute.
|
||||
|
||||
B<rinstall> -c I<node1>
|
||||
|
||||
Install node1 and start a console to monitor the process
|
||||
Provisoon node1 and start a console to monitor the process.
|
||||
|
||||
|
||||
=head1 B<See> B<Also>
|
||||
|
@ -1,15 +1,18 @@
|
||||
=head1 Name
|
||||
|
||||
B<winstall> - Begin installation on a noderange and display in wcons
|
||||
B<winstall> - Begin OS provision on a noderange and display in wcons
|
||||
|
||||
=head1 B<Synopsis>
|
||||
|
||||
B<winstall> [I<-o>|I<--osver>] [I<-p>|I<--profile>] [I<-a>|I<--arch>] [I<noderange>]
|
||||
B<winstall> [I<-o>|I<--osver>] [I<-p>|I<--profile>] [I<-a>|I<--arch>] [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. It will then commence a wcons command to the
|
||||
noderange for monitoring.
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
=head1 B<Options>
|
||||
|
||||
@ -17,28 +20,36 @@ noderange for monitoring.
|
||||
|
||||
=item B<-o>|B<--osver>
|
||||
|
||||
Specifies which os version to install. If unspecified, the current table values are used.
|
||||
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>.
|
||||
|
||||
=item B<-p>|B<--profile>
|
||||
|
||||
Specifies what profile should be used of the operating system. If not specified the tables are used as is.
|
||||
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>.
|
||||
|
||||
|
||||
=item B<-a>|B<--arch>
|
||||
|
||||
Specifies what architecture of the OS to install. Typically this is unneeded, but if provisioning betweer x86_64 and x86 frequently, this may be a useful flag.
|
||||
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>.
|
||||
|
||||
=item B<-O>|B<--osimage>
|
||||
|
||||
Specifies the osimage to provision.
|
||||
|
||||
=back
|
||||
|
||||
=head1 B<Examples>
|
||||
|
||||
B<winstall> I<node1-node20>
|
||||
B<rinstall> I<node1-node20>
|
||||
|
||||
Install nodes 1 through 20, using configuration as is from tables.
|
||||
Provison nodes 1 through 20, using configuration as is from tables.
|
||||
|
||||
B<winstall> -o rhels5.1 -p compute I<node1-node20>
|
||||
B<rinstall> -o rhels5.1 -p compute I<node1-node20>
|
||||
|
||||
Install nodes 1 through 20, forcing rhels5.1 and compute profile.
|
||||
Provision nodes 1 through 20, forcing rhels5.1 and compute profile.
|
||||
|
||||
B<rinstall> -O rhels6.4-ppc64-netboot-compute I<node1-node20>
|
||||
|
||||
Provision nodes 1 through 20 with the osimage rhels6.4-ppc64-netboot-compute.
|
||||
|
||||
=head1 B<See> B<Also>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user