summaryrefslogtreecommitdiff
path: root/redfish-core/lib/chassis.hpp
diff options
context:
space:
mode:
authorGunnar Mills <gmills@us.ibm.com>2019-01-22 02:03:51 +0300
committerEd Tanous <ed.tanous@intel.com>2019-03-13 19:09:30 +0300
commit603a664025801fd02079298374781f49ce816e5b (patch)
tree8b8a43dae8fe594c544527a68b83297f89015fd0 /redfish-core/lib/chassis.hpp
parent9474b3788017bddd70e493e2b9b7674be30abc87 (diff)
downloadbmcweb-603a664025801fd02079298374781f49ce816e5b.tar.xz
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>
Diffstat (limited to 'redfish-core/lib/chassis.hpp')
-rw-r--r--redfish-core/lib/chassis.hpp30
1 files changed, 26 insertions, 4 deletions
diff --git a/redfish-core/lib/chassis.hpp b/redfish-core/lib/chassis.hpp
index 7f58ab5ba5..d24e641595 100644
--- a/redfish-core/lib/chassis.hpp
+++ b/redfish-core/lib/chassis.hpp
@@ -131,16 +131,25 @@ class ChassisCollection : public Node
void doGet(crow::Response &res, const crow::Request &req,
const std::vector<std::string> &params) 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 @@ class Chassis : public Node
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 @@ class Chassis : public Node
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 "