diff options
author | Cheng C Yang <cheng.c.yang@intel.com> | 2019-10-29 09:58:41 +0300 |
---|---|---|
committer | Yang, Cheng C <cheng.c.yang@intel.com> | 2019-10-30 04:23:57 +0300 |
commit | 3fd2cd71a5d228b3f8ceb793dd6e6b857175e435 (patch) | |
tree | 073b5c321df295fdca859c9359b733dd7034fffc | |
parent | d9c17f8494700cb3ae079181d417e3e123d215f8 (diff) | |
download | provingground-3fd2cd71a5d228b3f8ceb793dd6e6b857175e435.tar.xz |
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 <cheng.c.yang@intel.com>
-rw-r--r-- | psu-manager/src/cold_redundancy.cpp | 32 |
1 files 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<sdbusplus::asio::connection>& 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++; } |