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