defect 3397
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/branches/2.8@15336 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
parent
1919c0b25d
commit
0dd99cd1cf
@ -1,362 +0,0 @@
|
||||
#!/usr/bin/env perl
|
||||
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
|
||||
#
|
||||
#####################################################
|
||||
# cfm2xcat:
|
||||
#
|
||||
# This routine will read in cfmupdatenode distribution files
|
||||
# and build the files need to input to xdcp rsync function
|
||||
# in xCAT.
|
||||
#
|
||||
# cfm2xcat will run cfmupdatenode -a, it sets the environment
|
||||
# variable CSM_CFM_SAVE_DISTFILE to the file path input with the -i option
|
||||
# to save the built cfm distribution file(s).
|
||||
# These are normally deleted after cfm runs.
|
||||
#
|
||||
# cfm2xcat will then take the files that were created from calling
|
||||
# cfmupdatenode and create xCAT xdcp files synch files and store them in the
|
||||
# path input with the -o flag.
|
||||
#
|
||||
# Example:
|
||||
# cfm2xcat -i <...cfmsave> -o < path to output file>
|
||||
# cfm2xcat -i /tmp/cfmsave -o /tmp/xcat/xcatdistfile
|
||||
#
|
||||
# The routine will process all the /.../cfmsave* files and when finished,
|
||||
# you will have the new files xcatdistfile* and noderange* generated which
|
||||
# will be the correct format to input to the xdcp -F command in xCAT to run
|
||||
# the equivalent syncing of files that you were running on CSM.
|
||||
#
|
||||
# Take the files in the /tmp/xcat/* directory from the example above and
|
||||
# place on your xCAT Management Node. Then run for each file combination:
|
||||
# xdcp ^/tmp/xcat/noderange1 -F /tmp/xcat/xcatdistfile1
|
||||
# More information is in the manpage for cfm2xcat and xdcp
|
||||
#####################################################
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Getopt::Long;
|
||||
use Data::Dumper;
|
||||
|
||||
my $help;
|
||||
my $input;
|
||||
my $output;
|
||||
my $rc = 0;
|
||||
|
||||
if (
|
||||
!GetOptions(
|
||||
'h|help' => \$help,
|
||||
'i|input=s' => \$input,
|
||||
'o|output=s' => \$output,
|
||||
)
|
||||
)
|
||||
{
|
||||
&usage;
|
||||
exit 1;
|
||||
}
|
||||
|
||||
if ($help)
|
||||
{
|
||||
&usage;
|
||||
exit 0;
|
||||
}
|
||||
if (!($input))
|
||||
{
|
||||
print "Input file path must be supplied with the -i flag.\n";
|
||||
exit 1;
|
||||
}
|
||||
if (!($output))
|
||||
{
|
||||
print "Output file path and name must be supplied with the -o flag.\n";
|
||||
exit 1;
|
||||
}
|
||||
|
||||
# call cfmupdatenode and build cfm distribution files
|
||||
&buildcfmdistfiles($input);
|
||||
if (-e ($input)) # if anything built
|
||||
{
|
||||
|
||||
# build the xcat sync files
|
||||
$rc = &buildxcatrsyncfiles($input, $output);
|
||||
if ($rc == 0)
|
||||
{
|
||||
print
|
||||
"Conversion finished, please carefully review $output files! Make sure that all the files list to sync to the nodes are relevant and available on the xCAT system in the directory indicated. \n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print " Error converting cfm file to xdcp files.\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print " Error building CFM dist files, or nothing to do.\n";
|
||||
}
|
||||
exit 0;
|
||||
|
||||
# end main
|
||||
#
|
||||
#
|
||||
# Builds the CFM distribution files from the cfmupdatenode -a call
|
||||
#
|
||||
|
||||
sub buildcfmdistfiles
|
||||
{
|
||||
|
||||
my ($cfmfile) = @_;
|
||||
my $cmd;
|
||||
my @output;
|
||||
|
||||
# remove old files , if they exist
|
||||
my $tmpcfmfile = $cfmfile;
|
||||
if (-e ($tmpcfmfile))
|
||||
{
|
||||
$tmpcfmfile .= "*";
|
||||
$cmd = "rm $tmpcfmfile";
|
||||
@output = runcmd($cmd);
|
||||
if ($::RUNCMD_RC != 0)
|
||||
{
|
||||
print " Error running $cmd.\n";
|
||||
return 1;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
# export the CSM_CFM_SAVE_DISTFILE variable to the input (-i)
|
||||
# path, makes cfmupdatenode save the dist file(s) from the run in a
|
||||
# file by that name
|
||||
|
||||
$cmd = "CSM_CFM_SAVE_DISTFILE=$cfmfile cfmupdatenode -a";
|
||||
|
||||
# run the cfmupdate command
|
||||
@output = runcmd($cmd);
|
||||
if ($::RUNCMD_RC != 0)
|
||||
{
|
||||
print " Error running $cmd.\n";
|
||||
return 1;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#
|
||||
#
|
||||
# Builds the xdcp sync files from the CFM dist files
|
||||
#
|
||||
|
||||
sub buildxcatrsyncfiles
|
||||
{
|
||||
|
||||
my ($CFMfiles, $xcatfile) = @_;
|
||||
my $cmd;
|
||||
my @output;
|
||||
my %noderangequeue;
|
||||
|
||||
# remove old files, if they exist
|
||||
my $tmpxcatfile = $xcatfile;
|
||||
if (-e ($tmpxcatfile))
|
||||
{
|
||||
$tmpxcatfile .= "*";
|
||||
$cmd = "rm $tmpxcatfile";
|
||||
@output = runcmd($cmd);
|
||||
if ($::RUNCMD_RC != 0)
|
||||
{
|
||||
print " Error running $cmd.\n";
|
||||
return 1;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
# get list of CFM files that were built
|
||||
$cmd = "ls $CFMfiles";
|
||||
$cmd .= "*";
|
||||
my @CFMfilelist = runcmd($cmd);
|
||||
if ($::RUNCMD_RC != 0)
|
||||
{
|
||||
print " Error running $cmd.\n";
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
my $msg = "Building xCat rsync files $xcatfile from $CFMfiles\n";
|
||||
print "$msg";
|
||||
|
||||
# For each CFM output file, open the CFM input file to read
|
||||
foreach my $cfmfile (@CFMfilelist)
|
||||
{
|
||||
open(CFM, "< $cfmfile")
|
||||
or die "Can't open $cfmfile for reading: $!";
|
||||
|
||||
#
|
||||
# convert the CFM rdist format to the xdcp format for rsync
|
||||
# build a hash of noderange -> to distribution files
|
||||
#
|
||||
while (my $line = <CFM>)
|
||||
{
|
||||
chomp $line;
|
||||
if ($line =~ /^#/) # skip commments
|
||||
{
|
||||
next;
|
||||
}
|
||||
if ($line =~ /.runclocal/) # skip sending runclocal
|
||||
{
|
||||
next;
|
||||
}
|
||||
my ($sourcefile, $rest) = split("->", $line);
|
||||
my ($tmpnodes, $destfile) = split("install", $rest);
|
||||
|
||||
# get rid of parenthesis
|
||||
my ($paren, $tnodes) = split(/\(/, $tmpnodes);
|
||||
my ($nodes, $paren2) = split(/\)/, $tnodes);
|
||||
chomp $nodes;
|
||||
|
||||
# strip off /cfmroot and /var/opt/csm/cfmlocal paths
|
||||
|
||||
my ($root, $strippedsourcefile) = split("cfmroot", $sourcefile);
|
||||
chomp $strippedsourcefile;
|
||||
my ($root2, $strippeddestfile) = split("cfmlocal", $destfile);
|
||||
chomp $strippeddestfile;
|
||||
chop $strippeddestfile;
|
||||
$noderangequeue{$nodes}{'files'}{$strippedsourcefile} =
|
||||
$strippeddestfile;
|
||||
|
||||
}
|
||||
|
||||
close(CFM);
|
||||
}
|
||||
|
||||
#
|
||||
# now take the hash and build the xdcp file(s), key is the noderange
|
||||
# (use short hostname)
|
||||
# one for each noderange and a matching noderange file
|
||||
# for example xdcpfile1 xdcpfile1.noderange
|
||||
#
|
||||
my $index;
|
||||
foreach (keys %noderangequeue)
|
||||
{
|
||||
my $noderange = $_;
|
||||
|
||||
# open the xCAT output files to write
|
||||
|
||||
my $newxcatfilenr = $xcatfile;
|
||||
$newxcatfilenr .= ".nr";
|
||||
|
||||
# file to hold the noderange
|
||||
if ($index)
|
||||
{ # processing more than one noderange then building
|
||||
# more than one xdcp file
|
||||
$newxcatfilenr .= "$index";
|
||||
}
|
||||
open(XCATNR, "> $newxcatfilenr")
|
||||
or die "Can't open $newxcatfilenr for writing: $!";
|
||||
|
||||
# create an appropriate noderange ( comma seperated)
|
||||
my @nodes = split(/ /, $noderange);
|
||||
my $goodnr = "";
|
||||
foreach my $node (@nodes)
|
||||
{
|
||||
if ($node !~ /^\s*$/)
|
||||
{ #skip blanks
|
||||
my @shorthost = split(/\./, $node);
|
||||
$goodnr .= $shorthost[0];
|
||||
$goodnr .= ",";
|
||||
|
||||
}
|
||||
}
|
||||
chop $goodnr;
|
||||
|
||||
# write into the noderange file
|
||||
write_line_nr($goodnr);
|
||||
write_line_nr("\n");
|
||||
|
||||
# file to hold the rsync interface file to file list
|
||||
my $newxcatfile = $xcatfile;
|
||||
|
||||
# file to hold the noderange
|
||||
if ($index)
|
||||
{ # processing more than one noderange then building
|
||||
# more than one xdcp file
|
||||
$newxcatfile .= "$index";
|
||||
}
|
||||
open(XCAT, "> $newxcatfile")
|
||||
or die "Can't open $newxcatfile for writing: $!";
|
||||
my $srcfile;
|
||||
my $destfile;
|
||||
foreach my $sourcefile (keys %{$noderangequeue{$noderange}{'files'}})
|
||||
{
|
||||
$srcfile = $sourcefile;
|
||||
$destfile = $noderangequeue{$noderange}{'files'}{$sourcefile};
|
||||
write_line($srcfile);
|
||||
write_line("-> ");
|
||||
write_line($destfile);
|
||||
write_line("\n");
|
||||
}
|
||||
close(XCAT);
|
||||
close(XCATNR);
|
||||
$index++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#
|
||||
# runs the input command and handles the errors. Returns the output
|
||||
#
|
||||
|
||||
sub runcmd
|
||||
{
|
||||
my ($cmd) = @_;
|
||||
my $rc = 0;
|
||||
$::RUNCMD_RC = 0;
|
||||
my $outref = [];
|
||||
@$outref = `$cmd`;
|
||||
if ($?)
|
||||
{
|
||||
$rc = $?;
|
||||
$::RUNCMD_RC = $rc;
|
||||
if ($rc > 0)
|
||||
{
|
||||
my $msg = "$cmd returned rc=$rc @$outref\n";
|
||||
print "$msg";
|
||||
}
|
||||
}
|
||||
chomp(@$outref);
|
||||
return @$outref;
|
||||
|
||||
}
|
||||
|
||||
sub usage
|
||||
{
|
||||
print "CFM distribution file to xCAT xdcp rsync migration facility.\n";
|
||||
print "Usage:\n";
|
||||
print "\t-h - usage\n";
|
||||
print
|
||||
"\t-i - Complete path to the CFM file(s) saved to be converted for xCAT.";
|
||||
print " Be sure directory exists.\n";
|
||||
print
|
||||
"\t-o - Complete Path to the xCAT xdcp rsync input file(s) created from.";
|
||||
print " the CFM file. Be sure directory exists.\n";
|
||||
print
|
||||
" Example: cfm2xcat -i /tmp/migration/cfmfiles -o /tmp/migration/xdcpfiles.";
|
||||
print "\n";
|
||||
return;
|
||||
}
|
||||
|
||||
#
|
||||
# write to xCAT rsync files
|
||||
#
|
||||
sub write_line
|
||||
{
|
||||
print XCAT @_;
|
||||
}
|
||||
|
||||
#
|
||||
# write to xCAT rsync noderange files
|
||||
#
|
||||
sub write_line_nr
|
||||
{
|
||||
print XCATNR @_;
|
||||
}
|
||||
|
@ -1,68 +0,0 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
#
|
||||
# Used this script while testing the port of xCAT to AIX - might turn it
|
||||
# into a real command some day.
|
||||
#
|
||||
# Just want to save it for future reference - Norm - 4/22/2008
|
||||
#
|
||||
#-----------------------------------------------------------------------
|
||||
#
|
||||
# This script can be used to completely clean up an AIX xCAT management node
|
||||
# so that it can be used to do a fresh install.
|
||||
#
|
||||
# It will uninstall the xCAT RPMs and OSS prereq RPMs but doesn't remove
|
||||
# the openssh and openssl installp packages.
|
||||
#
|
||||
# It will also remove some additional files/directories that were created by
|
||||
# xCAT.
|
||||
#
|
||||
|
||||
BEGIN
|
||||
{
|
||||
$::XCATDIR = $ENV{'XCATDIR'} ? $ENV{'XCATDIR'} : '/etc/xcat';
|
||||
}
|
||||
|
||||
print " Removing xCAT RPMs.\n";
|
||||
`rpm -e xCAT-2.0`;
|
||||
`rpm -e xCAT-server-2.0`;
|
||||
`rpm -e xCAT-client-2.0`;
|
||||
`rpm -e perl-xCAT-2.0`;
|
||||
|
||||
print " Removing /install & /etc/xcat.\n";
|
||||
# rm /install dir
|
||||
`rm -rf /install`;
|
||||
|
||||
# remove /etc/xcat
|
||||
`rm -rf $::XCATDIR`;
|
||||
|
||||
print " Removing SSH keys (/.ssh) and xcatd certificates (/.xcat).\n";
|
||||
`rm -rf /.ssh`;
|
||||
`rm -rf /.xcat`;
|
||||
|
||||
print " Removing OSS prerequisite software.\n";
|
||||
`rpm -e fping-2.2b1-1`;
|
||||
`rpm -e perl-Digest-MD5-2.36-1`;
|
||||
`rpm -e perl-Net_SSLeay.pm-1.30-1`;
|
||||
`rpm -e perl-IO-Socket-SSL-1.06-1`;
|
||||
`rpm -e perl-IO-Stty-.02-1`;
|
||||
`rpm -e perl-IO-Tty-1.07-1`;
|
||||
`rpm -e perl-Expect-1.21-1`;
|
||||
`rpm -e conserver-8.1.16-2`;
|
||||
`rpm -e perl-DBD-SQLite-1.13-1`;
|
||||
`rpm -e perl-DBI-1.55-1`;
|
||||
|
||||
print " Killing the xcatd processes.\n";
|
||||
my @xpids = `ps -ef\|grep \"xcatd\"`;
|
||||
foreach $ps (@xpids)
|
||||
{
|
||||
$ps =~ s/^\s+//; # strip any leading spaces
|
||||
my ($uid, $pid, $ppid, $desc) = split /\s+/, $ps;
|
||||
# if $ps contains "grep" then it's not one of the daemon processes
|
||||
if ( $ps !~/grep/)
|
||||
{
|
||||
# print "pid=$pid\n";
|
||||
`/bin/kill -9 $pid`;
|
||||
}
|
||||
}
|
||||
exit 0;
|
@ -1,730 +0,0 @@
|
||||
#!/usr/bin/env perl
|
||||
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
|
||||
#
|
||||
#####################################################
|
||||
#
|
||||
# This script will read the CSM database and build
|
||||
# xCAT stanza files to be input into an xCAT database
|
||||
# using the chdef command
|
||||
# example node.stanza | chdef -z
|
||||
#
|
||||
#####################################################
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Getopt::Long;
|
||||
use Data::Dumper;
|
||||
|
||||
my $needhelp = 0;
|
||||
my $directory = "/tmp/csm2xcat";
|
||||
|
||||
if (
|
||||
!GetOptions("help" => \$needhelp,
|
||||
"dir=s" => \$directory,)
|
||||
)
|
||||
{
|
||||
&usage;
|
||||
exit 1;
|
||||
}
|
||||
|
||||
if ($needhelp)
|
||||
{
|
||||
&usage;
|
||||
exit 0;
|
||||
}
|
||||
|
||||
#Create the users choice directory
|
||||
mkdir $directory unless -d $directory;
|
||||
|
||||
# create a log
|
||||
open(LOG, ">$directory/conversion.log")
|
||||
or die "Can't open logfile for writing: $!";
|
||||
&log_this("Conversion started at " . scalar(localtime()));
|
||||
|
||||
# build the stanza files for the site table
|
||||
# rsh/rcp attribute not longer supported. Leave logic here
|
||||
# incase we decide there are other attribute needed
|
||||
#&getSiteinfo;
|
||||
|
||||
# build the stanza files for the node
|
||||
&getNodeinfo;
|
||||
|
||||
# build the stanza files for the devices
|
||||
&getDevinfo;
|
||||
|
||||
log_this("Conversion finished at " . scalar(localtime()));
|
||||
print
|
||||
"Conversion finished, please carefully review $directory/conversion.log and check results in the $directory stanza files before using chdef -z to update the database!\n";
|
||||
close(LOG);
|
||||
exit 0;
|
||||
|
||||
# end main
|
||||
|
||||
#
|
||||
# logger
|
||||
#
|
||||
|
||||
sub log_this
|
||||
{
|
||||
print LOG join('', @_), "\n";
|
||||
}
|
||||
|
||||
#
|
||||
# write to stanza files
|
||||
#
|
||||
sub write_stanza
|
||||
{
|
||||
print STANZA @_;
|
||||
}
|
||||
|
||||
#
|
||||
# runs csmconfig or uses the csmconfig.output file
|
||||
# and builds site table stanza file
|
||||
#
|
||||
|
||||
sub getSiteinfo
|
||||
{
|
||||
log_this("Reading Site information\n");
|
||||
print "Running csmconfg to read site info!\n";
|
||||
|
||||
# open the site stanza file
|
||||
my $stanzafile = "$directory/site.stanza";
|
||||
open(STANZA, ">$stanzafile")
|
||||
or die "Can't open $stanzafile for writing: $!";
|
||||
write_stanza("# <xCAT data object stanza file>\n\n");
|
||||
write_stanza("clustersite:\n");
|
||||
write_stanza(" objtype=site\n");
|
||||
|
||||
my @results;
|
||||
my $cmd;
|
||||
|
||||
# use of file is for debug
|
||||
my $csmconfiginfofile = "$directory/csmconfigdebug.output";
|
||||
if (-e $csmconfiginfofile)
|
||||
{ # use the imported file
|
||||
$cmd = "cat $csmconfiginfofile";
|
||||
log_this("Reading $csmconfiginfofile information\n");
|
||||
@results = runcmd($cmd);
|
||||
}
|
||||
else
|
||||
{ # run the command
|
||||
$cmd = "/opt/csm/bin/csmconfig";
|
||||
@results = runcmd($cmd);
|
||||
}
|
||||
if ($::RUNCMD_RC != 0)
|
||||
{
|
||||
my $msg = "Error processing csmconfig information\n";
|
||||
log_this($msg);
|
||||
print "$msg";
|
||||
close(STANZA);
|
||||
return;
|
||||
}
|
||||
|
||||
foreach my $line (@results)
|
||||
{
|
||||
my $xcatline;
|
||||
$line =~ s/\s*//g; #remove extra blanks
|
||||
my ($attr, $value) = split(/=/, $line);
|
||||
if ($attr eq "RemoteShell")
|
||||
{
|
||||
|
||||
if ($value)
|
||||
{
|
||||
$xcatline = " rsh=";
|
||||
$xcatline .= "$value\n";
|
||||
}
|
||||
}
|
||||
if ($attr eq "RemoteCopyCmd")
|
||||
{
|
||||
|
||||
if ($value)
|
||||
{
|
||||
$xcatline = " rcp=";
|
||||
$xcatline .= "$value\n";
|
||||
}
|
||||
}
|
||||
if ($xcatline)
|
||||
{
|
||||
write_stanza($xcatline);
|
||||
}
|
||||
}
|
||||
close(STANZA);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#
|
||||
# runs lsnodes -l and build node stanza file
|
||||
#
|
||||
|
||||
sub getNodeinfo
|
||||
{
|
||||
|
||||
# open the node stanza file
|
||||
my $stanzafile = "$directory/node.stanza";
|
||||
open(STANZA, ">$stanzafile")
|
||||
or die "Can't open $stanzafile for writing: $!";
|
||||
write_stanza("# <xCAT data object stanza file\n");
|
||||
log_this("Reading Node information\n");
|
||||
print "Running lsnode -l for node info!\n";
|
||||
|
||||
my $OS = "";
|
||||
my $GRP = "";
|
||||
my $ARCH = "";
|
||||
my $DISTNAME = "";
|
||||
|
||||
my @results;
|
||||
my $cmd;
|
||||
my $lsnodefile = "$directory/lsnodedebug.output";
|
||||
|
||||
# use of file is for debug
|
||||
if (-e $lsnodefile)
|
||||
{ # use the imported file
|
||||
log_this("Reading $lsnodefile information\n");
|
||||
$cmd = "cat $lsnodefile";
|
||||
@results = runcmd($cmd);
|
||||
}
|
||||
else
|
||||
{ # run the command
|
||||
$cmd = "/opt/csm/bin/lsnode -l";
|
||||
@results = runcmd($cmd);
|
||||
}
|
||||
if ($::RUNCMD_RC != 0)
|
||||
{
|
||||
my $msg = "Error processing lsnode information\n";
|
||||
log_this($msg);
|
||||
print "$msg";
|
||||
close(STANZA);
|
||||
return;
|
||||
}
|
||||
|
||||
#
|
||||
# build hash of lsnode info
|
||||
#
|
||||
my $output = buildNodehash(\@results);
|
||||
my %nodehash = %$output;
|
||||
my %attrhash;
|
||||
my $nodename;
|
||||
my $attributes;
|
||||
|
||||
# my $test = $nodehash{"c55n03.ppd.pok.ibm.com"}{"PowerStatus"};
|
||||
|
||||
while (($nodename, $attributes) = each %nodehash)
|
||||
{
|
||||
|
||||
#
|
||||
# build commonly needed attributes
|
||||
#
|
||||
%attrhash = %$attributes;
|
||||
|
||||
# get osname, distribution name for later
|
||||
$OS = $attrhash{"InstallOSName"};
|
||||
my $tmpname = $attrhash{"InstallDistributionName"};
|
||||
$DISTNAME = lc($tmpname);
|
||||
my $pkgarch = $attrhash{"InstallPkgArchitecture"};
|
||||
if ($pkgarch)
|
||||
{
|
||||
if ($OS eq "LINUX")
|
||||
{
|
||||
$ARCH = $pkgarch; # save arch
|
||||
}
|
||||
else
|
||||
{ #AIX
|
||||
$ARCH = "ppc64";
|
||||
}
|
||||
}
|
||||
|
||||
#
|
||||
# first process the nodename
|
||||
#
|
||||
my $value;
|
||||
my $xcatline;
|
||||
my $attr;
|
||||
my $grplist = get_groups($nodename);
|
||||
if (!(grep /compute/, $grplist))
|
||||
{
|
||||
$grplist .= ",compute";
|
||||
}
|
||||
if (!(grep /all/, $grplist))
|
||||
{
|
||||
$grplist .= ",all";
|
||||
}
|
||||
$GRP = $grplist; # save for setting up other tables
|
||||
my $shortnodename = get_shortname($nodename);
|
||||
$xcatline = "$shortnodename:\n"; # write node name
|
||||
$xcatline .= " objtype=node\n";
|
||||
if ($grplist)
|
||||
{
|
||||
$xcatline .= " groups=$grplist\n";
|
||||
$xcatline .= " profile=compute\n";
|
||||
}
|
||||
$xcatline .= " status=defined\n";
|
||||
|
||||
if ($xcatline)
|
||||
{
|
||||
write_stanza($xcatline);
|
||||
$xcatline = "";
|
||||
}
|
||||
|
||||
#now process all the attributes associated with the nodename
|
||||
#my $test = $attrhash{"InstallServer"};
|
||||
#my $test1 = $attrhash{"Mode"};
|
||||
|
||||
while (($attr, $value) = each %$attributes)
|
||||
{
|
||||
#if ($attr eq "InstallServer")
|
||||
#{
|
||||
# if ($value)
|
||||
# {
|
||||
# $xcatline = " xcatmaster=$value\n";
|
||||
# $xcatline .= " servicenode=$value\n";
|
||||
|
||||
#}
|
||||
#}
|
||||
# since we are suggesting that the xCAT MN is a different machine
|
||||
# than the CSM MS, we will not use the Management Server value
|
||||
#if ($attr eq "ManagementServer")
|
||||
#{
|
||||
|
||||
# my $installserver = $attrhash{"InstallServer"};
|
||||
# if ($installserver eq "") # if no install server, use MN
|
||||
# {
|
||||
# if ($value)
|
||||
# {
|
||||
# $xcatline = " xcatmaster=$value\n";
|
||||
# }
|
||||
# }
|
||||
#}
|
||||
if ($attr eq "InstallOSName")
|
||||
{
|
||||
if ($value)
|
||||
{
|
||||
if ($value eq "AIX")
|
||||
{
|
||||
$xcatline = " os=$value\n";
|
||||
$xcatline .= " arch=ppc64\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($attr eq "InstallDistributionVersion")
|
||||
{
|
||||
if ( $value
|
||||
&& $DISTNAME) # put together DistributeName and Version
|
||||
{
|
||||
$xcatline = " os=$DISTNAME";
|
||||
$xcatline .= "$value\n";
|
||||
}
|
||||
}
|
||||
if ($attr eq "InstallPkgArchitecture") # filled in for Linux
|
||||
{
|
||||
if ($value)
|
||||
{
|
||||
if ($OS eq "LINUX")
|
||||
{
|
||||
$xcatline = " arch=$value\n";
|
||||
if ($value =~ /86/)
|
||||
{
|
||||
$xcatline .= " netboot=pxe\n";
|
||||
}
|
||||
if ($value =~ /ppc/)
|
||||
{
|
||||
$xcatline .= " netboot=yaboot\n";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($attr eq "HWControlPoint")
|
||||
{
|
||||
if ($value)
|
||||
{
|
||||
$xcatline = " hcp=$value\n";
|
||||
}
|
||||
}
|
||||
if ($attr eq "LParID")
|
||||
{
|
||||
if ($ARCH =~ /ppc/)
|
||||
{
|
||||
if ($value)
|
||||
{ # this is an LPAR
|
||||
$xcatline = " id=$value\n";
|
||||
$xcatline .= " hwtype=lpar\n";
|
||||
$xcatline .= " nodetype=ppc\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($attr eq "ConsoleMethod")
|
||||
{
|
||||
if ($value)
|
||||
{
|
||||
$xcatline = " cons=$value\n";
|
||||
}
|
||||
}
|
||||
if ($attr eq "ConsolePortNum")
|
||||
{
|
||||
if ($value)
|
||||
{
|
||||
$xcatline = " termport=$value\n";
|
||||
}
|
||||
}
|
||||
if ($attr eq "PowerMethod")
|
||||
{
|
||||
if ($value)
|
||||
{
|
||||
if ($value eq "xseries")
|
||||
{
|
||||
$value = "ipmi";
|
||||
}
|
||||
$xcatline = " power=$value\n";
|
||||
$xcatline .= " mgt=$value\n";
|
||||
}
|
||||
}
|
||||
if ($attr eq "InstallAdapterMacaddr")
|
||||
{
|
||||
if ($value)
|
||||
{
|
||||
$xcatline = " mac=$value\n";
|
||||
}
|
||||
}
|
||||
if ($attr eq "HWSerialNum")
|
||||
{
|
||||
if ($value)
|
||||
{
|
||||
$xcatline = " serial=$value\n";
|
||||
}
|
||||
}
|
||||
if ($attr eq "ConsoleSerialSpeed")
|
||||
{
|
||||
if ($value)
|
||||
{
|
||||
$xcatline = " serialspeed=$value\n";
|
||||
$xcatline .= " serialflow=hard\n"; # hardcoded
|
||||
}
|
||||
}
|
||||
if ($attr eq "ConsoleSerialDevice")
|
||||
{
|
||||
if ($value)
|
||||
{
|
||||
$xcatline = " serialport=$value\n";
|
||||
}
|
||||
}
|
||||
if ($attr eq "ConsoleServerName")
|
||||
{
|
||||
if ($value)
|
||||
{
|
||||
$xcatline = " termserver=$value\n";
|
||||
}
|
||||
}
|
||||
if ($xcatline)
|
||||
{
|
||||
write_stanza($xcatline);
|
||||
$xcatline = "";
|
||||
}
|
||||
}
|
||||
$xcatline = "\n";
|
||||
write_stanza($xcatline);
|
||||
$xcatline = "";
|
||||
}
|
||||
|
||||
close(STANZA);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#
|
||||
# runs lshwdev -l stanza file and builds node stanza file for xCAT
|
||||
#
|
||||
|
||||
sub getDevinfo
|
||||
{
|
||||
|
||||
# open the node stanza file
|
||||
my $stanzafile = "$directory/device.stanza";
|
||||
open(STANZA, ">$stanzafile")
|
||||
or die "Can't open $stanzafile for writing: $!";
|
||||
write_stanza("# <xCAT data object stanza file\n");
|
||||
|
||||
log_this("Reading Device information\n");
|
||||
print "Running lshwdev -l for device info!\n";
|
||||
|
||||
my $MN;
|
||||
my $OS;
|
||||
my $hwmodel;
|
||||
|
||||
my @results;
|
||||
my $cmd;
|
||||
my $HWMODEL = "";
|
||||
|
||||
# use of file is for debug
|
||||
my $lshwdevfile = "$directory/lshwdevdebug.output";
|
||||
if (-e $lshwdevfile)
|
||||
{ # use the imported file
|
||||
log_this("Reading $lshwdevfile information\n");
|
||||
$cmd = "cat $lshwdevfile";
|
||||
@results = runcmd($cmd);
|
||||
}
|
||||
else
|
||||
{ # run the command
|
||||
$cmd = "/opt/csm/bin/lshwdev -l";
|
||||
@results = runcmd($cmd);
|
||||
}
|
||||
if ($::RUNCMD_RC != 0)
|
||||
{
|
||||
my $msg = "Error processing lshwdev information\n";
|
||||
log_this($msg);
|
||||
print "$msg";
|
||||
close(STANZA);
|
||||
return;
|
||||
}
|
||||
|
||||
#
|
||||
# build hash of lshwdev info
|
||||
#
|
||||
my $output = buildNodehash(\@results);
|
||||
my %nodehash = %$output;
|
||||
my %attrhash;
|
||||
my $nodename;
|
||||
my $attributes;
|
||||
|
||||
while (($nodename, $attributes) = each %nodehash)
|
||||
{
|
||||
|
||||
#
|
||||
# build commonly needed attributes
|
||||
#
|
||||
%attrhash = %$attributes;
|
||||
$HWMODEL = $attrhash{"HWModel"};
|
||||
|
||||
#
|
||||
# first process the devicename
|
||||
#
|
||||
my $value;
|
||||
my $xcatline;
|
||||
my $attr;
|
||||
|
||||
my $grplist = get_dev_groups($nodename);
|
||||
my $shortnodename = get_shortname($nodename);
|
||||
$xcatline = "$shortnodename:\n"; # write node name
|
||||
$xcatline .= " objtype=node\n";
|
||||
if ($grplist)
|
||||
{
|
||||
$xcatline .= " groups=$grplist\n";
|
||||
}
|
||||
$xcatline .= " status=defined\n";
|
||||
if ($xcatline)
|
||||
{
|
||||
write_stanza($xcatline);
|
||||
$xcatline = "";
|
||||
}
|
||||
|
||||
#now process all the attributes associated with the device
|
||||
while (($attr, $value) = each %$attributes)
|
||||
{
|
||||
|
||||
if ($attr eq "DeviceType")
|
||||
{
|
||||
if ($value)
|
||||
{
|
||||
my $lcvalue = lc($value);
|
||||
$xcatline = " nodetype=ppc\n";
|
||||
if ($lcvalue eq "hmc") {
|
||||
$xcatline .= " mgt=$lcvalue\n";
|
||||
$xcatline .= " hwtype=$lcvalue\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($attr eq "HWType") # put Model and type together
|
||||
{
|
||||
if ($value)
|
||||
{
|
||||
$xcatline = " mtm=$HWMODEL";
|
||||
$xcatline .= "-";
|
||||
$xcatline .= "$value\n";
|
||||
}
|
||||
}
|
||||
if ($attr eq "HWSerialNum")
|
||||
{
|
||||
if ($value)
|
||||
{
|
||||
$xcatline = " serial=$value\n";
|
||||
}
|
||||
}
|
||||
if ($attr eq "PhysicalLocation")
|
||||
{
|
||||
if ($value)
|
||||
{
|
||||
$xcatline = " room=$value\n";
|
||||
}
|
||||
}
|
||||
if ($attr eq "Macaddr")
|
||||
{
|
||||
if ($value)
|
||||
{
|
||||
$xcatline = " mac=$value\n";
|
||||
}
|
||||
}
|
||||
if ($xcatline)
|
||||
{
|
||||
write_stanza($xcatline);
|
||||
$xcatline = "";
|
||||
}
|
||||
}
|
||||
$xcatline = "\n";
|
||||
write_stanza($xcatline);
|
||||
$xcatline = "";
|
||||
}
|
||||
close(STANZA);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#
|
||||
# change to short hostname for xCAT
|
||||
# if ip address, just return it
|
||||
#
|
||||
sub get_shortname
|
||||
{
|
||||
my $hostname = shift();
|
||||
|
||||
# if not ip address
|
||||
if ($hostname !~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/)
|
||||
{
|
||||
my @shorthost = split(/\./, $hostname);
|
||||
return $shorthost[0];
|
||||
}
|
||||
else
|
||||
{ # return ip address
|
||||
return $hostname;
|
||||
}
|
||||
}
|
||||
|
||||
#
|
||||
# get list of groups for input hostname
|
||||
#
|
||||
sub get_groups
|
||||
{
|
||||
my $hostname = shift();
|
||||
my $grouplist;
|
||||
my @results;
|
||||
my $cmd;
|
||||
|
||||
# use of file is for debug
|
||||
my $groupfile = "$directory/nodegrpdebug.output";
|
||||
if (-e $groupfile)
|
||||
{ # use the imported file
|
||||
$cmd = "cat $groupfile";
|
||||
@results = runcmd($cmd);
|
||||
}
|
||||
else
|
||||
{ # run the command
|
||||
$cmd = "/opt/csm/bin/nodegrp -s $hostname";
|
||||
@results = runcmd($cmd);
|
||||
}
|
||||
|
||||
foreach my $line (@results)
|
||||
{
|
||||
$grouplist .= $line;
|
||||
$grouplist .= ",";
|
||||
}
|
||||
chop $grouplist; # get rid of last comma
|
||||
return $grouplist;
|
||||
}
|
||||
|
||||
#
|
||||
# get list of groups for input device
|
||||
#
|
||||
sub get_dev_groups
|
||||
{
|
||||
my $devname = shift();
|
||||
my $grouplist;
|
||||
my $cmd;
|
||||
my @results;
|
||||
my $hwgroupfile = "$directory/hwdevgrpdebug.output";
|
||||
if (-e $hwgroupfile)
|
||||
{ # use the imported file
|
||||
$cmd = "cat $hwgroupfile";
|
||||
@results = runcmd($cmd);
|
||||
}
|
||||
else
|
||||
{ # run the command
|
||||
$cmd = "/opt/csm/bin/hwdevgrp -s $devname";
|
||||
@results = runcmd($cmd);
|
||||
}
|
||||
|
||||
foreach my $line (@results)
|
||||
{
|
||||
$grouplist .= $line;
|
||||
$grouplist .= ",";
|
||||
}
|
||||
chop $grouplist; # get rid of last comma
|
||||
return $grouplist;
|
||||
}
|
||||
|
||||
#
|
||||
# build node hash. Build a hash of hashes, each entry
|
||||
# nodex=> {
|
||||
# attribute=>value
|
||||
# attribute=>value
|
||||
# .
|
||||
#
|
||||
#
|
||||
|
||||
sub buildNodehash
|
||||
{
|
||||
my ($info) = @_;
|
||||
my @nodeinfo = @$info;
|
||||
my %nodehash;
|
||||
my $nodename;
|
||||
foreach my $line (@nodeinfo)
|
||||
{
|
||||
$line =~ s/\s*//g; #remove extra blanks
|
||||
my ($attr, $value) = split(/=/, $line);
|
||||
if (($attr eq "Hostname") || ($attr eq "Name"))
|
||||
{
|
||||
$nodename = $value; # set the hash key
|
||||
}
|
||||
else
|
||||
{ # all other lines are part of hash
|
||||
$nodehash{$nodename}{$attr} = $value;
|
||||
}
|
||||
}
|
||||
return \%nodehash;
|
||||
}
|
||||
|
||||
#
|
||||
# runs the input command and handles the errors. Returns the output
|
||||
#
|
||||
|
||||
sub runcmd
|
||||
{
|
||||
my ($cmd) = @_;
|
||||
my $rc = 0;
|
||||
$::RUNCMD_RC = 0;
|
||||
my $outref = [];
|
||||
@$outref = `$cmd`;
|
||||
if ($?)
|
||||
{
|
||||
$rc = $? ;
|
||||
$::RUNCMD_RC = $rc;
|
||||
if ($rc > 0)
|
||||
{
|
||||
my $msg = "$cmd returned rc=$rc @$outref\n";
|
||||
log_this($msg);
|
||||
print "$msg";
|
||||
}
|
||||
}
|
||||
chomp(@$outref);
|
||||
return @$outref;
|
||||
|
||||
}
|
||||
|
||||
sub usage
|
||||
{
|
||||
print "CSM database to xCAT stanza files migration utility.\n";
|
||||
print
|
||||
"Reads the CSM database and creates xCAT stanza files that \ncan be imported using the chdef command into the xCAT database.\n";
|
||||
print "Usage:\n";
|
||||
print "\t--help - usage\n";
|
||||
print
|
||||
"\t--dir - output directory for stanza files.\n Default is /tmp/csm2xcat.\n";
|
||||
print "\n";
|
||||
return;
|
||||
}
|
||||
|
@ -1,246 +0,0 @@
|
||||
#!/usr/bin/env perl
|
||||
#
|
||||
# This was a first pass at a script that could be used to convert CSM
|
||||
# stanza files into xCAT stanza files.
|
||||
#
|
||||
# Just want to save it for future reference - Norm - 4/22/2008
|
||||
#
|
||||
#-----------------------------------------------------------------------
|
||||
#
|
||||
|
||||
use lib "/opt/xcat/lib/perl";
|
||||
use xCAT::DBobjUtils;
|
||||
use xCAT::Table;
|
||||
use xCAT::NodeRange;
|
||||
use Getopt::Long;
|
||||
|
||||
use strict;
|
||||
|
||||
use Socket;
|
||||
|
||||
# options can be bundled up like -vV
|
||||
Getopt::Long::Configure("bundling") ;
|
||||
$Getopt::Long::ignorecase=0;
|
||||
|
||||
# parse the options
|
||||
if(!GetOptions(
|
||||
'h|help' => \$::HELP,
|
||||
'z=s' => \$::opt_z,
|
||||
'v|version' => \$::VERSION,))
|
||||
{
|
||||
&usage;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
# display the usage if -h or --help is specified
|
||||
if ($::HELP) { &usage; exit(0);}
|
||||
|
||||
# display the version statement if -v or --verison is specified
|
||||
if ($::VERSION)
|
||||
{
|
||||
print "csm2xcatdefs version 2.0\n";
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#
|
||||
# define the CSM to xCAT attr name equivalents
|
||||
#
|
||||
my %csm2xcat;
|
||||
$csm2xcat{'InstallOSName'} = 'os';
|
||||
$csm2xcat{'ConsoleMethod'} = 'cons';
|
||||
$csm2xcat{'ManagementServer'} = 'xcatmaster';
|
||||
$csm2xcat{'InstallServerAKBNode'} = 'xcatmaster'; # ???
|
||||
$csm2xcat{'PowerMethod'} = 'power';
|
||||
$csm2xcat{'HWControlPoint'} = 'hcp';
|
||||
$csm2xcat{'HWType'} = 'mtm';
|
||||
$csm2xcat{'HWModel'} = 'mtm'; # ???
|
||||
$csm2xcat{'HWSerialNum'} = 'serial';
|
||||
$csm2xcat{'InstallAdapterMacaddr'} = 'mac';
|
||||
$csm2xcat{'InstallAdapterName'} = 'installnic';
|
||||
# installnic, or primarynic or interface ????
|
||||
$csm2xcat{'InstallKernelVersion'} = 'kernel';
|
||||
$csm2xcat{'InstallPkgArchitecture'} = 'arch';
|
||||
$csm2xcat{'InstallServer'} = 'servicenode';
|
||||
$csm2xcat{'InstallTemplate'} = 'profile';
|
||||
$csm2xcat{'LParID'} = 'id';
|
||||
$csm2xcat{'Name'} = 'node';
|
||||
$csm2xcat{'UserComment'} = 'usercomment';
|
||||
$csm2xcat{'Status'} = 'status';
|
||||
|
||||
#
|
||||
# read the CSM definitions from the CSM stanza file
|
||||
#
|
||||
my %csmdefs = getCSMdefs($::opt_z);
|
||||
|
||||
#
|
||||
# convert each CSM node def to the corresponding xCAT node def
|
||||
#
|
||||
#my %::xcatvals;
|
||||
foreach my $node (keys %csmdefs)
|
||||
{
|
||||
|
||||
#print "node= $node\n";
|
||||
|
||||
foreach my $attr (keys %csm2xcat)
|
||||
{
|
||||
# if the CSM attr is defined
|
||||
# and if there is a corresponding xCAT attr
|
||||
if ( ($csmdefs{$node}{$attr}) ) {
|
||||
|
||||
#print "\t$attr = $csmdefs{$node}{$attr}, xcat attr = $csm2xcat{$attr}\n";
|
||||
|
||||
# use short host name for xcat node name
|
||||
my $shorthost;
|
||||
($shorthost = $node) =~ s/\..*$//;
|
||||
chomp $shorthost;
|
||||
|
||||
if ( ($attr eq 'HWType') || ($attr eq 'HWModel')) {
|
||||
if ( ( defined($csmdefs{$node}{'HWType'}) ) && ( defined($csmdefs{$node}{'HWModel'}) ) ) {
|
||||
|
||||
$::xcatvals{$shorthost}{$csm2xcat{$attr}}="$csmdefs{$node}{'HWType'}-$csmdefs{$node}{'HWModel'}";
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
$::xcatvals{$shorthost}{$csm2xcat{$attr}}=$csmdefs{$node}{$attr};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
} # end - for each attr
|
||||
|
||||
} # END for each node
|
||||
|
||||
#
|
||||
# display the xCAT info in stanza format
|
||||
#
|
||||
print "# <xCAT data object stanza file>\n";
|
||||
foreach my $node (keys %::xcatvals)
|
||||
{
|
||||
print "$node:\n";
|
||||
|
||||
print "\tobjtype=node\n";
|
||||
|
||||
foreach my $a (keys %{$::xcatvals{$node}} )
|
||||
{
|
||||
if ($a eq 'node') {
|
||||
next;
|
||||
}
|
||||
|
||||
if ( defined($::xcatvals{$node}{$a}) ) {
|
||||
print "\t$a=$::xcatvals{$node}{$a}\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
exit 0;
|
||||
|
||||
sub usage {
|
||||
print "Usage:\n";
|
||||
print "To convert a CSM stanza file to an xCAT stanza file.\n\n";
|
||||
print "\tcsm2xcatdefs -z <csm_stanza_file>\n\n";
|
||||
print "Proceedure:\n";
|
||||
print "\tCreate a CSM stanza file using the CSM lsnode command.\n";
|
||||
print "\tRun the csm2xcatdefs command and redirect the output to \n";
|
||||
print "\t an xCAT stanza file.\n";
|
||||
print "\tUse the xCAT stanza file as input to the xCAT mkdef command.\n\n";
|
||||
}
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
=head3 getCSMdefs
|
||||
|
||||
|
||||
Read a CSM stanza file and populate the %::Nodes hash
|
||||
and the @::node_list array.
|
||||
|
||||
%csmdefs = getCSMdefs($stanzafile);
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
sub getCSMdefs
|
||||
{
|
||||
my ($nodedef_file) = @_;
|
||||
my $n = -1;
|
||||
my @lines;
|
||||
my $line;
|
||||
my $linenum =0;
|
||||
my ($junk1, $junk2);
|
||||
my ($attr, $val);
|
||||
my %nodedefs;
|
||||
|
||||
unless (open(NODEDEF, "<$nodedef_file")) {
|
||||
print "Could not open $nodedef_file.\n";
|
||||
}
|
||||
|
||||
my $look_for_colon = 1; # start with first line that has a colon
|
||||
|
||||
# parse the contents of the nodedef file
|
||||
@lines = <NODEDEF>;
|
||||
close(NODEDEF);
|
||||
|
||||
foreach $line (@lines)
|
||||
{
|
||||
$linenum++;
|
||||
chomp $line;
|
||||
|
||||
(grep(/^\s*#/, $line)) && next; # Skip comment lines
|
||||
|
||||
next if ($line =~ /^\s*$/); # Next if empty blank line
|
||||
|
||||
if (grep(/:\s*$/, $line))
|
||||
{ # see if it's a stanza name
|
||||
$look_for_colon = 0;
|
||||
($::hostname, $junk1, $junk2) = split(/:/, $line);
|
||||
|
||||
$::hostname =~ s/^\s*//; # Remove any leading whitespace
|
||||
$::hostname =~ s/\s*$//; # Remove any trailing whitespace
|
||||
if ($::hostname eq "default")
|
||||
{
|
||||
next;
|
||||
}
|
||||
|
||||
$nodedefs{$::hostname}{'Name'} = $::hostname;
|
||||
$n++;
|
||||
|
||||
}
|
||||
elsif ($line =~ /^\s*(\w+)\s*=\s*(.*)\s*/)
|
||||
{
|
||||
$attr = $1;
|
||||
$val = $2;
|
||||
$attr =~ s/^\s*//; # Remove any leading whitespace
|
||||
$attr =~ s/\s*$//; # Remove any trailing whitespace
|
||||
$val =~ s/^\s*//;
|
||||
$val =~ s/\s*$//;
|
||||
|
||||
# remove spaces and quotes so createnode won't get upset
|
||||
$val =~ s/^\s*"\s*//;
|
||||
$val =~ s/\s*"\s*$//;
|
||||
|
||||
if ($::hostname eq "")
|
||||
{
|
||||
$look_for_colon++;
|
||||
next;
|
||||
}
|
||||
|
||||
$nodedefs{$::hostname}{$attr} = $val;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
# error - invalid line in node definition file
|
||||
$look_for_colon++;
|
||||
}
|
||||
} # end parsing loop
|
||||
|
||||
|
||||
return %nodedefs;
|
||||
}
|
@ -1,151 +0,0 @@
|
||||
#!/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";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,180 +0,0 @@
|
||||
#!/usr/bin/perl
|
||||
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
|
||||
#(C)IBM Corp
|
||||
|
||||
#
|
||||
|
||||
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)
|
||||
|
||||
example command:
|
||||
mkrrnodes -C d -L 2 -R 1,180 ( 12 blades per rack)
|
||||
|
||||
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
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Main
|
||||
|
||||
my $rc = 0;
|
||||
|
||||
&parse_args;
|
||||
my $cmd = "";
|
||||
my @bladename;
|
||||
@bladename = ("a", "b", "c");
|
||||
foreach my $CU (@::CU)
|
||||
{
|
||||
foreach my $range (@::RANGE)
|
||||
{
|
||||
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 .= $nodeno;
|
||||
$cmd .= "$blade";
|
||||
$cmd .= " ";
|
||||
if ($blade eq "a")
|
||||
{
|
||||
|
||||
$cmd .=
|
||||
"groups=rr$CU$nodeno,ls21,cu$CU,opteron,opteron-cu$CU,compute,tb,all";
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($blade eq "b")
|
||||
{
|
||||
$cmd .=
|
||||
"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$nodeno,qs22,cu$CU,cell,cell-c,cell-cu$CU-c,cell-cu$CU,compute,all,tb";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
# calculate the rack number ( 12 triblades/rack)
|
||||
# 15 racks/CU
|
||||
# Rack number = (triblade# / 12) +1
|
||||
my $count = ($range -1) / 12;
|
||||
my ($rackno, $rem) = split '\.', $count;
|
||||
|
||||
$rackno = $rackno + $::LOCATION;
|
||||
if ($rackno <=9) { # want rack0X
|
||||
$rack .="0";
|
||||
}
|
||||
$rack .= $rackno;
|
||||
|
||||
$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)
|
||||
{
|
||||
if ($::TEST) {
|
||||
print ("noderm $cmd \n");
|
||||
} else {
|
||||
system("noderm $cmd");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($::TEST) {
|
||||
print ("nodeadd $cmd \n");
|
||||
} else {
|
||||
system("nodeadd $cmd");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
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 =
|
||||
" 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,
|
||||
'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";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,178 +0,0 @@
|
||||
#!/usr/bin/perl
|
||||
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
|
||||
#(C)IBM Corp
|
||||
|
||||
#
|
||||
|
||||
use Getopt::Long;
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
=head1 mkrtnodes
|
||||
|
||||
Make node definitions for RR nodes
|
||||
|
||||
mkrtnodes -C <cu letter> -L < start Rack number for CU> -R <startrange,endrange> (add)
|
||||
mkrtnodes -d -C <cu letter> -R <startrange,endrange> (delete)
|
||||
|
||||
example command:
|
||||
mkrtnodes -C d -L 2 -R 1,180 ( 6 blades per rack)
|
||||
|
||||
Builds some nodelist entries that look like this
|
||||
"rtd171a","rtd171,ls21,cud,opteron,opteron-cud,compute,tb,all,rack16,bc57",,,
|
||||
"rtd171b","rtd171,qs22,cud,cell,cell-b,cell-cud-b,cell-cud,compute,all,tb,rack16,bc57",,,
|
||||
"rtd171c","rtd171,qs22,cud,cell,cell-c,cell-cud-c,cell-cud,compute,all,tb,rack16,bc57",,,
|
||||
|
||||
=cut
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Main
|
||||
|
||||
my $rc = 0;
|
||||
|
||||
&parse_args;
|
||||
my $cmd = "";
|
||||
my @bladename;
|
||||
@bladename = ("a", "b", "c");
|
||||
foreach my $CU (@::CU)
|
||||
{
|
||||
foreach my $range (@::RANGE)
|
||||
{
|
||||
foreach my $blade (@bladename)
|
||||
{
|
||||
my $nodeno = "";
|
||||
if ($range <=9) { # want rt00X
|
||||
$nodeno .="0";
|
||||
}
|
||||
if ($range <=99) { # want rt0XX
|
||||
$nodeno .="0";
|
||||
}
|
||||
$nodeno .= $range;
|
||||
|
||||
$rack = "rack";
|
||||
$bc = "bc";
|
||||
$cmd = "rt";
|
||||
$cmd .= $CU;
|
||||
$cmd .= $nodeno;
|
||||
$cmd .= "$blade";
|
||||
$cmd .= " ";
|
||||
if ($blade eq "a")
|
||||
{
|
||||
|
||||
$cmd .=
|
||||
"groups=rt$CU$nodeno,ls21,cu$CU,opteron,opteron-cu$CU,compute,tb,all";
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($blade eq "b")
|
||||
{
|
||||
$cmd .=
|
||||
"groups=rt$CU$nodeno,qs22,cu$CU,cell,cell-b,cell-cu$CU-b,cell-cu$CU,compute,all,tb";
|
||||
}
|
||||
else
|
||||
{ # c
|
||||
$cmd .=
|
||||
"groups=rt$CU$nodeno,qs22,cu$CU,cell,cell-c,cell-cu$CU-c,cell-cu$CU,compute,all,tb";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
# calculate the rack number ( 6 triblades/rack)
|
||||
my $count = ($range -1) / 6;
|
||||
my ($rackno, $rem) = split '\.', $count;
|
||||
|
||||
$rackno = $rackno + $::LOCATION;
|
||||
if ($rackno <=9) { # want rack0X
|
||||
$rack .="0";
|
||||
}
|
||||
$rack .= $rackno;
|
||||
|
||||
$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)
|
||||
{
|
||||
if ($::TEST) {
|
||||
print ("noderm $cmd \n");
|
||||
} else {
|
||||
system("noderm $cmd");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($::TEST) {
|
||||
print ("nodeadd $cmd \n");
|
||||
} else {
|
||||
system("nodeadd $cmd");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
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 =
|
||||
" mkrtnodes -h \n mkrtnodes [-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";
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user