diff --git a/buildcore.sh b/buildcore.sh index 0b8ab4845..8bb9af445 100755 --- a/buildcore.sh +++ b/buildcore.sh @@ -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 diff --git a/xCAT-client/xpod2man b/xCAT-client/xpod2man index 5517cc9a6..6fb39f20c 100755 --- a/xCAT-client/xpod2man +++ b/xCAT-client/xpod2man @@ -153,6 +153,11 @@ OS diskful/diskfree deployment. All of the cluster configuration information is in the xCAT database. See L 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 diff --git a/xCAT-server/build-readme b/xCAT-server/build-readme new file mode 100755 index 000000000..3a7b86ade --- /dev/null +++ b/xCAT-server/build-readme @@ -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'; + + + xCAT Tool Descriptions + + +

xCAT Tool Descriptions

+HTMLEOS1 + + # write the table of contents for the html readme + print $html "\n"; + + # write the intro + print $html "

Introduction

\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 "

\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"; +
+ +

$toolname

+
+HTMLEOS2
+
+	# write the actual contents of the tool help
+	printtoboth $txt, $html, $toolhelp;
+
+	# finish up
+	print $html <<"HTMLEOS3";
+
+HTMLEOS3 +} + + +sub writeending { + my $html = shift; + # finish up the html readme + print $html <<'HTMLEOS4'; + + +HTMLEOS4 +} \ No newline at end of file diff --git a/xCAT-server/share/xcat/tools/detect_dhcpd b/xCAT-server/share/xcat/tools/detect_dhcpd index 3dbf7fd86..1e2ece8cd 100755 --- a/xCAT-server/share/xcat/tools/detect_dhcpd +++ b/xCAT-server/share/xcat/tools/detect_dhcpd @@ -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; diff --git a/xCAT-server/share/xcat/tools/mac2linklocal b/xCAT-server/share/xcat/tools/mac2linklocal index 377fe446d..fa4911c0b 100755 --- a/xCAT-server/share/xcat/tools/mac2linklocal +++ b/xCAT-server/share/xcat/tools/mac2linklocal @@ -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 \n"; + print "Usage: mac2linklocal -m \n\n"; + print "Determines the IPv6 link local address that is appropriate for a NIC, based on its MAC.\n"; return; } diff --git a/xCAT-server/share/xcat/tools/mktoolscenter b/xCAT-server/share/xcat/tools/mktoolscenter index 4ff09163f..9044c6abf 100755 --- a/xCAT-server/share/xcat/tools/mktoolscenter +++ b/xCAT-server/share/xcat/tools/mktoolscenter @@ -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 \n"; + print " --pp \n"; + print " --puser \n"; + print " --ppw \n"; + print " -l \n"; + print " -s\n"; + print " --nfsserver \n"; + print " --nfspath \n"; + print " --profilename \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 \n"; - printf "--pp \n"; - printf "--puser \n"; - printf "--ppw \n"; - printf "-l \n"; - printf "-s\n"; - printf "--nfsserver \n"; - printf "--nfspath \n"; - printf "--profilename \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} = ''; diff --git a/xCAT-server/share/xcat/tools/nodesw b/xCAT-server/share/xcat/tools/nodesw index 67022d540..619561736 100755 --- a/xCAT-server/share/xcat/tools/nodesw +++ b/xCAT-server/share/xcat/tools/nodesw @@ -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"; } diff --git a/xCAT-server/share/xcat/tools/reorgtbls b/xCAT-server/share/xcat/tools/reorgtbls index 6ab309781..694141a3a 100755 --- a/xCAT-server/share/xcat/tools/reorgtbls +++ b/xCAT-server/share/xcat/tools/reorgtbls @@ -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") { diff --git a/xCAT-server/share/xcat/tools/rmblade b/xCAT-server/share/xcat/tools/rmblade index ad329b8ef..ca8ec201e 100755 --- a/xCAT-server/share/xcat/tools/rmblade +++ b/xCAT-server/share/xcat/tools/rmblade @@ -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 = $_; diff --git a/xCAT-server/share/xcat/tools/rmnodecfg b/xCAT-server/share/xcat/tools/rmnodecfg index e90b48b76..c2ab8a00e 100755 --- a/xCAT-server/share/xcat/tools/rmnodecfg +++ b/xCAT-server/share/xcat/tools/rmnodecfg @@ -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] + +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"; diff --git a/xCAT-server/xCAT-server.spec b/xCAT-server/xCAT-server.spec index 67b7901a3..e9c78e620 100644 --- a/xCAT-server/xCAT-server.spec +++ b/xCAT-server/xCAT-server.spec @@ -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