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