summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Redfish.md5
-rw-r--r--meson.build1
-rw-r--r--redfish-core/include/redfish.hpp4
-rw-r--r--redfish-core/lib/chassis.hpp5
-rw-r--r--redfish-core/lib/thermal_subsystem.hpp59
-rw-r--r--redfish-core/lib/ut/thermal_subsystem_test.cpp42
6 files changed, 116 insertions, 0 deletions
diff --git a/Redfish.md b/Redfish.md
index e964c2cc41..0270208a6a 100644
--- a/Redfish.md
+++ b/Redfish.md
@@ -223,6 +223,11 @@ Chassis to Drives, The name of the association is "chassis<->drive")
- MinNumNeeded
- MaxNumSupported
+#### /redfish/v1/Chassis/{ChassisId}/ThermalSubsystem
+
+##### ThermalSubsystem
+- Status
+
#### /redfish/v1/Chassis/{ChassisId}/Power/
##### Power
PowerControl Voltages PowerSupplies Redundancy
diff --git a/meson.build b/meson.build
index ec7051053e..ad1f4018dd 100644
--- a/meson.build
+++ b/meson.build
@@ -398,6 +398,7 @@ srcfiles_unittest = [
'include/ut/openbmc_dbus_rest_test.cpp',
'redfish-core/include/utils/query_param_test.cpp',
'redfish-core/lib/ut/service_root_test.cpp',
+ 'redfish-core/lib/ut/thermal_subsystem_test.cpp',
'redfish-core/lib/chassis_test.cpp',
'redfish-core/ut/configfile_test.cpp',
'redfish-core/ut/hex_utils_test.cpp',
diff --git a/redfish-core/include/redfish.hpp b/redfish-core/include/redfish.hpp
index ab635f913f..ed42b89a2f 100644
--- a/redfish-core/include/redfish.hpp
+++ b/redfish-core/include/redfish.hpp
@@ -44,6 +44,7 @@
#include "../lib/task.hpp"
#include "../lib/telemetry_service.hpp"
#include "../lib/thermal.hpp"
+#include "../lib/thermal_subsystem.hpp"
#include "../lib/trigger.hpp"
#include "../lib/update_service.hpp"
#include "../lib/virtual_media.hpp"
@@ -76,6 +77,9 @@ class RedfishService
requestRoutesThermal(app);
requestRoutesPower(app);
#endif
+#ifdef BMCWEB_NEW_POWERSUBSYSTEM_THERMALSUBSYSTEM
+ requestRoutesThermalSubsystem(app);
+#endif
requestRoutesManagerCollection(app);
requestRoutesManager(app);
requestRoutesManagerResetAction(app);
diff --git a/redfish-core/lib/chassis.hpp b/redfish-core/lib/chassis.hpp
index 7982281618..f1de38c805 100644
--- a/redfish-core/lib/chassis.hpp
+++ b/redfish-core/lib/chassis.hpp
@@ -384,6 +384,11 @@ inline void
asyncResp->res.jsonValue["Power"]["@odata.id"] =
"/redfish/v1/Chassis/" + chassisId + "/Power";
#endif
+#ifdef BMCWEB_NEW_POWERSUBSYSTEM_THERMALSUBSYSTEM
+ asyncResp->res.jsonValue["ThermalSubsystem"]["@odata.id"] =
+ crow::utility::urlFromPieces("redfish", "v1", "Chassis",
+ chassisId, "ThermalSubsystem");
+#endif
// SensorCollection
asyncResp->res.jsonValue["Sensors"]["@odata.id"] =
"/redfish/v1/Chassis/" + chassisId + "/Sensors";
diff --git a/redfish-core/lib/thermal_subsystem.hpp b/redfish-core/lib/thermal_subsystem.hpp
new file mode 100644
index 0000000000..0d5b88b49f
--- /dev/null
+++ b/redfish-core/lib/thermal_subsystem.hpp
@@ -0,0 +1,59 @@
+#pragma once
+
+#include "app.hpp"
+#include "query.hpp"
+#include "registries/privilege_registry.hpp"
+#include "utils/chassis_utils.hpp"
+#include "utils/json_utils.hpp"
+
+namespace redfish
+{
+
+inline void doThermalSubsystemCollection(
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& chassisId,
+ const std::optional<std::string>& validChassisPath)
+{
+ if (!validChassisPath)
+ {
+ BMCWEB_LOG_ERROR << "Not a valid chassis ID" << chassisId;
+ messages::resourceNotFound(asyncResp->res, "Chassis", chassisId);
+ return;
+ }
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#ThermalSubsystem.v1_0_0.ThermalSubsystem";
+ asyncResp->res.jsonValue["Name"] = "Thermal Subsystem";
+ asyncResp->res.jsonValue["Id"] = "ThermalSubsystem";
+
+ asyncResp->res.jsonValue["@odata.id"] = crow::utility::urlFromPieces(
+ "redfish", "v1", "Chassis", chassisId, "ThermalSubsystem");
+
+ asyncResp->res.jsonValue["Status"]["State"] = "Enabled";
+ asyncResp->res.jsonValue["Status"]["Health"] = "OK";
+}
+
+inline void handleThermalSubsystemCollectionGet(
+ App& app, const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& param)
+{
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
+ const std::string& chassisId = param;
+
+ redfish::chassis_utils::getValidChassisPath(
+ asyncResp, chassisId,
+ std::bind_front(doThermalSubsystemCollection, asyncResp, chassisId));
+}
+
+inline void requestRoutesThermalSubsystem(App& app)
+{
+ BMCWEB_ROUTE(app, "/redfish/v1/Chassis/<str>/ThermalSubsystem/")
+ .privileges(redfish::privileges::getThermalSubsystem)
+ .methods(boost::beast::http::verb::get)(std::bind_front(
+ handleThermalSubsystemCollectionGet, std::ref(app)));
+}
+
+} // namespace redfish
diff --git a/redfish-core/lib/ut/thermal_subsystem_test.cpp b/redfish-core/lib/ut/thermal_subsystem_test.cpp
new file mode 100644
index 0000000000..c6880239da
--- /dev/null
+++ b/redfish-core/lib/ut/thermal_subsystem_test.cpp
@@ -0,0 +1,42 @@
+#include "include/async_resp.hpp"
+#include "thermal_subsystem.hpp"
+
+#include <nlohmann/json.hpp>
+
+#include <optional>
+#include <string>
+
+#include <gtest/gtest.h>
+
+namespace redfish
+{
+namespace
+{
+
+constexpr const char* chassisId = "ChassisId";
+constexpr const char* validChassisPath = "ChassisPath";
+
+void assertThemalCollectionGet(crow::Response& res)
+{
+ nlohmann::json& json = res.jsonValue;
+ EXPECT_EQ(json["@odata.type"], "#ThermalSubsystem.v1_0_0.ThermalSubsystem");
+ EXPECT_EQ(json["Name"], "Thermal Subsystem");
+ EXPECT_EQ(json["Id"], "ThermalSubsystem");
+ EXPECT_EQ(json["@odata.id"],
+ "/redfish/v1/Chassis/ChassisId/ThermalSubsystem");
+ EXPECT_EQ(json["Status"]["State"], "Enabled");
+ EXPECT_EQ(json["Status"]["Health"], "OK");
+}
+
+TEST(ThermalSubsystemCollectionTest,
+ ThermalSubsystemCollectionStaticAttributesAreExpected)
+{
+ auto shareAsyncResp = std::make_shared<bmcweb::AsyncResp>();
+ shareAsyncResp->res.setCompleteRequestHandler(assertThemalCollectionGet);
+ doThermalSubsystemCollection(
+ shareAsyncResp, chassisId,
+ std::make_optional<std::string>(validChassisPath));
+}
+
+} // namespace
+} // namespace redfish