| 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 |  | 
| Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 22 | constexpr auto MAPPER_BUSNAME = "xyz.openbmc_project.ObjectMapper"; | 
 | 23 | constexpr auto MAPPER_OBJ_PATH = "/xyz/openbmc_project/object_mapper"; | 
 | 24 | constexpr auto MAPPER_IFACE = "xyz.openbmc_project.ObjectMapper"; | 
 | 25 | constexpr auto OBJMGR_IFACE = "org.freedesktop.DBus.ObjectManager"; | 
 | 26 | constexpr auto LED_GROUPS = "/xyz/openbmc_project/led/groups/"; | 
 | 27 | constexpr auto LOG_PATH = "/xyz/openbmc_project/logging"; | 
 | 28 | constexpr auto LOG_IFACE = "xyz.openbmc_project.Logging.Entry"; | 
| Dhruvaraj Subhashchandran | 3c6f29a | 2017-04-20 09:47:28 -0500 | [diff] [blame] | 29 |  | 
| Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 30 | using AssociationList = | 
 | 31 |     std::vector<std::tuple<std::string, std::string, std::string>>; | 
| Patrick Williams | a41d282 | 2020-05-13 17:57:23 -0500 | [diff] [blame] | 32 | using Attributes = std::variant<bool, AssociationList>; | 
| Dhruvaraj Subhashchandran | aebfde8 | 2017-07-11 01:36:33 -0500 | [diff] [blame] | 33 | using PropertyName = std::string; | 
| Matt Spinler | b2f253b | 2018-06-13 09:54:13 -0500 | [diff] [blame] | 34 | using PropertyMap = std::map<PropertyName, Attributes>; | 
 | 35 | using InterfaceName = std::string; | 
 | 36 | using InterfaceMap = std::map<InterfaceName, PropertyMap>; | 
| Dhruvaraj Subhashchandran | aebfde8 | 2017-07-11 01:36:33 -0500 | [diff] [blame] | 37 |  | 
| Dhruvaraj Subhashchandran | 891c476 | 2017-07-31 14:26:37 -0500 | [diff] [blame] | 38 | using Service = std::string; | 
 | 39 | using Path = std::string; | 
 | 40 | using Interface = std::string; | 
 | 41 | using Interfaces = std::vector<Interface>; | 
 | 42 | using MapperResponseType = std::map<Path, std::map<Service, Interfaces>>; | 
 | 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 Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 49 | std::string getService(sdbusplus::bus::bus& bus, const std::string& path) | 
