From e147e3a45d7985b2f7c3393a6216288687cf5496 Mon Sep 17 00:00:00 2001 From: "Evgeny Alekseev (IBS Group)" Date: Tue, 6 Sep 2022 15:08:39 +0300 Subject: [PATCH] Add critical thresholds to redfish --- redfish-core/lib/sensors.hpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/redfish-core/lib/sensors.hpp b/redfish-core/lib/sensors.hpp index 1c636f20..f7d6bc3b 100644 --- a/redfish-core/lib/sensors.hpp +++ b/redfish-core/lib/sensors.hpp @@ -2876,9 +2876,11 @@ inline void setSensorsWarning( std::unordered_map> overrideMap; std::string memberId; std::string thresholdName; - static const std::unordered_map validThresholdNames = - {{std::string {"LowerThresholdNonCritical"},std::string {"WarningLow"}}, - {std::string {"UpperThresholdNonCritical"},std::string {"WarningHigh"}}}; + static const std::unordered_map> validThresholdNames = + {{std::string {"LowerThresholdNonCritical"},std::make_tuple(std::string("WarningLow"), std::string("xyz.openbmc_project.Sensor.Threshold.Warning"))}, + {std::string {"UpperThresholdNonCritical"},std::make_tuple(std::string("WarningHigh"), std::string("xyz.openbmc_project.Sensor.Threshold.Warning"))}, + {std::string {"LowerThresholdCritical"},std::make_tuple(std::string("CriticalLow"), std::string("xyz.openbmc_project.Sensor.Threshold.Critical"))}, + {std::string {"UpperThresholdCritical"},std::make_tuple(std::string("CriticalHigh"), std::string("xyz.openbmc_project.Sensor.Threshold.Critical"))}}; double value = 0.0; for (auto& collectionItems : allCollections) { @@ -2888,6 +2890,11 @@ inline void setSensorsWarning( { if(item.contains(elem.first))propertyValueName = elem.first.c_str(); } + if(!propertyValueName) + { + messages::actionParameterMissing(sensorAsyncResp->asyncResp->res, collectionItems.first, "Threshold"); + return; + } if (!json_util::readJson(item, sensorAsyncResp->asyncResp->res, "MemberId", memberId, propertyValueName, value)) @@ -2964,7 +2971,7 @@ inline void setSensorsWarning( messages::internalError(sensorAsyncResp->asyncResp->res); return; } - BMCWEB_LOG_INFO << "Tryong to set warning property: " <(iterator->second)); + BMCWEB_LOG_INFO << "Trying to set warning property: " <(validThresholdNames.at(std::get<2>(iterator->second))); crow::connections::systemBus->async_method_call( [sensorAsyncResp](const boost::system::error_code ec) { @@ -2988,7 +2995,7 @@ inline void setSensorsWarning( } }, item.second, item.first, "org.freedesktop.DBus.Properties", - "Set", "xyz.openbmc_project.Sensor.Threshold.Warning", validThresholdNames.at(std::get<2>(iterator->second)), + "Set", std::get<1>(validThresholdNames.at(std::get<2>(iterator->second))), std::get<0>(validThresholdNames.at(std::get<2>(iterator->second))), dbus::utility::DbusVariantType(std::get<0>(iterator->second))); } }; -- 2.35.1