2008-03-27 18:36:32 +00:00
|
|
|
#!/usr/bin/perl
|
|
|
|
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
|
|
|
|
#(C)IBM Corp
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
use Getopt::Long;
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
=head1 mkrrnodes
|
|
|
|
|
2008-05-07 18:13:48 +00:00
|
|
|
Make node definitions for RR nodes
|
2008-03-27 18:36:32 +00:00
|
|
|
|
2008-04-23 12:16:52 +00:00
|
|
|
mkrrnodes -C <cu letter> -L < start Rack number for CU> -R <startrange,endrange> (add)
|
2008-03-27 18:36:32 +00:00
|
|
|
mkrrnodes -d -C <cu letter> -R <startrange,endrange> (delete)
|
2008-04-23 12:16:52 +00:00
|
|
|
|
2008-05-07 18:13:48 +00:00
|
|
|
example command:
|
|
|
|
mkrrnodes -C d -L 2 -R 1,180
|
2008-03-27 18:36:32 +00:00
|
|
|
|
2008-05-07 18:13:48 +00:00
|
|
|
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",,,
|
2008-03-27 18:36:32 +00:00
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
# Main
|
|
|
|
|
|
|
|
my $rc = 0;
|
|
|
|
|
|
|
|
&parse_args;
|
2008-04-23 12:16:52 +00:00
|
|
|
my $cmd = "";
|
2008-03-27 18:36:32 +00:00
|
|
|
my @bladename;
|
2008-04-23 12:16:52 +00:00
|
|
|
@bladename = ("a", "b", "c");
|
2008-03-27 18:36:32 +00:00
|
|
|
foreach my $CU (@::CU)
|
|
|
|
{
|
|
|
|
foreach my $range (@::RANGE)
|
|
|
|
{
|
|
|
|
foreach my $blade (@bladename)
|
|
|
|
{
|
2008-05-07 18:13:48 +00:00
|
|
|
my $nodeno = "";
|
|
|
|
if ($range <=9) { # want rr00X
|
|
|
|
$nodeno .="0";
|
|
|
|
}
|
|
|
|
if ($range <=99) { # want rr0XX
|
|
|
|
$nodeno .="0";
|
|
|
|
}
|
|
|
|
$nodeno .= $range;
|
|
|
|
|
2008-04-23 12:16:52 +00:00
|
|
|
$rack = "rack";
|
2008-05-07 18:13:48 +00:00
|
|
|
$bc = "bc";
|
2008-04-23 12:16:52 +00:00
|
|
|
$cmd = "rr";
|
2008-03-27 18:36:32 +00:00
|
|
|
$cmd .= $CU;
|
2008-05-07 18:13:48 +00:00
|
|
|
$cmd .= $nodeno;
|
2008-03-27 18:36:32 +00:00
|
|
|
$cmd .= "$blade";
|
|
|
|
$cmd .= " ";
|
2008-04-23 12:16:52 +00:00
|
|
|
if ($blade eq "a")
|
|
|
|
{
|
|
|
|
|
|
|
|
$cmd .=
|
2008-05-07 18:13:48 +00:00
|
|
|
"groups=rr$CU$nodeno,ls21,cu$CU,opteron,opteron-cu$CU,compute,tb,all";
|
2008-03-27 18:36:32 +00:00
|
|
|
}
|
2008-04-23 12:16:52 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if ($blade eq "b")
|
|
|
|
{
|
|
|
|
$cmd .=
|
2008-05-07 18:13:48 +00:00
|
|
|
"groups=rr$CU$nodeno,qs22,cu$CU,cell,cell-b,cell-cu$CU-b,cell-cu$CU,compute,all,tb";
|
2008-04-23 12:16:52 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{ # c
|
|
|
|
$cmd .=
|
2008-05-07 18:13:48 +00:00
|
|
|
"groups=rr$CU$nodeno,qs22,cu$CU,cell,cell-c,cell-cu$CU-c,cell-cu$CU,compute,all,tb";
|
2008-04-23 12:16:52 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-17 18:19:19 +00:00
|
|
|
# calculate the rack number ( 12 triblades/rack)
|
2008-04-23 12:16:52 +00:00
|
|
|
# 15 racks/CU
|
|
|
|
# Rack number = (triblade# / 12) +1
|
2008-08-05 12:35:42 +00:00
|
|
|
my $count = ($range -1) / 12;
|
2008-04-23 12:16:52 +00:00
|
|
|
my ($rackno, $rem) = split '\.', $count;
|
|
|
|
|
|
|
|
$rackno = $rackno + $::LOCATION;
|
|
|
|
if ($rackno <=9) { # want rack0X
|
|
|
|
$rack .="0";
|
|
|
|
}
|
|
|
|
$rack .= $rackno;
|
|
|
|
|
|
|
|
$cmd .= ",";
|
|
|
|
$cmd .= $rack;
|
2008-05-07 18:13:48 +00:00
|
|
|
|
|
|
|
# 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;
|
|
|
|
|
|
|
|
|
2008-04-23 12:16:52 +00:00
|
|
|
if ($::DELETE)
|
|
|
|
{
|
2008-05-07 18:13:48 +00:00
|
|
|
if ($::TEST) {
|
|
|
|
print ("noderm $cmd \n");
|
|
|
|
} else {
|
|
|
|
system("noderm $cmd");
|
|
|
|
}
|
2008-04-23 12:16:52 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-05-07 18:13:48 +00:00
|
|
|
if ($::TEST) {
|
|
|
|
print ("nodeadd $cmd \n");
|
|
|
|
} else {
|
|
|
|
system("nodeadd $cmd");
|
|
|
|
}
|
2008-03-27 18:36:32 +00:00
|
|
|
}
|
2008-04-23 12:16:52 +00:00
|
|
|
|
2008-03-27 18:36:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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");
|
2008-04-23 12:16:52 +00:00
|
|
|
my $usagemsg =
|
2008-05-07 18:13:48 +00:00
|
|
|
" mkrrnodes -h \n mkrrnodes [-d] -C [a|b|,...,r] -L [start rack number for CU] -R [startrange,endrange] [-t|--test]\n";
|
2008-03-27 18:36:32 +00:00
|
|
|
if (
|
|
|
|
!GetOptions(
|
|
|
|
'C|CU=s' => \$::CU,
|
2008-04-23 12:16:52 +00:00
|
|
|
'L|LOC=s' => \$::LOCATION,
|
2008-03-27 18:36:32 +00:00
|
|
|
'h|help' => \$::HELP,
|
|
|
|
'd|delete' => \$::DELETE,
|
2008-05-07 18:13:48 +00:00
|
|
|
'R|RANGE=s' => \$::RANGE,
|
|
|
|
't|test' => \$::TEST
|
2008-03-27 18:36:32 +00:00
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
{
|
|
|
|
printf $usagemsg;
|
|
|
|
exit 1;
|
|
|
|
}
|
|
|
|
if ($::HELP)
|
|
|
|
{
|
|
|
|
printf $usagemsg;
|
|
|
|
exit 0;
|
|
|
|
}
|
2008-04-23 12:16:52 +00:00
|
|
|
@::CU = split(',', $::CU);
|
|
|
|
|
|
|
|
my ($fNum, $eNum) = split(',', $::RANGE);
|
2008-03-27 18:36:32 +00:00
|
|
|
my $prefix;
|
|
|
|
foreach my $suffix ($fNum .. $eNum)
|
|
|
|
{
|
2008-04-23 12:16:52 +00:00
|
|
|
my $numOfZeros = (length($fNum) - length($suffix));
|
|
|
|
my $prefix = '0' x $numOfZeros;
|
|
|
|
push @::RANGE, "$fRoot$prefix$suffix$fDomain";
|
2008-03-27 18:36:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|