psu-ng: Use a separate map for required PSUs data
Use a different map for collecting the additional error data from the
hasRequiredPSUs() check, to avoid polluting other faults with data
collected from that call. Only make the hasRequiredPSUs() call if a
power supply is seen as not present, to avoid needlessly calling it
every time the analyze() function is called. If there is a power supply
detected as not present, then merge the data into the additionalData.
Tested:
Verified comm fault error details did not include additional data.
Prior to change, doubled up PSU call out, and expected/actual count.
Change-Id: Ib3fb125b56a74d3b70136897c007fd077306716f
Signed-off-by: Brandon Wyman <bjwyman@gmail.com>
diff --git a/phosphor-power-supply/psu_manager.cpp b/phosphor-power-supply/psu_manager.cpp
index 0a78a4d..378c0c1 100644
--- a/phosphor-power-supply/psu_manager.cpp
+++ b/phosphor-power-supply/psu_manager.cpp
@@ -374,15 +374,17 @@
if (powerOn)
{
std::map<std::string, std::string> additionalData;
- auto requiredPSUsPresent = hasRequiredPSUs(additionalData);
for (auto& psu : psus)
{
// TODO: Fault priorities #918
if (!psu->isFaultLogged() && !psu->isPresent())
{
+ std::map<std::string, std::string> requiredPSUsData;
+ auto requiredPSUsPresent = hasRequiredPSUs(requiredPSUsData);
if (!requiredPSUsPresent)
{
+ additionalData.merge(requiredPSUsData);
// Create error for power supply missing.
additionalData["CALLOUT_INVENTORY_PATH"] =
psu->getInventoryPath();