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