Cheng C Yang | 58b2b53 | 2019-05-31 00:19:45 +0800 | [diff] [blame] | 1 | /* |
| 2 | // Copyright (c) 2019 Intel Corporation |
| 3 | // |
| 4 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | // you may not use this file except in compliance with the License. |
| 6 | // You may obtain a copy of the License at |
| 7 | // |
| 8 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | // |
| 10 | // Unless required by applicable law or agreed to in writing, software |
| 11 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | // See the License for the specific language governing permissions and |
| 14 | // limitations under the License. |
| 15 | */ |
| 16 | |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 17 | #include <PSUEvent.hpp> |
Ed Tanous | 6cb732a | 2021-02-18 15:33:51 -0800 | [diff] [blame] | 18 | #include <SensorPaths.hpp> |
James Feist | 8086aba | 2020-08-25 16:00:59 -0700 | [diff] [blame] | 19 | #include <boost/asio/io_service.hpp> |
| 20 | #include <boost/asio/read_until.hpp> |
Patrick Venture | 96e97db | 2019-10-31 13:44:38 -0700 | [diff] [blame] | 21 | #include <boost/container/flat_map.hpp> |
Patrick Williams | 0c42f40 | 2021-08-27 16:05:45 -0500 | [diff] [blame] | 22 | #include <phosphor-logging/lg2.hpp> |
Cheng C Yang | 58b2b53 | 2019-05-31 00:19:45 +0800 | [diff] [blame] | 23 | #include <sdbusplus/asio/connection.hpp> |
| 24 | #include <sdbusplus/asio/object_server.hpp> |
James Feist | 38fb598 | 2020-05-28 10:09:54 -0700 | [diff] [blame] | 25 | |
| 26 | #include <iostream> |
| 27 | #include <memory> |
Patrick Venture | 96e97db | 2019-10-31 13:44:38 -0700 | [diff] [blame] | 28 | #include <stdexcept> |
| 29 | #include <string> |
| 30 | #include <utility> |
| 31 | #include <variant> |
| 32 | #include <vector> |
Cheng C Yang | 58b2b53 | 2019-05-31 00:19:45 +0800 | [diff] [blame] | 33 | |
| 34 | PSUCombineEvent::PSUCombineEvent( |
Yong Li | 3046a02 | 2020-04-03 13:01:02 +0800 | [diff] [blame] | 35 | sdbusplus::asio::object_server& objectServer, |
| 36 | std::shared_ptr<sdbusplus::asio::connection>& conn, |
| 37 | boost::asio::io_service& io, const std::string& psuName, |
Konstantin Aladyshev | c7a1ae6 | 2021-04-30 08:50:43 +0000 | [diff] [blame] | 38 | const PowerState& powerState, |
Cheng C Yang | 58b2b53 | 2019-05-31 00:19:45 +0800 | [diff] [blame] | 39 | boost::container::flat_map<std::string, std::vector<std::string>>& |
| 40 | eventPathList, |
Cheng C Yang | 202a1ff | 2020-01-09 09:34:22 +0800 | [diff] [blame] | 41 | boost::container::flat_map< |
| 42 | std::string, |
| 43 | boost::container::flat_map<std::string, std::vector<std::string>>>& |
| 44 | groupEventPathList, |
Lei YU | 7170a23 | 2021-02-04 16:19:27 +0800 | [diff] [blame] | 45 | const std::string& combineEventName, double pollRate) : |
Cheng C Yang | 58b2b53 | 2019-05-31 00:19:45 +0800 | [diff] [blame] | 46 | objServer(objectServer) |
| 47 | { |
Ed Tanous | 6cb732a | 2021-02-18 15:33:51 -0800 | [diff] [blame] | 48 | std::string psuNameEscaped = sensor_paths::escapePathForDbus(psuName); |
Cheng C Yang | 58b2b53 | 2019-05-31 00:19:45 +0800 | [diff] [blame] | 49 | eventInterface = objServer.add_interface( |
Ed Tanous | 6cb732a | 2021-02-18 15:33:51 -0800 | [diff] [blame] | 50 | "/xyz/openbmc_project/State/Decorator/" + psuNameEscaped + "_" + |
Cheng C Yang | 58b2b53 | 2019-05-31 00:19:45 +0800 | [diff] [blame] | 51 | combineEventName, |
| 52 | "xyz.openbmc_project.State.Decorator.OperationalStatus"); |
James Feist | b6c0b91 | 2019-07-09 12:21:44 -0700 | [diff] [blame] | 53 | eventInterface->register_property("functional", true); |
Cheng C Yang | 58b2b53 | 2019-05-31 00:19:45 +0800 | [diff] [blame] | 54 | |
| 55 | if (!eventInterface->initialize()) |
| 56 | { |
| 57 | std::cerr << "error initializing event interface\n"; |
| 58 | } |
| 59 | |
| 60 | std::shared_ptr<std::set<std::string>> combineEvent = |
| 61 | std::make_shared<std::set<std::string>>(); |
| 62 | for (const auto& pathList : eventPathList) |
| 63 | { |
Yong Li | 591b1e4 | 2019-12-19 17:46:31 +0800 | [diff] [blame] | 64 | std::shared_ptr<std::set<std::string>> assert = |
| 65 | std::make_shared<std::set<std::string>>(); |
Cheng C Yang | 202a1ff | 2020-01-09 09:34:22 +0800 | [diff] [blame] | 66 | std::shared_ptr<bool> state = std::make_shared<bool>(false); |
Yong Li | 591b1e4 | 2019-12-19 17:46:31 +0800 | [diff] [blame] | 67 | |
Cheng C Yang | 58b2b53 | 2019-05-31 00:19:45 +0800 | [diff] [blame] | 68 | const std::string& eventName = pathList.first; |
| 69 | std::string eventPSUName = eventName + psuName; |
| 70 | for (const auto& path : pathList.second) |
| 71 | { |
Yong Li | bf8b1da | 2020-04-15 16:32:50 +0800 | [diff] [blame] | 72 | auto p = std::make_shared<PSUSubEvent>( |
Konstantin Aladyshev | c7a1ae6 | 2021-04-30 08:50:43 +0000 | [diff] [blame] | 73 | eventInterface, path, conn, io, powerState, eventName, |
| 74 | eventName, assert, combineEvent, state, psuName, pollRate); |
Yong Li | bf8b1da | 2020-04-15 16:32:50 +0800 | [diff] [blame] | 75 | p->setupRead(); |
| 76 | |
| 77 | events[eventPSUName].emplace_back(p); |
Cheng C Yang | 58b2b53 | 2019-05-31 00:19:45 +0800 | [diff] [blame] | 78 | asserts.emplace_back(assert); |
| 79 | states.emplace_back(state); |
| 80 | } |
| 81 | } |
Cheng C Yang | 202a1ff | 2020-01-09 09:34:22 +0800 | [diff] [blame] | 82 | |
| 83 | for (const auto& groupPathList : groupEventPathList) |
| 84 | { |
| 85 | for (const auto& pathList : groupPathList.second) |
| 86 | { |
| 87 | std::shared_ptr<std::set<std::string>> assert = |
| 88 | std::make_shared<std::set<std::string>>(); |
| 89 | std::shared_ptr<bool> state = std::make_shared<bool>(false); |
| 90 | |
| 91 | const std::string& groupEventName = pathList.first; |
| 92 | std::string eventPSUName = groupEventName + psuName; |
| 93 | for (const auto& path : pathList.second) |
| 94 | { |
Yong Li | bf8b1da | 2020-04-15 16:32:50 +0800 | [diff] [blame] | 95 | auto p = std::make_shared<PSUSubEvent>( |
Konstantin Aladyshev | c7a1ae6 | 2021-04-30 08:50:43 +0000 | [diff] [blame] | 96 | eventInterface, path, conn, io, powerState, groupEventName, |
Lei YU | 7170a23 | 2021-02-04 16:19:27 +0800 | [diff] [blame] | 97 | groupPathList.first, assert, combineEvent, state, psuName, |
| 98 | pollRate); |
Yong Li | bf8b1da | 2020-04-15 16:32:50 +0800 | [diff] [blame] | 99 | p->setupRead(); |
| 100 | events[eventPSUName].emplace_back(p); |
| 101 | |
Cheng C Yang | 202a1ff | 2020-01-09 09:34:22 +0800 | [diff] [blame] | 102 | asserts.emplace_back(assert); |
| 103 | states.emplace_back(state); |
| 104 | } |
| 105 | } |
| 106 | } |
Cheng C Yang | 58b2b53 | 2019-05-31 00:19:45 +0800 | [diff] [blame] | 107 | } |
| 108 | |
| 109 | PSUCombineEvent::~PSUCombineEvent() |
| 110 | { |
Cheng C Yang | 202a1ff | 2020-01-09 09:34:22 +0800 | [diff] [blame] | 111 | // Clear unique_ptr first |
| 112 | for (auto& event : events) |
| 113 | { |
| 114 | for (auto& subEventPtr : event.second) |
| 115 | { |
| 116 | subEventPtr.reset(); |
| 117 | } |
| 118 | } |
Cheng C Yang | 58b2b53 | 2019-05-31 00:19:45 +0800 | [diff] [blame] | 119 | events.clear(); |
| 120 | objServer.remove_interface(eventInterface); |
| 121 | } |
| 122 | |
Cheng C Yang | 9b53a62 | 2019-08-27 22:13:58 +0800 | [diff] [blame] | 123 | static boost::container::flat_map<std::string, |
| 124 | std::pair<std::string, std::string>> |
| 125 | logID = { |
| 126 | {"PredictiveFailure", |
| 127 | {"OpenBMC.0.1.PowerSupplyFailurePredicted", |
| 128 | "OpenBMC.0.1.PowerSupplyPredictedFailureRecovered"}}, |
| 129 | {"Failure", |
| 130 | {"OpenBMC.0.1.PowerSupplyFailed", "OpenBMC.0.1.PowerSupplyRecovered"}}, |
| 131 | {"ACLost", |
Cheng C Yang | bb732ef | 2019-09-18 16:25:58 +0800 | [diff] [blame] | 132 | {"OpenBMC.0.1.PowerSupplyPowerLost", |
| 133 | "OpenBMC.0.1.PowerSupplyPowerRestored"}}, |
Cheng C Yang | 9b53a62 | 2019-08-27 22:13:58 +0800 | [diff] [blame] | 134 | {"FanFault", |
| 135 | {"OpenBMC.0.1.PowerSupplyFanFailed", |
| 136 | "OpenBMC.0.1.PowerSupplyFanRecovered"}}, |
jayaprakash Mutyala | d12f23e | 2019-12-03 23:03:52 +0000 | [diff] [blame] | 137 | {"ConfigureError", |
| 138 | {"OpenBMC.0.1.PowerSupplyConfigurationError", |
| 139 | "OpenBMC.0.1.PowerSupplyConfigurationErrorRecovered"}}}; |
Cheng C Yang | 5665db2 | 2019-07-12 00:57:30 +0800 | [diff] [blame] | 140 | |
Cheng C Yang | 58b2b53 | 2019-05-31 00:19:45 +0800 | [diff] [blame] | 141 | PSUSubEvent::PSUSubEvent( |
| 142 | std::shared_ptr<sdbusplus::asio::dbus_interface> eventInterface, |
Yong Li | 3046a02 | 2020-04-03 13:01:02 +0800 | [diff] [blame] | 143 | const std::string& path, std::shared_ptr<sdbusplus::asio::connection>& conn, |
Konstantin Aladyshev | c7a1ae6 | 2021-04-30 08:50:43 +0000 | [diff] [blame] | 144 | boost::asio::io_service& io, const PowerState& powerState, |
| 145 | const std::string& groupEventName, const std::string& eventName, |
Cheng C Yang | 58b2b53 | 2019-05-31 00:19:45 +0800 | [diff] [blame] | 146 | std::shared_ptr<std::set<std::string>> asserts, |
| 147 | std::shared_ptr<std::set<std::string>> combineEvent, |
Lei YU | 7170a23 | 2021-02-04 16:19:27 +0800 | [diff] [blame] | 148 | std::shared_ptr<bool> state, const std::string& psuName, double pollRate) : |
Ed Tanous | 2049bd2 | 2022-07-09 07:20:26 -0700 | [diff] [blame] | 149 | eventInterface(std::move(eventInterface)), |
| 150 | asserts(std::move(asserts)), combineEvent(std::move(combineEvent)), |
| 151 | assertState(std::move(state)), path(path), eventName(eventName), |
Ed Tanous | 16966b5 | 2021-09-15 15:06:59 -0700 | [diff] [blame] | 152 | readState(powerState), waitTimer(io), |
| 153 | |
| 154 | inputDev(io, path, boost::asio::random_access_file::read_only), |
| 155 | psuName(psuName), groupEventName(groupEventName), systemBus(conn) |
Cheng C Yang | 58b2b53 | 2019-05-31 00:19:45 +0800 | [diff] [blame] | 156 | { |
Ed Tanous | 16966b5 | 2021-09-15 15:06:59 -0700 | [diff] [blame] | 157 | buffer = std::make_shared<std::array<char, 128>>(); |
Lei YU | 7170a23 | 2021-02-04 16:19:27 +0800 | [diff] [blame] | 158 | if (pollRate > 0.0) |
| 159 | { |
| 160 | eventPollMs = static_cast<unsigned int>(pollRate * 1000); |
| 161 | } |
Ed Tanous | 99c4409 | 2022-01-14 09:59:09 -0800 | [diff] [blame] | 162 | |
Cheng C Yang | 5665db2 | 2019-07-12 00:57:30 +0800 | [diff] [blame] | 163 | auto found = logID.find(eventName); |
| 164 | if (found == logID.end()) |
| 165 | { |
Cheng C Yang | 9b53a62 | 2019-08-27 22:13:58 +0800 | [diff] [blame] | 166 | assertMessage.clear(); |
| 167 | deassertMessage.clear(); |
Cheng C Yang | 5665db2 | 2019-07-12 00:57:30 +0800 | [diff] [blame] | 168 | } |
| 169 | else |
| 170 | { |
Cheng C Yang | 9b53a62 | 2019-08-27 22:13:58 +0800 | [diff] [blame] | 171 | assertMessage = found->second.first; |
| 172 | deassertMessage = found->second.second; |
Cheng C Yang | 5665db2 | 2019-07-12 00:57:30 +0800 | [diff] [blame] | 173 | } |
| 174 | |
| 175 | auto fanPos = path.find("fan"); |
| 176 | if (fanPos != std::string::npos) |
| 177 | { |
| 178 | fanName = path.substr(fanPos); |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 179 | auto fanNamePos = fanName.find('_'); |
Cheng C Yang | 9b53a62 | 2019-08-27 22:13:58 +0800 | [diff] [blame] | 180 | if (fanNamePos != std::string::npos) |
| 181 | { |
| 182 | fanName = fanName.substr(0, fanNamePos); |
| 183 | } |
Cheng C Yang | 5665db2 | 2019-07-12 00:57:30 +0800 | [diff] [blame] | 184 | } |
Cheng C Yang | 58b2b53 | 2019-05-31 00:19:45 +0800 | [diff] [blame] | 185 | } |
| 186 | |
Konstantin Aladyshev | c7a1ae6 | 2021-04-30 08:50:43 +0000 | [diff] [blame] | 187 | PSUSubEvent::~PSUSubEvent() |
| 188 | { |
| 189 | waitTimer.cancel(); |
| 190 | inputDev.close(); |
| 191 | } |
| 192 | |
Cheng C Yang | 58b2b53 | 2019-05-31 00:19:45 +0800 | [diff] [blame] | 193 | void PSUSubEvent::setupRead(void) |
| 194 | { |
Konstantin Aladyshev | c7a1ae6 | 2021-04-30 08:50:43 +0000 | [diff] [blame] | 195 | if (!readingStateGood(readState)) |
| 196 | { |
| 197 | // Deassert the event |
| 198 | updateValue(0); |
| 199 | restartRead(); |
| 200 | return; |
| 201 | } |
Ed Tanous | 16966b5 | 2021-09-15 15:06:59 -0700 | [diff] [blame] | 202 | if (!buffer) |
| 203 | { |
| 204 | std::cerr << "Buffer was invalid?"; |
| 205 | return; |
| 206 | } |
Konstantin Aladyshev | c7a1ae6 | 2021-04-30 08:50:43 +0000 | [diff] [blame] | 207 | |
Yong Li | bf8b1da | 2020-04-15 16:32:50 +0800 | [diff] [blame] | 208 | std::weak_ptr<PSUSubEvent> weakRef = weak_from_this(); |
Ed Tanous | 16966b5 | 2021-09-15 15:06:59 -0700 | [diff] [blame] | 209 | inputDev.async_read_some_at( |
| 210 | 0, boost::asio::buffer(buffer->data(), buffer->size() - 1), |
| 211 | [weakRef, buffer{buffer}](const boost::system::error_code& ec, |
| 212 | std::size_t bytesTransferred) { |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 213 | std::shared_ptr<PSUSubEvent> self = weakRef.lock(); |
| 214 | if (self) |
| 215 | { |
Ed Tanous | 16966b5 | 2021-09-15 15:06:59 -0700 | [diff] [blame] | 216 | self->handleResponse(ec, bytesTransferred); |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 217 | } |
Yong Li | bf8b1da | 2020-04-15 16:32:50 +0800 | [diff] [blame] | 218 | }); |
Cheng C Yang | 58b2b53 | 2019-05-31 00:19:45 +0800 | [diff] [blame] | 219 | } |
| 220 | |
Konstantin Aladyshev | c7a1ae6 | 2021-04-30 08:50:43 +0000 | [diff] [blame] | 221 | void PSUSubEvent::restartRead() |
Cheng C Yang | 58b2b53 | 2019-05-31 00:19:45 +0800 | [diff] [blame] | 222 | { |
Konstantin Aladyshev | c7a1ae6 | 2021-04-30 08:50:43 +0000 | [diff] [blame] | 223 | std::weak_ptr<PSUSubEvent> weakRef = weak_from_this(); |
| 224 | waitTimer.expires_from_now(boost::posix_time::milliseconds(eventPollMs)); |
| 225 | waitTimer.async_wait([weakRef](const boost::system::error_code& ec) { |
| 226 | if (ec == boost::asio::error::operation_aborted) |
| 227 | { |
| 228 | return; |
| 229 | } |
| 230 | std::shared_ptr<PSUSubEvent> self = weakRef.lock(); |
| 231 | if (self) |
| 232 | { |
| 233 | self->setupRead(); |
| 234 | } |
| 235 | }); |
Cheng C Yang | 58b2b53 | 2019-05-31 00:19:45 +0800 | [diff] [blame] | 236 | } |
| 237 | |
Ed Tanous | 16966b5 | 2021-09-15 15:06:59 -0700 | [diff] [blame] | 238 | void PSUSubEvent::handleResponse(const boost::system::error_code& err, |
| 239 | size_t bytesTransferred) |
Cheng C Yang | 58b2b53 | 2019-05-31 00:19:45 +0800 | [diff] [blame] | 240 | { |
Ed Tanous | 16966b5 | 2021-09-15 15:06:59 -0700 | [diff] [blame] | 241 | if (err == boost::asio::error::operation_aborted) |
| 242 | { |
| 243 | return; |
| 244 | } |
| 245 | |
Yong Li | bf8b1da | 2020-04-15 16:32:50 +0800 | [diff] [blame] | 246 | if ((err == boost::system::errc::bad_file_descriptor) || |
| 247 | (err == boost::asio::error::misc_errors::not_found)) |
Cheng C Yang | 58b2b53 | 2019-05-31 00:19:45 +0800 | [diff] [blame] | 248 | { |
| 249 | return; |
| 250 | } |
Ed Tanous | 16966b5 | 2021-09-15 15:06:59 -0700 | [diff] [blame] | 251 | if (!buffer) |
| 252 | { |
| 253 | std::cerr << "Buffer was invalid?"; |
| 254 | return; |
| 255 | } |
| 256 | // null terminate the string so we don't walk off the end |
| 257 | std::array<char, 128>& bufferRef = *buffer; |
| 258 | bufferRef[bytesTransferred] = '\0'; |
| 259 | |
Cheng C Yang | 58b2b53 | 2019-05-31 00:19:45 +0800 | [diff] [blame] | 260 | if (!err) |
| 261 | { |
| 262 | std::string response; |
| 263 | try |
| 264 | { |
Ed Tanous | 16966b5 | 2021-09-15 15:06:59 -0700 | [diff] [blame] | 265 | int nvalue = std::stoi(bufferRef.data()); |
Josh Lehan | 833661a | 2020-03-04 17:35:41 -0800 | [diff] [blame] | 266 | updateValue(nvalue); |
Cheng C Yang | 58b2b53 | 2019-05-31 00:19:45 +0800 | [diff] [blame] | 267 | errCount = 0; |
| 268 | } |
| 269 | catch (const std::invalid_argument&) |
| 270 | { |
| 271 | errCount++; |
| 272 | } |
| 273 | } |
| 274 | else |
| 275 | { |
| 276 | errCount++; |
| 277 | } |
| 278 | if (errCount >= warnAfterErrorCount) |
| 279 | { |
| 280 | if (errCount == warnAfterErrorCount) |
| 281 | { |
| 282 | std::cerr << "Failure to read event at " << path << "\n"; |
| 283 | } |
| 284 | updateValue(0); |
| 285 | errCount++; |
| 286 | } |
Cheng C Yang | a97f134 | 2020-02-11 15:10:41 +0800 | [diff] [blame] | 287 | lseek(fd, 0, SEEK_SET); |
Konstantin Aladyshev | c7a1ae6 | 2021-04-30 08:50:43 +0000 | [diff] [blame] | 288 | restartRead(); |
Cheng C Yang | 58b2b53 | 2019-05-31 00:19:45 +0800 | [diff] [blame] | 289 | } |
| 290 | |
| 291 | // Any of the sub events of one event is asserted, then the event will be |
| 292 | // asserted. Only if none of the sub events are asserted, the event will be |
| 293 | // deasserted. |
| 294 | void PSUSubEvent::updateValue(const int& newValue) |
| 295 | { |
Josh Lehan | 833661a | 2020-03-04 17:35:41 -0800 | [diff] [blame] | 296 | // Take no action if value already equal |
| 297 | // Same semantics as Sensor::updateValue(const double&) |
| 298 | if (newValue == value) |
| 299 | { |
| 300 | return; |
| 301 | } |
| 302 | |
Cheng C Yang | 58b2b53 | 2019-05-31 00:19:45 +0800 | [diff] [blame] | 303 | if (newValue == 0) |
| 304 | { |
Yong Li | 591b1e4 | 2019-12-19 17:46:31 +0800 | [diff] [blame] | 305 | // log deassert only after all asserts are gone |
Cheng C Yang | 58b2b53 | 2019-05-31 00:19:45 +0800 | [diff] [blame] | 306 | if (!(*asserts).empty()) |
| 307 | { |
Yong Li | 591b1e4 | 2019-12-19 17:46:31 +0800 | [diff] [blame] | 308 | auto found = (*asserts).find(path); |
| 309 | if (found == (*asserts).end()) |
| 310 | { |
| 311 | return; |
| 312 | } |
| 313 | (*asserts).erase(path); |
| 314 | |
Cheng C Yang | 58b2b53 | 2019-05-31 00:19:45 +0800 | [diff] [blame] | 315 | return; |
| 316 | } |
Ed Tanous | 2049bd2 | 2022-07-09 07:20:26 -0700 | [diff] [blame] | 317 | if (*assertState) |
Cheng C Yang | 58b2b53 | 2019-05-31 00:19:45 +0800 | [diff] [blame] | 318 | { |
| 319 | *assertState = false; |
Cheng C Yang | 202a1ff | 2020-01-09 09:34:22 +0800 | [diff] [blame] | 320 | auto foundCombine = (*combineEvent).find(groupEventName); |
Cheng C Yang | 9b53a62 | 2019-08-27 22:13:58 +0800 | [diff] [blame] | 321 | if (foundCombine == (*combineEvent).end()) |
Cheng C Yang | 58b2b53 | 2019-05-31 00:19:45 +0800 | [diff] [blame] | 322 | { |
| 323 | return; |
| 324 | } |
Cheng C Yang | 202a1ff | 2020-01-09 09:34:22 +0800 | [diff] [blame] | 325 | (*combineEvent).erase(groupEventName); |
Cheng C Yang | 9b53a62 | 2019-08-27 22:13:58 +0800 | [diff] [blame] | 326 | if (!deassertMessage.empty()) |
| 327 | { |
| 328 | // Fan Failed has two args |
Cheng C Yang | 9b53a62 | 2019-08-27 22:13:58 +0800 | [diff] [blame] | 329 | if (deassertMessage == "OpenBMC.0.1.PowerSupplyFanRecovered") |
| 330 | { |
Patrick Williams | 0c42f40 | 2021-08-27 16:05:45 -0500 | [diff] [blame] | 331 | lg2::info("{EVENT} deassert", "EVENT", eventName, |
| 332 | "REDFISH_MESSAGE_ID", deassertMessage, |
| 333 | "REDFISH_MESSAGE_ARGS", |
| 334 | (psuName + ',' + fanName)); |
Cheng C Yang | 9b53a62 | 2019-08-27 22:13:58 +0800 | [diff] [blame] | 335 | } |
| 336 | else |
| 337 | { |
Patrick Williams | 0c42f40 | 2021-08-27 16:05:45 -0500 | [diff] [blame] | 338 | lg2::info("{EVENT} deassert", "EVENT", eventName, |
| 339 | "REDFISH_MESSAGE_ID", deassertMessage, |
| 340 | "REDFISH_MESSAGE_ARGS", psuName); |
Cheng C Yang | 9b53a62 | 2019-08-27 22:13:58 +0800 | [diff] [blame] | 341 | } |
| 342 | } |
| 343 | |
Cheng C Yang | 58b2b53 | 2019-05-31 00:19:45 +0800 | [diff] [blame] | 344 | if ((*combineEvent).empty()) |
| 345 | { |
| 346 | eventInterface->set_property("functional", true); |
| 347 | } |
| 348 | } |
| 349 | } |
| 350 | else |
| 351 | { |
Paul Fertser | 3453354 | 2021-07-20 08:29:09 +0000 | [diff] [blame] | 352 | std::cerr << "PSUSubEvent asserted by " << path << "\n"; |
| 353 | |
Ed Tanous | 2049bd2 | 2022-07-09 07:20:26 -0700 | [diff] [blame] | 354 | if ((!*assertState) && ((*asserts).empty())) |
Cheng C Yang | 58b2b53 | 2019-05-31 00:19:45 +0800 | [diff] [blame] | 355 | { |
| 356 | *assertState = true; |
Cheng C Yang | 9b53a62 | 2019-08-27 22:13:58 +0800 | [diff] [blame] | 357 | if (!assertMessage.empty()) |
Cheng C Yang | 5665db2 | 2019-07-12 00:57:30 +0800 | [diff] [blame] | 358 | { |
| 359 | // Fan Failed has two args |
Cheng C Yang | 9b53a62 | 2019-08-27 22:13:58 +0800 | [diff] [blame] | 360 | if (assertMessage == "OpenBMC.0.1.PowerSupplyFanFailed") |
Cheng C Yang | 5665db2 | 2019-07-12 00:57:30 +0800 | [diff] [blame] | 361 | { |
Patrick Williams | 0c42f40 | 2021-08-27 16:05:45 -0500 | [diff] [blame] | 362 | lg2::warning("{EVENT} assert", "EVENT", eventName, |
| 363 | "REDFISH_MESSAGE_ID", assertMessage, |
| 364 | "REDFISH_MESSAGE_ARGS", |
| 365 | (psuName + ',' + fanName)); |
Cheng C Yang | 5665db2 | 2019-07-12 00:57:30 +0800 | [diff] [blame] | 366 | } |
| 367 | else |
| 368 | { |
Patrick Williams | 0c42f40 | 2021-08-27 16:05:45 -0500 | [diff] [blame] | 369 | lg2::warning("{EVENT} assert", "EVENT", eventName, |
| 370 | "REDFISH_MESSAGE_ID", assertMessage, |
| 371 | "REDFISH_MESSAGE_ARGS", psuName); |
Cheng C Yang | 5665db2 | 2019-07-12 00:57:30 +0800 | [diff] [blame] | 372 | } |
| 373 | } |
Cheng C Yang | 58b2b53 | 2019-05-31 00:19:45 +0800 | [diff] [blame] | 374 | if ((*combineEvent).empty()) |
| 375 | { |
| 376 | eventInterface->set_property("functional", false); |
| 377 | } |
Cheng C Yang | 202a1ff | 2020-01-09 09:34:22 +0800 | [diff] [blame] | 378 | (*combineEvent).emplace(groupEventName); |
Cheng C Yang | 58b2b53 | 2019-05-31 00:19:45 +0800 | [diff] [blame] | 379 | } |
Yong Li | 591b1e4 | 2019-12-19 17:46:31 +0800 | [diff] [blame] | 380 | (*asserts).emplace(path); |
Cheng C Yang | 58b2b53 | 2019-05-31 00:19:45 +0800 | [diff] [blame] | 381 | } |
| 382 | value = newValue; |
| 383 | } |