Fix for IndicatorLED if blinking object not found
Currently some systems doesn't have enclosure_identity_blink
object for supporting blinking feature which are leading
to systems/system uri failing with 500 error.
Corrected the code to make enclosure_identity_blink object
get/set as optional.
Tested:
Tested IndicatorLED for all 3 cases and it works fine.
Simulated case to not have enclosure_identity_blink object
and teste all 3 InidicatorLED value set and get.
Ran the redfish validator with success results.
Change-Id: I310fb71269aae6d36ea025556ad3b1d87b0acb39
Signed-off-by: AppaRao Puli <apparao.puli@linux.intel.com>
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/redfish-core/lib/systems.hpp b/redfish-core/lib/systems.hpp
index 88590ee..4299227 100644
--- a/redfish-core/lib/systems.hpp
+++ b/redfish-core/lib/systems.hpp
@@ -566,51 +566,46 @@
crow::connections::systemBus->async_method_call(
[aResp](const boost::system::error_code ec,
const std::variant<bool> asserted) {
- if (ec)
+ // Some systems may not have enclosure_identify_blink object so
+ // proceed to get enclosure_identify state.
+ if (!ec)
{
- BMCWEB_LOG_DEBUG << "DBUS response error " << ec;
- messages::internalError(aResp->res);
- return;
- }
-
- const bool *blinking = std::get_if<bool>(&asserted);
- if (!blinking)
- {
- BMCWEB_LOG_DEBUG << "Get identity blinking LED failed";
- messages::internalError(aResp->res);
- return;
- }
- // Blinking ON, no need to check enclosure_identify assert.
- if (*blinking)
- {
- aResp->res.jsonValue["IndicatorLED"] = "Blinking";
- return;
+ const bool *blinking = std::get_if<bool>(&asserted);
+ if (!blinking)
+ {
+ BMCWEB_LOG_DEBUG << "Get identity blinking LED failed";
+ messages::internalError(aResp->res);
+ return;
+ }
+ // Blinking ON, no need to check enclosure_identify assert.
+ if (*blinking)
+ {
+ aResp->res.jsonValue["IndicatorLED"] = "Blinking";
+ return;
+ }
}
crow::connections::systemBus->async_method_call(
[aResp](const boost::system::error_code ec,
const std::variant<bool> asserted) {
- if (ec)
+ if (!ec)
{
- BMCWEB_LOG_DEBUG << "DBUS response error " << ec;
- messages::internalError(aResp->res);
- return;
- }
+ const bool *ledOn = std::get_if<bool>(&asserted);
+ if (!ledOn)
+ {
+ BMCWEB_LOG_DEBUG
+ << "Get enclosure identity led failed";
+ messages::internalError(aResp->res);
+ return;
+ }
- const bool *ledOn = std::get_if<bool>(&asserted);
- if (!ledOn)
- {
- BMCWEB_LOG_DEBUG << "Get enclosure identity led failed";
- messages::internalError(aResp->res);
- return;
- }
-
- if (*ledOn)
- {
- aResp->res.jsonValue["IndicatorLED"] = "Lit";
- }
- else
- {
- aResp->res.jsonValue["IndicatorLED"] = "Off";
+ if (*ledOn)
+ {
+ aResp->res.jsonValue["IndicatorLED"] = "Lit";
+ }
+ else
+ {
+ aResp->res.jsonValue["IndicatorLED"] = "Off";
+ }
}
return;
},
@@ -654,29 +649,33 @@
}
crow::connections::systemBus->async_method_call(
- [aResp](const boost::system::error_code ec,
- const std::variant<bool> asserted) {
+ [aResp, ledOn, ledBlinkng](const boost::system::error_code ec,
+ const std::variant<bool> asserted) mutable {
if (ec)
{
- BMCWEB_LOG_DEBUG << "DBUS response error " << ec;
- messages::internalError(aResp->res);
- return;
+ // Some systems may not have enclosure_identify_blink object so
+ // Lets set enclosure_identify state to true if Blinking is
+ // true.
+ if (ledBlinkng)
+ {
+ ledOn = true;
+ }
}
- },
- "xyz.openbmc_project.LED.GroupManager",
- "/xyz/openbmc_project/led/groups/enclosure_identify",
- "org.freedesktop.DBus.Properties", "Set",
- "xyz.openbmc_project.Led.Group", "Asserted", std::variant<bool>(ledOn));
-
- crow::connections::systemBus->async_method_call(
- [aResp](const boost::system::error_code ec,
- const std::variant<bool> asserted) {
- if (ec)
- {
- BMCWEB_LOG_DEBUG << "DBUS response error " << ec;
- messages::internalError(aResp->res);
- return;
- }
+ crow::connections::systemBus->async_method_call(
+ [aResp](const boost::system::error_code ec,
+ const std::variant<bool> asserted) {
+ if (ec)
+ {
+ BMCWEB_LOG_DEBUG << "DBUS response error " << ec;
+ messages::internalError(aResp->res);
+ return;
+ }
+ },
+ "xyz.openbmc_project.LED.GroupManager",
+ "/xyz/openbmc_project/led/groups/enclosure_identify",
+ "org.freedesktop.DBus.Properties", "Set",
+ "xyz.openbmc_project.Led.Group", "Asserted",
+ std::variant<bool>(ledOn));
},
"xyz.openbmc_project.LED.GroupManager",
"/xyz/openbmc_project/led/groups/enclosure_identify_blink",