From 0dd0eec0a7064fa0314fcab5d86e54826fb84f88 Mon Sep 17 00:00:00 2001 From: Cheng C Yang Date: Wed, 6 Nov 2019 15:21:30 +0800 Subject: Add LED Support for Power Redundancy Add status LED support for Power Unit Redundancy. Tested: AC off or remove one PSU, status LED changes to amber blinking. AC on the PSU again, status LED changes back to solid green. Change-Id: I86c9e03c0e2a5f035a6bf5140c850c1551fb40a7 Signed-off-by: Cheng C Yang --- psu-manager/include/cold_redundancy.hpp | 14 +++++++++++++- psu-manager/src/cold_redundancy.cpp | 28 +++++++++++++++++++++++++++- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/psu-manager/include/cold_redundancy.hpp b/psu-manager/include/cold_redundancy.hpp index 8597615..cd7a5f6 100644 --- a/psu-manager/include/cold_redundancy.hpp +++ b/psu-manager/include/cold_redundancy.hpp @@ -23,6 +23,8 @@ const constexpr char* psuInterface = const constexpr int secondsInOneDay = 86400; const constexpr uint8_t bmcSpecific = 0; +using Association = std::tuple; + class ColdRedundancy : sdbusplus::xyz::openbmc_project::Control::server::PowerSupplyRedundancy { @@ -32,7 +34,10 @@ class ColdRedundancy sdbusplus::asio::object_server& objectServer, std::shared_ptr& dbusConnection, std::vector>& matches); - ~ColdRedundancy() = default; + ~ColdRedundancy() + { + objServer.remove_interface(association); + }; uint8_t pSUNumber() const override; void @@ -62,6 +67,7 @@ class ColdRedundancy void checkRedundancyEvent(); + sdbusplus::asio::object_server& objServer; std::shared_ptr& systemBus; boost::asio::steady_timer timerRotation; @@ -71,6 +77,12 @@ class ColdRedundancy boost::asio::steady_timer keepAliveTimer; boost::asio::steady_timer filterTimer; boost::asio::steady_timer puRedundantTimer; + + std::shared_ptr association; + std::vector associationsOk; + std::vector associationsWarning; + std::vector associationsNonCrit; + std::vector associationsCrit; }; constexpr const uint8_t pmbusCmdCRSupport = 0xd0; diff --git a/psu-manager/src/cold_redundancy.cpp b/psu-manager/src/cold_redundancy.cpp index 7e7c39e..bc902ab 100644 --- a/psu-manager/src/cold_redundancy.cpp +++ b/psu-manager/src/cold_redundancy.cpp @@ -40,6 +40,7 @@ static const constexpr char* inventoryPath = static const constexpr char* eventPath = "/xyz/openbmc_project/State/Decorator"; static const constexpr char* coldRedundancyPath = "/xyz/openbmc_project/control/power_supply_redundancy"; +static const constexpr char* rootPath = "/xyz/openbmc_project/CallbackManager"; static std::vector> powerSupplies; static std::vector addrTable = {0x50, 0x51}; @@ -53,8 +54,25 @@ ColdRedundancy::ColdRedundancy( *systemBus, coldRedundancyPath), timerRotation(io), timerCheck(io), systemBus(systemBus), warmRedundantTimer1(io), warmRedundantTimer2(io), keepAliveTimer(io), - filterTimer(io), puRedundantTimer(io) + filterTimer(io), puRedundantTimer(io), objServer(objectServer) { + associationsOk.emplace_back("", "", ""); + associationsWarning.emplace_back("", "warning", coldRedundancyPath); + associationsWarning.emplace_back("", "warning", rootPath); + associationsNonCrit.emplace_back("", "critical", coldRedundancyPath); + associationsNonCrit.emplace_back("", "warning", rootPath); + associationsCrit.emplace_back("", "critical", coldRedundancyPath); + associationsCrit.emplace_back("", "critical", rootPath); + + association = objectServer.add_interface( + coldRedundancyPath, "xyz.openbmc_project.Association.Definitions"); + association->register_property("Associations", associationsOk); + + if (!association->initialize()) + { + std::cerr << "error initializing assoc interface\n"; + } + io.post([this, &io, &objectServer, &systemBus]() { createPSU(io, objectServer, systemBus); }); @@ -763,6 +781,7 @@ void ColdRedundancy::checkRedundancyEvent() "MESSAGE=%s", "Power Unit Full Redundancy Regained", "PRIORITY=%i", LOG_INFO, "REDFISH_MESSAGE_ID=%s", "OpenBMC.0.1.PowerUnitRedundancyRegained", NULL); + association->set_property("Associations", associationsOk); } else if (psuPreviousWorkable <= redundancyPSURequire) { @@ -774,6 +793,8 @@ void ColdRedundancy::checkRedundancyEvent() "Redundancy", "PRIORITY=%i", LOG_INFO, "REDFISH_MESSAGE_ID=%s", "OpenBMC.0.1.PowerUnitDegradedFromNonRedundant", NULL); + association->set_property("Associations", + associationsWarning); } } else if (psuPreviousWorkable == 0) @@ -786,6 +807,7 @@ void ColdRedundancy::checkRedundancyEvent() "Power Unit Redundancy Sufficient from insufficient", "PRIORITY=%i", LOG_INFO, "REDFISH_MESSAGE_ID=%s", "OpenBMC.0.1.PowerUnitNonRedundantFromInsufficient", NULL); + association->set_property("Associations", associationsNonCrit); } } else if (psuWorkable < psuPreviousWorkable) @@ -798,6 +820,7 @@ void ColdRedundancy::checkRedundancyEvent() "MESSAGE=%s", "Power Unit Redundancy Degraded", "PRIORITY=%i", LOG_WARNING, "REDFISH_MESSAGE_ID=%s", "OpenBMC.0.1.PowerUnitRedundancyDegraded", NULL); + association->set_property("Associations", associationsWarning); if (psuPreviousWorkable == numberOfPSU) { @@ -830,6 +853,8 @@ void ColdRedundancy::checkRedundancyEvent() "PRIORITY=%i", LOG_WARNING, "REDFISH_MESSAGE_ID=%s", "OpenBMC.0.1.PowerUnitNonRedundantSufficient", NULL); + association->set_property("Associations", + associationsNonCrit); } } if (psuWorkable == 0) @@ -839,6 +864,7 @@ void ColdRedundancy::checkRedundancyEvent() "MESSAGE=%s", "Power Unit Redundancy Insufficient", "PRIORITY=%i", LOG_ERR, "REDFISH_MESSAGE_ID=%s", "OpenBMC.0.1.PowerUnitNonRedundantInsufficient", NULL); + association->set_property("Associations", associationsCrit); } } } -- cgit v1.2.3