From e70ed0f3f0951b4474a3ffb5d9b2a97b869432ac Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Thu, 25 Jan 2018 09:17:41 -0500 Subject: [PATCH 1/5] Handle some warning messages based on this code - isn't numeric in numeric ne (!=) - Scalar value @attr_value[-1] better written as $attr_value[-1] --- xCAT-server/lib/xcat/plugins/openbmc.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index 87a979061..66ef88298 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -1171,7 +1171,7 @@ sub parse_args { my $all_subcommand = ""; foreach $subcommand (@ARGV) { $::RSPCONFIG_CONFIGURED_API_KEY = &is_valid_config_api($subcommand, $callback); - if ($::RSPCONFIG_CONFIGURED_API_KEY != -1) { + if ($::RSPCONFIG_CONFIGURED_API_KEY ne -1) { # subcommand defined in the configured API hash, return from here, the RSPCONFIG_CONFIGURED_API_KEY is the key into the hash return; } @@ -1574,7 +1574,7 @@ sub parse_command_status { my @options = (); my $num_subcommand = @$subcommands; #Setup chain to process the configured command - if ($::RSPCONFIG_CONFIGURED_API_KEY != -1) { + if ($::RSPCONFIG_CONFIGURED_API_KEY ne -1) { $subcommand = $$subcommands[0]; # Check if setting or quering if ($subcommand =~ /^(\w+)=(.*)/) { @@ -3609,7 +3609,7 @@ sub rspconfig_api_config_response { # For example "xyz.openbmc_project.Control.Power.RestorePolicy.Policy.Restore" # will be displayed as "Restore" my @attr_value = split('\.', $value); - my $last_component = @attr_value[-1]; + my $last_component = $attr_value[-1]; my @valid_values = values $api_config_info{$::RSPCONFIG_CONFIGURED_API_KEY}{attr_value}; if ($value) { if ($value ~~ @valid_values) { From e2d49ce2b273069df2b9277f650128fbcff5a9e6 Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Thu, 25 Jan 2018 13:12:21 -0500 Subject: [PATCH 2/5] Add data structure to support get/set BootMode of the BMC --- xCAT-server/lib/xcat/plugins/openbmc.pm | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index 66ef88298..18d4cc796 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -596,6 +596,20 @@ my %api_config_info = ( type => "boolean", subcommand => "autoreboot", }, + RSPCONFIG_BOOT_MODE => { + command => "rspconfig", + url => "/control/host0/boot", + attr_url => "BootMode", + display_name => "BMC BootMode", + instruct_msg => "", + type => "attribute", + subcommand => "bootmode", + attr_value => { + regular => "xyz.openbmc_project.Control.Boot.Mode.Modes.Regular", + safe => "xyz.openbmc_project.Control.Boot.Mode.Modes.Safe", + setup => "xyz.openbmc_project.Control.Boot.Mode.Modes.Setup", + }, + }, RSPCONFIG_POWERSUPPLY_REDUNDANCY => { command => "rspconfig", url => "/sensors/chassis/PowerSupplyRedundancy", From 0a51ba60fdda3e64549b6ddbf83bb6a712771b56 Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Thu, 25 Jan 2018 13:26:51 -0500 Subject: [PATCH 3/5] Reduce duplicate print statement, only print when value does not match --- xCAT-server/lib/xcat/plugins/openbmc.pm | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index 18d4cc796..7ef7e5947 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -3626,13 +3626,12 @@ sub rspconfig_api_config_response { my $last_component = $attr_value[-1]; my @valid_values = values $api_config_info{$::RSPCONFIG_CONFIGURED_API_KEY}{attr_value}; if ($value) { - if ($value ~~ @valid_values) { - # Received one of the expected values (defined in attr_value hash for this command - xCAT::SvrUtils::sendmsg($api_config_info{$::RSPCONFIG_CONFIGURED_API_KEY}{display_name} . " : $last_component", $callback, $node); - } else { + xCAT::SvrUtils::sendmsg($api_config_info{$::RSPCONFIG_CONFIGURED_API_KEY}{display_name} . " : $last_component", $callback, $node); + my $found = grep(/$value/, @valid_values); + if ($found eq 0) { # Received data value not expected - xCAT::SvrUtils::sendmsg($api_config_info{$::RSPCONFIG_CONFIGURED_API_KEY}{display_name} . " : $last_component", $callback, $node); - xCAT::SvrUtils::sendmsg("Warning: Unexpected value set. Valid values: " . join(",", @valid_values), $callback, $node); + xCAT::SvrUtils::sendmsg("WARNING: Unexpected value set: $value", $callback, $node); + xCAT::SvrUtils::sendmsg("WARNING: Valid values: " . join(",", @valid_values), $callback, $node); } } else { From 84ea2dd458583c5a8f37564d34bbbf1103e995da Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Thu, 25 Jan 2018 13:56:21 -0500 Subject: [PATCH 4/5] PowerSupplyRedundancy does not take effect in bmcreboot, but on IPL --- xCAT-server/lib/xcat/plugins/openbmc.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index 7ef7e5947..3a6a3514c 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -616,7 +616,7 @@ my %api_config_info = ( attr_url => "/action/setValue", query_url => "/action/getValue", display_name => "BMC PowerSupplyRedundancy", - instruct_msg => "bmc reboot is required", + instruct_msg => "", type => "action_attribute", subcommand => "powersupplyredundancy", attr_value => { From dc5e5fb3e2020e06a5002a0da208353e0dd2be53 Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Thu, 25 Jan 2018 14:16:59 -0500 Subject: [PATCH 5/5] Adding man page for rspconfig to add boot mode --- .../admin-guides/references/man1/rspconfig.1.rst | 10 ++++++++++ xCAT-client/pods/man1/rspconfig.1.pod | 8 ++++++++ 2 files changed, 18 insertions(+) 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 f8d9e8b85..118a39de1 100644 --- a/docs/source/guides/admin-guides/references/man1/rspconfig.1.rst +++ b/docs/source/guides/admin-guides/references/man1/rspconfig.1.rst @@ -63,6 +63,10 @@ OpenBMC specific: \ **rspconfig**\ \ *noderange*\ \ **autoreboot={0|1}**\ +\ **rspconfig**\ \ *noderange*\ \ **bootmode**\ + +\ **rspconfig**\ \ *noderange*\ \ **bootmode={safe|regular|setup}**\ + MPA specific: ============= @@ -462,6 +466,12 @@ OPTIONS +\ **bootmode**\ + + Display or control BMC Boot Mode attribute setting. + + + \ **dump**\ Manage OpenBMC system dumps. If no sub-option is provided, will generate, wait, and download the dump. diff --git a/xCAT-client/pods/man1/rspconfig.1.pod b/xCAT-client/pods/man1/rspconfig.1.pod index 2f72806f2..c75d8dae7 100644 --- a/xCAT-client/pods/man1/rspconfig.1.pod +++ b/xCAT-client/pods/man1/rspconfig.1.pod @@ -40,6 +40,10 @@ 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} @@ -350,6 +354,10 @@ Display or control BMC Power Supply Redundancy attribute setting. Display or control BMC Auto Reboot attribute setting. +=item B + +Display or control BMC Boot Mode attribute setting. + =item B Manage OpenBMC system dumps. If no sub-option is provided, will generate, wait, and download the dump.