summaryrefslogtreecommitdiff
path: root/redfish-core/lib
diff options
context:
space:
mode:
authorEd Tanous <edtanous@google.com>2022-09-15 20:52:19 +0300
committerEd Tanous <ed@tanous.net>2022-09-17 02:52:35 +0300
commit677bb756282b3029ed7c8cbf2c0440b89b0d5928 (patch)
tree3f64bafaac93d162ef792fd4349550429d0ce18a /redfish-core/lib
parent6169de2c39d2b08451a64fbf45798ae8cb5624fb (diff)
downloadbmcweb-677bb756282b3029ed7c8cbf2c0440b89b0d5928.tar.xz
Fix regression on expand handling
It was found that as part of c1d019a6056a2a0ef50e577b3139ab5a8dc49355 Sensor optimization We missed updating the odata.id for the expand case. This wasn't really found because most clients either use expand, or they don't, and depending on which path you take, both paths are valid. With that said, we should be following the spec here, and returning the same result regardless of whether we're being processed as expand or not. This patchset is a little rough, and probably should be iterated on. TODO (at a later date). Try to get a tool that can detect these failures. Tested: Tested by @Carson to resolve the regression. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ieed7796895a3c5937fd901d5afa7dd4ea0693099
Diffstat (limited to 'redfish-core/lib')
-rw-r--r--redfish-core/lib/sensors.hpp21
1 files changed, 16 insertions, 5 deletions
diff --git a/redfish-core/lib/sensors.hpp b/redfish-core/lib/sensors.hpp
index cf63bd7078..ac69f26db4 100644
--- a/redfish-core/lib/sensors.hpp
+++ b/redfish-core/lib/sensors.hpp
@@ -2544,11 +2544,20 @@ inline void getSensorData(
}
else if (fieldName == "Members")
{
+ std::string sensorTypeEscaped(sensorType);
+ sensorTypeEscaped.erase(
+ std::remove(sensorTypeEscaped.begin(),
+ sensorTypeEscaped.end(), '_'),
+ sensorTypeEscaped.end());
+ std::string sensorId(sensorTypeEscaped);
+ sensorId += "_";
+ sensorId += sensorName;
+
nlohmann::json::object_t member;
- member["@odata.id"] =
- "/redfish/v1/Chassis/" +
- sensorsAsyncResp->chassisId + "/" +
- sensorsAsyncResp->chassisSubNode + "/" + sensorName;
+ member["@odata.id"] = crow::utility::urlFromPieces(
+ "redfish", "v1", "Chassis",
+ sensorsAsyncResp->chassisId,
+ sensorsAsyncResp->chassisSubNode, sensorId);
tempArray.push_back(std::move(member));
sensorJson = &(tempArray.back());
}
@@ -3007,7 +3016,7 @@ inline void
inline void handleSensorGet(App& app, const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& /*chassisId*/,
+ const std::string& chassisId,
const std::string& sensorId)
{
if (!redfish::setUpRedfishRoute(app, req, asyncResp))
@@ -3020,6 +3029,8 @@ inline void handleSensorGet(App& app, const crow::Request& req,
messages::resourceNotFound(asyncResp->res, sensorId, "Sensor");
return;
}
+ asyncResp->res.jsonValue["@odata.id"] = crow::utility::urlFromPieces(
+ "redfish", "v1", "Chassis", chassisId, "Sensors", sensorId);
std::string sensorType = sensorId.substr(0, index);
std::string sensorName = sensorId.substr(index + 1);
// fan_pwm and fan_tach need special handling