psusensor: fix sensor name matching during rescan
When psusensor is created, sensor name is modified using
boost::replace_all_copy(sensorName, " ", "_").
Apply the same call when matching up sensor name string in base config
and name of the sensor object.
Without this change, psusensor service does not create sensor object if
pmbus configuration has spaces in Name field, like
{
...
"Name" : "PSU$BUS $ADDRESS"
...
}
Tested:
psu sensor name with space are created correctly with the change.
Example"
busctl introspect xyz.openbmc_project.EntityManager /xyz/openbmc_project/inventory/system/powersupply/SOLUM_CO_IS162F22_PSU2_Node_1/PSU17_2
...
xyz.openbmc_project.Configuration.pmbus interface - - -
.Address property t 89 emits-change
.Bus property t 17 emits-change
.Labels property as 8 "pin" "pout1" "vin" "iin" "iout1" "... emits-change
.Name property s "PSU17 2" emits-change
.Name1 property s "PSU17 2" emits-change
.Type property s "pmbus" emits-change
...
Signed-off-by: Zhikui Ren <zhikui.ren@intel.com>
Change-Id: Ie8fdbe78bdd88de5dc7db3f065c74cd9872e9d86
diff --git a/src/PSUSensorMain.cpp b/src/PSUSensorMain.cpp
index 7576e68..fd151d9 100644
--- a/src/PSUSensorMain.cpp
+++ b/src/PSUSensorMain.cpp
@@ -425,7 +425,8 @@
// on rescans, only update sensors we were signaled by
if (!firstScan)
{
- std::string psuNameStr = "/" + *psuName;
+ std::string psuNameStr =
+ "/" + boost::replace_all_copy(*psuName, " ", "_");
auto it =
std::find_if(sensorsChanged->begin(), sensorsChanged->end(),
[psuNameStr](std::string& s) {