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