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