automatically build readme for tools

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@15490 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
bp-sawyers 2013-03-13 23:01:17 +00:00
parent 4b09b8f926
commit 111782a728
11 changed files with 265 additions and 27 deletions

View File

@ -459,5 +459,11 @@ if [ "$OSNAME" != "AIX" -a "$REL" = "devel" -a "$PROMOTE" != 1 -a -z "$EMBED" ];
i=0
while [ $((i+=1)) -le 5 ] && ! rsync $verboseflag -r opt/xcat/share/doc/man1 opt/xcat/share/doc/man3 opt/xcat/share/doc/man5 opt/xcat/share/doc/man7 opt/xcat/share/doc/man8 $UPLOADUSER,xcat@web.sourceforge.net:htdocs/
do : ; done
# extract and upload the tools readme
rpm2cpio ../$XCATCORE/xCAT-server-*.$NOARCH.rpm | cpio -id ./opt/xcat/share/xcat/tools/README.html
i=0
while [ $((i+=1)) -le 5 ] && ! rsync $verboseflag opt/xcat/share/xcat/tools/README.html $UPLOADUSER,xcat@web.sourceforge.net:htdocs/tools/
do : ; done
cd ..
fi

View File

@ -153,6 +153,11 @@ OS diskful/diskfree deployment.
All of the cluster configuration information is in the xCAT database. See L<xcatdb(5)|xcatdb.5> for
descriptions of every table in the database.
=head1 XCAT ADDITIONAL TOOLS
Some additional tools have been contributed to xCAT. You can read about them at http://xcat.sourceforge.net/tools/README.html
or in /opt/xcat/share/xcat/tools/README.txt on your xCAT management node.
=head1 XCAT COMMANDS
What follows is a short description of each xCAT command. To get more information about a particular

164
xCAT-server/build-readme Executable file
View File

@ -0,0 +1,164 @@
#!/usr/bin/perl
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
# Runs each of the tools in the share/xcat/tools dir with the --help option
# and compiles the output into a tools readme file (both text version and
# html version).
use strict;
#use lib '.';
my $toolsdir = 'share/xcat/tools';
my $textreadme = "$toolsdir/README.txt";
my $htmlreadme = "$toolsdir/README.html";
#my $cachedir = '/tmp';
my @tools = getToolList($toolsdir);
#foreach (@tools) { print "$_\n"; }
# Put the intro text in the readme files
print "Building tools README files...\n";
open(TXT, ">$textreadme") or die "Error: could not open $textreadme for writing.\n";
open(HTML, ">$htmlreadme") or die "Error: could not open $htmlreadme for writing.\n";
writeintro(\*TXT, \*HTML, @tools);
# Run each tool with --help flag
foreach my $toolfile (@tools) {
my $cmd = "./$toolsdir/$toolfile --help";
my $output = `$cmd`;
if ($?) {
my $err = "Error: execution of '$cmd' failed with rc=" . ($?>>8) . ".\n";
print $err;
$output .= $err;
}
writetoolhelp(\*TXT, \*HTML, $toolfile, $output);
}
# close files
writeending(\*HTML);
close TXT;
close HTML;
exit;
# get the list of tool script files.
sub getToolList {
my $toolsdir = shift;
# 1st get toplevel dir listing
opendir(DIR, $toolsdir) or die "Error: could not read $toolsdir.\n";
my @files = grep !/^\./, readdir(DIR); # /
close(DIR);
# remove files that are not regular files (not dirs) and executable
my @newlist;
foreach my $f (@files) {
my $file = "$toolsdir/$f";
if ((-f $file) && (-x $file)) { push @newlist, $f; }
}
#foreach (@files) { print "$_\n"; }
#foreach (@newlist) { print "$_\n"; }
return sort @newlist;
}
# print some text to both readmes
sub printtoboth {
my $txt = shift;
my $html = shift;
my $str = shift;
print $txt $str;
print $html $str;
}
# write the up front stuff of the readme
sub writeintro {
my $txt = shift; # the file handle to the txt readme file
my $html = shift; # the file handle to the html readme file
# the rest of @_ contains the tool files in the dir
# write title part of readmes
print $txt <<'TXTEOS1';
xCAT TOOL DESCRIPTIONS
----------------------
TXTEOS1
print $html <<'HTMLEOS1';
<html>
<head>
<title>xCAT Tool Descriptions</title>
</head>
<body>
<h1 align="center">xCAT Tool Descriptions</h1>
HTMLEOS1
# write the table of contents for the html readme
print $html "<ul><li><a href='#Introduction'>Introduction</a>\n";
foreach my $tool (@_) {
print $html "<li><a href='#$tool'>$tool</a>\n";
}
print $html "</ul>\n";
# write the intro
print $html "<a id='Introduction'></a><h2>Introduction</h2><p>\n";
printtoboth $txt, $html, <<'EOS1';
This is a list of additional tools that are provided by xCAT. They are located
in /opt/xcat/share/xcat/tools/, but should also be in your path. Many of these
tools have been contributed by xCAT users that are not part of the core xCAT
development team. That means they might not be supported as well as the main
xCAT code. Read the help here, take a look at the code, and use at your own
risk. If you have problems with a tool, post to the xCAT mailing list and
the author will try to help you.
EOS1
print $html "</p>\n";
}
# write the help for one tool
sub writetoolhelp {
my $txt = shift; # the file handle to the txt readme file
my $html = shift; # the file handle to the html readme file
my $toolname = shift; # the script name of the tool
my $toolhelp = shift; # the --help output from the tool
# write the heading for this tool
print $txt <<"TXTEOS2";
$toolname
--------------------
TXTEOS2
print $html <<"HTMLEOS2";
<hr>
<a id='$toolname'></a>
<h2>$toolname</h2>
<pre>
HTMLEOS2
# write the actual contents of the tool help
printtoboth $txt, $html, $toolhelp;
# finish up
print $html <<"HTMLEOS3";
</pre>
HTMLEOS3
}
sub writeending {
my $html = shift;
# finish up the html readme
print $html <<'HTMLEOS4';
</body>
</html>
HTMLEOS4
}

