psusensor: Add power state for label
In the bytedance system, the vout of a psusensor is related to
powerstate, but the temp of this psusensor has nothing to do
with powerstate, so a label like: " vout1_PowerState" is needed to
mark that vout is related to powerstate, but does not affect
the temp of this psusensor
Tested: Run`ipmitool power off&&ipmitool sensor list`
the vout is na, but temp is correct.
Signed-off-by: Lotus Xu <xuxiaohan@bytedance.com>
Change-Id: I3fb17a10cffcd7fb46faa11a45582a6c00eabdfa
diff --git a/src/PSUSensorMain.cpp b/src/PSUSensorMain.cpp
index 4f7eb06..b27cecc 100644
--- a/src/PSUSensorMain.cpp
+++ b/src/PSUSensorMain.cpp
@@ -633,6 +633,7 @@
std::string keyMin = labelHead + "_Min";
std::string keyMax = labelHead + "_Max";
std::string keyOffset = labelHead + "_Offset";
+ std::string keyPowerState = labelHead + "_PowerState";
bool customizedName = false;
auto findCustomName = baseConfig->second.find(keyName);
@@ -725,6 +726,14 @@
}
}
+ // if we find label head power state set ,override the powerstate.
+ auto findPowerState = baseConfig->second.find(keyPowerState);
+ if (findPowerState != baseConfig->second.end())
+ {
+ std::string powerState = std::visit(VariantToStringVisitor(),
+ findPowerState->second);
+ setReadState(powerState, readState);
+ }
if (!(psuProperty->minReading < psuProperty->maxReading))
{
std::cerr << "Min must be less than Max\n";