| Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1 | #include "fru-fault-monitor.hpp" | 
 | 2 |  | 
| Patrick Williams | 9bd334f | 2022-03-16 11:28:26 -0500 | [diff] [blame] | 3 | #include <phosphor-logging/elog-errors.hpp> | 
| Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 4 | #include <phosphor-logging/elog.hpp> | 
| George Liu | e9fb5c6 | 2021-07-01 14:05:32 +0800 | [diff] [blame] | 5 | #include <phosphor-logging/lg2.hpp> | 
| Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 6 | #include <sdbusplus/exception.hpp> | 
| Patrick Williams | 9bd334f | 2022-03-16 11:28:26 -0500 | [diff] [blame] | 7 | #include <xyz/openbmc_project/Common/error.hpp> | 
| Dhruvaraj Subhashchandran | 3c6f29a | 2017-04-20 09:47:28 -0500 | [diff] [blame] | 8 |  | 
| Dhruvaraj Subhashchandran | 59b86cd | 2017-04-13 00:19:44 -0500 | [diff] [blame] | 9 | namespace phosphor | 
 | 10 | { | 
 | 11 | namespace led | 
 | 12 | { | 
 | 13 | namespace fru | 
 | 14 | { | 
 | 15 | namespace fault | 
 | 16 | { | 
 | 17 | namespace monitor | 
 | 18 | { | 
 | 19 |  | 
| Dhruvaraj Subhashchandran | 3c6f29a | 2017-04-20 09:47:28 -0500 | [diff] [blame] | 20 | using namespace phosphor::logging; | 
 | 21 |  | 
| George Liu | 1f0b715 | 2023-07-18 09:24:34 +0800 | [diff] [blame^] | 22 | static constexpr auto mapperBusName = "xyz.openbmc_project.ObjectMapper"; | 
 | 23 | static constexpr auto mapperObjPath = "/xyz/openbmc_project/object_mapper"; | 
 | 24 | static constexpr auto mapperIntf = "xyz.openbmc_project.ObjectMapper"; | 
 | 25 | static constexpr auto objMgrIntf = "org.freedesktop.DBus.ObjectManager"; | 
 | 26 | static constexpr auto ledGroups = "/xyz/openbmc_project/led/groups/"; | 
 | 27 | static constexpr auto logIntf = "xyz.openbmc_project.Logging.Entry"; | 
| Dhruvaraj Subhashchandran | 3c6f29a | 2017-04-20 09:47:28 -0500 | [diff] [blame] | 28 |  | 
| Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 29 | using AssociationList = | 
 | 30 |     std::vector<std::tuple<std::string, std::string, std::string>>; | 
| Patrick Williams | a41d282 | 2020-05-13 17:57:23 -0500 | [diff] [blame] | 31 | using Attributes = std::variant<bool, AssociationList>; | 
| Dhruvaraj Subhashchandran | aebfde8 | 2017-07-11 01:36:33 -0500 | [diff] [blame] | 32 | using PropertyName = std::string; | 
| Patrick Williams | f204403 | 2022-03-17 05:12:30 -0500 | [diff] [blame] | 33 | using PropertyMap = std::unordered_map<PropertyName, Attributes>; | 
| Matt Spinler | b2f253b | 2018-06-13 09:54:13 -0500 | [diff] [blame] | 34 | using InterfaceName = std::string; | 
| Patrick Williams | f204403 | 2022-03-17 05:12:30 -0500 | [diff] [blame] | 35 | using InterfaceMap = std::unordered_map<InterfaceName, PropertyMap>; | 
| Dhruvaraj Subhashchandran | aebfde8 | 2017-07-11 01:36:33 -0500 | [diff] [blame] | 36 |  | 
| Dhruvaraj Subhashchandran | 891c476 | 2017-07-31 14:26:37 -0500 | [diff] [blame] | 37 | using Service = std::string; | 
 | 38 | using Path = std::string; | 
 | 39 | using Interface = std::string; | 
 | 40 | using Interfaces = std::vector<Interface>; | 
| Patrick Williams | f204403 | 2022-03-17 05:12:30 -0500 | [diff] [blame] | 41 | using MapperResponseType = | 
 | 42 |     std::unordered_map<Path, std::unordered_map<Service, Interfaces>>; | 
| Dhruvaraj Subhashchandran | 891c476 | 2017-07-31 14:26:37 -0500 | [diff] [blame] | 43 |  | 
| Patrick Williams | 9bd334f | 2022-03-16 11:28:26 -0500 | [diff] [blame] | 44 | using ResourceNotFoundErr = | 
 | 45 |     sdbusplus::xyz::openbmc_project::Common::Error::ResourceNotFound; | 
 | 46 | using InvalidArgumentErr = | 
 | 47 |     sdbusplus::xyz::openbmc_project::Common::Error::InvalidArgument; | 
| Dhruvaraj Subhashchandran | 3c6f29a | 2017-04-20 09:47:28 -0500 | [diff] [blame] | 48 |  | 
| Patrick Williams | 3e073ba | 2022-07-22 19:26:52 -0500 | [diff] [blame] | 49 | std::string getService(sdbusplus::bus_t& bus, const std::string& path) | 
| Dhruvaraj Subhashchandran | 3c6f29a | 2017-04-20 09:47:28 -0500 | [diff] [blame] | 50 | { | 
| George Liu | 1f0b715 | 2023-07-18 09:24:34 +0800 | [diff] [blame^] | 51 |     auto mapper = bus.new_method_call(mapperBusName, mapperObjPath, mapperIntf, | 
 | 52 |                                       "GetObject"); | 
 | 53 |     mapper.append(path.c_str(), std::vector<std::string>({objMgrIntf})); | 
| Dhruvaraj Subhashchandran | 3c6f29a | 2017-04-20 09:47:28 -0500 | [diff] [blame] | 54 |  | 
| Patrick Williams | f204403 | 2022-03-17 05:12:30 -0500 | [diff] [blame] | 55 |     std::unordered_map<std::string, std::vector<std::string>> mapperResponse; | 
| William A. Kennington III | 151122a | 2018-05-15 12:00:32 -0700 | [diff] [blame] | 56 |     try | 
 | 57 |     { | 
| George Liu | d78de14 | 2021-08-23 16:16:32 +0800 | [diff] [blame] | 58 |         auto mapperResponseMsg = bus.call(mapper); | 
| William A. Kennington III | 151122a | 2018-05-15 12:00:32 -0700 | [diff] [blame] | 59 |         mapperResponseMsg.read(mapperResponse); | 
 | 60 |     } | 
| Patrick Williams | 3e073ba | 2022-07-22 19:26:52 -0500 | [diff] [blame] | 61 |     catch (const sdbusplus::exception_t& e) | 
| William A. Kennington III | 151122a | 2018-05-15 12:00:32 -0700 | [diff] [blame] | 62 |     { | 
| George Liu | e9fb5c6 | 2021-07-01 14:05:32 +0800 | [diff] [blame] | 63 |         lg2::error( | 
 | 64 |             "Failed to parse getService mapper response, ERROR = {ERROR}", | 
 | 65 |             "ERROR", e); | 
| Patrick Williams | 9bd334f | 2022-03-16 11:28:26 -0500 | [diff] [blame] | 66 |         using namespace xyz::openbmc_project::Common; | 
 | 67 |         elog<ResourceNotFoundErr>(ResourceNotFound::RESOURCE(path.c_str())); | 
| William A. Kennington III | 151122a | 2018-05-15 12:00:32 -0700 | [diff] [blame] | 68 |     } | 
| Dhruvaraj Subhashchandran | 3c6f29a | 2017-04-20 09:47:28 -0500 | [diff] [blame] | 69 |     if (mapperResponse.empty()) | 
 | 70 |     { | 
| Patrick Williams | 9bd334f | 2022-03-16 11:28:26 -0500 | [diff] [blame] | 71 |         using namespace xyz::openbmc_project::Common; | 
 | 72 |         elog<ResourceNotFoundErr>(ResourceNotFound::RESOURCE(path.c_str())); | 
| George Liu | c5e0f31 | 2021-12-27 15:54:31 +0800 | [diff] [blame] | 73 |         return {}; | 
| Dhruvaraj Subhashchandran | 3c6f29a | 2017-04-20 09:47:28 -0500 | [diff] [blame] | 74 |     } | 
 | 75 |  | 
 | 76 |     return mapperResponse.cbegin()->first; | 
 | 77 | } | 
 | 78 |  | 
| Patrick Williams | 3e073ba | 2022-07-22 19:26:52 -0500 | [diff] [blame] | 79 | void action(sdbusplus::bus_t& bus, const std::string& path, bool assert) | 
| Dhruvaraj Subhashchandran | 59b86cd | 2017-04-13 00:19:44 -0500 | [diff] [blame] | 80 | { | 
| Dhruvaraj Subhashchandran | 3c6f29a | 2017-04-20 09:47:28 -0500 | [diff] [blame] | 81 |     std::string service; | 
 | 82 |     try | 
 | 83 |     { | 
| George Liu | 1f0b715 | 2023-07-18 09:24:34 +0800 | [diff] [blame^] | 84 |         std::string groups{ledGroups}; | 
| Matt Spinler | e77b834 | 2018-09-12 10:41:53 -0500 | [diff] [blame] | 85 |         groups.pop_back(); | 
 | 86 |         service = getService(bus, groups); | 
| Dhruvaraj Subhashchandran | 3c6f29a | 2017-04-20 09:47:28 -0500 | [diff] [blame] | 87 |     } | 
| Patrick Williams | 9bd334f | 2022-03-16 11:28:26 -0500 | [diff] [blame] | 88 |     catch (const ResourceNotFoundErr& e) | 
| Dhruvaraj Subhashchandran | 3c6f29a | 2017-04-20 09:47:28 -0500 | [diff] [blame] | 89 |     { | 
| Patrick Williams | 9bd334f | 2022-03-16 11:28:26 -0500 | [diff] [blame] | 90 |         commit<ResourceNotFoundErr>(); | 
| Dhruvaraj Subhashchandran | 3c6f29a | 2017-04-20 09:47:28 -0500 | [diff] [blame] | 91 |         return; | 
 | 92 |     } | 
 | 93 |  | 
 | 94 |     auto pos = path.rfind("/"); | 
 | 95 |     if (pos == std::string::npos) | 
 | 96 |     { | 
| Patrick Williams | 9bd334f | 2022-03-16 11:28:26 -0500 | [diff] [blame] | 97 |         using namespace xyz::openbmc_project::Common; | 
 | 98 |         report<InvalidArgumentErr>( | 
 | 99 |             InvalidArgument::ARGUMENT_NAME("path"), | 
 | 100 |             InvalidArgument::ARGUMENT_VALUE(path.c_str())); | 
| Dhruvaraj Subhashchandran | 3c6f29a | 2017-04-20 09:47:28 -0500 | [diff] [blame] | 101 |         return; | 
 | 102 |     } | 
 | 103 |     auto unit = path.substr(pos + 1); | 
 | 104 |  | 
| George Liu | 1f0b715 | 2023-07-18 09:24:34 +0800 | [diff] [blame^] | 105 |     std::string ledPath = ledGroups + unit + '_' + LED_FAULT; | 
| Dhruvaraj Subhashchandran | 3c6f29a | 2017-04-20 09:47:28 -0500 | [diff] [blame] | 106 |  | 
| Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 107 |     auto method = bus.new_method_call(service.c_str(), ledPath.c_str(), | 
 | 108 |                                       "org.freedesktop.DBus.Properties", "Set"); | 
| Dhruvaraj Subhashchandran | 3c6f29a | 2017-04-20 09:47:28 -0500 | [diff] [blame] | 109 |     method.append("xyz.openbmc_project.Led.Group"); | 
 | 110 |     method.append("Asserted"); | 
 | 111 |  | 
| Patrick Williams | a41d282 | 2020-05-13 17:57:23 -0500 | [diff] [blame] | 112 |     method.append(std::variant<bool>(assert)); | 
| Adriana Kobylak | 08d613e | 2018-07-18 15:30:39 -0500 | [diff] [blame] | 113 |  | 
 | 114 |     try | 
 | 115 |     { | 
 | 116 |         bus.call_noreply(method); | 
 | 117 |     } | 
| Patrick Williams | 3e073ba | 2022-07-22 19:26:52 -0500 | [diff] [blame] | 118 |     catch (const sdbusplus::exception_t& e) | 
| Adriana Kobylak | 08d613e | 2018-07-18 15:30:39 -0500 | [diff] [blame] | 119 |     { | 
 | 120 |         // Log an info message, system may not have all the LED Groups defined | 
| George Liu | e9fb5c6 | 2021-07-01 14:05:32 +0800 | [diff] [blame] | 121 |         lg2::info("Failed to Assert LED Group, ERROR = {ERROR}", "ERROR", e); | 
| Adriana Kobylak | 08d613e | 2018-07-18 15:30:39 -0500 | [diff] [blame] | 122 |     } | 
| Dhruvaraj Subhashchandran | 3c6f29a | 2017-04-20 09:47:28 -0500 | [diff] [blame] | 123 |  | 
| Dhruvaraj Subhashchandran | 59b86cd | 2017-04-13 00:19:44 -0500 | [diff] [blame] | 124 |     return; | 
 | 125 | } | 
 | 126 |  | 
| Patrick Williams | 3e073ba | 2022-07-22 19:26:52 -0500 | [diff] [blame] | 127 | void Add::created(sdbusplus::message_t& msg) | 
| Dhruvaraj Subhashchandran | 59b86cd | 2017-04-13 00:19:44 -0500 | [diff] [blame] | 128 | { | 
| Patrick Williams | 3eedbe4 | 2017-05-31 17:27:05 -0500 | [diff] [blame] | 129 |     auto bus = msg.get_bus(); | 
| Dhruvaraj Subhashchandran | 3c6f29a | 2017-04-20 09:47:28 -0500 | [diff] [blame] | 130 |  | 
| Matt Spinler | b2f253b | 2018-06-13 09:54:13 -0500 | [diff] [blame] | 131 |     sdbusplus::message::object_path objectPath; | 
 | 132 |     InterfaceMap interfaces; | 
| William A. Kennington III | 151122a | 2018-05-15 12:00:32 -0700 | [diff] [blame] | 133 |     try | 
 | 134 |     { | 
| Matt Spinler | b2f253b | 2018-06-13 09:54:13 -0500 | [diff] [blame] | 135 |         msg.read(objectPath, interfaces); | 
| William A. Kennington III | 151122a | 2018-05-15 12:00:32 -0700 | [diff] [blame] | 136 |     } | 
| Patrick Williams | 3e073ba | 2022-07-22 19:26:52 -0500 | [diff] [blame] | 137 |     catch (const sdbusplus::exception_t& e) | 
| William A. Kennington III | 151122a | 2018-05-15 12:00:32 -0700 | [diff] [blame] | 138 |     { | 
| George Liu | e9fb5c6 | 2021-07-01 14:05:32 +0800 | [diff] [blame] | 139 |         lg2::error("Failed to parse created message, ERROR = {ERROR}", "ERROR", | 
 | 140 |                    e); | 
| William A. Kennington III | 151122a | 2018-05-15 12:00:32 -0700 | [diff] [blame] | 141 |         return; | 
 | 142 |     } | 
| Dhruvaraj Subhashchandran | 3c6f29a | 2017-04-20 09:47:28 -0500 | [diff] [blame] | 143 |  | 
| Matt Spinler | b2f253b | 2018-06-13 09:54:13 -0500 | [diff] [blame] | 144 |     std::size_t found = objectPath.str.find(ELOG_ENTRY); | 
| Dhruvaraj Subhashchandran | 3c6f29a | 2017-04-20 09:47:28 -0500 | [diff] [blame] | 145 |     if (found == std::string::npos) | 
 | 146 |     { | 
| Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 147 |         // Not a new error entry skip | 
| Patrick Williams | 3eedbe4 | 2017-05-31 17:27:05 -0500 | [diff] [blame] | 148 |         return; | 
| Dhruvaraj Subhashchandran | 3c6f29a | 2017-04-20 09:47:28 -0500 | [diff] [blame] | 149 |     } | 
| Andrew Geissler | a6e4892 | 2019-11-06 08:43:54 -0600 | [diff] [blame] | 150 |     auto iter = interfaces.find("xyz.openbmc_project.Association.Definitions"); | 
| Matt Spinler | b2f253b | 2018-06-13 09:54:13 -0500 | [diff] [blame] | 151 |     if (iter == interfaces.end()) | 
| Dhruvaraj Subhashchandran | 3c6f29a | 2017-04-20 09:47:28 -0500 | [diff] [blame] | 152 |     { | 
| Patrick Williams | 3eedbe4 | 2017-05-31 17:27:05 -0500 | [diff] [blame] | 153 |         return; | 
| Dhruvaraj Subhashchandran | 3c6f29a | 2017-04-20 09:47:28 -0500 | [diff] [blame] | 154 |     } | 
 | 155 |  | 
| Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 156 |     // Nothing else shows when a specific error log | 
 | 157 |     // has been created. Do it here. | 
| George Liu | b4c82cf | 2023-01-04 10:23:36 +0800 | [diff] [blame] | 158 |     lg2::info("{PATH} created", "PATH", objectPath); | 
| Matt Spinler | 3d2b0d6 | 2018-03-29 08:48:37 -0500 | [diff] [blame] | 159 |  | 
| Andrew Geissler | a6e4892 | 2019-11-06 08:43:54 -0600 | [diff] [blame] | 160 |     auto attr = iter->second.find("Associations"); | 
| Dhruvaraj Subhashchandran | aebfde8 | 2017-07-11 01:36:33 -0500 | [diff] [blame] | 161 |     if (attr == iter->second.end()) | 
| Dhruvaraj Subhashchandran | 3c6f29a | 2017-04-20 09:47:28 -0500 | [diff] [blame] | 162 |     { | 
| Patrick Williams | 3eedbe4 | 2017-05-31 17:27:05 -0500 | [diff] [blame] | 163 |         return; | 
| Dhruvaraj Subhashchandran | 3c6f29a | 2017-04-20 09:47:28 -0500 | [diff] [blame] | 164 |     } | 
 | 165 |  | 
| Patrick Williams | 5ebebef | 2020-05-13 11:47:27 -0500 | [diff] [blame] | 166 |     auto& assocs = std::get<AssociationList>(attr->second); | 
| Dhruvaraj Subhashchandran | 3c6f29a | 2017-04-20 09:47:28 -0500 | [diff] [blame] | 167 |     if (assocs.empty()) | 
 | 168 |     { | 
| Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 169 |         // No associations skip | 
| Patrick Williams | 3eedbe4 | 2017-05-31 17:27:05 -0500 | [diff] [blame] | 170 |         return; | 
| Dhruvaraj Subhashchandran | 3c6f29a | 2017-04-20 09:47:28 -0500 | [diff] [blame] | 171 |     } | 
 | 172 |  | 
 | 173 |     for (const auto& item : assocs) | 
 | 174 |     { | 
 | 175 |         if (std::get<1>(item).compare(CALLOUT_REV_ASSOCIATION) == 0) | 
 | 176 |         { | 
| Patrick Williams | 3eedbe4 | 2017-05-31 17:27:05 -0500 | [diff] [blame] | 177 |             removeWatches.emplace_back( | 
| Dhruvaraj Subhashchandran | aebfde8 | 2017-07-11 01:36:33 -0500 | [diff] [blame] | 178 |                 std::make_unique<Remove>(bus, std::get<2>(item))); | 
| Dhruvaraj Subhashchandran | 891c476 | 2017-07-31 14:26:37 -0500 | [diff] [blame] | 179 |             action(bus, std::get<2>(item), true); | 
| Dhruvaraj Subhashchandran | 3c6f29a | 2017-04-20 09:47:28 -0500 | [diff] [blame] | 180 |         } | 
 | 181 |     } | 
| Dhruvaraj Subhashchandran | aebfde8 | 2017-07-11 01:36:33 -0500 | [diff] [blame] | 182 |  | 
| Patrick Williams | 3eedbe4 | 2017-05-31 17:27:05 -0500 | [diff] [blame] | 183 |     return; | 
| Dhruvaraj Subhashchandran | 59b86cd | 2017-04-13 00:19:44 -0500 | [diff] [blame] | 184 | } | 
 | 185 |  | 
| Patrick Williams | 3e073ba | 2022-07-22 19:26:52 -0500 | [diff] [blame] | 186 | void getLoggingSubTree(sdbusplus::bus_t& bus, MapperResponseType& subtree) | 
| Dhruvaraj Subhashchandran | 891c476 | 2017-07-31 14:26:37 -0500 | [diff] [blame] | 187 | { | 
 | 188 |     auto depth = 0; | 
| George Liu | 1f0b715 | 2023-07-18 09:24:34 +0800 | [diff] [blame^] | 189 |     auto mapperCall = bus.new_method_call(mapperBusName, mapperObjPath, | 
 | 190 |                                           mapperIntf, "GetSubTree"); | 
| Dhruvaraj Subhashchandran | 891c476 | 2017-07-31 14:26:37 -0500 | [diff] [blame] | 191 |     mapperCall.append("/"); | 
 | 192 |     mapperCall.append(depth); | 
| George Liu | 1f0b715 | 2023-07-18 09:24:34 +0800 | [diff] [blame^] | 193 |     mapperCall.append(std::vector<Interface>({logIntf})); | 
| Dhruvaraj Subhashchandran | 891c476 | 2017-07-31 14:26:37 -0500 | [diff] [blame] | 194 |  | 
| William A. Kennington III | 151122a | 2018-05-15 12:00:32 -0700 | [diff] [blame] | 195 |     try | 
 | 196 |     { | 
| Matt Spinler | 9112292 | 2018-09-24 11:31:44 -0500 | [diff] [blame] | 197 |         auto mapperResponseMsg = bus.call(mapperCall); | 
| George Liu | d78de14 | 2021-08-23 16:16:32 +0800 | [diff] [blame] | 198 |         mapperResponseMsg.read(subtree); | 
| William A. Kennington III | 151122a | 2018-05-15 12:00:32 -0700 | [diff] [blame] | 199 |     } | 
| Patrick Williams | 3e073ba | 2022-07-22 19:26:52 -0500 | [diff] [blame] | 200 |     catch (const sdbusplus::exception_t& e) | 
| William A. Kennington III | 151122a | 2018-05-15 12:00:32 -0700 | [diff] [blame] | 201 |     { | 
| George Liu | e9fb5c6 | 2021-07-01 14:05:32 +0800 | [diff] [blame] | 202 |         lg2::error( | 
 | 203 |             "Failed to parse existing callouts subtree message, ERROR = {ERROR}", | 
 | 204 |             "ERROR", e); | 
| William A. Kennington III | 151122a | 2018-05-15 12:00:32 -0700 | [diff] [blame] | 205 |     } | 
| Matt Spinler | 9112292 | 2018-09-24 11:31:44 -0500 | [diff] [blame] | 206 | } | 
 | 207 |  | 
| Patrick Williams | 3e073ba | 2022-07-22 19:26:52 -0500 | [diff] [blame] | 208 | void Add::processExistingCallouts(sdbusplus::bus_t& bus) | 
| Matt Spinler | 9112292 | 2018-09-24 11:31:44 -0500 | [diff] [blame] | 209 | { | 
| Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 210 |     MapperResponseType mapperResponse; | 
| Matt Spinler | 9112292 | 2018-09-24 11:31:44 -0500 | [diff] [blame] | 211 |  | 
 | 212 |     getLoggingSubTree(bus, mapperResponse); | 
| Dhruvaraj Subhashchandran | 891c476 | 2017-07-31 14:26:37 -0500 | [diff] [blame] | 213 |     if (mapperResponse.empty()) | 
 | 214 |     { | 
| Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 215 |         // No errors to process. | 
| Dhruvaraj Subhashchandran | 891c476 | 2017-07-31 14:26:37 -0500 | [diff] [blame] | 216 |         return; | 
 | 217 |     } | 
 | 218 |  | 
 | 219 |     for (const auto& elem : mapperResponse) | 
 | 220 |     { | 
| Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 221 |         auto method = bus.new_method_call( | 
 | 222 |             elem.second.begin()->first.c_str(), elem.first.c_str(), | 
 | 223 |             "org.freedesktop.DBus.Properties", "Get"); | 
| Andrew Geissler | a6e4892 | 2019-11-06 08:43:54 -0600 | [diff] [blame] | 224 |         method.append("xyz.openbmc_project.Association.Definitions"); | 
 | 225 |         method.append("Associations"); | 
| Dhruvaraj Subhashchandran | 891c476 | 2017-07-31 14:26:37 -0500 | [diff] [blame] | 226 |         auto reply = bus.call(method); | 
 | 227 |         if (reply.is_method_error()) | 
 | 228 |         { | 
| Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 229 |             // do not stop, continue with next elog | 
| George Liu | e9fb5c6 | 2021-07-01 14:05:32 +0800 | [diff] [blame] | 230 |             lg2::error("Error in getting associations"); | 
| Dhruvaraj Subhashchandran | 891c476 | 2017-07-31 14:26:37 -0500 | [diff] [blame] | 231 |             continue; | 
 | 232 |         } | 
 | 233 |  | 
| Patrick Williams | a41d282 | 2020-05-13 17:57:23 -0500 | [diff] [blame] | 234 |         std::variant<AssociationList> assoc; | 
| William A. Kennington III | 151122a | 2018-05-15 12:00:32 -0700 | [diff] [blame] | 235 |         try | 
 | 236 |         { | 
 | 237 |             reply.read(assoc); | 
 | 238 |         } | 
| Patrick Williams | 3e073ba | 2022-07-22 19:26:52 -0500 | [diff] [blame] | 239 |         catch (const sdbusplus::exception_t& e) | 
| William A. Kennington III | 151122a | 2018-05-15 12:00:32 -0700 | [diff] [blame] | 240 |         { | 
| George Liu | e9fb5c6 | 2021-07-01 14:05:32 +0800 | [diff] [blame] | 241 |             lg2::error( | 
 | 242 |                 "Failed to parse existing callouts associations message, ERROR = {ERROR}", | 
 | 243 |                 "ERROR", e); | 
| William A. Kennington III | 151122a | 2018-05-15 12:00:32 -0700 | [diff] [blame] | 244 |             continue; | 
 | 245 |         } | 
| Patrick Williams | 5ebebef | 2020-05-13 11:47:27 -0500 | [diff] [blame] | 246 |         auto& assocs = std::get<AssociationList>(assoc); | 
| Dhruvaraj Subhashchandran | 891c476 | 2017-07-31 14:26:37 -0500 | [diff] [blame] | 247 |         if (assocs.empty()) | 
 | 248 |         { | 
| Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 249 |             // no associations, skip | 
| Dhruvaraj Subhashchandran | 891c476 | 2017-07-31 14:26:37 -0500 | [diff] [blame] | 250 |             continue; | 
 | 251 |         } | 
 | 252 |  | 
 | 253 |         for (const auto& item : assocs) | 
 | 254 |         { | 
 | 255 |             if (std::get<1>(item).compare(CALLOUT_REV_ASSOCIATION) == 0) | 
 | 256 |             { | 
 | 257 |                 removeWatches.emplace_back( | 
 | 258 |                     std::make_unique<Remove>(bus, std::get<2>(item))); | 
 | 259 |                 action(bus, std::get<2>(item), true); | 
 | 260 |             } | 
 | 261 |         } | 
 | 262 |     } | 
 | 263 | } | 
 | 264 |  | 
| Patrick Williams | 3e073ba | 2022-07-22 19:26:52 -0500 | [diff] [blame] | 265 | void Remove::removed(sdbusplus::message_t& msg) | 
| Dhruvaraj Subhashchandran | 59b86cd | 2017-04-13 00:19:44 -0500 | [diff] [blame] | 266 | { | 
| Patrick Williams | 3eedbe4 | 2017-05-31 17:27:05 -0500 | [diff] [blame] | 267 |     auto bus = msg.get_bus(); | 
| Dhruvaraj Subhashchandran | 3c6f29a | 2017-04-20 09:47:28 -0500 | [diff] [blame] | 268 |  | 
| Patrick Williams | 3eedbe4 | 2017-05-31 17:27:05 -0500 | [diff] [blame] | 269 |     action(bus, inventoryPath, false); | 
 | 270 |     return; | 
| Dhruvaraj Subhashchandran | 59b86cd | 2017-04-13 00:19:44 -0500 | [diff] [blame] | 271 | } | 
 | 272 |  | 
| Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 273 | } // namespace monitor | 
 | 274 | } // namespace fault | 
 | 275 | } // namespace fru | 
 | 276 | } // namespace led | 
 | 277 | } // namespace phosphor |