mirror of
https://github.com/xcat2/xcat-core.git
synced 2025-06-03 03:50:08 +00:00
consolidates the hardware control commands into one place
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@1027 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
parent
1164d85070
commit
8059f5e40d
@ -4,6 +4,7 @@ package xCAT::PPC;
|
||||
use strict;
|
||||
use xCAT::Table;
|
||||
use xCAT::Utils;
|
||||
use xCAT::Usage;
|
||||
use POSIX "WNOHANG";
|
||||
use Storable qw(freeze thaw);
|
||||
use Time::HiRes qw(gettimeofday);
|
||||
@ -835,6 +836,33 @@ sub process_request {
|
||||
# Get hwtype
|
||||
####################################
|
||||
$package =~ s/xCAT_plugin:://;
|
||||
|
||||
|
||||
####################################
|
||||
# Prompt for usage if needed
|
||||
####################################
|
||||
my $noderange = $req->{node}; #Should be arrayref
|
||||
my $command = $req->{command}->[0];
|
||||
my $extrargs = $req->{arg};
|
||||
my @exargs=($req->{arg});
|
||||
if (ref($extrargs)) {
|
||||
@exargs=@$extrargs;
|
||||
}
|
||||
|
||||
my $usage_string=xCAT::Usage->parseCommand($command, @exargs);
|
||||
if ($usage_string) {
|
||||
$callback->({data=>$usage_string});
|
||||
$req = {};
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$noderange) {
|
||||
$usage_string=xCAT::Usage->getUsage($command);
|
||||
$callback->({data=>$usage_string});
|
||||
$req = {};
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
####################################
|
||||
# Build hash to pass around
|
||||
|
@ -4,30 +4,23 @@ package xCAT::PPCboot;
|
||||
use strict;
|
||||
use Getopt::Long;
|
||||
use xCAT::PPCcli qw(SUCCESS EXPECT_ERROR RC_ERROR NR_ERROR);
|
||||
|
||||
use xCAT::Usage;
|
||||
|
||||
##########################################################################
|
||||
# Parse the command line for options and operands
|
||||
##########################################################################
|
||||
sub parse_args {
|
||||
|
||||
my $request = shift;
|
||||
my %opt = ();
|
||||
my $cmd = $request->{command};
|
||||
my $args = $request->{arg};
|
||||
my @VERSION = qw( 2.0 );
|
||||
|
||||
#############################################
|
||||
# Responds with usage statement
|
||||
#############################################
|
||||
local *usage = sub {
|
||||
return( [ $_[0],
|
||||
"rnetboot -h|--help",
|
||||
"rnetboot -v|--version",
|
||||
"rnetboot [-V|--verbose] noderange",
|
||||
" -h writes usage information to standard output",
|
||||
" -v displays command version",
|
||||
" -V verbose output" ]);
|
||||
my $usage_string=xCAT::Usage->getUsage($cmd);
|
||||
return( [ $_[0], $usage_string]);
|
||||
};
|
||||
#############################################
|
||||
# Process command-line arguments
|
||||
@ -44,22 +37,10 @@ sub parse_args {
|
||||
$Getopt::Long::ignorecase = 0;
|
||||
Getopt::Long::Configure( "bundling" );
|
||||
|
||||
if ( !GetOptions( \%opt, qw(h|help V|Verbose v|version) )) {
|
||||
if ( !GetOptions( \%opt, qw(V|Verbose) )) {
|
||||
return( usage() );
|
||||
}
|
||||
####################################
|
||||
# Option -h for Help
|
||||
####################################
|
||||
if ( exists( $opt{h} )) {
|
||||
return( usage() );
|
||||
}
|
||||
####################################
|
||||
# Option -v for version
|
||||
####################################
|
||||
if ( exists( $opt{v} )) {
|
||||
return( \@VERSION );
|
||||
}
|
||||
####################################
|
||||
####################################
|
||||
# Check for "-" with no option
|
||||
####################################
|
||||
if ( grep(/^-$/, @ARGV )) {
|
||||
|
@ -7,7 +7,7 @@ use LWP;
|
||||
use HTTP::Cookies;
|
||||
use HTML::Form;
|
||||
use xCAT::PPCcli qw(SUCCESS EXPECT_ERROR RC_ERROR NR_ERROR);
|
||||
|
||||
use xCAT::Usage;
|
||||
|
||||
##########################################
|
||||
# Globals
|
||||
@ -47,7 +47,6 @@ sub parse_args {
|
||||
my $args = $request->{arg};
|
||||
my $cmd = join( '|',@rsp );
|
||||
my %opt = ();
|
||||
my @VERSION = qw( 2.0 );
|
||||
|
||||
#############################################
|
||||
# Modify usage statement
|
||||
@ -67,13 +66,8 @@ sub parse_args {
|
||||
# Responds with usage statement
|
||||
#############################################
|
||||
local *usage = sub {
|
||||
return( [ $_[0],
|
||||
"rspconfig -h|--help",
|
||||
"rspconfig -v|--version",
|
||||
"rspconfig [-V|--verbose] noderange $cmd\n",
|
||||
" -h writes usage information to standard output",
|
||||
" -v displays command version",
|
||||
" -V verbose output"] );
|
||||
my $usage_string=xCAT::Usage->getUsage($command);
|
||||
return( [ $_[0], $usage_string]);
|
||||
};
|
||||
#############################################
|
||||
# Process command-line arguments
|
||||
@ -91,22 +85,10 @@ sub parse_args {
|
||||
Getopt::Long::Configure( "bundling" );
|
||||
$request->{method} = undef;
|
||||
|
||||
if ( !GetOptions( \%opt, qw(h|help V|Verbose v|version) )) {
|
||||
if ( !GetOptions( \%opt, qw(V|Verbose) )) {
|
||||
return( usage() );
|
||||
}
|
||||
####################################
|
||||
# Option -h for Help
|
||||
####################################
|
||||
if ( exists( $opt{h} )) {
|
||||
return( usage() );
|
||||
}
|
||||
####################################
|
||||
# Option -v for version
|
||||
####################################
|
||||
if ( exists( $opt{v} )) {
|
||||
return( \@VERSION );
|
||||
}
|
||||
####################################
|
||||
# Check for "-" with no option
|
||||
####################################
|
||||
if ( grep(/^-$/, @ARGV )) {
|
||||
|
@ -4,6 +4,7 @@ package xCAT::PPCinv;
|
||||
use strict;
|
||||
use Getopt::Long;
|
||||
use xCAT::PPCcli qw(SUCCESS EXPECT_ERROR RC_ERROR NR_ERROR);
|
||||
use xCAT::Usage;
|
||||
|
||||
|
||||
##########################################################################
|
||||
@ -12,22 +13,17 @@ use xCAT::PPCcli qw(SUCCESS EXPECT_ERROR RC_ERROR NR_ERROR);
|
||||
sub parse_args {
|
||||
|
||||
my $request = shift;
|
||||
my $command = $request->{command};
|
||||
my $args = $request->{arg};
|
||||
my %opt = ();
|
||||
my @rinv = qw(bus config model serial all);
|
||||
my @VERSION = qw( 2.0 );
|
||||
|
||||
#############################################
|
||||
# Responds with usage statement
|
||||
#############################################
|
||||
local *usage = sub {
|
||||
return( [ $_[0],
|
||||
"rinv -h|--help",
|
||||
"rinv -v|--version",
|
||||
"rinv [-V|--verbose] noderange " . join( '|', @rinv ),
|
||||
" -h writes usage information to standard output",
|
||||
" -v displays command version",
|
||||
" -V verbose output" ]);
|
||||
my $usage_string=xCAT::Usage->getUsage($command);
|
||||
return( [ $_[0], $usage_string]);
|
||||
};
|
||||
#############################################
|
||||
# Process command-line arguments
|
||||
@ -44,22 +40,10 @@ sub parse_args {
|
||||
$Getopt::Long::ignorecase = 0;
|
||||
Getopt::Long::Configure( "bundling" );
|
||||
|
||||
if ( !GetOptions( \%opt, qw(h|help V|Verbose v|version) )) {
|
||||
if ( !GetOptions( \%opt, qw(V|Verbose) )) {
|
||||
return( usage() );
|
||||
}
|
||||
####################################
|
||||
# Option -h for Help
|
||||
####################################
|
||||
if ( exists( $opt{h} )) {
|
||||
return( usage() );
|
||||
}
|
||||
####################################
|
||||
# Option -v for version
|
||||
####################################
|
||||
if ( exists( $opt{v} )) {
|
||||
return( \@VERSION );
|
||||
}
|
||||
####################################
|
||||
# Check for "-" with no option
|
||||
####################################
|
||||
if ( grep(/^-$/, @ARGV )) {
|
||||
|
@ -3,6 +3,7 @@
|
||||
package xCAT::PPClog;
|
||||
use strict;
|
||||
use Getopt::Long;
|
||||
use xCAT::Usage;
|
||||
|
||||
|
||||
##########################################################################
|
||||
@ -11,23 +12,18 @@ use Getopt::Long;
|
||||
sub parse_args {
|
||||
|
||||
my $request = shift;
|
||||
my $command = $request->{command};
|
||||
my $args = $request->{arg};
|
||||
my %opt = ();
|
||||
my @reventlog = qw(clear all);
|
||||
my @VERSION = qw( 2.0 );
|
||||
my $cmd;
|
||||
|
||||
#############################################
|
||||
# Responds with usage statement
|
||||
#############################################
|
||||
local *usage = sub {
|
||||
return( [ $_[0],
|
||||
"reventlog -h|--help",
|
||||
"reventlog -v|--version",
|
||||
"reventlog [-V|--verbose] noderange " . join( '|', @reventlog )."|<number of entries>",
|
||||
" -h writes usage information to standard output",
|
||||
" -v displays command version",
|
||||
" -V verbose output"])
|
||||
my $usage_string=xCAT::Usage->getUsage($command);
|
||||
return( [ $_[0], $usage_string]);
|
||||
};
|
||||
#############################################
|
||||
# Process command-line arguments
|
||||
@ -44,22 +40,10 @@ sub parse_args {
|
||||
$Getopt::Long::ignorecase = 0;
|
||||
Getopt::Long::Configure( "bundling" );
|
||||
|
||||
if ( !GetOptions( \%opt, qw(h|help V|Verbose v|version) )) {
|
||||
if ( !GetOptions( \%opt, qw(V|Verbose) )) {
|
||||
return( usage() );
|
||||
}
|
||||
####################################
|
||||
# Option -h for Help
|
||||
####################################
|
||||
if ( exists( $opt{h} )) {
|
||||
return( usage() );
|
||||
}
|
||||
####################################
|
||||
# Option -v for version
|
||||
####################################
|
||||
if ( exists( $opt{v} )) {
|
||||
return( \@VERSION );
|
||||
}
|
||||
####################################
|
||||
# Check for "-" with no option
|
||||
####################################
|
||||
if ( grep(/^-$/, @ARGV )) {
|
||||
|
@ -4,6 +4,7 @@ package xCAT::PPCmac;
|
||||
use strict;
|
||||
use Getopt::Long;
|
||||
use xCAT::PPCcli qw(SUCCESS EXPECT_ERROR RC_ERROR NR_ERROR);
|
||||
use xCAT::Usage;
|
||||
|
||||
|
||||
|
||||
@ -16,24 +17,13 @@ sub parse_args {
|
||||
my %opt = ();
|
||||
my $cmd = $request->{command};
|
||||
my $args = $request->{arg};
|
||||
my @VERSION = qw( 2.0 );
|
||||
|
||||
#############################################
|
||||
# Responds with usage statement
|
||||
#############################################
|
||||
local *usage = sub {
|
||||
return( [ $_[0],
|
||||
"getmacs -h|--help",
|
||||
"getmacs -v|--version",
|
||||
"getmacs [-V|--verbose] noderange [-c][-w][-S server -G gateway -C client]",
|
||||
" -h writes usage information to standard output",
|
||||
" -v displays command version",
|
||||
" -c colon seperated output",
|
||||
" -C IP of the partition",
|
||||
" -G Gateway IP of the partition specified",
|
||||
" -S Server IP to ping",
|
||||
" -V verbose output",
|
||||
" -w writes first adapter MAC to the xCAT database"]);
|
||||
my $usage_string=xCAT::Usage->getUsage($cmd);
|
||||
return( [ $_[0], $usage_string]);
|
||||
};
|
||||
#############################################
|
||||
# Process command-line arguments
|
||||
@ -51,22 +41,10 @@ sub parse_args {
|
||||
$Getopt::Long::ignorecase = 0;
|
||||
Getopt::Long::Configure( "bundling" );
|
||||
|
||||
if ( !GetOptions( \%opt,qw(h|help V|Verbose v|version C=s G=s S=s c w))) {
|
||||
if ( !GetOptions( \%opt,qw(V|Verbose C=s G=s S=s c w))) {
|
||||
return( usage() );
|
||||
}
|
||||
####################################
|
||||
# Option -h for Help
|
||||
####################################
|
||||
if ( exists( $opt{h} )) {
|
||||
return( usage() );
|
||||
}
|
||||
####################################
|
||||
# Option -v for version
|
||||
####################################
|
||||
if ( exists( $opt{v} )) {
|
||||
return( \@VERSION );
|
||||
}
|
||||
####################################
|
||||
# Check for "-" with no option
|
||||
####################################
|
||||
if ( grep(/^-$/, @ARGV )) {
|
||||
|
@ -4,30 +4,25 @@ package xCAT::PPCpower;
|
||||
use strict;
|
||||
use Getopt::Long;
|
||||
use xCAT::PPCcli qw(SUCCESS EXPECT_ERROR RC_ERROR NR_ERROR);
|
||||
use xCAT::Usage;
|
||||
|
||||
|
||||
##########################################################################
|
||||
# Parse the command line for options and operands
|
||||
##########################################################################
|
||||
sub parse_args {
|
||||
|
||||
my $request = shift;
|
||||
my $command = $request->{command};
|
||||
my $args = $request->{arg};
|
||||
my %opt = ();
|
||||
my @rpower = qw(on off stat state reset boot of);
|
||||
my @VERSION = qw( 2.0 );
|
||||
|
||||
#############################################
|
||||
# Responds with usage statement
|
||||
#############################################
|
||||
local *usage = sub {
|
||||
return( [ $_[0],
|
||||
"rpower -h|--help",
|
||||
"rpower -v|--version",
|
||||
"rpower [-V|--verbose] noderange " . join( '|', @rpower ),
|
||||
" -h writes usage information to standard output",
|
||||
" -v displays command version",
|
||||
" -V verbose output" ]);
|
||||
my $usage_string=xCAT::Usage->getUsage($command);
|
||||
return( [ $_[0], $usage_string]);
|
||||
};
|
||||
#############################################
|
||||
# Process command-line arguments
|
||||
@ -44,22 +39,10 @@ sub parse_args {
|
||||
$Getopt::Long::ignorecase = 0;
|
||||
Getopt::Long::Configure( "bundling" );
|
||||
|
||||
if ( !GetOptions( \%opt, qw(h|help V|Verbose v|version) )) {
|
||||
if ( !GetOptions( \%opt, qw(V|Verbose) )) {
|
||||
return( usage() );
|
||||
}
|
||||
####################################
|
||||
# Option -h for Help
|
||||
####################################
|
||||
if ( exists( $opt{h} )) {
|
||||
return( usage() );
|
||||
}
|
||||
####################################
|
||||
# Option -v for version
|
||||
####################################
|
||||
if ( exists( $opt{v} )) {
|
||||
return( \@VERSION );
|
||||
}
|
||||
####################################
|
||||
# Check for "-" with no option
|
||||
####################################
|
||||
if ( grep(/^-$/, @ARGV )) {
|
||||
|
@ -9,6 +9,7 @@ $XML::Simple::PREFERRED_PARSER='XML::Parser';
|
||||
use xCAT::PPCcli qw(SUCCESS EXPECT_ERROR RC_ERROR NR_ERROR);
|
||||
use xCAT::PPCdb;
|
||||
use xCAT::GlobalDef;
|
||||
use xCAT::Usage;
|
||||
|
||||
|
||||
##############################################
|
||||
@ -39,22 +40,13 @@ sub parse_args {
|
||||
my %opt = ();
|
||||
my $cmd = $request->{command};
|
||||
my $args = $request->{arg};
|
||||
my @VERSION = qw( 2.0 );
|
||||
|
||||
#############################################
|
||||
# Responds with usage statement
|
||||
#############################################
|
||||
local *usage = sub {
|
||||
return( [ $_[0],
|
||||
"rscan -h|--help",
|
||||
"rscan -v|--version",
|
||||
"rscan [-V|--verbose] noderange [-w][-x|-z]",
|
||||
" -h writes usage information to standard output",
|
||||
" -v displays command version",
|
||||
" -V verbose output",
|
||||
" -w writes output to xCat database",
|
||||
" -x xml formatted output",
|
||||
" -z stanza formatted output." ]);
|
||||
my $usage_string=xCAT::Usage->getUsage($cmd);
|
||||
return( [ $_[0], $usage_string]);
|
||||
};
|
||||
#############################################
|
||||
# Process command-line arguments
|
||||
@ -72,22 +64,10 @@ sub parse_args {
|
||||
$Getopt::Long::ignorecase = 0;
|
||||
Getopt::Long::Configure( "bundling" );
|
||||
|
||||
if ( !GetOptions( \%opt, qw(h|help V|Verbose v|version w x z) )){
|
||||
if ( !GetOptions( \%opt, qw(V|Verbose w x z) )){
|
||||
return( usage() );
|
||||
}
|
||||
####################################
|
||||
# Option -h for Help
|
||||
####################################
|
||||
if ( exists( $opt{h} )) {
|
||||
return( usage() );
|
||||
}
|
||||
####################################
|
||||
# Option -v for version
|
||||
####################################
|
||||
if ( exists( $opt{v} )) {
|
||||
return( \@VERSION );
|
||||
}
|
||||
####################################
|
||||
# Check for "-" with no option
|
||||
####################################
|
||||
if ( grep(/^-$/, @ARGV )) {
|
||||
|
@ -5,7 +5,7 @@ use strict;
|
||||
use Getopt::Long;
|
||||
use xCAT::PPCcli qw(SUCCESS EXPECT_ERROR RC_ERROR NR_ERROR);
|
||||
use xCAT::PPCpower;
|
||||
|
||||
use xCAT::Usage;
|
||||
|
||||
##########################################################################
|
||||
# Parse the command line for options and operands
|
||||
@ -13,22 +13,17 @@ use xCAT::PPCpower;
|
||||
sub parse_args {
|
||||
|
||||
my $request = shift;
|
||||
my $command = $request->{command};
|
||||
my $args = $request->{arg};
|
||||
my %opt = ();
|
||||
my @rvitals = qw(temp voltage power state all);
|
||||
my @VERSION = qw( 2.0 );
|
||||
|
||||
#############################################
|
||||
# Responds with usage statement
|
||||
#############################################
|
||||
local *usage = sub {
|
||||
return( [ $_[0],
|
||||
"rvitals -h|--help",
|
||||
"rvitals -v|--version",
|
||||
"rvitals [-V|--verbose] noderange " . join( '|', @rvitals ),
|
||||
" -h writes usage information to standard output",
|
||||
" -v displays command version",
|
||||
" -V verbose output" ]);
|
||||
my $usage_string=xCAT::Usage->getUsage($command);
|
||||
return( [ $_[0], $usage_string]);
|
||||
};
|
||||
#############################################
|
||||
# Process command-line arguments
|
||||
@ -45,22 +40,10 @@ sub parse_args {
|
||||
$Getopt::Long::ignorecase = 0;
|
||||
Getopt::Long::Configure( "bundling" );
|
||||
|
||||
if ( !GetOptions( \%opt, qw(h|help V|Verbose v|version) )) {
|
||||
if ( !GetOptions( \%opt, qw(V|Verbose) )) {
|
||||
return( usage() );
|
||||
}
|
||||
####################################
|
||||
# Option -h for Help
|
||||
####################################
|
||||
if ( exists( $opt{h} )) {
|
||||
return( usage() );
|
||||
}
|
||||
####################################
|
||||
# Option -v for version
|
||||
####################################
|
||||
if ( exists( $opt{v} )) {
|
||||
return( \@VERSION );
|
||||
}
|
||||
####################################
|
||||
# Check for "-" with no option
|
||||
####################################
|
||||
if ( grep(/^-$/, @ARGV )) {
|
||||
|
@ -5,6 +5,7 @@ use strict;
|
||||
use Getopt::Long;
|
||||
use xCAT::PPCcli qw(SUCCESS EXPECT_ERROR RC_ERROR NR_ERROR);
|
||||
use xCAT::PPCdb;
|
||||
use xCAT::Usage;
|
||||
|
||||
|
||||
##############################################
|
||||
@ -43,19 +44,13 @@ sub chvm_parse_args {
|
||||
my %opt = ();
|
||||
my $cmd = $request->{command};
|
||||
my $args = $request->{arg};
|
||||
my @VERSION = qw( 2.0 );
|
||||
|
||||
#############################################
|
||||
# Responds with usage statement
|
||||
#############################################
|
||||
local *usage = sub {
|
||||
return( [ $_[0],
|
||||
"chvm -h|--help",
|
||||
"chvm -v|--version",
|
||||
"chvm [-V|--verbose] noderange",
|
||||
" -h writes usage information to standard output",
|
||||
" -v displays command version",
|
||||
" -V verbose output" ]);
|
||||
my $usage_string=xCAT::Usage->getUsage($cmd);
|
||||
return( [ $_[0], $usage_string]);
|
||||
};
|
||||
####################################
|
||||
# Configuration file required
|
||||
@ -79,22 +74,10 @@ sub chvm_parse_args {
|
||||
$Getopt::Long::ignorecase = 0;
|
||||
Getopt::Long::Configure( "bundling" );
|
||||
|
||||
if ( !GetOptions( \%opt, qw(h|help V|Verbose v|version) )) {
|
||||
if ( !GetOptions( \%opt, qw(V|Verbose) )) {
|
||||
return( usage() );
|
||||
}
|
||||
####################################
|
||||
# Option -h for Help
|
||||
####################################
|
||||
if ( exists( $opt{h} )) {
|
||||
return( usage() );
|
||||
}
|
||||
####################################
|
||||
# Option -v for version
|
||||
####################################
|
||||
if ( exists( $opt{v} )) {
|
||||
return( \@VERSION );
|
||||
}
|
||||
####################################
|
||||
# Check for "-" with no option
|
||||
####################################
|
||||
if ( grep(/^-$/, @ARGV )) {
|
||||
@ -123,23 +106,13 @@ sub mkvm_parse_args {
|
||||
my %opt = ();
|
||||
my $cmd = $request->{command};
|
||||
my $args = $request->{arg};
|
||||
my @VERSION = qw( 2.0 );
|
||||
|
||||
#############################################
|
||||
# Responds with usage statement
|
||||
#############################################
|
||||
local *usage = sub {
|
||||
return( [ $_[0],
|
||||
"mkvm -h|--help",
|
||||
"mkvm -v|--version",
|
||||
"mkvm [-V|--verbose] singlenode -i id -n name",
|
||||
"mkvm [-V|--verbose] src_fsp -c dest_fsp",
|
||||
" -h writes usage information to standard output",
|
||||
" -c copy partitions from src_fsp to dest_fsp on single HMC",
|
||||
" -i new partition numeric id",
|
||||
" -n new partition name",
|
||||
" -v displays command version",
|
||||
" -V verbose output" ]);
|
||||
my $usage_string=xCAT::Usage->getUsage($cmd);
|
||||
return( [ $_[0], $usage_string]);
|
||||
};
|
||||
#############################################
|
||||
# Process command-line arguments
|
||||
@ -162,22 +135,10 @@ sub mkvm_parse_args {
|
||||
$Getopt::Long::ignorecase = 0;
|
||||
Getopt::Long::Configure( "bundling" );
|
||||
|
||||
if ( !GetOptions( \%opt, qw(h|help V|Verbose v|version i=s n=s c=s) )) {
|
||||
if ( !GetOptions( \%opt, qw(V|Verbose i=s n=s c=s) )) {
|
||||
return( usage() );
|
||||
}
|
||||
####################################
|
||||
# Option -h for Help
|
||||
####################################
|
||||
if ( exists( $opt{h} )) {
|
||||
return( usage() );
|
||||
}
|
||||
####################################
|
||||
# Option -v for version
|
||||
####################################
|
||||
if ( exists( $opt{v} )) {
|
||||
return( \@VERSION );
|
||||
}
|
||||
####################################
|
||||
# Check for "-" with no option
|
||||
####################################
|
||||
if ( grep(/^-$/, @ARGV )) {
|
||||
@ -230,19 +191,13 @@ sub rmvm_parse_args {
|
||||
my %opt = ();
|
||||
my $cmd = $request->{command};
|
||||
my $args = $request->{arg};
|
||||
my @VERSION = qw( 2.0 );
|
||||
|
||||
#############################################
|
||||
# Responds with usage statement
|
||||
#############################################
|
||||
local *usage = sub {
|
||||
return( [ $_[0],
|
||||
"rmvm -h|--help",
|
||||
"rmvm -v|--version",
|
||||
"rmvm [-V|--verbose] noderange",
|
||||
" -h writes usage information to standard output",
|
||||
" -v displays command version",
|
||||
" -V verbose output" ]);
|
||||
my $usage_string=xCAT::Usage->getUsage($cmd);
|
||||
return( [ $_[0], $usage_string]);
|
||||
};
|
||||
#############################################
|
||||
# Process command-line arguments
|
||||
@ -260,22 +215,10 @@ sub rmvm_parse_args {
|
||||
$Getopt::Long::ignorecase = 0;
|
||||
Getopt::Long::Configure( "bundling" );
|
||||
|
||||
if ( !GetOptions( \%opt, qw(h|help V|Verbose v|version) )) {
|
||||
if ( !GetOptions( \%opt, qw(V|Verbose) )) {
|
||||
return( usage() );
|
||||
}
|
||||
####################################
|
||||
# Option -h for Help
|
||||
####################################
|
||||
if ( exists( $opt{h} )) {
|
||||
return( usage() );
|
||||
}
|
||||
####################################
|
||||
# Option -v for version
|
||||
####################################
|
||||
if ( exists( $opt{v} )) {
|
||||
return( \@VERSION );
|
||||
}
|
||||
####################################
|
||||
# Check for "-" with no option
|
||||
####################################
|
||||
if ( grep(/^-$/, @ARGV )) {
|
||||
@ -304,19 +247,13 @@ sub lsvm_parse_args {
|
||||
my %opt = ();
|
||||
my $cmd = $request->{command};
|
||||
my $args = $request->{arg};
|
||||
my @VERSION = qw( 2.0 );
|
||||
|
||||
#############################################
|
||||
# Responds with usage statement
|
||||
#############################################
|
||||
local *usage = sub {
|
||||
return( [ $_[0],
|
||||
"lsvm -h|--help",
|
||||
"lsvm -v|--version",
|
||||
"lsvm [-V|--verbose] noderange",
|
||||
" -h writes usage information to standard output",
|
||||
" -v displays command version",
|
||||
" -V verbose output" ]);
|
||||
my $usage_string=xCAT::Usage->getUsage($cmd);
|
||||
return( [ $_[0], $usage_string]);
|
||||
};
|
||||
#############################################
|
||||
# Process command-line arguments
|
||||
@ -334,22 +271,10 @@ sub lsvm_parse_args {
|
||||
$Getopt::Long::ignorecase = 0;
|
||||
Getopt::Long::Configure( "bundling" );
|
||||
|
||||
if ( !GetOptions( \%opt, qw(h|help V|Verbose v|version) )) {
|
||||
if ( !GetOptions( \%opt, qw(V|Verbose) )) {
|
||||
return( usage() );
|
||||
}
|
||||
####################################
|
||||
# Option -h for Help
|
||||
####################################
|
||||
if ( exists( $opt{h} )) {
|
||||
return( usage() );
|
||||
}
|
||||
####################################
|
||||
# Option -v for version
|
||||
####################################
|
||||
if ( exists( $opt{v} )) {
|
||||
return( \@VERSION );
|
||||
}
|
||||
####################################
|
||||
# Check for "-" with no option
|
||||
####################################
|
||||
if ( grep(/^-$/, @ARGV )) {
|
||||
|
@ -2,6 +2,7 @@
|
||||
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
|
||||
|
||||
package xCAT::Usage;
|
||||
use Getopt::Long;
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
=head1 xCAT::Usage
|
||||
@ -14,25 +15,101 @@ package xCAT::Usage;
|
||||
|
||||
|
||||
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]",
|
||||
"rnetboot" =>
|
||||
"Usage: rnetboot <noderange> [-V|--verbose]
|
||||
rnetboot [-h|--help|-v|--version]",
|
||||
"rpower" =>
|
||||
"Usage: rpower <noderange> [--nodeps][on|off|reset|stat|state|boot|of|cycle] [-V|--verbose]
|
||||
rpower [-h|--help|-v|--version]",
|
||||
"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:
|
||||
rinv <noderange> [bus|config]",
|
||||
"rsetboot" =>
|
||||
"Usage: rsetboot <noderange> [net|hd|cd|def|stat] [-V|--verbose]
|
||||
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]",
|
||||
"rspconfig" =>
|
||||
"Usage:
|
||||
Common:
|
||||
rspconfig <noderange> [snmpdest|alert|community]
|
||||
rspconfig <noderange> [snmpdest|alert|community] [-V|--verbose]
|
||||
rspconfig <noderange> [snmpdest=<dest ip address>|alert=<on|off|en|dis|enable|disable>|community=<string>]
|
||||
rspconfig [-h|--help|-v|--version]
|
||||
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>]"
|
||||
rspconfig <noderange> [shcfg=<enable|disable>|snmpcfg=<enable|disable>]
|
||||
PPC specific:
|
||||
rspconfig <noderange> autopower [enable|disable]|
|
||||
decfg [{enable|disable} policy,...]|
|
||||
spdump|
|
||||
date [mm-dd-yyyy]|
|
||||
time [hh:mm:ss]|
|
||||
memdecfg [{configure|deconfigure} unit=id (unit|bank)=all|id,...]|
|
||||
sysdump|
|
||||
procdecfg [{configure|deconfigure} unit=id all|id,...]|
|
||||
iocap [enable|disable]",
|
||||
"getmacs" =>
|
||||
"Usage:
|
||||
Common:
|
||||
getmacs <noderange> [-V|--verbose]
|
||||
getmacs [-h|--help|-v|--version]
|
||||
PPC specific:
|
||||
getmacs <noderange> [-c][-w][-S server -G gateway -C client]",
|
||||
"mkvm" =>
|
||||
"Usage: mkvm singlenode -i id -n name [-V|--verbose]
|
||||
mkvm src_fsp -c dest_fsp [-V|--verbose]
|
||||
mkvm [-h|--help|-v|--version]",
|
||||
"lsvm" =>
|
||||
"Usage: lsvm <noderange> [-V|--verbose]
|
||||
lsvm [-h|--help|-v|--version]",
|
||||
"chvm" =>
|
||||
"Usage: chvm <noderange> [-V|--verbose]
|
||||
chvm [-h|--help|-v|--version]",
|
||||
"rmvm" =>
|
||||
"Usage: rmvm <noderange> [-V|--verbose]
|
||||
rmvm [-h|--help|-v|--version]"
|
||||
);
|
||||
|
||||
my %version = (
|
||||
"rnetboot" => "Version 2.0",
|
||||
"rpower" => "Version 2.0",
|
||||
"rbeacon" => "Version 2.0",
|
||||
"rvitals" => "Version 2.0",
|
||||
"reventlog" => "Version 2.0",
|
||||
"rinv" => "Version 2.0",
|
||||
"rsetboot" => "Version 2.0",
|
||||
"rbootseq" => "Version 2.0",
|
||||
"rscan" => "Version 2.0",
|
||||
"rspconfig" => "Version 2.0",
|
||||
"getmacs" => "Version 2.0",
|
||||
"mkvm" => "Version 2.0",
|
||||
"lsvm" => "Version 2.0",
|
||||
"chvm" => "Version 2.0",
|
||||
"rmvm" => "Version 2.0"
|
||||
);
|
||||
|
||||
#--------------------------------------------------------------------------------
|
||||
@ -49,3 +126,57 @@ sub getUsage {
|
||||
if (exists($usage{$command})) { return $usage{$command};}
|
||||
else { return "Usage for command $command cannot be found\n"; }
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------------------------
|
||||
=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";
|
||||
|
||||
$Getopt::Long::ignorecase=0;
|
||||
$Getopt::Long::pass_through=1;
|
||||
|
||||
# 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 "";
|
||||
}
|
||||
|
@ -24,16 +24,16 @@ use Getopt::Long;
|
||||
sub handled_commands {
|
||||
return {
|
||||
findme => 'blade',
|
||||
getmacs => 'nodehm:getmacs,mgt',
|
||||
getmacs => 'nodehm:getmac,mgt',
|
||||
rscan => 'nodehm:mgt',
|
||||
rpower => 'nodehm:power,mgt',
|
||||
rvitals => 'nodehm:vitals,mgt',
|
||||
rinv => 'nodehm:inv,mgt',
|
||||
rbeacon => 'nodehm:beacon,mgt',
|
||||
rvitals => 'nodehm:mgt',
|
||||
rinv => 'nodehm:mgt',
|
||||
rbeacon => 'nodehm:mgt',
|
||||
rspreset => 'nodehm:mgt',
|
||||
rspconfig => 'nodehm:mgt',
|
||||
rbootseq => 'nodehm:bootseq,mgt',
|
||||
reventlog => 'nodehm:eventlog,mgt',
|
||||
rbootseq => 'nodehm:mgt',
|
||||
reventlog => 'nodehm:mgt',
|
||||
switchblade => 'nodehm:mgt',
|
||||
};
|
||||
}
|
||||
@ -698,27 +698,16 @@ sub rscan {
|
||||
Getopt::Long::Configure("bundling");
|
||||
|
||||
local *usage = sub {
|
||||
return( join('',($_[0],
|
||||
"rscan -h|--help\n",
|
||||
"rscan -v|--version\n",
|
||||
"rscan [-V|--verbose] noderange [-w][-x|-z]\n",
|
||||
" -h writes usage information to standard output\n",
|
||||
" -v displays command version\n",
|
||||
" -V verbose output\n",
|
||||
" -w writes output to xCat database\n",
|
||||
" -x xml formatted output\n",
|
||||
" -z stanza formatted output.\n")));
|
||||
my $usage_string=xCAT::Usage->getUsage("rscan");
|
||||
return( join('',($_[0],$usage_string)));
|
||||
};
|
||||
|
||||
if ( !GetOptions(\%opt,qw(h|help V|Verbose v|version w x z))){
|
||||
if ( !GetOptions(\%opt,qw(V|Verbose w x z))){
|
||||
return(1,usage());
|
||||
}
|
||||
if (@ARGV) {
|
||||
return(1,usage("Invalid argument: @ARGV\n"));
|
||||
}
|
||||
if (exists($opt{h})) {
|
||||
return(1,usage());
|
||||
}
|
||||
if (exists($opt{x}) and exists($opt{z})) {
|
||||
return(1,usage("-x and -z are mutually exclusive\n"));
|
||||
}
|
||||
@ -1212,20 +1201,29 @@ sub process_request {
|
||||
unless ($command) {
|
||||
return; #Empty request
|
||||
}
|
||||
unless ($noderange or $command eq "findme") {
|
||||
my $usage_string=xCAT::Usage->getUsage($command);
|
||||
if ($usage_string) {
|
||||
$callback->({data=>[$usage_string]});
|
||||
$request = {};
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (ref($request->{arg})) {
|
||||
@exargs = @{$request->{arg}};
|
||||
} else {
|
||||
@exargs = ($request->{arg});
|
||||
}
|
||||
|
||||
if ($command ne "findme") {
|
||||
my $usage_string=xCAT::Usage->parseCommand($command, @exargs);
|
||||
if ($usage_string) {
|
||||
$callback->({data=>$usage_string});
|
||||
$request = {};
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$noderange) {
|
||||
$usage_string=xCAT::Usage->getUsage($command);
|
||||
$callback->({data=>$usage_string});
|
||||
$request = {};
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ($command eq "rpower" and grep(/^on|off|boot|reset|cycle$/, @exargs)) {
|
||||
if (!grep /^--nodeps$/, @exargs) {
|
||||
# handles 1 level of dependencies only
|
||||
|
@ -23,11 +23,11 @@ sub handled_commands {
|
||||
return {
|
||||
rpower => 'nodehm:power,mgt',
|
||||
rspconfig => 'nodehm:mgt',
|
||||
rvitals => 'nodehm:vitals,mgt',
|
||||
rinv => 'nodehm:inv,mgt',
|
||||
rvitals => 'nodehm:mgt',
|
||||
rinv => 'nodehm:mgt',
|
||||
rsetboot => 'nodehm:mgt',
|
||||
rbeacon => 'nodehm:beacon,mgt',
|
||||
reventlog => 'nodehm:eventlog,mgt',
|
||||
rbeacon => 'nodehm:mgt',
|
||||
reventlog => 'nodehm:mgt',
|
||||
}
|
||||
}
|
||||
|
||||
@ -4535,9 +4535,34 @@ sub loadsdrcache {
|
||||
|
||||
sub preprocess_request {
|
||||
my $request = shift;
|
||||
my $callback=shift;
|
||||
my @requests;
|
||||
my %servicenodehash;
|
||||
my %noservicenodehash;
|
||||
|
||||
my $noderange = $request->{node}; #Should be arrayref
|
||||
my $command = $request->{command}->[0];
|
||||
my $extrargs = $request->{arg};
|
||||
my @exargs=($request->{arg});
|
||||
if (ref($extrargs)) {
|
||||
@exargs=@$extrargs;
|
||||
}
|
||||
|
||||
my $usage_string=xCAT::Usage->parseCommand($command, @exargs);
|
||||
if ($usage_string) {
|
||||
$callback->({data=>$usage_string});
|
||||
$request = {};
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$noderange) {
|
||||
$usage_string=xCAT::Usage->getUsage($command);
|
||||
$callback->({data=>$usage_string});
|
||||
$request = {};
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
my $nrtab = xCAT::Table->new('noderes');
|
||||
foreach my $node (@{$request->{node}}) {
|
||||
my $tent = $nrtab->getNodeAttribs($node,['servicenode']);
|
||||
@ -4563,28 +4588,18 @@ sub preprocess_request {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
sub process_request {
|
||||
my $request = shift;
|
||||
my $callback = shift;
|
||||
my $noderange = $request->{node}; #Should be arrayref
|
||||
my $command = $request->{command}->[0];
|
||||
my $extrargs = $request->{arg};
|
||||
my @exargs=($request->{arg});
|
||||
unless ($noderange) {
|
||||
my $usage_string=xCAT::Usage->getUsage($command);
|
||||
if ($usage_string) {
|
||||
$callback->({data=>[$usage_string]});
|
||||
$request = {};
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (ref($extrargs)) {
|
||||
@exargs=@$extrargs;
|
||||
}
|
||||
my $request = shift;
|
||||
my $callback = shift;
|
||||
my $noderange = $request->{node}; #Should be arrayref
|
||||
my $command = $request->{command}->[0];
|
||||
my $extrargs = $request->{arg};
|
||||
my @exargs=($request->{arg});
|
||||
if (ref($extrargs)) {
|
||||
@exargs=@$extrargs;
|
||||
}
|
||||
|
||||
my $ipmiuser = 'USERID';
|
||||
my $ipmipass = 'PASSW0RD';
|
||||
my $ipmitrys = 3;
|
||||
|
Loading…
x
Reference in New Issue
Block a user