diff options
author | Cheng C Yang <cheng.c.yang@intel.com> | 2019-11-06 10:21:30 +0300 |
---|---|---|
committer | Yang, Cheng C <cheng.c.yang@intel.com> | 2019-11-11 02:48:33 +0300 |
commit | 0dd0eec0a7064fa0314fcab5d86e54826fb84f88 (patch) | |
tree | 56eb6811ddb9037ff9167591a912c51a5d30f9bb /psu-manager | |
parent | b21586a85b6b434dc90b35285f363f97384fcdd4 (diff) | |
download | provingground-0dd0eec0a7064fa0314fcab5d86e54826fb84f88.tar.xz |
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 <cheng.c.yang@intel.com>
Diffstat (limited to 'psu-manager')
-rw-r--r-- | psu-manager/include/cold_redundancy.hpp | 14 | ||||
-rw-r--r-- | 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<std::string, std::string, std::string>; + class ColdRedundancy : sdbusplus::xyz::openbmc_project::Control::server::PowerSupplyRedundancy { @@ -32,7 +34,10 @@ class ColdRedundancy sdbusplus::asio::object_server& objectServer, std::shared_ptr<sdbusplus::asio::connection>& dbusConnection, std::vector<std::unique_ptr<sdbusplus::bus::match::match>>& 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<sdbusplus::asio::connection>& 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<sdbusplus::asio::dbus_interface> association; + std::vector<Association> associationsOk; + std::vector<Association> associationsWarning; + std::vector<Association> associationsNonCrit; + std::vector<Association> 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<std::unique_ptr<PowerSupply>> powerSupplies; static std::vector<uint64_t> 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); } } } |