diff --git a/docs/source/guides/admin-guides/references/man1/rspconfig.1.rst b/docs/source/guides/admin-guides/references/man1/rspconfig.1.rst index c9278d2f7..f8d9e8b85 100644 --- a/docs/source/guides/admin-guides/references/man1/rspconfig.1.rst +++ b/docs/source/guides/admin-guides/references/man1/rspconfig.1.rst @@ -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. diff --git a/perl-xCAT/xCAT/Usage.pm b/perl-xCAT/xCAT/Usage.pm index d28130199..f5b8eaaff 100755 --- a/perl-xCAT/xCAT/Usage.pm +++ b/perl-xCAT/xCAT/Usage.pm @@ -134,21 +134,28 @@ my %usage = ( "rscan" => "Usage: rscan [-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 [ipsrc|ip|netmask|gateway|hostname|vlan] + rspconfig dump [-l|--list] [-g|--generate] [-c|--clear {|all}] [-d|--download {|all}] +", + "rspconfig.begin" => + "BMC/MPA Common: rspconfig [snmpdest|alert|community] [-V|--verbose] rspconfig [snmpdest=|alert=|community=] BMC specific: rspconfig [ip|netmask|gateway|backupgateway|garp|vlan] rspconfig [garp=] rspconfig [userid= username= password=] - OpenBMC specific: - rspconfig [ipsrc|ip|netmask|gateway|hostname|vlan] - rspconfig dump [-l|--list] [-g|--generate] [-c|--clear {|all}] [-d|--download {|all}] - iDataplex specific: + ", + "rspconfig.end" => + "iDataplex specific: rspconfig [thermprofile] rspconfig [thermprofile=] 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", diff --git a/xCAT-client/pods/man1/rspconfig.1.pod b/xCAT-client/pods/man1/rspconfig.1.pod index 9088188f7..2f72806f2 100644 --- a/xCAT-client/pods/man1/rspconfig.1.pod +++ b/xCAT-client/pods/man1/rspconfig.1.pod @@ -28,6 +28,18 @@ B I {B|B|B|B|B|B I B [B<-l>|B<--list>] [B<-g>|B<--generate>] [B<-c>|B<--clear> {I | B}] [B<-d>|B<--download> {I | B}] +B I B + +B I B + +B I B + +B I B + +B I B + +B I B + =head2 MPA specific: B I {B|B|B|B|B|B|B|B|B} @@ -326,6 +338,18 @@ Select whether each memory bank should be enabled or disabled. State changes tak The subnet mask. +=item B + +Display or control BMC Power Restore Policy attribute setting. + +=item B + +Display or control BMC Power Supply Redundancy attribute setting. + +=item B + +Display or control BMC Auto Reboot attribute setting. + =item B Manage OpenBMC system dumps. If no sub-option is provided, will generate, wait, and download the dump. diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index 63c9d8983..746de86a7 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -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 # rspconfig =0 # rspconfig =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 $subcommand" . "\n"; + + if ($type eq "boolean") { + $usage_string .= " $command $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 $subcommand={" . $attr_values . "}". "\n"; + } + } + } + return $usage_string; +} 1;