worked on the usage logic for rinv,rspconfig etc.commands
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@1019 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
parent
929f8dfe1a
commit
1e5f60acb4
51
perl-xCAT-2.0/xCAT/Usage.pm
Normal file
51
perl-xCAT-2.0/xCAT/Usage.pm
Normal file
@ -0,0 +1,51 @@
|
||||
#!/usr/bin/perl
|
||||
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
|
||||
|
||||
package xCAT::Usage;
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
=head1 xCAT::Usage
|
||||
=head2 Package Description
|
||||
xCAT usage module. Some commands such as rpower have different implementations
|
||||
for different hardware. This module holds the usage usage string for these kind
|
||||
of commands so that the usage can be referenced from different modules.
|
||||
=cut
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
|
||||
my %usage = (
|
||||
"rpower" => "Usage: rpower <noderange> [--nodeps][on|off|reset|stat|boot]",
|
||||
"rbeacon" => "Usage: rbeacon <noderange> [on|off|stat]",
|
||||
"rvitals" => "Usage: rvitals <noderange> [all|temp|wattage|voltage|fanspeed|power|leds]",
|
||||
"reventlog" => "Usage: reventlog <noderange> [all|clear|<number of entries to retrieve>]",
|
||||
"rinv" => "Usage: rinv <noderange> [all|model|serial|vpd|mprom|deviceid|uuid]",
|
||||
"rsetboot" => "Usage: rsetboot <noderange> [net|hd|cd|def|stat]",
|
||||
"rbootseq" => "Usage: rbootseq <noderange> [hd0|hd1|hd2|hd3|net|iscsi|usbflash|floppy|none],...",
|
||||
"rscan" => "Usage: rscan <noderange> [-w][-x|-z]",
|
||||
"rspconfig" =>
|
||||
"Usage:
|
||||
Common:
|
||||
rspconfig <noderange> [snmpdest|alert|community]
|
||||
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>]
|
||||
MPA specific:
|
||||
rspconfig <noderange> [sshcfg|snmpcfg|build]
|
||||
rspconfig <noderange> [shcfg=<enable|disable>|snmpcfg=<enable|disable>]"
|
||||
);
|
||||
|
||||
#--------------------------------------------------------------------------------
|
||||
=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"; }
|
||||
}
|
@ -4,9 +4,7 @@ B<rspconfig> - remote power control of nodes
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
B<rspconfig> I<noderange> {B<alert>|B<snmpdest>|B<community>|B<garp>}
|
||||
|
||||
B<rspconfig> I<noderange> {B<ip>|B<netmask>|B<gateway>|B<backupgateway>}
|
||||
B<rspconfig> I<noderange> {B<alert>|B<snmpdest>|B<community>}
|
||||
|
||||
B<rspconfig> I<noderange> B<alert>={B<on>|B<enable>|B<off>|B<disable>}
|
||||
|
||||
@ -14,10 +12,22 @@ B<rspconfig> I<noderange> B<snmpdest>=I<snmpmanager-IP>
|
||||
|
||||
B<rspconfig> I<noderange> B<community>={B<public>|I<string>}
|
||||
|
||||
B<rspconfig> I<noderange> B<garp>=I<time>
|
||||
|
||||
B<rspconfig> [B<-h>|B<--help>|B<-v>|B<--version>]
|
||||
|
||||
=head2 BMC specific:
|
||||
|
||||
B<rspconfig> I<noderange> {B<ip>|B<netmask>|B<gateway>|B<backupgateway>|B<garp>}
|
||||
|
||||
B<rspconfig> I<noderange> B<garp>={I<time>}
|
||||
|
||||
=head2 MPA specific:
|
||||
|
||||
B<rspconfig> I<noderange> {B<sshcfg>|B<snmpcfg>|B<build>}
|
||||
|
||||
B<rspconfig> I<noderange> B<shcfg>={B<enable>|B<disable>}
|
||||
|
||||
B<rspconfig> I<noderange> B<snmpcfg>={B<enable>|B<disable>}
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
B<rspconfig> configures various settings in the nodes' service processors. If only a keyword is
|
||||
@ -55,10 +65,18 @@ Get the BMC ip address.
|
||||
|
||||
Get the BMC subnet mask.
|
||||
|
||||
=item B<snmpcfg>={I<enable>|I<disable>}
|
||||
|
||||
Enable or disable SNMP on MPA.
|
||||
|
||||
=item B<snmpdest>=I<snmpmanager-IP>
|
||||
|
||||
Get or set where the SNMP alerts should be sent to.
|
||||
|
||||
=item B<sshcfg>={I<enable>|I<disable>}
|
||||
|
||||
Enable or disable SSH on MPA.
|
||||
|
||||
=item B<-h>|B<--help>
|
||||
|
||||
Prints out a brief usage message.
|
||||
|
@ -5,6 +5,7 @@ package xCAT_plugin::blade;
|
||||
use xCAT::Table;
|
||||
use Thread qw(yield);
|
||||
use xCAT::Utils;
|
||||
use xCAT::Usage;
|
||||
use IO::Socket;
|
||||
use SNMP;
|
||||
use strict;
|
||||
@ -36,16 +37,7 @@ sub handled_commands {
|
||||
switchblade => 'nodehm:mgt',
|
||||
};
|
||||
}
|
||||
my %usage = (
|
||||
"rpower" => "Usage: rpower <noderange> [--nodeps][on|off|reset|stat|boot]",
|
||||
"rbeacon" => "Usage: rbeacon <noderange> [on|off|stat]",
|
||||
"rvitals" => "Usage: rvitals <noderange> [all|temp|voltage|fanspeed|power|leds]",
|
||||
"reventlog" => "Usage: reventlog <noderange> [all|clear|<number of entries to retrieve>]",
|
||||
"rinv" => "Usage: rinv <noderange> [all|model|serial|vpd|mprom|deviceid|uuid]",
|
||||
"rbootseq" => "Usage: rbootseq <noderange> [hd0|hd1|hd2|hd3|net|iscsi|usbflash|floppy|none],...",
|
||||
"rscan" => "Usage: rscan <noderange> [-w][-x|-z]",
|
||||
"rspconfig" => "Usage: rspconfig <noderange> [snmpdest[=<dest ip address>]|alert[=on|off|en|dis|enable|disable]|community[=<string>]|sshcfg[=enable|disable]|snmpcfg[=enable|disable]|build]"
|
||||
);
|
||||
|
||||
my %macmap; #Store responses from rinv for discovery
|
||||
my $macmaptimestamp; #reflect freshness of cache
|
||||
my $mmprimoid = '1.3.6.1.4.1.2.3.51.2.22.5.1.1.4';#mmPrimary
|
||||
@ -1199,11 +1191,12 @@ sub process_request {
|
||||
my $command = $request->{command}->[0];
|
||||
my @exargs;
|
||||
unless ($noderange or $command eq "findme") {
|
||||
if ($usage{$command}) {
|
||||
$callback->({data=>$usage{$command}});
|
||||
$request = {};
|
||||
}
|
||||
return;
|
||||
my $usage_string=xCAT::Usage->getUsage($command);
|
||||
if ($usage_string) {
|
||||
$callback->({data=>$usage_string});
|
||||
$request = {};
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (ref($request->{arg})) {
|
||||
@exargs = @{$request->{arg}};
|
||||
|
@ -8,6 +8,7 @@ package xCAT_plugin::ipmi;
|
||||
|
||||
use Storable qw(store_fd retrieve_fd thaw freeze);
|
||||
use xCAT::Utils;
|
||||
use xCAT::Usage;
|
||||
use Thread qw(yield);
|
||||
my $tfactor = 0;
|
||||
|
||||
@ -29,16 +30,6 @@ sub handled_commands {
|
||||
reventlog => 'nodehm:eventlog,mgt',
|
||||
}
|
||||
}
|
||||
my %usage = (
|
||||
"rpower" => "Usage: rpower <noderange> [on|off|reset|stat|boot]",
|
||||
"rbeacon" => "Usage: rbeacon <noderange> [on|off|stat]",
|
||||
"rvitals" => "Usage: rvitals <noderange> [all|temp|wattage|voltage|fanspeed|power|leds]",
|
||||
"reventlog" => "Usage: reventlog <noderange> [all|clear|<number of entries to retrieve>]",
|
||||
"rinv" => "Usage: rinv <noderange> [all|model|serial|vpd|mprom|deviceid|uuid]",
|
||||
"rsetboot" => "Usage: rsetboot <noderange> [net|hd|cd|def|stat]",
|
||||
"rspconfig" => "Usage: rspconfig <noderange> [snmpdest[=<dest ip address>]|alert[=on|off|en|dis|enable|disable]|community[=<string>]|garp[=<number of 1/2 second>]]"
|
||||
);
|
||||
|
||||
|
||||
|
||||
use strict;
|
||||
@ -52,6 +43,7 @@ use Digest::MD5 qw(md5);
|
||||
use POSIX qw(WNOHANG mkfifo strftime);
|
||||
use Fcntl qw(:flock);
|
||||
|
||||
|
||||
#local to module
|
||||
my @rmcp = (0x06,0x00,0xff,0x07);
|
||||
my $auth;
|
||||
@ -4583,8 +4575,9 @@ sub process_request {
|
||||
my $extrargs = $request->{arg};
|
||||
my @exargs=($request->{arg});
|
||||
unless ($noderange) {
|
||||
if ($usage{$command}) {
|
||||
$callback->({data=>$usage{$command}});
|
||||
my $usage_string=xCAT::Usage->getUsage($command);
|
||||
if ($usage_string) {
|
||||
$callback->({data=>$usage_string});
|
||||
$request = {};
|
||||
}
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user