View File

@ -6,7 +6,10 @@ Getopt::Long::Configure("bundling");
Getopt::Long::Configure("pass_through");
$::USAGE = "Usage: detect_dhcpd -i interface [-m macaddress] [-t timeout] [-V]
This command can be used to detect the dhcp server in a network for a specific mac address.
This command can be used to detect the dhcp server in a network for a specific mac address.
Options:
-i interface: The interface which facing the target network.
-m macaddress: The mac that will be used to detect dhcp server. Recommend to use the real mac of the node that will be netboot. If no specified, the mac of interface which specified by -i will be used.
-t timeout: The time to wait to detect the dhcp messages. The default value is 10s.\n";
@ -14,11 +17,14 @@ if (!GetOptions(
'i=s' => \$::IF,
'm=s' => \$::MACADD,
't=s' => \$::TIMEOUT,
'V|verbose' => \$::VERBOSE,)) {
'V|verbose' => \$::VERBOSE,
'h|help' => \$::HELP,)) {
print $::USAGE;
exit 1;
}
if ($::HELP) { print $::USAGE; exit 0; }
my $nic;
if ($::IF) {
$nic = $::IF;

View File

@ -21,7 +21,6 @@ use lib "$::XCATROOT/lib/perl";
use strict;
use warnings;
use Getopt::Long;
use xCAT::NetworkUtils;
if (
!GetOptions("h|help" => \$::HELP,
@ -38,6 +37,8 @@ if ($::HELP)
exit 0;
}
require xCAT::NetworkUtils;
if ($::MACADDR)
{
my $linklocal = xCAT::NetworkUtils->linklocaladdr($::MACADDR);
@ -46,8 +47,7 @@ if ($::MACADDR)
sub usage
{
print "Mac to IPv6 link local address utility.\n";
print "Usage:\n";
print "\t mac2linklocal -m <mac_address>\n";
print "Usage: mac2linklocal -m <mac_address>\n\n";
print "Determines the IPv6 link local address that is appropriate for a NIC, based on its MAC.\n";
return;
}

View File

@ -33,6 +33,7 @@ my %Options = ('interactive',"yes",'warnings','','log',"yes",'dump',"yes");
my @warnings;
my $logfile = DEFAULT_LOG_FILE;
my $now = localtime;
my $help;
#
# print a warning and wait a bit if warnings are enabled
@ -136,6 +137,22 @@ sub question {
return $reply;
}
sub usage {
print "Usage: mktoolscenter\n";
print " --ph <proxyhost>\n";
print " --pp <proxyport>\n";
print " --puser <proxyuser>\n";
print " --ppw <proxypassword>\n";
print " -l <logfile>\n";
print " -s\n";
print " --nfsserver <NFS server address>\n";
print " --nfspath <NFS server path>\n";
print " --profilename <profile name>\n";
print " --help\n\n";
print "Updates IBM system x server hardware using IBM Bootable Media Creator.\n";
}
#
# Begin main
#
@ -147,21 +164,14 @@ unless (GetOptions("s"=>\$surrogate, "l=s"=>\$logfile,
"ph=s"=>\$proxy{host}, "pp=i"=>\$proxy{port},
"puser=s"=>\$proxy{user}, "ppw=s"=>\$proxy{pw},
"nfsserver=s"=>\$nfsserver,"nfspath=s"=>\$nfspath,
"profilename=s"=>\$profilename,
"profilename=s"=>\$profilename, "help"=>\$help,
)) {
printf "Usage:\n";
printf "--ph <proxyhost>\n";
printf "--pp <proxyport>\n";
printf "--puser <proxyuser>\n";
printf "--ppw <proxypassword>\n";
printf "-l <logfile>\n";
printf "-s\n";
printf "--nfsserver <NFS server address>\n";
printf "--nfspath <NFS server path>\n";
printf "--profilename <profile name>\n";
usage();
exit(1);
}
if ($help) { usage(); exit 0; }
if (@ARGV > 0) {
open(IN,"<",@ARGV[0]) || die "Cannot open input file @ARGV[0]";
$Options{interactive} = '';

View File

@ -1,12 +1,8 @@
#!/usr/bin/perl
use strict;
use SNMP;
use Socket;
use Data::Dumper;
use Getopt::Long;
$SNMP::debugging = 1;
$SNMP::verbose = 1;
$SNMP::best_guess = 1;
# each 0 is four bits: 0000 0000
# thus its broken down:
# - ports 1-8 are in the first hex number
@ -427,6 +423,7 @@ sub show{
# we want to put this port on this new vlan, here is how we do it:
# connect to switch to see:
my $help =0;
$::DEBUG = 0;
GetOptions(
@ -438,6 +435,11 @@ if($help){
displayHelp(0);
}
require SNMP;
$SNMP::debugging = 1;
$SNMP::verbose = 1;
$SNMP::best_guess = 1;
if($::DEBUG){
print "verbose is set to on!\n";
}

View File

@ -17,7 +17,6 @@ BEGIN
}
use lib "$::XCATROOT/lib/perl";
use xCAT::Utils;
use Getopt::Long;
use strict;
@ -48,6 +47,9 @@ if ($help) {
print "\n";
exit 0;
}
require xCAT::Utils;
# check to see if running DB2
my $DBname = xCAT::Utils->get_DBName;
if ($DBname ne "DB2") {

View File

@ -13,10 +13,31 @@ BEGIN
}
use lib "$::XCATROOT/lib/perl";
use xCAT::Utils;
use xCAT::TableUtils;
use strict;
use Socket; # for name resolution
use Getopt::Long;
my $help;
GetOptions('h|help' => \$help);
if ($help) {
print <<'EOS';
Usage: rmblade [-h|--help]
Response to SNMP for monsetting to remove blade from xCAT when trap is recieved.
Pipe the MM IP address and blade slot number into this cmd.
Example:
1. user removes a blade from the chassis
2. snmp trap setup to point here
3. this script removes the blade configuration from xCAT
4. so if blade is placed in new slot or back in then xCAT goes
through rediscover process again.
EOS
exit 0;
}
require xCAT::Utils;
require xCAT::TableUtils;
my $ip='';
my $mm='';
@ -30,6 +51,7 @@ open(FILE,">>$log") or die "Can't open log!!!";
my $date = `date`;
chomp($date);
print FILE "==================== $date ============================\n";
sub rmblade {
my $blade = shift;
my $hex = ip2hex($blade);
@ -55,12 +77,13 @@ sub ip2hex {
my $packed_ip = gethostbyname($node);
if(defined $packed_ip){
$ip = inet_ntoa($packed_ip);
print FILE "IP that was removed is $ip\n";
print FILE "IP that was removed is $ip\n";
@quad = split('\.', $ip);
$hex = sprintf("%02X%02X%02X%02X", @quad);
}
return $hex;
}
foreach (<>){
if(/ip=UDP/){
$ip = $_;

View File

@ -10,11 +10,28 @@ BEGIN
}
use lib "$::XCATROOT/lib/perl";
use xCAT::Utils;
use xCAT::TableUtils;
use strict;
use Socket;
use Getopt::Long;
my $help;
GetOptions('h|help' => \$help);
if ($help) {
print <<'EOS';
Usage: rmnodecfg [-h|--help] <noderange>
Removes the configuration of a node so that the next time you reboot
it, it forces it to go through the discovery process.
This does not remove it completely from xCAT. You may want to do this
command before running noderm to completely purge the system of the node
EOS
exit 0;
}
require xCAT::Utils;
require xCAT::TableUtils;
my $blades = shift;
if(! $blades) {
print "Please specify a noderange of blades to remove\n";

View File

@ -60,6 +60,9 @@ xCAT-server provides the core server and configuration management components of
%setup -q -n xCAT-server
%build
# build the tools readme files from the --help output of all of the tools
./build-readme
%install
rm -rf $RPM_BUILD_ROOT
#cp foo bar