summaryrefslogtreecommitdiff
path: root/redfish-core
diff options
context:
space:
mode:
Diffstat (limited to 'redfish-core')
-rw-r--r--redfish-core/include/redfish.hpp2
-rw-r--r--redfish-core/lib/chassis.hpp3
-rw-r--r--redfish-core/lib/power_subsystem.hpp64
3 files changed, 69 insertions, 0 deletions
diff --git a/redfish-core/include/redfish.hpp b/redfish-core/include/redfish.hpp
index 796df8d87f..b20944b053 100644
--- a/redfish-core/include/redfish.hpp
+++ b/redfish-core/include/redfish.hpp
@@ -33,6 +33,7 @@
#include "../lib/network_protocol.hpp"
#include "../lib/pcie.hpp"
#include "../lib/power.hpp"
+#include "../lib/power_subsystem.hpp"
#include "../lib/processor.hpp"
#include "../lib/redfish_sessions.hpp"
#include "../lib/redfish_v1.hpp"
@@ -78,6 +79,7 @@ class RedfishService
requestRoutesPower(app);
#endif
#ifdef BMCWEB_NEW_POWERSUBSYSTEM_THERMALSUBSYSTEM
+ requestRoutesPowerSubsystem(app);
requestRoutesThermalSubsystem(app);
#endif
requestRoutesManagerCollection(app);
diff --git a/redfish-core/lib/chassis.hpp b/redfish-core/lib/chassis.hpp
index c51b150444..261411505c 100644
--- a/redfish-core/lib/chassis.hpp
+++ b/redfish-core/lib/chassis.hpp
@@ -403,6 +403,9 @@ inline void
asyncResp->res.jsonValue["ThermalSubsystem"]["@odata.id"] =
crow::utility::urlFromPieces("redfish", "v1", "Chassis",
chassisId, "ThermalSubsystem");
+ asyncResp->res.jsonValue["PowerSubsystem"]["@odata.id"] =
+ crow::utility::urlFromPieces("redfish", "v1", "Chassis",
+ chassisId, "PowerSubsystem");
#endif
// SensorCollection
asyncResp->res.jsonValue["Sensors"]["@odata.id"] =
diff --git a/redfish-core/lib/power_subsystem.hpp b/redfish-core/lib/power_subsystem.hpp
new file mode 100644
index 0000000000..c3b898c278
--- /dev/null
+++ b/redfish-core/lib/power_subsystem.hpp
@@ -0,0 +1,64 @@
+#pragma once
+
+#include "app.hpp"
+#include "query.hpp"
+#include "registries/privilege_registry.hpp"
+#include "utils/chassis_utils.hpp"
+
+#include <memory>
+#include <optional>
+#include <string>
+
+namespace redfish
+{
+
+inline void doPowerSubsystemCollection(
+ 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"] =
+ "#PowerSubsystem.v1_1_0.PowerSubsystem";
+ asyncResp->res.jsonValue["Name"] = "Power Subsystem";
+ asyncResp->res.jsonValue["Id"] = "PowerSubsystem";
+ asyncResp->res.jsonValue["@odata.id"] = crow::utility::urlFromPieces(
+ "redfish", "v1", "Chassis", chassisId, "PowerSubsystem");
+ asyncResp->res.jsonValue["Status"]["State"] = "Enabled";
+ asyncResp->res.jsonValue["Status"]["Health"] = "OK";
+
+ asyncResp->res.addHeader(
+ boost::beast::http::field::link,
+ "</redfish/v1/JsonSchemas/PowerSubsystem/PowerSubsystem.json>; rel=describedby");
+}
+
+inline void handlePowerSubsystemCollectionGet(
+ 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(doPowerSubsystemCollection, asyncResp, chassisId));
+}
+
+inline void requestRoutesPowerSubsystem(App& app)
+{
+ BMCWEB_ROUTE(app, "/redfish/v1/Chassis/<str>/PowerSubsystem/")
+ .privileges(redfish::privileges::getPowerSubsystem)
+ .methods(boost::beast::http::verb::get)(
+ std::bind_front(handlePowerSubsystemCollectionGet, std::ref(app)));
+}
+
+} // namespace redfish