new RR script to create AMM and switch nodes, updates to mkrrnodes for bc group and to add leading 0s to nodenums, added test options to both scripts

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@1314 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
mellor 2008-05-07 18:13:48 +00:00
parent f2c903e89f
commit a3fac8e2d4
2 changed files with 200 additions and 11 deletions

View File

@ -0,0 +1,151 @@
#!/usr/bin/perl
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
#(C)IBM Corp
#
use Getopt::Long;
#-----------------------------------------------------------------------------
=head1 mkrrbc
Make node definitions for AMMs and Switches (one each per bladecenter)
mkrrbc -C <cu letter> -L < start Rack number for CU> -R <startrange,endrange> (add)
mkrrbc -d -C <cu letter> -R <startrange,endrange> (delete)
./mkrrbc -C d -L 2 -R 1,60
will run commands such as:
nodeadd bcd60 groups=mm,cud,rack16
nodeadd swd60 groups=nortel,switch,cud,rack16
and build nodelist entries that looks like this:
"bcd60","mm,cud,rack16",,,
"swd60","nortel,switch,cud,rack16",,,
=cut
#-----------------------------------------------------------------------------
# Main
my $rc = 0;
&parse_args;
my $bccmd = "";
my $swcmd = "";
foreach my $CU (@::CU)
{
foreach my $range (@::RANGE)
{
$nodeno = "";
if ($range <=9) { # want rr0X
$nodeno .="0";
}
$nodeno .= $range;
$rack = "rack";
$bccmd = "bc";
$swcmd = "sw";
$bccmd .= $CU;
$swcmd.= $CU;
$bccmd .= $nodeno;
$swcmd.= $nodeno;
$bccmd .= " ";
$swcmd.= " ";
$bccmd .= "groups=mm,cu$CU";
$swcmd .= "groups=nortel,switch,cu$CU";
# calculate the rack number ( 4 AMMs/rack)
# 15 racks/CU
# Rack number = (AMM# / 4)
my $count = ($range-1) / 4;
my ($rackno, $rem) = split '\.', $count;
$rackno = $rackno + $::LOCATION;
if ($rackno <=9) { # want rack0X
$rack .="0";
}
$rack .= $rackno;
$bccmd .= ",";
$bccmd .= $rack;
$swcmd .= ",";
$swcmd .= $rack;
if ($::DELETE)
{
if ($::TEST) {
print ("noderm $bccmd \n");
print ("noderm $swcmd \n");
} else {
system("noderm $bccmd");
system("noderm $swcmd");
}
}
else
{
if ($::TEST) {
print ("nodeadd $bccmd \n");
print ("nodeadd $swcmd \n");
} else {
system("nodeadd $bccmd");
system("nodeadd $swcmd");
}
}
}
}
exit $rc;
#-----------------------------------------------------------------------------
=head3 parse_args
Parses for input
=cut
#-----------------------------------------------------------------------------
sub parse_args
{
Getopt::Long::Configure("posix_default");
Getopt::Long::Configure("no_gnu_compat");
Getopt::Long::Configure("bundling");
my $usagemsg =
" mkrrbc -h \n mkrrbc [-d] -C [a|b|,...,r] -L [start rack number for CU] -R [startrange,endrange] [-t|--test]\n";
if (
!GetOptions(
'C|CU=s' => \$::CU,
'L|LOC=s' => \$::LOCATION,
'h|help' => \$::HELP,
'd|delete' => \$::DELETE,
'R|RANGE=s' => \$::RANGE,
't|test' => \$::TEST
)
)
{
printf $usagemsg;
exit 1;
}
if ($::HELP)
{
printf $usagemsg;
exit 0;
}
@::CU = split(',', $::CU);
my ($fNum, $eNum) = split(',', $::RANGE);
my $prefix;
foreach my $suffix ($fNum .. $eNum)
{
my $numOfZeros = (length($fNum) - length($suffix));
my $prefix = '0' x $numOfZeros;
push @::RANGE, "$fRoot$prefix$suffix$fDomain";
}
}

View File

