summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com>2019-05-27 23:16:40 +0530
committerEd Tanous <ed.tanous@intel.com>2019-06-06 15:18:37 +0000
commit0a86febd7fda49d692666ab4ddd9efccf352c4d8 (patch)
tree99684fd664c61a2be18d9676f6823d32e81f0b02
parentd62cec731dcb533b3fecb08ba115dbf713539681 (diff)
downloadbmcweb-0a86febd7fda49d692666ab4ddd9efccf352c4d8.tar.gz
bmcweb-0a86febd7fda49d692666ab4ddd9efccf352c4d8.zip
bmcweb: Fix sensor name identification method
Sensor name was calculated based on 5th elemennt is not applicable any more. Get the last token in the path, which is the sensor name, which is used as member_id. Tested: 1. Verified the PATCH method for thermal & power overriding, temperatures, fans & voltages. Overriding works as expected. Change-Id: I08291171496a979f120a57ac0802733007e11871 Signed-off-by: Richard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com>
-rw-r--r--redfish-core/lib/sensors.hpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/redfish-core/lib/sensors.hpp b/redfish-core/lib/sensors.hpp
index 86e5a07..8309610 100644
--- a/redfish-core/lib/sensors.hpp
+++ b/redfish-core/lib/sensors.hpp
@@ -1051,20 +1051,18 @@ void getChassisData(std::shared_ptr<SensorsAsyncResp> SensorsAsyncResp)
* repeated calls to this function
*/
bool findSensorNameUsingSensorPath(
- const std::string& sensorName,
+ std::string_view sensorName,
boost::container::flat_set<std::string>& sensorsList,
boost::container::flat_set<std::string>& sensorsModified)
{
- for (const std::string& chassisSensor : sensorsList)
+ for (std::string_view chassisSensor : sensorsList)
{
- std::string thisSensorName;
- if (!dbus::utility::getNthStringFromPath(chassisSensor, 5,
- thisSensorName))
+ std::size_t pos = chassisSensor.rfind("/");
+ if (pos >= (chassisSensor.size() - 1))
{
- BMCWEB_LOG_ERROR << "Got path that isn't long enough "
- << chassisSensor;
continue;
}
+ std::string_view thisSensorName = chassisSensor.substr(pos + 1);
if (thisSensorName == sensorName)
{
sensorsModified.emplace(chassisSensor);
OpenPOWER on IntegriCloud