mirror of
https://github.com/xcat2/xcat-core.git
synced 2025-05-21 19:22:05 +00:00
Merge pull request #4644 from gurevichmark/openbmc_rspconfig_gen_usage
Build usage string based on command definitions
This commit is contained in:
commit
c8ace50d21
@ -51,6 +51,18 @@ OpenBMC specific:
|
||||
|
||||
\ **rspconfig**\ \ *noderange*\ \ **dump**\ [\ **-l | -**\ **-list**\ ] [\ **-g | -**\ **-generate**\ ] [\ **-c | -**\ **-clear**\ {\ *id*\ | \ **all**\ }] [\ **-d | -**\ **-download**\ {\ *id*\ | \ **all**\ }]
|
||||
|
||||
\ **rspconfig**\ \ *noderange*\ \ **powerrestorepolicy**\
|
||||
|
||||
\ **rspconfig**\ \ *noderange*\ \ **powerrestorepolicy={always_on|restore|always_off}**\
|
||||
|
||||
\ **rspconfig**\ \ *noderange*\ \ **powersupplyredundancy**\
|
||||
|
||||
\ **rspconfig**\ \ *noderange*\ \ **powersupplyredundancy={disabled|enabled}**\
|
||||
|
||||
\ **rspconfig**\ \ *noderange*\ \ **autoreboot**\
|
||||
|
||||
\ **rspconfig**\ \ *noderange*\ \ **autoreboot={0|1}**\
|
||||
|
||||
|
||||
MPA specific:
|
||||
=============
|
||||
@ -432,6 +444,24 @@ OPTIONS
|
||||
|
||||
|
||||
|
||||
\ **powerrestorepolicy**\
|
||||
|
||||
Display or control BMC Power Restore Policy attribute setting.
|
||||
|
||||
|
||||
|
||||
\ **powersupplyredundancy**\
|
||||
|
||||
Display or control BMC Power Supply Redundancy attribute setting.
|
||||
|
||||
|
||||
|
||||
\ **autoreboot**\
|
||||
|
||||
Display or control BMC Auto Reboot attribute setting.
|
||||
|
||||
|
||||
|
||||
\ **dump**\
|
||||
|
||||
Manage OpenBMC system dumps. If no sub-option is provided, will generate, wait, and download the dump.
|
||||
|
@ -134,21 +134,28 @@ my %usage = (
|
||||
"rscan" =>
|
||||
"Usage: rscan <noderange> [-u][-w][-x|-z] [-V|--verbose]
|
||||
rscan [-h|--help|-v|--version]",
|
||||
"rspconfig" =>
|
||||
"rspconfig" => "",
|
||||
"rspconfig.common" =>
|
||||
"Usage:
|
||||
Common:
|
||||
rspconfig [-h|--help|-v|--version|-V|--verbose]
|
||||
BMC/MPA Common:
|
||||
",
|
||||
"rspconfig.openbmc" =>
|
||||
"OpenBMC specific:
|
||||
rspconfig <noderange> [ipsrc|ip|netmask|gateway|hostname|vlan]
|
||||
rspconfig <noderange> dump [-l|--list] [-g|--generate] [-c|--clear {<id>|all}] [-d|--download {<id>|all}]
|
||||
",
|
||||
"rspconfig.begin" =>
|
||||
"BMC/MPA Common:
|
||||
rspconfig <noderange> [snmpdest|alert|community] [-V|--verbose]
|
||||
rspconfig <noderange> [snmpdest=<dest ip address>|alert=<on|off|en|dis|enable|disable>|community=<string>]
|
||||
BMC specific:
|
||||
rspconfig <noderange> [ip|netmask|gateway|backupgateway|garp|vlan]
|
||||
rspconfig <noderange> [garp=<number of 1/2 second>]
|
||||
rspconfig <noderange> [userid=<userid> username=<username> password=<password>]
|
||||
OpenBMC specific:
|
||||
rspconfig <noderange> [ipsrc|ip|netmask|gateway|hostname|vlan]
|
||||
rspconfig <noderange> dump [-l|--list] [-g|--generate] [-c|--clear {<id>|all}] [-d|--download {<id>|all}]
|
||||
iDataplex specific:
|
||||
",
|
||||
"rspconfig.end" =>
|
||||
"iDataplex specific:
|
||||
rspconfig <noderange> [thermprofile]
|
||||
rspconfig <noderange> [thermprofile=<two digit number from chassis>]
|
||||
MPA specific:
|
||||
@ -528,6 +535,17 @@ Options:
|
||||
"Usage:
|
||||
clonevm noderange [-t createmaster -f | -b basemaster -d | -h]",
|
||||
);
|
||||
|
||||
# Rebuild full command usage from its components
|
||||
$usage{"rspconfig"} = $usage{"rspconfig.common"} .
|
||||
$usage{"rspconfig.begin"} .
|
||||
$usage{"rspconfig.openbmc"} .
|
||||
" " .
|
||||
$usage{"rspconfig.end"};
|
||||
|
||||
$usage{"rspconfig.openbmc"} = $usage{"rspconfig.common"} .
|
||||
$usage{"rspconfig.openbmc"};
|
||||
|
||||
my $vers = xCAT::Utils->Version();
|
||||
my %version = (
|
||||
"rnetboot" => "$vers",
|
||||
|
@ -28,6 +28,18 @@ B<rspconfig> I<noderange> {B<ipsrc>|B<ip>|B<netmask>|B<gateway>|B<hostname>|B<vl
|
||||
|
||||
B<rspconfig> I<noderange> B<dump> [B<-l>|B<--list>] [B<-g>|B<--generate>] [B<-c>|B<--clear> {I<id> | B<all>}] [B<-d>|B<--download> {I<id> | B<all>}]
|
||||
|
||||
B<rspconfig> I<noderange> B<powerrestorepolicy>
|
||||
|
||||
B<rspconfig> I<noderange> B<powerrestorepolicy={always_on|restore|always_off}>
|
||||
|
||||
B<rspconfig> I<noderange> B<powersupplyredundancy>
|
||||
|
||||
B<rspconfig> I<noderange> B<powersupplyredundancy={disabled|enabled}>
|
||||
|
||||
B<rspconfig> I<noderange> B<autoreboot>
|
||||
|
||||
B<rspconfig> I<noderange> B<autoreboot={0|1}>
|
||||
|
||||
=head2 MPA specific:
|
||||
|
||||
B<rspconfig> I<noderange> {B<sshcfg>|B<snmpcfg>|B<pd1>|B<pd2>|B<network>|B<swnet>|B<ntp>|B<textid>|B<frame>}
|
||||
@ -326,6 +338,18 @@ Select whether each memory bank should be enabled or disabled. State changes tak
|
||||
|
||||
The subnet mask.
|
||||
|
||||
=item B<powerrestorepolicy>
|
||||
|
||||
Display or control BMC Power Restore Policy attribute setting.
|
||||
|
||||
=item B<powersupplyredundancy>
|
||||
|
||||
Display or control BMC Power Supply Redundancy attribute setting.
|
||||
|
||||
=item B<autoreboot>
|
||||
|
||||
Display or control BMC Auto Reboot attribute setting.
|
||||
|
||||
=item B<dump>
|
||||
|
||||
Manage OpenBMC system dumps. If no sub-option is provided, will generate, wait, and download the dump.
|
||||
|
@ -563,7 +563,13 @@ my %status_info = (
|
||||
},
|
||||
);
|
||||
|
||||
# Setup configured subcommand. Currently only rspconfig is supported and only for boolean commands.
|
||||
# Setup configured subcommand.
|
||||
# Currently only rspconfig is supported and only for boolean commands or attribute settings.
|
||||
#
|
||||
# Usage can also be autogenerated for these commands. However, changes to the xCAT::Usage->usage
|
||||
# need to be made to split a single string into its components. Look at "rspconfig" usage as an
|
||||
# example.
|
||||
#
|
||||
# For example: rspconfig <subcommand>
|
||||
# rspconfig <subcommand>=0
|
||||
# rspconfig <subcommand>=1
|
||||
@ -587,8 +593,8 @@ my %api_config_info = (
|
||||
type => "attribute",
|
||||
subcommand => "powersupplyredundancy",
|
||||
attr_value => {
|
||||
enabled => "Enabled",
|
||||
disabled => "Disabled",
|
||||
enabled => "Enabled",
|
||||
},
|
||||
},
|
||||
RSPCONFIG_POWERRESTORE_POLICY => {
|
||||
@ -727,11 +733,24 @@ sub preprocess_request {
|
||||
my $extrargs = $request->{arg};
|
||||
my @exargs = ($request->{arg});
|
||||
my @requests;
|
||||
my $usage_string;
|
||||
$::cwd = $request->{cwd}->[0];
|
||||
if (ref($extrargs)) {
|
||||
@exargs = @$extrargs;
|
||||
}
|
||||
my $usage_string = xCAT::Usage->parseCommand($command, @exargs);
|
||||
# Request usage for openbmc sections only
|
||||
$usage_string = xCAT::Usage->parseCommand($command . ".openbmc", @exargs);
|
||||
|
||||
if ($usage_string =~ /cannot be found/) {
|
||||
# Could not find usage for openbmc section, try getting usage for all sections
|
||||
$usage_string = xCAT::Usage->parseCommand($command, @exargs);
|
||||
}
|
||||
else {
|
||||
# Usage for openbmc section was extracted, append autogenerated usage for
|
||||
# configured commands
|
||||
$usage_string .= &build_config_api_usage($callback, $command);
|
||||
}
|
||||
|
||||
if ($usage_string) {
|
||||
$callback->({ data => [$usage_string] });
|
||||
$request = {};
|
||||
@ -4478,7 +4497,7 @@ sub rflash_upload {
|
||||
|
||||
=head3 is_valid_config_api
|
||||
|
||||
Verify passed in subcomaand is defined in the api_config_info
|
||||
Verify passed in subcommand is defined in the api_config_info
|
||||
Input:
|
||||
$subcommand: subcommand to verify
|
||||
$callback: callback for message display
|
||||
@ -4506,4 +4525,55 @@ sub is_valid_config_api {
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------
|
||||
|
||||
=head3 build_config_api_usage
|
||||
|
||||
Build usage string from the api_config_info
|
||||
Input:
|
||||
$callback: callback for message display
|
||||
$requested_command: command for the usage generation
|
||||
|
||||
Output:
|
||||
returns usage string
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------
|
||||
sub build_config_api_usage {
|
||||
my $callback = shift;
|
||||
my $requested_command = shift;
|
||||
my $command = "";
|
||||
my $subcommand = "";
|
||||
my $type = "";
|
||||
my $usage_string = "";
|
||||
my $attr_values = "";
|
||||
|
||||
foreach my $config_subcommand (keys %api_config_info) {
|
||||
$command = "";
|
||||
$subcommand = "";
|
||||
$type = "";
|
||||
$attr_values = "";
|
||||
if ($api_config_info{$config_subcommand}{command} eq $requested_command) {
|
||||
$command = $api_config_info{$config_subcommand}{command};
|
||||
$subcommand = $api_config_info{$config_subcommand}{subcommand};
|
||||
$type = $api_config_info{$config_subcommand}{type};
|
||||
|
||||
$usage_string .= " $command <noderange> $subcommand" . "\n";
|
||||
|
||||
if ($type eq "boolean") {
|
||||
$usage_string .= " $command <noderange> $subcommand={0|1}" . "\n";
|
||||
}
|
||||
if ($type eq "attribute") {
|
||||
foreach my $attribute_value (keys %{ $api_config_info{$config_subcommand}{attr_value} }) {
|
||||
$attr_values .= $attribute_value . "|"
|
||||
}
|
||||
chop $attr_values;
|
||||
$usage_string .= " $command <noderange> $subcommand={" . $attr_values . "}". "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
return $usage_string;
|
||||
}
|
||||
1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user