Add BMCWEB_ENABLE_REDFISH_ONE_CHASSIS build option
Define a new build option named BMCWEB_ENABLE_REDFISH_ONE_CHASSIS that
is not set by default.
When this build option is set, bmcweb will always return a single
chassis named "chassis".
Setting this option will also cause all sensors to be shown under this
chassis.
This is a short-term solution. Long term, inventory-manager needs to be
enhanced to allow sensors to be under a chassis, or the rest of the
project needs to move to EntityManager.
Currently IBM does not use EntityManager, but EntityManager is called
directly in sensors.hpp. This results in an HTTP 500 Internal Server
Error.
Tested: The URLs /redfish/v1/Chassis/ and /redfish/v1/Chassis/chassis
show correct data on a Witherspoon. /redfish/v1/Managers/bmc/
now has a link to the single chassis.
/redfish/v1/Chassis/chassis/Power and
/redfish/v1/Chassis/chassis/Thermal no longer result in an
HTTP 500 Internal Server Error. Ran Redfish Service Validator.
Change-Id: Iec8f4da333946f19330f37ab084cd9787c52c8ea
Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
Signed-off-by: Shawn McCarney <shawnmm@us.ibm.com>
diff --git a/redfish-core/lib/chassis.hpp b/redfish-core/lib/chassis.hpp
index 7f58ab5..d24e641 100644
--- a/redfish-core/lib/chassis.hpp
+++ b/redfish-core/lib/chassis.hpp
@@ -131,16 +131,25 @@
void doGet(crow::Response &res, const crow::Request &req,
const std::vector<std::string> ¶ms) override
{
- const std::array<const char *, 3> interfaces = {
- "xyz.openbmc_project.Inventory.Item.Board",
- "xyz.openbmc_project.Inventory.Item.Chassis",
- "xyz.openbmc_project.Inventory.Item.PowerSupply"};
res.jsonValue["@odata.type"] = "#ChassisCollection.ChassisCollection";
res.jsonValue["@odata.id"] = "/redfish/v1/Chassis";
res.jsonValue["@odata.context"] =
"/redfish/v1/$metadata#ChassisCollection.ChassisCollection";
res.jsonValue["Name"] = "Chassis Collection";
+#ifdef BMCWEB_ENABLE_REDFISH_ONE_CHASSIS
+ // Assume one Chassis named "chassis"
+ res.jsonValue["Members@odata.count"] = 1;
+ res.jsonValue["Members"] = {
+ {{"@odata.id", "/redfish/v1/Chassis/chassis"}}};
+ res.end();
+ return;
+#endif
+ const std::array<const char *, 3> interfaces = {
+ "xyz.openbmc_project.Inventory.Item.Board",
+ "xyz.openbmc_project.Inventory.Item.Chassis",
+ "xyz.openbmc_project.Inventory.Item.PowerSupply"};
+
auto asyncResp = std::make_shared<AsyncResp>(res);
crow::connections::systemBus->async_method_call(
[asyncResp](const boost::system::error_code ec,
@@ -215,6 +224,16 @@
return;
}
const std::string &chassisId = params[0];
+#ifdef BMCWEB_ENABLE_REDFISH_ONE_CHASSIS
+ // In a one chassis system the only supported name is "chassis"
+ if (chassisId != "chassis")
+ {
+ messages::resourceNotFound(res, "#Chassis.v1_4_0.Chassis",
+ chassisId);
+ res.end();
+ return;
+ }
+#endif
res.jsonValue["@odata.type"] = "#Chassis.v1_4_0.Chassis";
res.jsonValue["@odata.id"] = "/redfish/v1/Chassis/" + chassisId;
@@ -249,10 +268,13 @@
std::pair<std::string, std::vector<std::string>>>
&connectionNames = object.second;
+// If only one chassis, just select the first one
+#ifndef BMCWEB_ENABLE_REDFISH_ONE_CHASSIS
if (!boost::ends_with(path, chassisId))
{
continue;
}
+#endif
if (connectionNames.size() < 1)
{
BMCWEB_LOG_ERROR << "Only got "
diff --git a/redfish-core/lib/managers.hpp b/redfish-core/lib/managers.hpp
index 936d655..f9c2f38 100644
--- a/redfish-core/lib/managers.hpp
+++ b/redfish-core/lib/managers.hpp
@@ -968,11 +968,14 @@
"GracefulRestart"};
res.jsonValue["DateTime"] = getDateTime();
- res.jsonValue["Links"] = {
- {"ManagerForServers@odata.count", 1},
- {"ManagerForServers",
- {{{"@odata.id", "/redfish/v1/Systems/system"}}}},
- {"ManagerForServers", nlohmann::json::array()}};
+ res.jsonValue["Links"]["ManagerForServers@odata.count"] = 1;
+ res.jsonValue["Links"]["ManagerForServers"] = {
+ {{"@odata.id", "/redfish/v1/Systems/system"}}};
+#ifdef BMCWEB_ENABLE_REDFISH_ONE_CHASSIS
+ res.jsonValue["Links"]["ManagerForChassis@odata.count"] = 1;
+ res.jsonValue["Links"]["ManagerForChassis"] = {
+ {{"@odata.id", "/redfish/v1/Chassis/chassis"}}};
+#endif
std::shared_ptr<AsyncResp> asyncResp = std::make_shared<AsyncResp>(res);
crow::connections::systemBus->async_method_call(
diff --git a/redfish-core/lib/power.hpp b/redfish-core/lib/power.hpp
index c2f9b43..ebfac98 100644
--- a/redfish-core/lib/power.hpp
+++ b/redfish-core/lib/power.hpp
@@ -51,6 +51,16 @@
return;
}
const std::string& chassis_name = params[0];
+#ifdef BMCWEB_ENABLE_REDFISH_ONE_CHASSIS
+ // In a one chassis system the only supported name is "chassis"
+ if (chassis_name != "chassis")
+ {
+ messages::resourceNotFound(res, "#Chassis.v1_4_0.Chassis",
+ chassis_name);
+ res.end();
+ return;
+ }
+#endif
res.jsonValue["@odata.id"] =
"/redfish/v1/Chassis/" + chassis_name + "/Power";
@@ -58,6 +68,10 @@
res.jsonValue["@odata.context"] = "/redfish/v1/$metadata#Power.Power";
res.jsonValue["Id"] = "Power";
res.jsonValue["Name"] = "Power";
+#ifdef BMCWEB_ENABLE_REDFISH_ONE_CHASSIS
+ res.end();
+ return;
+#endif
auto sensorAsyncResp = std::make_shared<SensorsAsyncResp>(
res, chassis_name, typeList, "Power");
// TODO Need to retrieve Power Control information.
diff --git a/redfish-core/lib/systems.hpp b/redfish-core/lib/systems.hpp
index 737aa3a..255c094 100644
--- a/redfish-core/lib/systems.hpp
+++ b/redfish-core/lib/systems.hpp
@@ -1147,6 +1147,11 @@
res.jsonValue["LogServices"] = {
{"@odata.id", "/redfish/v1/Systems/system/LogServices"}};
+#ifdef BMCWEB_ENABLE_REDFISH_ONE_CHASSIS
+ res.jsonValue["Links"]["Chassis"] = {
+ {{"@odata.id", "/redfish/v1/Chassis/chassis"}}};
+#endif
+
auto asyncResp = std::make_shared<AsyncResp>(res);
getLedGroupIdentify(
diff --git a/redfish-core/lib/thermal.hpp b/redfish-core/lib/thermal.hpp
index d18b62d..5c0aa5a 100644
--- a/redfish-core/lib/thermal.hpp
+++ b/redfish-core/lib/thermal.hpp
@@ -51,6 +51,16 @@
return;
}
const std::string& chassisName = params[0];
+#ifdef BMCWEB_ENABLE_REDFISH_ONE_CHASSIS
+ // In a one chassis system the only supported name is "chassis"
+ if (chassisName != "chassis")
+ {
+ messages::resourceNotFound(res, "#Chassis.v1_4_0.Chassis",
+ chassisName);
+ res.end();
+ return;
+ }
+#endif
res.jsonValue["@odata.type"] = "#Thermal.v1_4_0.Thermal";
res.jsonValue["@odata.context"] =
@@ -60,7 +70,10 @@
res.jsonValue["@odata.id"] =
"/redfish/v1/Chassis/" + chassisName + "/Thermal";
-
+#ifdef BMCWEB_ENABLE_REDFISH_ONE_CHASSIS
+ res.end();
+ return;
+#endif
auto sensorAsyncResp = std::make_shared<SensorsAsyncResp>(
res, chassisName, typeList, "Thermal");