2008-04-10 21:06:26 +00:00
|
|
|
#!/usr/bin/perl
|
|
|
|
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
|
|
|
|
|
|
|
|
package xCAT::Usage;
|
2008-04-12 14:53:11 +00:00
|
|
|
use Getopt::Long;
|
2008-07-07 19:04:37 +00:00
|
|
|
use xCAT::Utils;
|
2008-04-10 21:06:26 +00:00
|
|
|
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
=head1 xCAT::Usage
|
|
|
|
=head2 Package Description
|
|
|
|
xCAT usage module. Some commands such as rpower have different implementations
|
2008-10-22 15:56:46 +00:00
|
|
|
for different hardware. This module holds the usage string for these kind
|
2008-04-10 21:06:26 +00:00
|
|
|
of commands so that the usage can be referenced from different modules.
|
|
|
|
=cut
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
my %usage = (
|
2008-04-12 14:53:11 +00:00
|
|
|
"rnetboot" =>
|
2008-04-18 16:44:25 +00:00
|
|
|
"Usage: rnetboot <noderange> [-f][-V|--verbose]
|
2008-04-12 14:53:11 +00:00
|
|
|
rnetboot [-h|--help|-v|--version]",
|
|
|
|
"rpower" =>
|
2008-10-13 15:29:32 +00:00
|
|
|
"Usage: rpower <noderange> [--nodeps][on|off|reset|stat|state|boot|cycle|softoff] [-V|--verbose]
|
2008-10-06 16:06:34 +00:00
|
|
|
rpower [-h|--help|-v|--version]
|
|
|
|
PPC (with IVM or HMC) specific:
|
|
|
|
rpower <noderange> [--nodeps] [of] [-V|--verbose]
|
|
|
|
",
|
2008-04-12 14:53:11 +00:00
|
|
|
"rbeacon" =>
|
|
|
|
"Usage: rbeacon <noderange> [on|off|stat] [-V|--verbose]
|
|
|
|
rbeacon [-h|--help|-v|--version]",
|
|
|
|
"rvitals" =>
|
|
|
|
"Usage: rvitals <noderange> [all|temp|wattage|voltage|fanspeed|power|leds|state] [-V|--verbose]
|
|
|
|
rvitals [-h|--help|-v|--version]",
|
|
|
|
"reventlog" =>
|
|
|
|
"Usage: reventlog <noderange> [all|clear|<number of entries to retrieve>] [-V|--verbose]
|
|
|
|
reventlog [-h|--help|-v|--version]",
|
|
|
|
"rinv" =>
|
|
|
|
"Usage:
|
|
|
|
Common:
|
|
|
|
rinv <noderange> [all|model|serial] [-V|--verbose]
|
|
|
|
rinv [-h|--help|-v|--version]
|
|
|
|
BMC specific:
|
|
|
|
rinv <noderange> [vpd|mprom|deviceid|uuid|guid]
|
|
|
|
MPA specific:
|
|
|
|
rinv <noderange> [firm|bios|diag|mprom|sprom|mparom|mac|mtm]
|
|
|
|
PPC specific:
|
2008-06-19 19:22:37 +00:00
|
|
|
rinv <noderange> [bus|config|serial|model|firm|all]",
|
2008-04-12 14:53:11 +00:00
|
|
|
"rsetboot" =>
|
2008-07-14 15:33:06 +00:00
|
|
|
"Usage: rsetboot <noderange> [net|hd|cd|floppy|def|stat] [-V|--verbose]
|
2008-04-12 14:53:11 +00:00
|
|
|
rsetboot [-h|--help|-v|--version]",
|
|
|
|
"rbootseq" =>
|
|
|
|
"Usage: rbootseq <noderange> [hd0|hd1|hd2|hd3|net|iscsi|usbflash|floppy|none],...
|
|
|
|
rbootseq [-h|--help|-v|--version]",
|
|
|
|
"rscan" =>
|
|
|
|
"Usage: rscan <noderange> [-w][-x|-z] [-V|--verbose]
|
|
|
|
rscan [-h|--help|-v|--version]",
|
2008-04-10 21:06:26 +00:00
|
|
|
"rspconfig" =>
|
|
|
|
"Usage:
|
|
|
|
Common:
|
2008-05-20 18:57:12 +00:00
|
|
|
rspconfig [-h|--help|-v|--version]
|
|
|
|
BMC/MPA Common:
|
2008-04-12 14:53:11 +00:00
|
|
|
rspconfig <noderange> [snmpdest|alert|community] [-V|--verbose]
|
2008-04-10 21:06:26 +00:00
|
|
|
rspconfig <noderange> [snmpdest=<dest ip address>|alert=<on|off|en|dis|enable|disable>|community=<string>]
|
|
|
|
BMC specific:
|
|
|
|
rspconfig <noderange> [ip|netmask|gateway|backupgateway|garp]
|
|
|
|
rspconfig <noderange> [garp=<number of 1/2 second>]
|
2008-06-10 15:32:14 +00:00
|
|
|
iDataplex specific:
|
|
|
|
rspconfig <noderange> [thermprofile]
|
|
|
|
rspconfig <noderange> [thermprofile=<two digit number from chassis>]
|
2008-04-10 21:06:26 +00:00
|
|
|
MPA specific:
|
2008-06-20 14:36:30 +00:00
|
|
|
rspconfig <noderange> [sshcfg|snmpcfg|pd1|pd2|network|swnet|ntp|textid]
|
2008-05-20 18:57:12 +00:00
|
|
|
rspconfig <singlenode> [textid=name]
|
2008-05-27 14:29:01 +00:00
|
|
|
rspconfig <noderange> [sshcfg=<enable|disable>|
|
2008-04-21 13:40:51 +00:00
|
|
|
snmpcfg=<enable|disable>|
|
|
|
|
pd1=<nonred|redwoperf|redwperf>|
|
|
|
|
pd2=<nonred|redwoperf|redwperf>|
|
2008-04-22 19:28:29 +00:00
|
|
|
network=<*|[ip],[host],[gateway],[netmask]>|
|
|
|
|
swnet=<[ip],[gateway],[netmask]>|
|
2008-05-20 18:57:12 +00:00
|
|
|
textid=<*>|
|
2008-04-22 19:28:29 +00:00
|
|
|
ntp=<[ntp],[ip],[frequency],[v3]>
|
2008-05-27 14:29:01 +00:00
|
|
|
FSP specific:
|
2008-04-21 13:40:51 +00:00
|
|
|
rspconfig <noderange> [autopower|iocap|decfg|memdecfg|procdecfg|time|date|spdump|sysdump]
|
|
|
|
rspconfig <noderange> autopower=<enable|disable>|
|
|
|
|
iocap=<enable|disable>|
|
|
|
|
decfg=<enable|disable>:<policy name>,...|
|
|
|
|
memdecfg=<configure|deconfigure>:<processing unit>:<bank|unit>:<bank/unit number>:id,...|
|
|
|
|
procdecfg=<configure|deconfigure>:<processing unit>:id,...|
|
|
|
|
date=<mm-dd-yyyy>|
|
2008-05-27 14:29:01 +00:00
|
|
|
time=<hh:mm:ss>
|
|
|
|
PPC specific:
|
|
|
|
rspconfig <noderange> [sshcfg]
|
|
|
|
rspconfig <noderange> [sshcfg=<enable|disable>]",
|
2008-04-12 14:53:11 +00:00
|
|
|
"getmacs" =>
|
|
|
|
"Usage:
|
|
|
|
Common:
|
|
|
|
getmacs <noderange> [-V|--verbose]
|
|
|
|
getmacs [-h|--help|-v|--version]
|
|
|
|
PPC specific:
|
2008-06-23 16:43:49 +00:00
|
|
|
getmacs <noderange> [-f][-d][-S server -G gateway -C client]",
|
2008-04-12 14:53:11 +00:00
|
|
|
"mkvm" =>
|
2008-04-30 19:20:42 +00:00
|
|
|
"Usage: mkvm singlenode -i id -n noderange [-V|--verbose]
|
|
|
|
mkvm srccec -c destcec [-V|--verbose]
|
2008-04-12 14:53:11 +00:00
|
|
|
mkvm [-h|--help|-v|--version]",
|
|
|
|
"lsvm" =>
|
2008-11-04 01:45:46 +00:00
|
|
|
"Usage:
|
|
|
|
Common:
|
|
|
|
lsvm <noderange> [-V|--verbose]
|
|
|
|
lsvm [-h|--help|-v|--version]
|
|
|
|
PPC specific:
|
|
|
|
lsvm <noderange> [-a|--all]",
|
2008-04-12 14:53:11 +00:00
|
|
|
"chvm" =>
|
2008-06-20 13:23:11 +00:00
|
|
|
"Usage: chvm <noderange> [-p profile][-V|--verbose]
|
2008-04-12 14:53:11 +00:00
|
|
|
chvm [-h|--help|-v|--version]",
|
|
|
|
"rmvm" =>
|
|
|
|
"Usage: rmvm <noderange> [-V|--verbose]
|
2008-06-17 13:48:08 +00:00
|
|
|
rmvm [-h|--help|-v|--version]",
|
|
|
|
"lsslp" =>
|
|
|
|
"Usage: lsslp [-h|--help|-v|--version]
|
2008-09-10 15:51:47 +00:00
|
|
|
lsslp [-V|--verbose][-i ip[,ip..]][-w][-r|-x|-z][-s BPA|MM|IVM|RSA|FSP|HMC]
|
|
|
|
[-t tries][-m][-e cmd][-c [timeout[timeout,..]]]"
|
2008-04-12 14:53:11 +00:00
|
|
|
);
|
2008-07-07 19:04:37 +00:00
|
|
|
my $vers = xCAT::Utils->Version();
|
2008-04-12 14:53:11 +00:00
|
|
|
my %version = (
|
2008-07-07 19:04:37 +00:00
|
|
|
"rnetboot" => "$vers",
|
|
|
|
"rpower" => "$vers",
|
|
|
|
"rbeacon" => "$vers",
|
|
|
|
"rvitals" => "$vers",
|
|
|
|
"reventlog" => "$vers",
|
|
|
|
"rinv" => "$vers",
|
|
|
|
"rsetboot" => "$vers",
|
|
|
|
"rbootseq" => "$vers",
|
|
|
|
"rscan" => "$vers",
|
|
|
|
"rspconfig" => "$vers",
|
|
|
|
"getmacs" => "$vers",
|
|
|
|
"mkvm" => "$vers",
|
|
|
|
"lsvm" => "$vers",
|
|
|
|
"chvm" => "$vers",
|
|
|
|
"rmvm" => "$vers",
|
|
|
|
"lsslp" => "$vers"
|
2008-04-10 21:06:26 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
#--------------------------------------------------------------------------------
|
|
|
|
=head3 getUsage
|
|
|
|
It returns the usage string for the given command.
|
|
|
|
Arguments:
|
|
|
|
command
|
|
|
|
Returns:
|
|
|
|
the usage string for the command.
|
|
|
|
=cut
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
sub getUsage {
|
|
|
|
my ($class, $command)=@_;
|
|
|
|
if (exists($usage{$command})) { return $usage{$command};}
|
|
|
|
else { return "Usage for command $command cannot be found\n"; }
|
|
|
|
}
|
2008-04-12 14:53:11 +00:00
|
|
|
|
|
|
|
#--------------------------------------------------------------------------------
|
|
|
|
=head3 getVersion
|
|
|
|
It returns the version string for the given command.
|
|
|
|
Arguments:
|
|
|
|
command
|
|
|
|
Returns:
|
|
|
|
the version string for the command.
|
|
|
|
=cut
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
sub getVersion {
|
|
|
|
my ($class, $command)=@_;
|
|
|
|
if (exists($version{$command})) { return $version{$command};}
|
|
|
|
else { return "Version string for command $command cannot be found\n"; }
|
|
|
|
}
|
|
|
|
|
|
|
|
#--------------------------------------------------------------------------------
|
|
|
|
=head3 parseCommand
|
|
|
|
This function parses the given command to see if the usage or version string
|
|
|
|
need to be returned.
|
|
|
|
Arguments:
|
|
|
|
command
|
|
|
|
arguments
|
|
|
|
Returns:
|
|
|
|
the usage or the version string for the command. The caller need to display the
|
|
|
|
string and then exit.
|
|
|
|
none, if no usage or version strings are needed. The caller can keep going.
|
|
|
|
=cut
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
sub parseCommand {
|
|
|
|
my $command=shift;
|
|
|
|
if ($command =~ /xCAT::Usage/) { $command=shift; }
|
|
|
|
my @exargs=@_;
|
|
|
|
|
|
|
|
@ARGV=@exargs;
|
|
|
|
|
|
|
|
#print "command=$command, args=@exargs, ARGV=@ARGV\n";
|
|
|
|
|
2008-10-22 15:56:46 +00:00
|
|
|
Getopt::Long::Configure('pass_through','no_ignore_case');
|
2008-04-12 14:53:11 +00:00
|
|
|
|
|
|
|
# parse the options
|
|
|
|
if(!GetOptions(
|
|
|
|
'h|help' => \$::HELP,
|
|
|
|
'v|version' => \$::VERSION)) {
|
|
|
|
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($::HELP) { return xCAT::Usage->getUsage($command); }
|
|
|
|
if ($::VERSION) { return xCAT::Usage->getVersion($command); }
|
|
|
|
|
|
|
|
return "";
|
|
|
|
}
|
2008-04-21 13:40:51 +00:00
|
|
|
|