diff options
-rw-r--r-- | Redfish.md | 5 | ||||
-rw-r--r-- | redfish-core/include/redfish.hpp | 2 | ||||
-rw-r--r-- | redfish-core/lib/thermal_metrics.hpp | 91 | ||||
-rw-r--r-- | redfish-core/lib/thermal_subsystem.hpp | 5 |
4 files changed, 103 insertions, 0 deletions
diff --git a/Redfish.md b/Redfish.md index 7290aa41c2..811dc87989 100644 --- a/Redfish.md +++ b/Redfish.md @@ -313,6 +313,11 @@ Fields common to all schemas #### ThermalSubsystem - Status +- ThermalMetrics + +#### /redfish/v1/Chassis/{ChassisId}/ThermalSubsystem/ThermalMetrics/ + +##### ThermalMetrics #### /redfish/v1/Chassis/{ChassisId}/ThermalSubsystem/Fans diff --git a/redfish-core/include/redfish.hpp b/redfish-core/include/redfish.hpp index 540bb070c7..89d5679d1f 100644 --- a/redfish-core/include/redfish.hpp +++ b/redfish-core/include/redfish.hpp @@ -52,6 +52,7 @@ #include "task.hpp" #include "telemetry_service.hpp" #include "thermal.hpp" +#include "thermal_metrics.hpp" #include "thermal_subsystem.hpp" #include "trigger.hpp" #include "update_service.hpp" @@ -95,6 +96,7 @@ class RedfishService requestRoutesPowerSubsystem(app); requestRoutesPowerSupply(app); requestRoutesPowerSupplyCollection(app); + requestRoutesThermalMetrics(app); requestRoutesThermalSubsystem(app); requestRoutesFan(app); requestRoutesFanCollection(app); diff --git a/redfish-core/lib/thermal_metrics.hpp b/redfish-core/lib/thermal_metrics.hpp new file mode 100644 index 0000000000..f2541182f7 --- /dev/null +++ b/redfish-core/lib/thermal_metrics.hpp @@ -0,0 +1,91 @@ +#pragma once + +#include "app.hpp" +#include "query.hpp" +#include "registries/privilege_registry.hpp" +#include "utils/chassis_utils.hpp" + +#include <functional> +#include <memory> +#include <optional> +#include <string> + +namespace redfish +{ +inline void + doThermalMetrics(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, + const std::string& chassisId, + const std::optional<std::string>& validChassisPath) +{ + if (!validChassisPath) + { + messages::resourceNotFound(asyncResp->res, "Chassis", chassisId); + return; + } + + asyncResp->res.addHeader( + boost::beast::http::field::link, + "</redfish/v1/JsonSchemas/ThermalMetrics/ThermalMetrics.json>; rel=describedby"); + asyncResp->res.jsonValue["@odata.type"] = + "#ThermalMetrics.v1_0_1.ThermalMetrics"; + asyncResp->res.jsonValue["@odata.id"] = boost::urls::format( + "/redfish/v1/Chassis/{}/ThermalSubsystem/ThermalMetrics", chassisId); + asyncResp->res.jsonValue["Id"] = "ThermalMetrics"; + asyncResp->res.jsonValue["Name"] = "Thermal Metrics"; +} + +inline void handleThermalMetricsHead( + App& app, const crow::Request& req, + const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, + const std::string& chassisId) +{ + if (!redfish::setUpRedfishRoute(app, req, asyncResp)) + { + return; + } + + redfish::chassis_utils::getValidChassisPath( + asyncResp, chassisId, + [asyncResp, + chassisId](const std::optional<std::string>& validChassisPath) { + if (!validChassisPath) + { + messages::resourceNotFound(asyncResp->res, "Chassis", chassisId); + return; + } + asyncResp->res.addHeader( + boost::beast::http::field::link, + "</redfish/v1/JsonSchemas/ThermalMetrics/ThermalMetrics.json>; rel=describedby"); + }); +} + +inline void + handleThermalMetricsGet(App& app, const crow::Request& req, + const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, + const std::string& chassisId) +{ + if (!redfish::setUpRedfishRoute(app, req, asyncResp)) + { + return; + } + + redfish::chassis_utils::getValidChassisPath( + asyncResp, chassisId, + std::bind_front(doThermalMetrics, asyncResp, chassisId)); +} + +inline void requestRoutesThermalMetrics(App& app) +{ + BMCWEB_ROUTE(app, + "/redfish/v1/Chassis/<str>/ThermalSubsystem/ThermalMetrics/") + .privileges(redfish::privileges::headThermalMetrics) + .methods(boost::beast::http::verb::head)( + std::bind_front(handleThermalMetricsHead, std::ref(app))); + + BMCWEB_ROUTE(app, + "/redfish/v1/Chassis/<str>/ThermalSubsystem/ThermalMetrics/") + .privileges(redfish::privileges::getThermalMetrics) + .methods(boost::beast::http::verb::get)( + std::bind_front(handleThermalMetricsGet, std::ref(app))); +} +} // namespace redfish diff --git a/redfish-core/lib/thermal_subsystem.hpp b/redfish-core/lib/thermal_subsystem.hpp index 92e623eaa7..c52f395686 100644 --- a/redfish-core/lib/thermal_subsystem.hpp +++ b/redfish-core/lib/thermal_subsystem.hpp @@ -41,6 +41,11 @@ inline void doThermalSubsystemCollection( asyncResp->res.jsonValue["Fans"]["@odata.id"] = boost::urls::format( "/redfish/v1/Chassis/{}/ThermalSubsystem/Fans", chassisId); + asyncResp->res.jsonValue["ThermalMetrics"]["@odata.id"] = + boost::urls::format( + "/redfish/v1/Chassis/{}/ThermalSubsystem/ThermalMetrics", + chassisId); + asyncResp->res.jsonValue["Status"]["State"] = "Enabled"; asyncResp->res.jsonValue["Status"]["Health"] = "OK"; } |