| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 1 | #include <bitset> | 
| Tom Joseph | 816e92b | 2017-09-06 19:23:00 +0530 | [diff] [blame] | 2 | #include <experimental/filesystem> | 
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 3 | #include <phosphor-logging/elog-errors.hpp> | 
|  | 4 | #include <phosphor-logging/log.hpp> | 
|  | 5 | #include "xyz/openbmc_project/Common/error.hpp" | 
|  | 6 | #include "types.hpp" | 
| Tom Joseph | 816e92b | 2017-09-06 19:23:00 +0530 | [diff] [blame] | 7 | #include "sensorhandler.h" | 
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 8 | #include "sensordatahandler.hpp" | 
| Tom Joseph | 816e92b | 2017-09-06 19:23:00 +0530 | [diff] [blame] | 9 | #include "utils.hpp" | 
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 10 |  | 
|  | 11 | namespace ipmi | 
|  | 12 | { | 
|  | 13 | namespace sensor | 
|  | 14 | { | 
|  | 15 |  | 
|  | 16 | using namespace phosphor::logging; | 
|  | 17 | using InternalFailure = | 
|  | 18 | sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure; | 
|  | 19 |  | 
|  | 20 | static constexpr auto MAPPER_BUSNAME = "xyz.openbmc_project.ObjectMapper"; | 
|  | 21 | static constexpr auto MAPPER_PATH = "/xyz/openbmc_project/object_mapper"; | 
|  | 22 | static constexpr auto MAPPER_INTERFACE = "xyz.openbmc_project.ObjectMapper"; | 
|  | 23 |  | 
|  | 24 | /** @brief get the D-Bus service and service path | 
|  | 25 | *  @param[in] bus - The Dbus bus object | 
|  | 26 | *  @param[in] interface - interface to the service | 
|  | 27 | *  @param[in] path - interested path in the list of objects | 
|  | 28 | *  @return pair of service path and service | 
|  | 29 | */ | 
|  | 30 | ServicePath getServiceAndPath(sdbusplus::bus::bus& bus, | 
|  | 31 | const std::string& interface, | 
|  | 32 | const std::string& path) | 
|  | 33 | { | 
|  | 34 | auto depth = 0; | 
|  | 35 | auto mapperCall = bus.new_method_call(MAPPER_BUSNAME, | 
|  | 36 | MAPPER_PATH, | 
|  | 37 | MAPPER_INTERFACE, | 
|  | 38 | "GetSubTree"); | 
|  | 39 | mapperCall.append("/"); | 
|  | 40 | mapperCall.append(depth); | 
|  | 41 | mapperCall.append(std::vector<Interface>({interface})); | 
|  | 42 |  | 
|  | 43 | auto mapperResponseMsg = bus.call(mapperCall); | 
|  | 44 | if (mapperResponseMsg.is_method_error()) | 
|  | 45 | { | 
| Dhruvaraj Subhashchandran | 18e9999 | 2017-08-09 09:10:47 -0500 | [diff] [blame] | 46 | log<level::ERR>("Mapper GetSubTree failed", | 
|  | 47 | entry("PATH=%s", path), | 
|  | 48 | entry("INTERFACE=%s", interface)); | 
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 49 | elog<InternalFailure>(); | 
|  | 50 | } | 
|  | 51 |  | 
|  | 52 | MapperResponseType mapperResponse; | 
|  | 53 | mapperResponseMsg.read(mapperResponse); | 
|  | 54 | if (mapperResponse.empty()) | 
|  | 55 | { | 
| Dhruvaraj Subhashchandran | 18e9999 | 2017-08-09 09:10:47 -0500 | [diff] [blame] | 56 | log<level::ERR>("Invalid mapper response", | 
|  | 57 | entry("PATH=%s", path), | 
|  | 58 | entry("INTERFACE=%s", interface)); | 
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 59 | elog<InternalFailure>(); | 
|  | 60 | } | 
|  | 61 |  | 
|  | 62 | if (path.empty()) | 
|  | 63 | { | 
|  | 64 | //Get the first one if the path is not in list. | 
|  | 65 | return std::make_pair(mapperResponse.begin()->first, | 
|  | 66 | mapperResponse.begin()->second.begin()->first); | 
|  | 67 | } | 
|  | 68 | const auto& iter = mapperResponse.find(path); | 
|  | 69 | if (iter == mapperResponse.end()) | 
|  | 70 | { | 
| Dhruvaraj Subhashchandran | 18e9999 | 2017-08-09 09:10:47 -0500 | [diff] [blame] | 71 | log<level::ERR>("Coudn't find d-bus path", | 
|  | 72 | entry("PATH=%s", path), | 
|  | 73 | entry("INTERFACE=%s", interface)); | 
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 74 | elog<InternalFailure>(); | 
|  | 75 | } | 
|  | 76 | return std::make_pair(iter->first, iter->second.begin()->first); | 
|  | 77 | } | 
|  | 78 |  | 
|  | 79 | AssertionSet getAssertionSet(const SetSensorReadingReq& cmdData) | 
|  | 80 | { | 
|  | 81 | Assertion assertionStates = | 
|  | 82 | (static_cast<Assertion>(cmdData.assertOffset8_14)) << 8 | | 
|  | 83 | cmdData.assertOffset0_7; | 
|  | 84 | Deassertion deassertionStates = | 
|  | 85 | (static_cast<Deassertion>(cmdData.deassertOffset8_14)) << 8 | | 
|  | 86 | cmdData.deassertOffset0_7; | 
|  | 87 | return std::make_pair(assertionStates, deassertionStates); | 
|  | 88 | } | 
|  | 89 |  | 
|  | 90 | ipmi_ret_t updateToDbus(IpmiUpdateData& msg) | 
|  | 91 | { | 
|  | 92 | sdbusplus::bus::bus bus{ipmid_get_sd_bus_connection()}; | 
|  | 93 | try | 
|  | 94 | { | 
|  | 95 | auto serviceResponseMsg = bus.call(msg); | 
|  | 96 | if (serviceResponseMsg.is_method_error()) | 
|  | 97 | { | 
|  | 98 | log<level::ERR>("Error in D-Bus call"); | 
|  | 99 | return IPMI_CC_UNSPECIFIED_ERROR; | 
|  | 100 | } | 
|  | 101 | } | 
|  | 102 | catch (InternalFailure& e) | 
|  | 103 | { | 
|  | 104 | commit<InternalFailure>(); | 
|  | 105 | return IPMI_CC_UNSPECIFIED_ERROR; | 
|  | 106 | } | 
|  | 107 | return IPMI_CC_OK; | 
|  | 108 | } | 
|  | 109 |  | 
| Tom Joseph | 816e92b | 2017-09-06 19:23:00 +0530 | [diff] [blame] | 110 | namespace get | 
|  | 111 | { | 
|  | 112 |  | 
| Tom Joseph | b0adbcd | 2018-01-24 11:51:29 +0530 | [diff] [blame] | 113 | SensorName nameParentLeaf(const Info& sensorInfo) | 
|  | 114 | { | 
|  | 115 | const auto pos = sensorInfo.sensorPath.find_last_of('/'); | 
|  | 116 | const auto leaf = sensorInfo.sensorPath.substr(pos + 1); | 
|  | 117 |  | 
|  | 118 | const auto remaining = sensorInfo.sensorPath.substr(0, pos); | 
|  | 119 |  | 
|  | 120 | const auto parentPos = remaining.find_last_of('/'); | 
|  | 121 | auto parent = remaining.substr(parentPos + 1); | 
|  | 122 |  | 
|  | 123 | parent += "_" + leaf; | 
|  | 124 | return parent; | 
|  | 125 | } | 
|  | 126 |  | 
| Tom Joseph | 816e92b | 2017-09-06 19:23:00 +0530 | [diff] [blame] | 127 | GetSensorResponse mapDbusToAssertion(const Info& sensorInfo, | 
|  | 128 | const InstancePath& path, | 
|  | 129 | const DbusInterface& interface) | 
|  | 130 | { | 
|  | 131 | sdbusplus::bus::bus bus{ipmid_get_sd_bus_connection()}; | 
|  | 132 | GetSensorResponse response {}; | 
|  | 133 | auto responseData = reinterpret_cast<GetReadingResponse*>(response.data()); | 
|  | 134 |  | 
|  | 135 | auto service = ipmi::getService(bus, interface, path); | 
|  | 136 |  | 
|  | 137 | const auto& interfaceList = sensorInfo.propertyInterfaces; | 
|  | 138 |  | 
|  | 139 | for (const auto& interface : interfaceList) | 
|  | 140 | { | 
|  | 141 | for (const auto& property : interface.second) | 
|  | 142 | { | 
|  | 143 | auto propValue = ipmi::getDbusProperty(bus, | 
|  | 144 | service, | 
|  | 145 | path, | 
|  | 146 | interface.first, | 
|  | 147 | property.first); | 
|  | 148 |  | 
| Dhruvaraj Subhashchandran | e245e4e | 2017-10-03 03:58:05 -0500 | [diff] [blame] | 149 | for (const auto& value : std::get<OffsetValueMap>(property.second)) | 
| Tom Joseph | 816e92b | 2017-09-06 19:23:00 +0530 | [diff] [blame] | 150 | { | 
|  | 151 | if (propValue == value.second.assert) | 
|  | 152 | { | 
|  | 153 | setOffset(value.first, responseData); | 
|  | 154 | break; | 
|  | 155 | } | 
|  | 156 |  | 
|  | 157 | } | 
|  | 158 | } | 
|  | 159 | } | 
|  | 160 |  | 
|  | 161 | return response; | 
|  | 162 | } | 
|  | 163 |  | 
|  | 164 | GetSensorResponse assertion(const Info& sensorInfo) | 
|  | 165 | { | 
|  | 166 | return mapDbusToAssertion(sensorInfo, | 
|  | 167 | sensorInfo.sensorPath, | 
|  | 168 | sensorInfo.sensorInterface); | 
|  | 169 | } | 
|  | 170 |  | 
| Tom Joseph | e4014fc | 2017-09-06 23:57:36 +0530 | [diff] [blame] | 171 | GetSensorResponse eventdata2(const Info& sensorInfo) | 
|  | 172 | { | 
|  | 173 | sdbusplus::bus::bus bus{ipmid_get_sd_bus_connection()}; | 
|  | 174 | GetSensorResponse response {}; | 
|  | 175 | auto responseData = reinterpret_cast<GetReadingResponse*>(response.data()); | 
|  | 176 |  | 
|  | 177 | auto service = ipmi::getService(bus, | 
|  | 178 | sensorInfo.sensorInterface, | 
|  | 179 | sensorInfo.sensorPath); | 
|  | 180 |  | 
|  | 181 | const auto& interfaceList = sensorInfo.propertyInterfaces; | 
|  | 182 |  | 
|  | 183 | for (const auto& interface : interfaceList) | 
|  | 184 | { | 
|  | 185 | for (const auto& property : interface.second) | 
|  | 186 | { | 
|  | 187 | auto propValue = ipmi::getDbusProperty(bus, | 
|  | 188 | service, | 
|  | 189 | sensorInfo.sensorPath, | 
|  | 190 | interface.first, | 
|  | 191 | property.first); | 
|  | 192 |  | 
| Dhruvaraj Subhashchandran | e245e4e | 2017-10-03 03:58:05 -0500 | [diff] [blame] | 193 | for (const auto& value : std::get<OffsetValueMap>(property.second)) | 
| Tom Joseph | e4014fc | 2017-09-06 23:57:36 +0530 | [diff] [blame] | 194 | { | 
|  | 195 | if (propValue == value.second.assert) | 
|  | 196 | { | 
|  | 197 | setReading(value.first, responseData); | 
|  | 198 | break; | 
|  | 199 | } | 
|  | 200 | } | 
|  | 201 | } | 
|  | 202 | } | 
|  | 203 |  | 
|  | 204 | return response; | 
|  | 205 | } | 
|  | 206 |  | 
| Tom Joseph | 816e92b | 2017-09-06 19:23:00 +0530 | [diff] [blame] | 207 | } //namespace get | 
|  | 208 |  | 
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 209 | namespace set | 
|  | 210 | { | 
|  | 211 |  | 
|  | 212 | IpmiUpdateData makeDbusMsg(const std::string& updateInterface, | 
|  | 213 | const std::string& sensorPath, | 
|  | 214 | const std::string& command, | 
|  | 215 | const std::string& sensorInterface) | 
|  | 216 | { | 
|  | 217 | sdbusplus::bus::bus bus{ipmid_get_sd_bus_connection()}; | 
|  | 218 | using namespace std::string_literals; | 
|  | 219 |  | 
| Tom Joseph | c6a571a | 2017-11-28 16:46:22 +0530 | [diff] [blame] | 220 | auto dbusService = getService(bus, | 
|  | 221 | sensorInterface, | 
|  | 222 | sensorPath); | 
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 223 |  | 
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 224 | return bus.new_method_call(dbusService.c_str(), | 
| Tom Joseph | c6a571a | 2017-11-28 16:46:22 +0530 | [diff] [blame] | 225 | sensorPath.c_str(), | 
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 226 | updateInterface.c_str(), | 
|  | 227 | command.c_str()); | 
|  | 228 | } | 
|  | 229 |  | 
| Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 230 | ipmi_ret_t eventdata(const SetSensorReadingReq& cmdData, | 
|  | 231 | const Info& sensorInfo, | 
|  | 232 | uint8_t data) | 
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 233 | { | 
| Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 234 | auto msg = makeDbusMsg( | 
|  | 235 | "org.freedesktop.DBus.Properties", | 
|  | 236 | sensorInfo.sensorPath, | 
|  | 237 | "Set", | 
|  | 238 | sensorInfo.sensorInterface); | 
|  | 239 |  | 
|  | 240 | const auto& interface = sensorInfo.propertyInterfaces.begin(); | 
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 241 | msg.append(interface->first); | 
|  | 242 | for (const auto& property : interface->second) | 
|  | 243 | { | 
|  | 244 | msg.append(property.first); | 
| Dhruvaraj Subhashchandran | e245e4e | 2017-10-03 03:58:05 -0500 | [diff] [blame] | 245 | const auto& iter = std::get<OffsetValueMap>(property.second).find(data); | 
|  | 246 | if (iter == std::get<OffsetValueMap>(property.second).end()) | 
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 247 | { | 
|  | 248 | log<level::ERR>("Invalid event data"); | 
|  | 249 | return IPMI_CC_PARM_OUT_OF_RANGE; | 
|  | 250 | } | 
|  | 251 | msg.append(iter->second.assert); | 
|  | 252 | } | 
| Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 253 | return updateToDbus(msg); | 
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 254 | } | 
|  | 255 |  | 
| Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 256 | ipmi_ret_t assertion(const SetSensorReadingReq& cmdData, | 
|  | 257 | const Info& sensorInfo) | 
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 258 | { | 
| Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 259 | auto msg = makeDbusMsg( | 
|  | 260 | "org.freedesktop.DBus.Properties", | 
|  | 261 | sensorInfo.sensorPath, | 
|  | 262 | "Set", | 
|  | 263 | sensorInfo.sensorInterface); | 
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 264 |  | 
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 265 | std::bitset<16> assertionSet(getAssertionSet(cmdData).first); | 
|  | 266 | std::bitset<16> deassertionSet(getAssertionSet(cmdData).second); | 
|  | 267 |  | 
| Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 268 | const auto& interface = sensorInfo.propertyInterfaces.begin(); | 
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 269 | msg.append(interface->first); | 
|  | 270 | for (const auto& property : interface->second) | 
|  | 271 | { | 
|  | 272 | msg.append(property.first); | 
| Dhruvaraj Subhashchandran | e245e4e | 2017-10-03 03:58:05 -0500 | [diff] [blame] | 273 | for (const auto& value : std::get<OffsetValueMap>(property.second)) | 
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 274 | { | 
|  | 275 | if (assertionSet.test(value.first)) | 
|  | 276 | { | 
|  | 277 | msg.append(value.second.assert); | 
|  | 278 | } | 
|  | 279 | if (deassertionSet.test(value.first)) | 
|  | 280 | { | 
|  | 281 | msg.append(value.second.deassert); | 
|  | 282 | } | 
|  | 283 | } | 
|  | 284 | } | 
| Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 285 | return updateToDbus(msg); | 
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 286 | } | 
| Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 287 |  | 
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 288 | }//namespace set | 
|  | 289 |  | 
|  | 290 | namespace notify | 
|  | 291 | { | 
|  | 292 |  | 
|  | 293 | IpmiUpdateData makeDbusMsg(const std::string& updateInterface, | 
|  | 294 | const std::string& sensorPath, | 
|  | 295 | const std::string& command, | 
|  | 296 | const std::string& sensorInterface) | 
|  | 297 | { | 
|  | 298 | sdbusplus::bus::bus bus{ipmid_get_sd_bus_connection()}; | 
|  | 299 | using namespace std::string_literals; | 
|  | 300 |  | 
| Dhruvaraj Subhashchandran | f915f85 | 2017-09-14 07:01:48 -0500 | [diff] [blame] | 301 | static const auto dbusPath = "/xyz/openbmc_project/inventory"s; | 
|  | 302 | std::string dbusService = ipmi::getService(bus, updateInterface, dbusPath); | 
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 303 |  | 
|  | 304 | return bus.new_method_call(dbusService.c_str(), | 
|  | 305 | dbusPath.c_str(), | 
|  | 306 | updateInterface.c_str(), | 
|  | 307 | command.c_str()); | 
|  | 308 | } | 
|  | 309 |  | 
| Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 310 | ipmi_ret_t assertion(const SetSensorReadingReq& cmdData, | 
|  | 311 | const Info& sensorInfo) | 
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 312 | { | 
| Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 313 | auto msg = makeDbusMsg( | 
|  | 314 | sensorInfo.sensorInterface, | 
|  | 315 | sensorInfo.sensorPath, | 
|  | 316 | "Notify", | 
|  | 317 | sensorInfo.sensorInterface); | 
|  | 318 |  | 
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 319 | std::bitset<16> assertionSet(getAssertionSet(cmdData).first); | 
|  | 320 | std::bitset<16> deassertionSet(getAssertionSet(cmdData).second); | 
|  | 321 | ipmi::sensor::ObjectMap objects; | 
|  | 322 | ipmi::sensor::InterfaceMap interfaces; | 
| Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 323 | for (const auto& interface : sensorInfo.propertyInterfaces) | 
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 324 | { | 
| Dhruvaraj Subhashchandran | e245e4e | 2017-10-03 03:58:05 -0500 | [diff] [blame] | 325 | //For a property like functional state the result will be | 
|  | 326 | //calculated based on the true value of all conditions. | 
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 327 | for (const auto& property : interface.second) | 
|  | 328 | { | 
|  | 329 | ipmi::sensor::PropertyMap props; | 
|  | 330 | bool valid = false; | 
| Dhruvaraj Subhashchandran | e245e4e | 2017-10-03 03:58:05 -0500 | [diff] [blame] | 331 | auto result = true; | 
|  | 332 | for (const auto& value : std::get<OffsetValueMap>(property.second)) | 
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 333 | { | 
|  | 334 | if (assertionSet.test(value.first)) | 
|  | 335 | { | 
| Dhruvaraj Subhashchandran | e84841c | 2017-08-22 07:40:27 -0500 | [diff] [blame] | 336 | //Skip update if skipOn is ASSERT | 
|  | 337 | if (SkipAssertion::ASSERT == value.second.skip) | 
|  | 338 | { | 
|  | 339 | return IPMI_CC_OK; | 
|  | 340 | } | 
| Dhruvaraj Subhashchandran | e245e4e | 2017-10-03 03:58:05 -0500 | [diff] [blame] | 341 | result = result && value.second.assert.get<bool>(); | 
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 342 | valid = true; | 
|  | 343 | } | 
|  | 344 | else if (deassertionSet.test(value.first)) | 
|  | 345 | { | 
| Dhruvaraj Subhashchandran | e84841c | 2017-08-22 07:40:27 -0500 | [diff] [blame] | 346 | //Skip update if skipOn is DEASSERT | 
|  | 347 | if (SkipAssertion::DEASSERT == value.second.skip) | 
|  | 348 | { | 
|  | 349 | return IPMI_CC_OK; | 
|  | 350 | } | 
| Dhruvaraj Subhashchandran | e245e4e | 2017-10-03 03:58:05 -0500 | [diff] [blame] | 351 | result = result && value.second.deassert.get<bool>(); | 
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 352 | valid = true; | 
|  | 353 | } | 
|  | 354 | } | 
| Dhruvaraj Subhashchandran | e245e4e | 2017-10-03 03:58:05 -0500 | [diff] [blame] | 355 | for (const auto& value : | 
|  | 356 | std::get<PreReqOffsetValueMap>(property.second)) | 
|  | 357 | { | 
|  | 358 | if (assertionSet.test(value.first)) | 
|  | 359 | { | 
|  | 360 | result = result && value.second.assert.get<bool>(); | 
|  | 361 | } | 
|  | 362 | else if (deassertionSet.test(value.first)) | 
|  | 363 | { | 
|  | 364 | result = result && value.second.deassert.get<bool>(); | 
|  | 365 | } | 
|  | 366 | } | 
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 367 | if (valid) | 
|  | 368 | { | 
| Dhruvaraj Subhashchandran | e245e4e | 2017-10-03 03:58:05 -0500 | [diff] [blame] | 369 | props.emplace(property.first, result); | 
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 370 | interfaces.emplace(interface.first, std::move(props)); | 
|  | 371 | } | 
|  | 372 | } | 
|  | 373 | } | 
| Dhruvaraj Subhashchandran | e84841c | 2017-08-22 07:40:27 -0500 | [diff] [blame] | 374 |  | 
| Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 375 | objects.emplace(sensorInfo.sensorPath, std::move(interfaces)); | 
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 376 | msg.append(std::move(objects)); | 
| Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 377 | return updateToDbus(msg); | 
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 378 | } | 
| Tom Joseph | 816e92b | 2017-09-06 19:23:00 +0530 | [diff] [blame] | 379 |  | 
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 380 | }//namespace notify | 
| Tom Joseph | 816e92b | 2017-09-06 19:23:00 +0530 | [diff] [blame] | 381 |  | 
|  | 382 | namespace inventory | 
|  | 383 | { | 
|  | 384 |  | 
|  | 385 | namespace get | 
|  | 386 | { | 
|  | 387 |  | 
|  | 388 | GetSensorResponse assertion(const Info& sensorInfo) | 
|  | 389 | { | 
|  | 390 | namespace fs = std::experimental::filesystem; | 
|  | 391 |  | 
|  | 392 | fs::path path{ipmi::sensor::inventoryRoot}; | 
|  | 393 | path += sensorInfo.sensorPath; | 
|  | 394 |  | 
|  | 395 | return ipmi::sensor::get::mapDbusToAssertion( | 
|  | 396 | sensorInfo, | 
|  | 397 | path.string(), | 
|  | 398 | sensorInfo.propertyInterfaces.begin()->first); | 
|  | 399 | } | 
|  | 400 |  | 
|  | 401 | } //namespace get | 
|  | 402 |  | 
|  | 403 | } // namespace inventory | 
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 404 | }//namespace sensor | 
|  | 405 | }//namespace ipmi |