add code comments

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/branches/2.8@16519 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
immarvin 2013-06-01 12:13:14 +00:00
parent b8e32de9c8
commit 8210f4d82a

View File

@ -1,4 +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]
# to make ease of node OS provision
# To use this, sym link your cmd name to this script.
use strict;
BEGIN
@ -57,20 +64,36 @@ 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($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"};
if($ARCH) {print 'warning: "'.$optstring.'" specified, "[-a|--arch] '.$OSVER."\" ignored\n"};
}
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) { die "nodeset failure" };
}else
{
# 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, complain and return
# group the nodes according to the nodetype.provmethod
@allnodes=noderange($noderange);
foreach(@allnodes){
my $tab=xCAT::Table->new("nodetype");
@ -92,7 +115,9 @@ if($OSIMAGE){
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";
@ -121,11 +146,15 @@ if($OSIMAGE){
}
elsif($key eq 'BLANK###')
{
# nodetype.provmethod is not set
print "nodetype.provmethod must be specified for nodes: $nodes\n";
$rc=1;
}
else
{
# nodetype.provmethod = <osimage>
&checkoption("nodetype.provmethod=$key");
$rclocal=system("nodeset $nodes osimage");
if ($rclocal) {
@ -141,11 +170,14 @@ if($rc){
die "nodeset failure";
}
# call "rpower" to start the node provision process
$rc=system("rpower $noderange boot");
if ($rc) { die "rpower failure" };
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){
die "rinstall [-c|--console] will only work if there is only one node in the noderange. See winstall(8) for consoles on multiple systems";
@ -153,5 +185,7 @@ if (basename($0) =~ /rinstall/) {
exec("rcons $noderange");
}
} elsif (basename($0) =~ /winstall/) {
# winstall can commence a wcons command to the noderange for monitoring the provision cycle
exec("wcons $noderange");
}