summaryrefslogtreecommitdiff
path: root/redfish-core
diff options
context:
space:
mode:
authorzhanghch05 <zhanghch05@inspur.com>2021-03-08 14:04:35 +0300
committerEd Tanous <ed@tanous.net>2024-01-23 01:03:54 +0300
commit5ae1f7f3e0c78f84d153f7ef24ee22bb1c73eaa0 (patch)
treed8c39310b6a833fb30d67190270268d36969ba0a /redfish-core
parentb5f288d294e17719f30e32acc40e07681baf04b9 (diff)
downloadbmcweb-5ae1f7f3e0c78f84d153f7ef24ee22bb1c73eaa0.tar.xz
Implements ThermalMetrics schema
The ThermalMetrics schema is a resource in Redfish version 2022.2[1]. It contains an array of temperature readings. It is a child of ThermalSubsystem schema[2] and it represents the thermal metrics of a chassis. Reading the current value of each temperature sensor and the corresponding link enumeration will be implemented in the next patch. This commit implements the Get and Head methods of the Redfish ThermalMetrics schema and implemented the basic information of Get. [1] https://www.dmtf.org/sites/default/files/standards/documents/DSP0268_2022.2.pdf [2] https://redfish.dmtf.org/schemas/v1/ThermalMetrics.v1_0_1.json Test: 1. Validator passed. 2. doGet method: """ curl -k -H "X-Auth-Token: $token" -X GET https://${bmc}/redfish/v1/Chassis/chassis/ThermalSubsystem/ThermalMetrics { "@odata.id": "/redfish/v1/Chassis/chassis/ThermalSubsystem/ThermalMetrics", "@odata.type": "#ThermalMetrics.v1_0_1.ThermalMetrics", "Id": "ThermalMetrics", "Name": "Thermal Metrics", } """ 3. A bad chassis ID: """ curl -k -H "X-Auth-Token: $token" -X GET https://${bmc}/redfish/v1/Chassis/chassisBAD/ThermalSubsystem/ThermalMetrics { "error": { "@Message.ExtendedInfo": [ { "@odata.type": "#Message.v1_1_1.Message", "Message": "The requested resource of type Chassis named 'chassisBAD' was not found.", "MessageArgs": [ "Chassis", "chassisBAD" ], "MessageId": "Base.1.13.0.ResourceNotFound", "MessageSeverity": "Critical", "Resolution": "Provide a valid resource identifier and resubmit the request." } ], "code": "Base.1.13.0.ResourceNotFound", "message": "The requested resource of type Chassis named 'chassisBAD' was not found." } } """ Signed-off-by: zhanghaicheng <zhanghch05@inspur.com> Change-Id: Ib4182e7dc6e204371636a33a391e8e2a58dad113
Diffstat (limited to 'redfish-core')
-rw-r--r--redfish-core/include/redfish.hpp2
-rw-r--r--redfish-core/lib/thermal_metrics.hpp91
-rw-r--r--redfish-core/lib/thermal_subsystem.hpp5
3 files changed, 98 insertions, 0 deletions
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";
}