From 3fd2cd71a5d228b3f8ceb793dd6e6b857175e435 Mon Sep 17 00:00:00 2001 From: Cheng C Yang Date: Tue, 29 Oct 2019 14:58:41 +0800 Subject: Fix PSU number incorrect issue. When remove PSU2, it will report PSU1 removed log. Correct this logic bug. Tested: Remove PSU2, PSU2 removed Redfish log is recorded. Insert PSU2, PSU2 inserted Redfish log is recorded. Change-Id: Ifba3175b6ac965cb35de2283d59b7b058985fe0b Signed-off-by: Cheng C Yang --- psu-manager/src/cold_redundancy.cpp | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/psu-manager/src/cold_redundancy.cpp b/psu-manager/src/cold_redundancy.cpp index c8fdcd4..7e7c39e 100644 --- a/psu-manager/src/cold_redundancy.cpp +++ b/psu-manager/src/cold_redundancy.cpp @@ -286,31 +286,29 @@ void keepAlive(std::shared_ptr& dbusConnection) if (0 == pingPSU(addr)) { auto found = psuPresence.find(addr); - if (found != psuPresence.end()) + if (found == psuPresence.end()) { - continue; + newPSUFound = true; + psuPresence.emplace(addr); + std::string psuNumStr = "PSU" + std::to_string(psuNumber); + sd_journal_send( + "MESSAGE=%s", "New PSU is found", "PRIORITY=%i", LOG_INFO, + "REDFISH_MESSAGE_ID=%s", "OpenBMC.0.1.PowerSupplyInserted", + "REDFISH_MESSAGE_ARGS=%s", psuNumStr.c_str(), NULL); } - newPSUFound = true; - psuPresence.emplace(addr); - std::string psuNumStr = "PSU" + std::to_string(psuNumber); - sd_journal_send("MESSAGE=%s", "New PSU is found", "PRIORITY=%i", - LOG_INFO, "REDFISH_MESSAGE_ID=%s", - "OpenBMC.0.1.PowerSupplyInserted", - "REDFISH_MESSAGE_ARGS=%s", psuNumStr.c_str(), NULL); } else { auto found = psuPresence.find(addr); - if (found == psuPresence.end()) + if (found != psuPresence.end()) { - continue; + psuPresence.erase(addr); + std::string psuNumStr = "PSU" + std::to_string(psuNumber); + sd_journal_send( + "MESSAGE=%s", "One PSU is removed", "PRIORITY=%i", LOG_INFO, + "REDFISH_MESSAGE_ID=%s", "OpenBMC.0.1.PowerSupplyRemoved", + "REDFISH_MESSAGE_ARGS=%s", psuNumStr.c_str(), NULL); } - psuPresence.erase(addr); - std::string psuNumStr = "PSU" + std::to_string(psuNumber); - sd_journal_send("MESSAGE=%s", "One PSU is removed", "PRIORITY=%i", - LOG_INFO, "REDFISH_MESSAGE_ID=%s", - "OpenBMC.0.1.PowerSupplyRemoved", - "REDFISH_MESSAGE_ARGS=%s", psuNumStr.c_str(), NULL); } psuNumber++; } -- cgit v1.2.3