| Dhruvaraj Subhashchandran | 3c6f29a | 2017-04-20 09:47:28 -0500 | [diff] [blame] | 50 | { | 
| Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 51 |     auto mapper = bus.new_method_call(MAPPER_BUSNAME, MAPPER_OBJ_PATH, | 
| Dhruvaraj Subhashchandran | 3c6f29a | 2017-04-20 09:47:28 -0500 | [diff] [blame] | 52 |                                       MAPPER_IFACE, "GetObject"); | 
 | 53 |     mapper.append(path.c_str(), std::vector<std::string>({OBJMGR_IFACE})); | 
| Dhruvaraj Subhashchandran | 3c6f29a | 2017-04-20 09:47:28 -0500 | [diff] [blame] | 54 |  | 
 | 55 |     std::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 | 7152edc | 2021-09-02 09:41:54 -0500 | [diff] [blame] | 61 |     catch (const sdbusplus::exception::exception& 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 Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 79 | void action(sdbusplus::bus::bus& 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 |     { | 
| Matt Spinler | e77b834 | 2018-09-12 10:41:53 -0500 | [diff] [blame] | 84 |         std::string groups{LED_GROUPS}; | 
 | 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 |  | 
| Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 105 |     std::string ledPath = LED_GROUPS + 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 | 7152edc | 2021-09-02 09:41:54 -0500 | [diff] [blame] | 118 |     catch (const sdbusplus::exception::exception& 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 | 3eedbe4 | 2017-05-31 17:27:05 -0500 | [diff] [blame] | 127 | void Add::created(sdbusplus::message::message& 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 | 7152edc | 2021-09-02 09:41:54 -0500 | [diff] [blame] | 137 |     catch (const sdbusplus::exception::exception& 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 | e9fb5c6 | 2021-07-01 14:05:32 +0800 | [diff] [blame] | 158 |     // TODO:(phosphor-logging#25): support sdbusplus::message::object_path | 
 | 159 |     // directly. | 
 | 160 |     lg2::info("{PATH} created", "PATH", objectPath.str); | 
| Matt Spinler | 3d2b0d6 | 2018-03-29 08:48:37 -0500 | [diff] [blame] | 161 |  | 
| Andrew Geissler | a6e4892 | 2019-11-06 08:43:54 -0600 | [diff] [blame] | 162 |     auto attr = iter->second.find("Associations"); | 
| Dhruvaraj Subhashchandran | aebfde8 | 2017-07-11 01:36:33 -0500 | [diff] [blame] | 163 |     if (attr == iter->second.end()) | 
| Dhruvaraj Subhashchandran | 3c6f29a | 2017-04-20 09:47:28 -0500 | [diff] [blame] | 164 |     { | 
| Patrick Williams | 3eedbe4 | 2017-05-31 17:27:05 -0500 | [diff] [blame] | 165 |         return; | 
| Dhruvaraj Subhashchandran | 3c6f29a | 2017-04-20 09:47:28 -0500 | [diff] [blame] | 166 |     } | 
 | 167 |  | 
| Patrick Williams | 5ebebef | 2020-05-13 11:47:27 -0500 | [diff] [blame] | 168 |     auto& assocs = std::get<AssociationList>(attr->second); | 
| Dhruvaraj Subhashchandran | 3c6f29a | 2017-04-20 09:47:28 -0500 | [diff] [blame] | 169 |     if (assocs.empty()) | 
 | 170 |     { | 
| Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 171 |         // No associations skip | 
| 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 |  | 
 | 175 |     for (const auto& item : assocs) | 
 | 176 |     { | 
 | 177 |         if (std::get<1>(item).compare(CALLOUT_REV_ASSOCIATION) == 0) | 
 | 178 |         { | 
| Patrick Williams | 3eedbe4 | 2017-05-31 17:27:05 -0500 | [diff] [blame] | 179 |             removeWatches.emplace_back( | 
| Dhruvaraj Subhashchandran | aebfde8 | 2017-07-11 01:36:33 -0500 | [diff] [blame] | 180 |                 std::make_unique<Remove>(bus, std::get<2>(item))); | 
| Dhruvaraj Subhashchandran | 891c476 | 2017-07-31 14:26:37 -0500 | [diff] [blame] | 181 |             action(bus, std::get<2>(item), true); | 
| Dhruvaraj Subhashchandran | 3c6f29a | 2017-04-20 09:47:28 -0500 | [diff] [blame] | 182 |         } | 
 | 183 |     } | 
| Dhruvaraj Subhashchandran | aebfde8 | 2017-07-11 01:36:33 -0500 | [diff] [blame] | 184 |  | 
| Patrick Williams | 3eedbe4 | 2017-05-31 17:27:05 -0500 | [diff] [blame] | 185 |     return; | 
| Dhruvaraj Subhashchandran | 59b86cd | 2017-04-13 00:19:44 -0500 | [diff] [blame] | 186 | } | 
 | 187 |  | 
| Matt Spinler | 9112292 | 2018-09-24 11:31:44 -0500 | [diff] [blame] | 188 | void getLoggingSubTree(sdbusplus::bus::bus& bus, MapperResponseType& subtree) | 
| Dhruvaraj Subhashchandran | 891c476 | 2017-07-31 14:26:37 -0500 | [diff] [blame] | 189 | { | 
 | 190 |     auto depth = 0; | 
| Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 191 |     auto mapperCall = bus.new_method_call(MAPPER_BUSNAME, MAPPER_OBJ_PATH, | 
 | 192 |                                           MAPPER_IFACE, "GetSubTree"); | 
| Dhruvaraj Subhashchandran | 891c476 | 2017-07-31 14:26:37 -0500 | [diff] [blame] | 193 |     mapperCall.append("/"); | 
 | 194 |     mapperCall.append(depth); | 
 | 195 |     mapperCall.append(std::vector<Interface>({LOG_IFACE})); | 
 | 196 |  | 
| William A. Kennington III | 151122a | 2018-05-15 12:00:32 -0700 | [diff] [blame] | 197 |     try | 
 | 198 |     { | 
| Matt Spinler | 9112292 | 2018-09-24 11:31:44 -0500 | [diff] [blame] | 199 |         auto mapperResponseMsg = bus.call(mapperCall); | 
| George Liu | d78de14 | 2021-08-23 16:16:32 +0800 | [diff] [blame] | 200 |         mapperResponseMsg.read(subtree); | 
| William A. Kennington III | 151122a | 2018-05-15 12:00:32 -0700 | [diff] [blame] | 201 |     } | 
| Patrick Williams | 7152edc | 2021-09-02 09:41:54 -0500 | [diff] [blame] | 202 |     catch (const sdbusplus::exception::exception& e) | 
| William A. Kennington III | 151122a | 2018-05-15 12:00:32 -0700 | [diff] [blame] | 203 |     { | 
| George Liu | e9fb5c6 | 2021-07-01 14:05:32 +0800 | [diff] [blame] | 204 |         lg2::error( | 
 | 205 |             "Failed to parse existing callouts subtree message, ERROR = {ERROR}", | 
 | 206 |             "ERROR", e); | 
| William A. Kennington III | 151122a | 2018-05-15 12:00:32 -0700 | [diff] [blame] | 207 |     } | 
| Matt Spinler | 9112292 | 2018-09-24 11:31:44 -0500 | [diff] [blame] | 208 | } | 
 | 209 |  | 
 | 210 | void Add::processExistingCallouts(sdbusplus::bus::bus& bus) | 
 | 211 | { | 
| Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 212 |     MapperResponseType mapperResponse; | 
| Matt Spinler | 9112292 | 2018-09-24 11:31:44 -0500 | [diff] [blame] | 213 |  | 
 | 214 |     getLoggingSubTree(bus, mapperResponse); | 
| Dhruvaraj Subhashchandran | 891c476 | 2017-07-31 14:26:37 -0500 | [diff] [blame] | 215 |     if (mapperResponse.empty()) | 
 | 216 |     { | 
| Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 217 |         // No errors to process. | 
| Dhruvaraj Subhashchandran | 891c476 | 2017-07-31 14:26:37 -0500 | [diff] [blame] | 218 |         return; | 
 | 219 |     } | 
 | 220 |  | 
 | 221 |     for (const auto& elem : mapperResponse) | 
 | 222 |     { | 
| Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 223 |         auto method = bus.new_method_call( | 
 | 224 |             elem.second.begin()->first.c_str(), elem.first.c_str(), | 
 | 225 |             "org.freedesktop.DBus.Properties", "Get"); | 
| Andrew Geissler | a6e4892 | 2019-11-06 08:43:54 -0600 | [diff] [blame] | 226 |         method.append("xyz.openbmc_project.Association.Definitions"); | 
 | 227 |         method.append("Associations"); | 
| Dhruvaraj Subhashchandran | 891c476 | 2017-07-31 14:26:37 -0500 | [diff] [blame] | 228 |         auto reply = bus.call(method); | 
 | 229 |         if (reply.is_method_error()) | 
 | 230 |         { | 
| Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 231 |             // do not stop, continue with next elog | 
| George Liu | e9fb5c6 | 2021-07-01 14:05:32 +0800 | [diff] [blame] | 232 |             lg2::error("Error in getting associations"); | 
| Dhruvaraj Subhashchandran | 891c476 | 2017-07-31 14:26:37 -0500 | [diff] [blame] | 233 |             continue; | 
 | 234 |         } | 
 | 235 |  | 
| Patrick Williams | a41d282 | 2020-05-13 17:57:23 -0500 | [diff] [blame] | 236 |         std::variant<AssociationList> assoc; | 
| William A. Kennington III | 151122a | 2018-05-15 12:00:32 -0700 | [diff] [blame] | 237 |         try | 
 | 238 |         { | 
 | 239 |             reply.read(assoc); | 
 | 240 |         } | 
| Patrick Williams | 7152edc | 2021-09-02 09:41:54 -0500 | [diff] [blame] | 241 |         catch (const sdbusplus::exception::exception& e) | 
| William A. Kennington III | 151122a | 2018-05-15 12:00:32 -0700 | [diff] [blame] | 242 |         { | 
| George Liu | e9fb5c6 | 2021-07-01 14:05:32 +0800 | [diff] [blame] | 243 |             lg2::error( | 
 | 244 |                 "Failed to parse existing callouts associations message, ERROR = {ERROR}", | 
 | 245 |                 "ERROR", e); | 
| William A. Kennington III | 151122a | 2018-05-15 12:00:32 -0700 | [diff] [blame] | 246 |             continue; | 
 | 247 |         } | 
| Patrick Williams | 5ebebef | 2020-05-13 11:47:27 -0500 | [diff] [blame] | 248 |         auto& assocs = std::get<AssociationList>(assoc); | 
| Dhruvaraj Subhashchandran | 891c476 | 2017-07-31 14:26:37 -0500 | [diff] [blame] | 249 |         if (assocs.empty()) | 
 | 250 |         { | 
| Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 251 |             // no associations, skip | 
| Dhruvaraj Subhashchandran | 891c476 | 2017-07-31 14:26:37 -0500 | [diff] [blame] | 252 |             continue; | 
 | 253 |         } | 
 | 254 |  | 
 | 255 |         for (const auto& item : assocs) | 
 | 256 |         { | 
 | 257 |             if (std::get<1>(item).compare(CALLOUT_REV_ASSOCIATION) == 0) | 
 | 258 |             { | 
 | 259 |                 removeWatches.emplace_back( | 
 | 260 |                     std::make_unique<Remove>(bus, std::get<2>(item))); | 
 | 261 |                 action(bus, std::get<2>(item), true); | 
 | 262 |             } | 
 | 263 |         } | 
 | 264 |     } | 
 | 265 | } | 
 | 266 |  | 
| Patrick Williams | 3eedbe4 | 2017-05-31 17:27:05 -0500 | [diff] [blame] | 267 | void Remove::removed(sdbusplus::message::message& msg) | 
| Dhruvaraj Subhashchandran | 59b86cd | 2017-04-13 00:19:44 -0500 | [diff] [blame] | 268 | { | 
| Patrick Williams | 3eedbe4 | 2017-05-31 17:27:05 -0500 | [diff] [blame] | 269 |     auto bus = msg.get_bus(); | 
| Dhruvaraj Subhashchandran | 3c6f29a | 2017-04-20 09:47:28 -0500 | [diff] [blame] | 270 |  | 
| Patrick Williams | 3eedbe4 | 2017-05-31 17:27:05 -0500 | [diff] [blame] | 271 |     action(bus, inventoryPath, false); | 
 | 272 |     return; | 
| Dhruvaraj Subhashchandran | 59b86cd | 2017-04-13 00:19:44 -0500 | [diff] [blame] | 273 | } | 
 | 274 |  | 
| Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 275 | } // namespace monitor | 
 | 276 | } // namespace fault | 
 | 277 | } // namespace fru | 
 | 278 | } // namespace led | 
 | 279 | } // namespace phosphor |