@ -10,14 +10,18 @@ use Getopt::Long;
=head1 mkrrnodes
Make node definitions for RR nodes
mkrrnodes -C <cu letter> -L < start Rack number for CU> -R <startrange,endrange> (add)
mkrrnodes -d -C <cu letter> -R <startrange,endrange> (delete)
Build an nodelist entry that looks like this
"rrb048c","rrb048,qs22,cub,cell,cell-cub-c,cell-c,compute,tb,all,rack16",,,,
example command:
mkrrnodes -C d -L 2 -R 1,180
Builds some nodelist entries that look like this
"rrd171a","rrd171,ls21,cud,opteron,opteron-cud,compute,tb,all,rack16,bc57",,,
"rrd171b","rrd171,qs22,cud,cell,cell-b,cell-cud-b,cell-cud,compute,all,tb,rack16,bc57",,,
"rrd171c","rrd171,qs22,cud,cell,cell-c,cell-cud-c,cell-cud,compute,all,tb,rack16,bc57",,,
=cut
@ -36,29 +40,39 @@ foreach my $CU (@::CU)
{
foreach my $blade (@bladename)
{
my $nodeno = "";
if ($range <=9) { # want rr00X
$nodeno .="0";
}
if ($range <=99) { # want rr0XX
$nodeno .="0";
}
$nodeno .= $range;
$rack = "rack";
$bc = "bc";
$cmd = "rr";
$cmd .= $CU;
$cmd .= $range;
$cmd .= $nodeno;
$cmd .= "$blade";
$cmd .= " ";
if ($blade eq "a")
{
$cmd .=
"groups=rr$CU$range,ls21,cu$CU,opteron,opteron-cu$CU,compute,tb,all";
"groups=rr$CU$nodeno,ls21,cu$CU,opteron,opteron-cu$CU,compute,tb,all";
}
else
{
if ($blade eq "b")
{
$cmd .=
"groups=rr$CU$range,qs22,cu$CU,cell,cell-b,cell-cu$CU-b,cell-cu$CU,compute,all,tb";
"groups=rr$CU$nodeno,qs22,cu$CU,cell,cell-b,cell-cu$CU-b,cell-cu$CU,compute,all,tb";
}
else
{ # c
$cmd .=
"groups=rr$CU$range,qs22,cu$CU,cell,cell-c,cell-cu$CU-c,cell-cu$CU,compute,all,tb";
"groups=rr$CU$nodeno,qs22,cu$CU,cell,cell-c,cell-cu$CU-c,cell-cu$CU,compute,all,tb";
}
}
@ -77,13 +91,36 @@ foreach my $CU (@::CU)
$cmd .= ",";
$cmd .= $rack;
# calculate the BC number ( 3 triblades/BladeCenter)
# BC number = (triblade# / 3)
my $count = (($range-1) / 3) + 1 ;
my ($bcno, $rem) = split '\.', $count;
if ($bcno <=9) { # want bc0X
$bc .="0";
}
$bc .= $bcno;
$cmd .= ",";
$cmd .= $bc;
if ($::DELETE)
{
system("noderm $cmd");
if ($::TEST) {
print ("noderm $cmd \n");
} else {
system("noderm $cmd");
}
}
else
{
system("nodeadd $cmd");
if ($::TEST) {
print ("nodeadd $cmd \n");
} else {
system("nodeadd $cmd");
}
}
}
@ -107,14 +144,15 @@ sub parse_args
Getopt::Long::Configure("no_gnu_compat");
Getopt::Long::Configure("bundling");
my $usagemsg =
" mkrrnodes -h \n mkrrnodes [-d] -C [a|b|,...,r] -L [start rack number for CU] -R [startrange,endrange]\n";
" mkrrnodes -h \n mkrrnodes [-d] -C [a|b|,...,r] -L [start rack number for CU] -R [startrange,endrange] [-t|--test]\n";
if (
!GetOptions(
'C|CU=s' => \$::CU,
'L|LOC=s' => \$::LOCATION,
'h|help' => \$::HELP,
'd|delete' => \$::DELETE,
'R|RANGE=s' => \$::RANGE
'R|RANGE=s' => \$::RANGE,
't|test' => \$::TEST
)
)