diff options
author | Evgeny Alekseev (IBS Group) <ealekseev@ibs.sila.ru> | 2022-08-10 15:52:03 +0300 |
---|---|---|
committer | Evgeny Alekseev (IBS Group) <ealekseev@ibs.sila.ru> | 2022-08-10 15:52:03 +0300 |
commit | d0ad48aa491be0de9e8a35eb9e39ab2675e641da (patch) | |
tree | 028f05c15d8920371d47a784db0d4730e23a8534 | |
parent | d32b8f22c1f1fea60c0208fe6182fa45bfba910b (diff) | |
download | openbmc-editable-sensor-thresholds.tar.xz |
IBS: bmcweb add sensor warn threshold level editeditable-sensor-thresholds
-rw-r--r-- | meta-ibs/meta-common/recipes-phosphor/interfaces/bmcweb/0004-IBS-Add-redfish2phosphor-logs.patch (renamed from meta-ibs/meta-common/recipes-phosphor/interfaces/bmcweb/0002-IBS-Add-redfish2phosphor-logs.patch) | 0 | ||||
-rw-r--r-- | meta-ibs/meta-common/recipes-phosphor/interfaces/bmcweb/0005-Add-Sensor-Warning-Threshold-Edit.patch | 233 | ||||
-rw-r--r-- | meta-ibs/meta-common/recipes-phosphor/interfaces/bmcweb/0006-IBS-bmcweb-evt-registry-add-BMCTimeUpdatedViaNTP.patch (renamed from meta-ibs/meta-common/recipes-phosphor/interfaces/bmcweb/0001-IBS-bmcweb-evt-registry-add-BMCTimeUpdatedViaNTP.patch) | 0 | ||||
-rw-r--r-- | meta-ibs/meta-common/recipes-phosphor/interfaces/bmcweb_%.bbappend | 5 |
4 files changed, 236 insertions, 2 deletions
diff --git a/meta-ibs/meta-common/recipes-phosphor/interfaces/bmcweb/0002-IBS-Add-redfish2phosphor-logs.patch b/meta-ibs/meta-common/recipes-phosphor/interfaces/bmcweb/0004-IBS-Add-redfish2phosphor-logs.patch index 841aac9ee7..841aac9ee7 100644 --- a/meta-ibs/meta-common/recipes-phosphor/interfaces/bmcweb/0002-IBS-Add-redfish2phosphor-logs.patch +++ b/meta-ibs/meta-common/recipes-phosphor/interfaces/bmcweb/0004-IBS-Add-redfish2phosphor-logs.patch diff --git a/meta-ibs/meta-common/recipes-phosphor/interfaces/bmcweb/0005-Add-Sensor-Warning-Threshold-Edit.patch b/meta-ibs/meta-common/recipes-phosphor/interfaces/bmcweb/0005-Add-Sensor-Warning-Threshold-Edit.patch new file mode 100644 index 0000000000..9326e5bb83 --- /dev/null +++ b/meta-ibs/meta-common/recipes-phosphor/interfaces/bmcweb/0005-Add-Sensor-Warning-Threshold-Edit.patch @@ -0,0 +1,233 @@ +From b4e619d9419fbccd818992330630af4920623796 Mon Sep 17 00:00:00 2001 +From: "Evgeny Alekseev (IBS Group)" <ealekseev@ibs.sila.ru> +Date: Wed, 10 Aug 2022 15:28:47 +0300 +Subject: [PATCH] [*]Add Sensor Warning Threshold Edit + +--- + redfish-core/lib/power.hpp | 6 +- + redfish-core/lib/sensors.hpp | 150 +++++++++++++++++++++++++++++++++++ + redfish-core/lib/thermal.hpp | 2 +- + 3 files changed, 155 insertions(+), 3 deletions(-) + +diff --git a/redfish-core/lib/power.hpp b/redfish-core/lib/power.hpp +index bc18157c..aff60ebf 100644 +--- a/redfish-core/lib/power.hpp ++++ b/redfish-core/lib/power.hpp +@@ -22,6 +22,8 @@ + #include <dbus_utility.hpp> + #include <query.hpp> + #include <registries/privilege_registry.hpp> ++#include <iostream> ++#include <algorithm> + + namespace redfish + { +@@ -331,11 +333,11 @@ inline void requestRoutesPower(App& app) + setPowerCapOverride(sensorAsyncResp, *powerCtlCollections); + } + if (voltageCollections) +- { ++ { + std::unordered_map<std::string, std::vector<nlohmann::json>> + allCollections; + allCollections.emplace("Voltages", *std::move(voltageCollections)); +- setSensorsOverride(sensorAsyncResp, allCollections); ++ setSensorsWarning(sensorAsyncResp, allCollections); + } + }); + } +diff --git a/redfish-core/lib/sensors.hpp b/redfish-core/lib/sensors.hpp +index 04b5190f..1601e8ed 100644 +--- a/redfish-core/lib/sensors.hpp ++++ b/redfish-core/lib/sensors.hpp +@@ -30,6 +30,8 @@ + #include <cmath> + #include <iterator> + #include <map> ++#include <unordered_map> ++#include <string> + #include <set> + #include <utility> + #include <variant> +@@ -2762,6 +2764,7 @@ inline bool + return false; + } + ++ + /** + * @brief Entry point for overriding sensor values of given sensor + * +@@ -2769,6 +2772,7 @@ inline bool + * @param allCollections Collections extract from sensors' request patch info + * @param chassisSubNode Chassis Node for which the query has to happen + */ ++ + inline void setSensorsOverride( + const std::shared_ptr<SensorsAsyncResp>& sensorAsyncResp, + std::unordered_map<std::string, std::vector<nlohmann::json>>& +@@ -2898,6 +2902,152 @@ inline void setSensorsOverride( + // get full sensor list for the given chassisId and cross verify the sensor. + getChassis(sensorAsyncResp, std::move(getChassisSensorListCb)); + } ++ ++ ++ ++/** ++ * @brief Entry point for setting sensor warning level of given sensor ++ * ++ * @param sensorAsyncResp response object ++ * @param allCollections Collections extract from sensors' request patch info ++ * @param chassisSubNode Chassis Node for which the query has to happen ++ */ ++inline void setSensorsWarning( ++ const std::shared_ptr<SensorsAsyncResp>& sensorAsyncResp, ++ std::unordered_map<std::string, std::vector<nlohmann::json>>& ++ allCollections) ++{ ++ BMCWEB_LOG_INFO << "setSensorsWarning for subNode" ++ << sensorAsyncResp->chassisSubNode << "\n"; ++ ++ const char* propertyValueName = nullptr; ++ std::unordered_map<std::string, std::tuple<double, std::string, std::string>> overrideMap; ++ std::string memberId; ++ std::string thresholdName; ++ static const std::unordered_map<std::string, std::string> validThresholdNames = ++ {{std::string {"LowerThresholdNonCritical"},std::string {"WarningLow"}}, ++ {std::string {"UpperThresholdNonCritical"},std::string {"WarningHigh"}}}; ++ double value = 0.0; ++ for (auto& collectionItems : allCollections) ++ { ++ ++ for (auto& item : collectionItems.second) ++ { ++ for(auto const &elem: validThresholdNames) ++ { ++ if(item.contains(elem.first))propertyValueName = elem.first.c_str(); ++ } ++ if (!json_util::readJson(item, sensorAsyncResp->asyncResp->res, ++ "MemberId", memberId, propertyValueName, ++ value)) ++ { ++ return; ++ } ++ if(propertyValueName) ++ { ++ overrideMap.emplace(memberId, ++ std::make_tuple(value, collectionItems.first, std::string(propertyValueName))); ++ } ++ } ++ } ++ for(auto [key, val] : overrideMap) ++ BMCWEB_LOG_INFO << "Override entry:" << key << " " ++ << std::get<0>(val) << " " ++ << std::get<1>(val)<< " " ++ << std::get<2>(val); ++ ++ auto getChassisSensorListCb = ++ [sensorAsyncResp, overrideMap]( ++ const std::shared_ptr<std::set<std::string>>& sensorsList) { ++ // Match sensor names in the PATCH request to those managed by the ++ // chassis node ++ const std::shared_ptr<std::set<std::string>> sensorNames = ++ std::make_shared<std::set<std::string>>(); ++ for (const auto& item : overrideMap) ++ { ++ const auto& sensor = item.first; ++ if (!findSensorNameUsingSensorPath(sensor, *sensorsList, ++ *sensorNames)) ++ { ++ BMCWEB_LOG_INFO << "Unable to find memberId " << item.first; ++ messages::resourceNotFound(sensorAsyncResp->asyncResp->res, ++ std::get<1>(item.second), item.first); ++ return; ++ } ++ } ++ // Get the connection to which the memberId belongs ++ auto getObjectsWithConnectionCb = ++ [sensorAsyncResp, ++ overrideMap](const std::set<std::string>& /*connections*/, ++ const std::set<std::pair<std::string, std::string>>& ++ objectsWithConnection) { ++ if (objectsWithConnection.size() != overrideMap.size()) ++ { ++ BMCWEB_LOG_INFO ++ << "Unable to find all objects with proper connection " ++ << objectsWithConnection.size() << " requested " ++ << overrideMap.size() << "\n"; ++ messages::resourceNotFound(sensorAsyncResp->asyncResp->res, ++ sensorAsyncResp->chassisSubNode == ++ sensors::node::thermal ++ ? "Temperatures" ++ : "Voltages", ++ "Count"); ++ return; ++ } ++ for (const auto& item : objectsWithConnection) ++ { ++ sdbusplus::message::object_path path(item.first); ++ std::string sensorName = path.filename(); ++ if (sensorName.empty()) ++ { ++ messages::internalError(sensorAsyncResp->asyncResp->res); ++ return; ++ } ++ ++ const auto& iterator = overrideMap.find(sensorName); ++ if (iterator == overrideMap.end()) ++ { ++ BMCWEB_LOG_INFO << "Unable to find sensor object" ++ << item.first << "\n"; ++ messages::internalError(sensorAsyncResp->asyncResp->res); ++ return; ++ } ++ BMCWEB_LOG_INFO << "Tryong to set warning property: " <<validThresholdNames.at(std::get<2>(iterator->second)); ++ ++ crow::connections::systemBus->async_method_call( ++ [sensorAsyncResp](const boost::system::error_code ec) { ++ if (ec) ++ { ++ if (ec.value() == ++ boost::system::errc::permission_denied) ++ { ++ BMCWEB_LOG_WARNING ++ << "Manufacturing mode is not Enabled...can't " ++ "Override the sensor value. "; ++ ++ messages::insufficientPrivilege( ++ sensorAsyncResp->asyncResp->res); ++ return; ++ } ++ BMCWEB_LOG_DEBUG ++ << "setOverrideValueStatus DBUS error: " << ec; ++ messages::internalError( ++ sensorAsyncResp->asyncResp->res); ++ } ++ }, ++ item.second, item.first, "org.freedesktop.DBus.Properties", ++ "Set", "xyz.openbmc_project.Sensor.Threshold.Warning", validThresholdNames.at(std::get<2>(iterator->second)), ++ dbus::utility::DbusVariantType(std::get<0>(iterator->second))); ++ } ++ }; ++ // Get object with connection for the given sensor name ++ getObjectsWithConnection(sensorAsyncResp, sensorNames, ++ std::move(getObjectsWithConnectionCb)); ++ }; ++ // get full sensor list for the given chassisId and cross verify the sensor. ++ getChassis(sensorAsyncResp, std::move(getChassisSensorListCb)); ++} + + /** + * @brief Retrieves mapping of Redfish URIs to sensor value property to D-Bus +diff --git a/redfish-core/lib/thermal.hpp b/redfish-core/lib/thermal.hpp +index 83f79af3..a44a4791 100644 +--- a/redfish-core/lib/thermal.hpp ++++ b/redfish-core/lib/thermal.hpp +@@ -86,7 +86,7 @@ inline void requestRoutesThermal(App& app) + { + allCollections.emplace("Fans", *std::move(fanCollections)); + } +- setSensorsOverride(sensorsAsyncResp, allCollections); ++ setSensorsWarning(sensorsAsyncResp, allCollections); + }); + } + diff --git a/meta-ibs/meta-common/recipes-phosphor/interfaces/bmcweb/0001-IBS-bmcweb-evt-registry-add-BMCTimeUpdatedViaNTP.patch b/meta-ibs/meta-common/recipes-phosphor/interfaces/bmcweb/0006-IBS-bmcweb-evt-registry-add-BMCTimeUpdatedViaNTP.patch index f4a9c0ed7e..f4a9c0ed7e 100644 --- a/meta-ibs/meta-common/recipes-phosphor/interfaces/bmcweb/0001-IBS-bmcweb-evt-registry-add-BMCTimeUpdatedViaNTP.patch +++ b/meta-ibs/meta-common/recipes-phosphor/interfaces/bmcweb/0006-IBS-bmcweb-evt-registry-add-BMCTimeUpdatedViaNTP.patch diff --git a/meta-ibs/meta-common/recipes-phosphor/interfaces/bmcweb_%.bbappend b/meta-ibs/meta-common/recipes-phosphor/interfaces/bmcweb_%.bbappend index 9c4ecfa65b..4becbda11a 100644 --- a/meta-ibs/meta-common/recipes-phosphor/interfaces/bmcweb_%.bbappend +++ b/meta-ibs/meta-common/recipes-phosphor/interfaces/bmcweb_%.bbappend @@ -6,8 +6,9 @@ SRC_URI += "\ file://0001-Enable-vm-nbdproxy-option.patch \ file://0002-Add-http-ftp-nfs-protocols-to-un-filter-them-FT-58-T.patch \ file://0003-Revert-Rearrange-forward_unauthorized.patch \ - file://0001-IBS-bmcweb-evt-registry-add-BMCTimeUpdatedViaNTP.patch \ - file://0002-IBS-Add-redfish2phosphor-logs.patch \ + file://0004-IBS-Add-redfish2phosphor-logs.patch \ + file://0005-Add-Sensor-Warning-Threshold-Edit.patch \ + file://0006-IBS-bmcweb-evt-registry-add-BMCTimeUpdatedViaNTP.patch \ " EXTRA_OEMESON += "\ |