summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPotin Lai <potin.lai@quantatw.com>2023-02-14 09:28:58 +0300
committerEd Tanous <ed@tanous.net>2023-05-10 20:06:50 +0300
commitcddbf3df0ea0b78521b62f30f2ce764c6619018a (patch)
tree10e7ec2048e78f965a49d0be9cb2d775c0e30513
parent662aa6e361f8705cfd91261080324ff0e74778e4 (diff)
downloadbmcweb-cddbf3df0ea0b78521b62f30f2ce764c6619018a.tar.xz
managers: fix bug of searching dbus object path
Notice a bug of patching existed object if the object name contains space or underscore. Normally dbus replace space with underscore for object path. Replacing all spaces in input name with underscore to find the correct dbus object path. Tested results: - Add new object Input JSON ``` { "Oem": { "OpenBmc": { "Fan": { "StepwiseControllers": { "Test_1": { "Direction": "Floor", "Inputs": [ "MB_U402_THERM_LOCAL" ], "NegativeHysteresis": 0.0, "PositiveHysteresis": 0.0, "Steps": [ { "Output": 0.0, "Target": 48.0 }, { "Output": 40.0, "Target": 52.0 } ], "Zones": [ { "@odata.id": "/redfish/v1/Managers/bmc#/Oem/OpenBmc/Fan/FanZones/Zone0" } ] } } } } } } ``` Check result from /redfish/v1/Managers/bmc ``` "Test_1": { "@odata.id": "/redfish/v1/Managers/bmc#/Oem/OpenBmc/Fan/StepwiseControllers/Test_1", "@odata.type": "#OemManager.StepwiseController", "Direction": "Floor", "Inputs": [ "MB U402 THERM LOCAL" ], "NegativeHysteresis": 0.0, "PositiveHysteresis": 0.0, "Steps": [ { "Output": 0.0, "Target": 48.0 }, { "Output": 40.0, "Target": 52.0 } ], "Zones": [ { "@odata.id": "/redfish/v1/Managers/bmc#/Oem/OpenBmc/Fan/FanZones/Zone0" } ] } ``` - Patching existed object successful Input JSON ``` { "Oem": { "OpenBmc": { "Fan": { "StepwiseControllers": { "Test_1": { "NegativeHysteresis": 0.0, "PositiveHysteresis": 5.0, } } } } } } ``` Check result from /redfish/v1/Managers/bmc ``` "Test_1": { "@odata.id": "/redfish/v1/Managers/bmc#/Oem/OpenBmc/Fan/StepwiseControllers/Test_1", "@odata.type": "#OemManager.StepwiseController", "Direction": "Floor", "Inputs": [ "MB U402 THERM LOCAL" ], "NegativeHysteresis": 0.0, "PositiveHysteresis": 5.0, "Steps": [ { "Output": 0.0, "Target": 48.0 }, { "Output": 40.0, "Target": 52.0 } ], "Zones": [ { "@odata.id": "/redfish/v1/Managers/bmc#/Oem/OpenBmc/Fan/FanZones/Zone0" } ] } ``` Signed-off-by: Potin Lai <potin.lai@quantatw.com> Change-Id: I12c78e52801bd0814ba2d928cf020e0a04214c39
-rw-r--r--redfish-core/lib/managers.hpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/redfish-core/lib/managers.hpp b/redfish-core/lib/managers.hpp
index ba63dc4c89..6e1427b344 100644
--- a/redfish-core/lib/managers.hpp
+++ b/redfish-core/lib/managers.hpp
@@ -1504,13 +1504,15 @@ struct SetPIDValues : std::enable_shared_from_this<SetPIDValues>
it != container->end(); ++it)
{
const auto& name = it.key();
+ std::string dbusObjName = name;
+ std::replace(dbusObjName.begin(), dbusObjName.end(), ' ', '_');
BMCWEB_LOG_DEBUG << "looking for " << name;
auto pathItr =
std::find_if(managedObj.begin(), managedObj.end(),
- [&name](const auto& obj) {
+ [&dbusObjName](const auto& obj) {
return boost::algorithm::ends_with(obj.first.str,
- "/" + name);
+ "/" + dbusObjName);
});
dbus::utility::DBusPropertiesMap output;