Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 1 | /* |
| 2 | // Copyright (c) 2018 Intel Corporation |
| 3 | // |
| 4 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | // you may not use this file except in compliance with the License. |
| 6 | // You may obtain a copy of the License at |
| 7 | // |
| 8 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | // |
| 10 | // Unless required by applicable law or agreed to in writing, software |
| 11 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | // See the License for the specific language governing permissions and |
| 14 | // limitations under the License. |
| 15 | */ |
| 16 | #pragma once |
| 17 | |
James Feist | 35e257a | 2020-06-05 13:30:51 -0700 | [diff] [blame] | 18 | #include "health.hpp" |
| 19 | |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 20 | #include <boost/container/flat_map.hpp> |
James Feist | c50e7c6 | 2020-07-27 15:39:36 -0700 | [diff] [blame^] | 21 | #include <boost/format.hpp> |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 22 | #include <node.hpp> |
| 23 | #include <utils/json_utils.hpp> |
| 24 | |
| 25 | namespace redfish |
| 26 | { |
| 27 | |
RAJESWARAN THILLAIGOVINDAN | ec8faf9 | 2019-02-21 10:59:03 -0600 | [diff] [blame] | 28 | using InterfacesProperties = boost::container::flat_map< |
| 29 | std::string, |
| 30 | boost::container::flat_map<std::string, dbus::utility::DbusVariantType>>; |
| 31 | |
Ed Tanous | 029573d | 2019-02-01 10:57:49 -0800 | [diff] [blame] | 32 | void getResourceList(std::shared_ptr<AsyncResp> aResp, |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 33 | const std::string& subclass, |
| 34 | const std::vector<const char*>& collectionName) |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 35 | { |
| 36 | BMCWEB_LOG_DEBUG << "Get available system cpu/mem resources."; |
| 37 | crow::connections::systemBus->async_method_call( |
Ed Tanous | 029573d | 2019-02-01 10:57:49 -0800 | [diff] [blame] | 38 | [subclass, aResp{std::move(aResp)}]( |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 39 | const boost::system::error_code ec, |
| 40 | const boost::container::flat_map< |
| 41 | std::string, boost::container::flat_map< |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 42 | std::string, std::vector<std::string>>>& |
| 43 | subtree) { |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 44 | if (ec) |
| 45 | { |
| 46 | BMCWEB_LOG_DEBUG << "DBUS response error"; |
| 47 | messages::internalError(aResp->res); |
| 48 | return; |
| 49 | } |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 50 | nlohmann::json& members = aResp->res.jsonValue["Members"]; |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 51 | members = nlohmann::json::array(); |
| 52 | |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 53 | for (const auto& object : subtree) |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 54 | { |
| 55 | auto iter = object.first.rfind("/"); |
| 56 | if ((iter != std::string::npos) && (iter < object.first.size())) |
| 57 | { |
| 58 | members.push_back( |
Ed Tanous | 029573d | 2019-02-01 10:57:49 -0800 | [diff] [blame] | 59 | {{"@odata.id", "/redfish/v1/Systems/system/" + |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 60 | subclass + "/" + |
| 61 | object.first.substr(iter + 1)}}); |
| 62 | } |
| 63 | } |
| 64 | aResp->res.jsonValue["Members@odata.count"] = members.size(); |
| 65 | }, |
| 66 | "xyz.openbmc_project.ObjectMapper", |
| 67 | "/xyz/openbmc_project/object_mapper", |
| 68 | "xyz.openbmc_project.ObjectMapper", "GetSubTree", |
Ed Tanous | 271584a | 2019-07-09 16:24:22 -0700 | [diff] [blame] | 69 | "/xyz/openbmc_project/inventory", 0, collectionName); |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 70 | } |
| 71 | |
RAJESWARAN THILLAIGOVINDAN | ec8faf9 | 2019-02-21 10:59:03 -0600 | [diff] [blame] | 72 | void getCpuDataByInterface(std::shared_ptr<AsyncResp> aResp, |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 73 | const InterfacesProperties& cpuInterfacesProperties) |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 74 | { |
RAJESWARAN THILLAIGOVINDAN | ec8faf9 | 2019-02-21 10:59:03 -0600 | [diff] [blame] | 75 | BMCWEB_LOG_DEBUG << "Get CPU resources by interface."; |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 76 | |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 77 | const bool* present = nullptr; |
| 78 | const bool* functional = nullptr; |
| 79 | for (const auto& interface : cpuInterfacesProperties) |
RAJESWARAN THILLAIGOVINDAN | ec8faf9 | 2019-02-21 10:59:03 -0600 | [diff] [blame] | 80 | { |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 81 | for (const auto& property : interface.second) |
RAJESWARAN THILLAIGOVINDAN | ec8faf9 | 2019-02-21 10:59:03 -0600 | [diff] [blame] | 82 | { |
| 83 | if (property.first == "ProcessorCoreCount") |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 84 | { |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 85 | const uint16_t* coresCount = |
RAJESWARAN THILLAIGOVINDAN | ec8faf9 | 2019-02-21 10:59:03 -0600 | [diff] [blame] | 86 | std::get_if<uint16_t>(&property.second); |
Ed Tanous | 883b311 | 2018-12-06 16:13:35 -0800 | [diff] [blame] | 87 | if (coresCount == nullptr) |
| 88 | { |
| 89 | // Important property not in desired type |
| 90 | messages::internalError(aResp->res); |
| 91 | return; |
| 92 | } |
| 93 | if (*coresCount == 0) |
| 94 | { |
| 95 | // Slot is not populated, set status end return |
| 96 | aResp->res.jsonValue["Status"]["State"] = "Absent"; |
| 97 | aResp->res.jsonValue["Status"]["Health"] = "OK"; |
| 98 | // HTTP Code will be set up automatically, just return |
| 99 | return; |
| 100 | } |
| 101 | |
| 102 | aResp->res.jsonValue["TotalCores"] = *coresCount; |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 103 | } |
RAJESWARAN THILLAIGOVINDAN | ec8faf9 | 2019-02-21 10:59:03 -0600 | [diff] [blame] | 104 | else if (property.first == "ProcessorType") |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 105 | { |
RAJESWARAN THILLAIGOVINDAN | ec8faf9 | 2019-02-21 10:59:03 -0600 | [diff] [blame] | 106 | aResp->res.jsonValue["Name"] = property.second; |
| 107 | } |
| 108 | else if (property.first == "Manufacturer") |
| 109 | { |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 110 | const std::string* value = |
RAJESWARAN THILLAIGOVINDAN | ec8faf9 | 2019-02-21 10:59:03 -0600 | [diff] [blame] | 111 | std::get_if<std::string>(&property.second); |
| 112 | if (value != nullptr) |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 113 | { |
| 114 | aResp->res.jsonValue["Manufacturer"] = property.second; |
RAJESWARAN THILLAIGOVINDAN | ec8faf9 | 2019-02-21 10:59:03 -0600 | [diff] [blame] | 115 | // Otherwise would be unexpected. |
| 116 | if (value->find("Intel") != std::string::npos) |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 117 | { |
RAJESWARAN THILLAIGOVINDAN | ec8faf9 | 2019-02-21 10:59:03 -0600 | [diff] [blame] | 118 | aResp->res.jsonValue["ProcessorArchitecture"] = "x86"; |
| 119 | aResp->res.jsonValue["InstructionSet"] = "x86-64"; |
| 120 | } |
| 121 | else if (value->find("IBM") != std::string::npos) |
| 122 | { |
| 123 | aResp->res.jsonValue["ProcessorArchitecture"] = "Power"; |
| 124 | aResp->res.jsonValue["InstructionSet"] = "PowerISA"; |
| 125 | } |
| 126 | } |
| 127 | } |
| 128 | else if (property.first == "ProcessorMaxSpeed") |
| 129 | { |
| 130 | aResp->res.jsonValue["MaxSpeedMHz"] = property.second; |
| 131 | } |
| 132 | else if (property.first == "ProcessorThreadCount") |
| 133 | { |
| 134 | aResp->res.jsonValue["TotalThreads"] = property.second; |
| 135 | } |
| 136 | else if (property.first == "Model") |
| 137 | { |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 138 | const std::string* value = |
RAJESWARAN THILLAIGOVINDAN | ec8faf9 | 2019-02-21 10:59:03 -0600 | [diff] [blame] | 139 | std::get_if<std::string>(&property.second); |
| 140 | if (value != nullptr) |
| 141 | { |
| 142 | aResp->res.jsonValue["Model"] = *value; |
| 143 | } |
| 144 | } |
Gunnar Mills | f9dcc11 | 2020-02-13 13:19:43 -0600 | [diff] [blame] | 145 | else if (property.first == "PartNumber") |
| 146 | { |
| 147 | aResp->res.jsonValue["PartNumber"] = property.second; |
| 148 | } |
| 149 | else if (property.first == "SerialNumber") |
| 150 | { |
| 151 | aResp->res.jsonValue["SerialNumber"] = property.second; |
| 152 | } |
| 153 | else if (property.first == "Version") |
| 154 | { |
| 155 | aResp->res.jsonValue["Version"] = property.second; |
| 156 | } |
RAJESWARAN THILLAIGOVINDAN | ec8faf9 | 2019-02-21 10:59:03 -0600 | [diff] [blame] | 157 | else if (property.first == "Present") |
| 158 | { |
| 159 | present = std::get_if<bool>(&property.second); |
| 160 | } |
| 161 | else if (property.first == "Functional") |
| 162 | { |
| 163 | functional = std::get_if<bool>(&property.second); |
| 164 | } |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | if ((present == nullptr) || (functional == nullptr)) |
| 169 | { |
| 170 | // Important property not in desired type |
| 171 | messages::internalError(aResp->res); |
| 172 | return; |
| 173 | } |
| 174 | |
| 175 | if (*present == false) |
| 176 | { |
| 177 | aResp->res.jsonValue["Status"]["State"] = "Absent"; |
| 178 | aResp->res.jsonValue["Status"]["Health"] = "OK"; |
| 179 | } |
| 180 | else |
| 181 | { |
| 182 | aResp->res.jsonValue["Status"]["State"] = "Enabled"; |
| 183 | if (*functional == true) |
| 184 | { |
| 185 | aResp->res.jsonValue["Status"]["Health"] = "OK"; |
| 186 | } |
| 187 | else |
| 188 | { |
| 189 | aResp->res.jsonValue["Status"]["Health"] = "Critical"; |
| 190 | } |
| 191 | } |
| 192 | |
| 193 | return; |
| 194 | } |
| 195 | |
| 196 | void getCpuDataByService(std::shared_ptr<AsyncResp> aResp, |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 197 | const std::string& cpuId, const std::string& service, |
| 198 | const std::string& objPath) |
RAJESWARAN THILLAIGOVINDAN | ec8faf9 | 2019-02-21 10:59:03 -0600 | [diff] [blame] | 199 | { |
| 200 | BMCWEB_LOG_DEBUG << "Get available system cpu resources by service."; |
| 201 | |
| 202 | crow::connections::systemBus->async_method_call( |
| 203 | [cpuId, service, objPath, aResp{std::move(aResp)}]( |
| 204 | const boost::system::error_code ec, |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 205 | const dbus::utility::ManagedObjectType& dbusData) { |
RAJESWARAN THILLAIGOVINDAN | ec8faf9 | 2019-02-21 10:59:03 -0600 | [diff] [blame] | 206 | if (ec) |
| 207 | { |
| 208 | BMCWEB_LOG_DEBUG << "DBUS response error"; |
| 209 | messages::internalError(aResp->res); |
| 210 | return; |
| 211 | } |
| 212 | aResp->res.jsonValue["Id"] = cpuId; |
| 213 | aResp->res.jsonValue["Name"] = "Processor"; |
| 214 | aResp->res.jsonValue["ProcessorType"] = "CPU"; |
| 215 | |
| 216 | std::string corePath = objPath + "/core"; |
| 217 | size_t totalCores = 0; |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 218 | for (const auto& object : dbusData) |
RAJESWARAN THILLAIGOVINDAN | ec8faf9 | 2019-02-21 10:59:03 -0600 | [diff] [blame] | 219 | { |
| 220 | if (object.first.str == objPath) |
| 221 | { |
| 222 | getCpuDataByInterface(aResp, object.second); |
| 223 | } |
| 224 | else if (boost::starts_with(object.first.str, corePath)) |
| 225 | { |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 226 | for (const auto& interface : object.second) |
RAJESWARAN THILLAIGOVINDAN | ec8faf9 | 2019-02-21 10:59:03 -0600 | [diff] [blame] | 227 | { |
| 228 | if (interface.first == |
| 229 | "xyz.openbmc_project.Inventory.Item") |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 230 | { |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 231 | for (const auto& property : interface.second) |
RAJESWARAN THILLAIGOVINDAN | ec8faf9 | 2019-02-21 10:59:03 -0600 | [diff] [blame] | 232 | { |
| 233 | if (property.first == "Present") |
| 234 | { |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 235 | const bool* present = |
RAJESWARAN THILLAIGOVINDAN | ec8faf9 | 2019-02-21 10:59:03 -0600 | [diff] [blame] | 236 | std::get_if<bool>(&property.second); |
| 237 | if (present != nullptr) |
| 238 | { |
| 239 | if (*present == true) |
| 240 | { |
| 241 | totalCores++; |
| 242 | } |
| 243 | } |
| 244 | } |
| 245 | } |
Gunnar Mills | b957ba5 | 2019-01-31 15:58:15 -0600 | [diff] [blame] | 246 | } |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 247 | } |
| 248 | } |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 249 | } |
RAJESWARAN THILLAIGOVINDAN | ec8faf9 | 2019-02-21 10:59:03 -0600 | [diff] [blame] | 250 | // In getCpuDataByInterface(), state and health are set |
| 251 | // based on the present and functional status. If core |
| 252 | // count is zero, then it has a higher precedence. |
| 253 | if (totalCores == 0) |
| 254 | { |
| 255 | // Slot is not populated, set status end return |
| 256 | aResp->res.jsonValue["Status"]["State"] = "Absent"; |
| 257 | aResp->res.jsonValue["Status"]["Health"] = "OK"; |
| 258 | } |
| 259 | aResp->res.jsonValue["TotalCores"] = totalCores; |
| 260 | return; |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 261 | }, |
RAJESWARAN THILLAIGOVINDAN | ec8faf9 | 2019-02-21 10:59:03 -0600 | [diff] [blame] | 262 | service, "/xyz/openbmc_project/inventory", |
| 263 | "org.freedesktop.DBus.ObjectManager", "GetManagedObjects"); |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 264 | } |
| 265 | |
Zhikui Ren | 5e54a36 | 2020-07-13 15:31:38 -0700 | [diff] [blame] | 266 | void getCpuAssetData(std::shared_ptr<AsyncResp> aResp, |
| 267 | const std::string& service, const std::string& objPath) |
| 268 | { |
| 269 | BMCWEB_LOG_DEBUG << "Get Cpu Asset Data"; |
| 270 | crow::connections::systemBus->async_method_call( |
| 271 | [objPath, aResp{std::move(aResp)}]( |
| 272 | const boost::system::error_code ec, |
| 273 | const boost::container::flat_map< |
| 274 | std::string, std::variant<std::string, uint32_t, uint16_t, |
| 275 | bool>>& properties) { |
| 276 | if (ec) |
| 277 | { |
| 278 | BMCWEB_LOG_DEBUG << "DBUS response error"; |
| 279 | messages::internalError(aResp->res); |
| 280 | return; |
| 281 | } |
| 282 | |
| 283 | for (const auto& property : properties) |
| 284 | { |
| 285 | if (property.first == "SerialNumber") |
| 286 | { |
| 287 | const std::string* sn = |
| 288 | std::get_if<std::string>(&property.second); |
| 289 | if (sn != nullptr) |
| 290 | { |
| 291 | aResp->res.jsonValue["SerialNumber"] = *sn; |
| 292 | } |
| 293 | } |
| 294 | else if (property.first == "Model") |
| 295 | { |
| 296 | const std::string* model = |
| 297 | std::get_if<std::string>(&property.second); |
| 298 | if (model != nullptr) |
| 299 | { |
| 300 | aResp->res.jsonValue["Model"] = *model; |
| 301 | } |
| 302 | } |
| 303 | } |
| 304 | }, |
| 305 | service, objPath, "org.freedesktop.DBus.Properties", "GetAll", |
| 306 | "xyz.openbmc_project.Inventory.Decorator.Asset"); |
| 307 | } |
| 308 | |
Alpana Kumari | 32bee76 | 2019-04-25 04:47:57 -0500 | [diff] [blame] | 309 | void getAcceleratorDataByService(std::shared_ptr<AsyncResp> aResp, |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 310 | const std::string& acclrtrId, |
| 311 | const std::string& service, |
| 312 | const std::string& objPath) |
Alpana Kumari | 32bee76 | 2019-04-25 04:47:57 -0500 | [diff] [blame] | 313 | { |
| 314 | BMCWEB_LOG_DEBUG |
| 315 | << "Get available system Accelerator resources by service."; |
| 316 | crow::connections::systemBus->async_method_call( |
| 317 | [acclrtrId, aResp{std::move(aResp)}]( |
| 318 | const boost::system::error_code ec, |
| 319 | const boost::container::flat_map< |
Santosh Puranik | 94e1b82 | 2019-07-24 04:48:32 -0500 | [diff] [blame] | 320 | std::string, std::variant<std::string, uint32_t, uint16_t, |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 321 | bool>>& properties) { |
Alpana Kumari | 32bee76 | 2019-04-25 04:47:57 -0500 | [diff] [blame] | 322 | if (ec) |
| 323 | { |
| 324 | BMCWEB_LOG_DEBUG << "DBUS response error"; |
| 325 | messages::internalError(aResp->res); |
| 326 | return; |
| 327 | } |
| 328 | aResp->res.jsonValue["Id"] = acclrtrId; |
| 329 | aResp->res.jsonValue["Name"] = "Processor"; |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 330 | const bool* accPresent = nullptr; |
| 331 | const bool* accFunctional = nullptr; |
Alpana Kumari | 32bee76 | 2019-04-25 04:47:57 -0500 | [diff] [blame] | 332 | |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 333 | for (const auto& property : properties) |
Alpana Kumari | 32bee76 | 2019-04-25 04:47:57 -0500 | [diff] [blame] | 334 | { |
| 335 | if (property.first == "Functional") |
| 336 | { |
Santosh Puranik | 94e1b82 | 2019-07-24 04:48:32 -0500 | [diff] [blame] | 337 | accFunctional = std::get_if<bool>(&property.second); |
Alpana Kumari | 32bee76 | 2019-04-25 04:47:57 -0500 | [diff] [blame] | 338 | } |
| 339 | else if (property.first == "Present") |
| 340 | { |
Santosh Puranik | 94e1b82 | 2019-07-24 04:48:32 -0500 | [diff] [blame] | 341 | accPresent = std::get_if<bool>(&property.second); |
Alpana Kumari | 32bee76 | 2019-04-25 04:47:57 -0500 | [diff] [blame] | 342 | } |
| 343 | } |
| 344 | |
Alpana Kumari | 657877c | 2020-02-24 02:24:07 -0600 | [diff] [blame] | 345 | if ((accPresent != nullptr) && (*accPresent == false)) |
Alpana Kumari | 32bee76 | 2019-04-25 04:47:57 -0500 | [diff] [blame] | 346 | { |
Alpana Kumari | 657877c | 2020-02-24 02:24:07 -0600 | [diff] [blame] | 347 | aResp->res.jsonValue["Status"]["State"] = "Absent"; |
| 348 | aResp->res.jsonValue["Status"]["Health"] = "OK"; |
Alpana Kumari | 32bee76 | 2019-04-25 04:47:57 -0500 | [diff] [blame] | 349 | } |
| 350 | else |
| 351 | { |
Alpana Kumari | 657877c | 2020-02-24 02:24:07 -0600 | [diff] [blame] | 352 | aResp->res.jsonValue["Status"]["State"] = "Enabled"; |
| 353 | |
| 354 | if ((accFunctional != nullptr) && (*accFunctional == false)) |
| 355 | { |
| 356 | aResp->res.jsonValue["Status"]["Health"] = "Critical"; |
| 357 | } |
| 358 | else |
| 359 | { |
| 360 | aResp->res.jsonValue["Status"]["Health"] = "OK"; |
| 361 | } |
Alpana Kumari | 32bee76 | 2019-04-25 04:47:57 -0500 | [diff] [blame] | 362 | } |
Alpana Kumari | 32bee76 | 2019-04-25 04:47:57 -0500 | [diff] [blame] | 363 | aResp->res.jsonValue["ProcessorType"] = "Accelerator"; |
| 364 | }, |
| 365 | service, objPath, "org.freedesktop.DBus.Properties", "GetAll", ""); |
| 366 | } |
| 367 | |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 368 | void getCpuData(std::shared_ptr<AsyncResp> aResp, const std::string& cpuId, |
| 369 | const std::vector<const char*> inventoryItems) |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 370 | { |
| 371 | BMCWEB_LOG_DEBUG << "Get available system cpu resources."; |
Alpana Kumari | 32bee76 | 2019-04-25 04:47:57 -0500 | [diff] [blame] | 372 | |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 373 | crow::connections::systemBus->async_method_call( |
Ed Tanous | 029573d | 2019-02-01 10:57:49 -0800 | [diff] [blame] | 374 | [cpuId, aResp{std::move(aResp)}]( |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 375 | const boost::system::error_code ec, |
| 376 | const boost::container::flat_map< |
| 377 | std::string, boost::container::flat_map< |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 378 | std::string, std::vector<std::string>>>& |
| 379 | subtree) { |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 380 | if (ec) |
| 381 | { |
| 382 | BMCWEB_LOG_DEBUG << "DBUS response error"; |
| 383 | messages::internalError(aResp->res); |
| 384 | return; |
| 385 | } |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 386 | for (const auto& object : subtree) |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 387 | { |
| 388 | if (boost::ends_with(object.first, cpuId)) |
| 389 | { |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 390 | for (const auto& service : object.second) |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 391 | { |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 392 | for (const auto& inventory : service.second) |
Zhikui Ren | 5e54a36 | 2020-07-13 15:31:38 -0700 | [diff] [blame] | 393 | { |
| 394 | if (inventory == "xyz.openbmc_project." |
| 395 | "Inventory.Decorator.Asset") |
| 396 | { |
| 397 | getCpuAssetData(aResp, service.first, |
| 398 | object.first); |
| 399 | } |
| 400 | else if (inventory == |
| 401 | "xyz.openbmc_project.Inventory.Item.Cpu") |
Alpana Kumari | 32bee76 | 2019-04-25 04:47:57 -0500 | [diff] [blame] | 402 | { |
| 403 | getCpuDataByService(aResp, cpuId, service.first, |
| 404 | object.first); |
| 405 | } |
| 406 | else if (inventory == "xyz.openbmc_project." |
| 407 | "Inventory.Item.Accelerator") |
| 408 | { |
| 409 | getAcceleratorDataByService( |
| 410 | aResp, cpuId, service.first, object.first); |
| 411 | } |
Zhikui Ren | 5e54a36 | 2020-07-13 15:31:38 -0700 | [diff] [blame] | 412 | } |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 413 | } |
Zhikui Ren | 5e54a36 | 2020-07-13 15:31:38 -0700 | [diff] [blame] | 414 | return; |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 415 | } |
| 416 | } |
| 417 | // Object not found |
| 418 | messages::resourceNotFound(aResp->res, "Processor", cpuId); |
| 419 | return; |
| 420 | }, |
| 421 | "xyz.openbmc_project.ObjectMapper", |
| 422 | "/xyz/openbmc_project/object_mapper", |
| 423 | "xyz.openbmc_project.ObjectMapper", "GetSubTree", |
Ed Tanous | 271584a | 2019-07-09 16:24:22 -0700 | [diff] [blame] | 424 | "/xyz/openbmc_project/inventory", 0, inventoryItems); |
| 425 | } |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 426 | |
James Feist | c50e7c6 | 2020-07-27 15:39:36 -0700 | [diff] [blame^] | 427 | using DimmProperty = |
| 428 | std::variant<std::string, std::vector<uint32_t>, std::vector<uint16_t>, |
| 429 | uint64_t, uint32_t, uint16_t, uint8_t, bool>; |
| 430 | |
| 431 | using DimmProperties = boost::container::flat_map<std::string, DimmProperty>; |
| 432 | |
| 433 | void dimmPropToHex(std::shared_ptr<AsyncResp> aResp, const char* key, |
| 434 | const std::pair<std::string, DimmProperty>& property) |
| 435 | { |
| 436 | const uint16_t* value = std::get_if<uint16_t>(&property.second); |
| 437 | if (value == nullptr) |
| 438 | { |
| 439 | messages::internalError(aResp->res); |
| 440 | BMCWEB_LOG_DEBUG << "Invalid property type for " << property.first; |
| 441 | return; |
| 442 | } |
| 443 | |
| 444 | aResp->res.jsonValue[key] = (boost::format("0x%04x") % *value).str(); |
| 445 | } |
| 446 | |
| 447 | void getPersistentMemoryProperties(std::shared_ptr<AsyncResp> aResp, |
| 448 | const DimmProperties& properties) |
| 449 | { |
| 450 | for (const auto& property : properties) |
| 451 | { |
| 452 | if (property.first == "ModuleManufacturerID") |
| 453 | { |
| 454 | dimmPropToHex(aResp, "ModuleManufacturerID", property); |
| 455 | } |
| 456 | else if (property.first == "ModuleProductID") |
| 457 | { |
| 458 | dimmPropToHex(aResp, "ModuleProductID", property); |
| 459 | } |
| 460 | else if (property.first == "SubsystemVendorID") |
| 461 | { |
| 462 | dimmPropToHex(aResp, "MemorySubsystemControllerManufacturerID", |
| 463 | property); |
| 464 | } |
| 465 | else if (property.first == "SubsystemDeviceID") |
| 466 | { |
| 467 | dimmPropToHex(aResp, "MemorySubsystemControllerProductID", |
| 468 | property); |
| 469 | } |
| 470 | else if (property.first == "VolatileRegionSizeLimitInKiB") |
| 471 | { |
| 472 | const uint64_t* value = std::get_if<uint64_t>(&property.second); |
| 473 | |
| 474 | if (value == nullptr) |
| 475 | { |
| 476 | messages::internalError(aResp->res); |
| 477 | BMCWEB_LOG_DEBUG << "Invalid property type for " |
| 478 | "VolatileRegionSizeLimitKiB"; |
| 479 | continue; |
| 480 | } |
| 481 | aResp->res.jsonValue["VolatileRegionSizeLimitMiB"] = (*value) >> 10; |
| 482 | } |
| 483 | else if (property.first == "PmRegionSizeLimitInKiB") |
| 484 | { |
| 485 | const uint64_t* value = std::get_if<uint64_t>(&property.second); |
| 486 | |
| 487 | if (value == nullptr) |
| 488 | { |
| 489 | messages::internalError(aResp->res); |
| 490 | BMCWEB_LOG_DEBUG |
| 491 | << "Invalid property type for PmRegioSizeLimitKiB"; |
| 492 | continue; |
| 493 | } |
| 494 | aResp->res.jsonValue["PersistentRegionSizeLimitMiB"] = |
| 495 | (*value) >> 10; |
| 496 | } |
| 497 | else if (property.first == "VolatileSizeInKiB") |
| 498 | { |
| 499 | const uint64_t* value = std::get_if<uint64_t>(&property.second); |
| 500 | |
| 501 | if (value == nullptr) |
| 502 | { |
| 503 | messages::internalError(aResp->res); |
| 504 | BMCWEB_LOG_DEBUG |
| 505 | << "Invalid property type for VolatileSizeInKiB"; |
| 506 | continue; |
| 507 | } |
| 508 | aResp->res.jsonValue["VolatileSizeMiB"] = (*value) >> 10; |
| 509 | } |
| 510 | else if (property.first == "PmSizeInKiB") |
| 511 | { |
| 512 | const uint64_t* value = std::get_if<uint64_t>(&property.second); |
| 513 | if (value == nullptr) |
| 514 | { |
| 515 | messages::internalError(aResp->res); |
| 516 | BMCWEB_LOG_DEBUG << "Invalid property type for PmSizeInKiB"; |
| 517 | continue; |
| 518 | } |
| 519 | aResp->res.jsonValue["NonVolatileSizeMiB"] = (*value) >> 10; |
| 520 | } |
| 521 | else if (property.first == "CacheSizeInKB") |
| 522 | { |
| 523 | const uint64_t* value = std::get_if<uint64_t>(&property.second); |
| 524 | if (value == nullptr) |
| 525 | { |
| 526 | messages::internalError(aResp->res); |
| 527 | BMCWEB_LOG_DEBUG << "Invalid property type for CacheSizeInKB"; |
| 528 | continue; |
| 529 | } |
| 530 | aResp->res.jsonValue["CacheSizeMiB"] = (*value >> 10); |
| 531 | } |
| 532 | |
| 533 | else if (property.first == "VoltaileRegionMaxSizeInKib") |
| 534 | { |
| 535 | const uint64_t* value = std::get_if<uint64_t>(&property.second); |
| 536 | |
| 537 | if (value == nullptr) |
| 538 | { |
| 539 | messages::internalError(aResp->res); |
| 540 | BMCWEB_LOG_DEBUG << "Invalid property type for " |
| 541 | "VolatileRegionMaxSizeInKib"; |
| 542 | continue; |
| 543 | } |
| 544 | aResp->res.jsonValue["VolatileRegionSizeMaxMiB"] = (*value) >> 10; |
| 545 | } |
| 546 | else if (property.first == "PmRegionMaxSizeInKiB") |
| 547 | { |
| 548 | const uint64_t* value = std::get_if<uint64_t>(&property.second); |
| 549 | |
| 550 | if (value == nullptr) |
| 551 | { |
| 552 | messages::internalError(aResp->res); |
| 553 | BMCWEB_LOG_DEBUG |
| 554 | << "Invalid property type for PmRegionMaxSizeInKiB"; |
| 555 | continue; |
| 556 | } |
| 557 | aResp->res.jsonValue["PersistentRegionSizeMaxMiB"] = (*value) >> 10; |
| 558 | } |
| 559 | else if (property.first == "AllocationIncrementInKiB") |
| 560 | { |
| 561 | const uint64_t* value = std::get_if<uint64_t>(&property.second); |
| 562 | |
| 563 | if (value == nullptr) |
| 564 | { |
| 565 | messages::internalError(aResp->res); |
| 566 | BMCWEB_LOG_DEBUG << "Invalid property type for " |
| 567 | "AllocationIncrementInKiB"; |
| 568 | continue; |
| 569 | } |
| 570 | aResp->res.jsonValue["AllocationIncrementMiB"] = (*value) >> 10; |
| 571 | } |
| 572 | else if (property.first == "AllocationAlignmentInKiB") |
| 573 | { |
| 574 | const uint64_t* value = std::get_if<uint64_t>(&property.second); |
| 575 | |
| 576 | if (value == nullptr) |
| 577 | { |
| 578 | messages::internalError(aResp->res); |
| 579 | BMCWEB_LOG_DEBUG << "Invalid property type for " |
| 580 | "AllocationAlignmentInKiB"; |
| 581 | continue; |
| 582 | } |
| 583 | aResp->res.jsonValue["AllocationAlignmentMiB"] = (*value) >> 10; |
| 584 | } |
| 585 | else if (property.first == "VolatileRegionNumberLimit") |
| 586 | { |
| 587 | aResp->res.jsonValue["VolatileRegionNumberLimit"] = property.second; |
| 588 | } |
| 589 | else if (property.first == "PmRegionNumberLimit") |
| 590 | { |
| 591 | aResp->res.jsonValue["PersistentRegionNumberLimit"] = |
| 592 | property.second; |
| 593 | } |
| 594 | else if (property.first == "SpareDeviceCount") |
| 595 | { |
| 596 | aResp->res.jsonValue["SpareDeviceCount"] = property.second; |
| 597 | } |
| 598 | else if (property.first == "IsSpareDeviceInUse") |
| 599 | { |
| 600 | aResp->res.jsonValue["IsSpareDeviceEnabled"] = property.second; |
| 601 | } |
| 602 | else if (property.first == "IsRankSpareEnabled") |
| 603 | { |
| 604 | aResp->res.jsonValue["IsRankSpareEnabled"] = property.second; |
| 605 | } |
| 606 | else if (property.first == "MaxAveragePowerLimitmW") |
| 607 | { |
| 608 | const auto* value = |
| 609 | std::get_if<std::vector<uint32_t>>(&property.second); |
| 610 | if (value == nullptr) |
| 611 | { |
| 612 | messages::internalError(aResp->res); |
| 613 | BMCWEB_LOG_DEBUG << "Invalid property type for " |
| 614 | "MaxAveragePowerLimitmW"; |
| 615 | continue; |
| 616 | } |
| 617 | aResp->res.jsonValue["MaxTDPMilliWatts"] = *value; |
| 618 | } |
| 619 | else if (property.first == "CurrentSecurityState") |
| 620 | { |
| 621 | aResp->res.jsonValue["SecurityState"] = property.second; |
| 622 | } |
| 623 | else if (property.first == "ConfigurationLocked") |
| 624 | { |
| 625 | aResp->res.jsonValue["ConfigurationLocked"] = property.second; |
| 626 | } |
| 627 | else if (property.first == "AllowedMemoryModes") |
| 628 | { |
| 629 | const std::string* value = |
| 630 | std::get_if<std::string>(&property.second); |
| 631 | if (value == nullptr) |
| 632 | { |
| 633 | messages::internalError(aResp->res); |
| 634 | BMCWEB_LOG_DEBUG << "Invalid property type for FormFactor"; |
| 635 | continue; |
| 636 | } |
| 637 | constexpr const std::array<const char*, 3> values{"Volatile", |
| 638 | "PMEM", "Block"}; |
| 639 | |
| 640 | for (const char* v : values) |
| 641 | { |
| 642 | if (boost::ends_with(*value, v)) |
| 643 | { |
| 644 | aResp->res.jsonValue["OperatingMemoryModes "] = v; |
| 645 | break; |
| 646 | } |
| 647 | } |
| 648 | } |
| 649 | else if (property.first == "MemoryMedia") |
| 650 | { |
| 651 | const std::string* value = |
| 652 | std::get_if<std::string>(&property.second); |
| 653 | if (value == nullptr) |
| 654 | { |
| 655 | messages::internalError(aResp->res); |
| 656 | BMCWEB_LOG_DEBUG << "Invalid property type for MemoryMedia"; |
| 657 | continue; |
| 658 | } |
| 659 | constexpr const std::array<const char*, 3> values{"DRAM", "NAND", |
| 660 | "Intel3DXPoint"}; |
| 661 | |
| 662 | for (const char* v : values) |
| 663 | { |
| 664 | if (boost::ends_with(*value, v)) |
| 665 | { |
| 666 | aResp->res.jsonValue["MemoryMedia"] = v; |
| 667 | break; |
| 668 | } |
| 669 | } |
| 670 | } |
| 671 | // PersistantMemory.PowerManagmentPolicy interface |
| 672 | else if (property.first == "AveragePowerBudgetmW" || |
| 673 | property.first == "MaxTDPmW" || |
| 674 | property.first == "PeakPowerBudgetmW" || |
| 675 | property.first == "PolicyEnabled") |
| 676 | { |
| 677 | std::string name = |
| 678 | boost::replace_all_copy(property.first, "mW", "MilliWatts"); |
| 679 | aResp->res.jsonValue["PowerManagementPolicy"][name] = |
| 680 | property.second; |
| 681 | } |
| 682 | // PersistantMemory.SecurityCapabilites interface |
| 683 | else if (property.first == "ConfigurationLockCapable" || |
| 684 | property.first == "DataLockCapable" || |
| 685 | property.first == "MaxPassphraseCount" || |
| 686 | property.first == "PassphraseCapable" || |
| 687 | property.first == "PassphraseLockLimit") |
| 688 | { |
| 689 | aResp->res.jsonValue["SecurityCapabilities"][property.first] = |
| 690 | property.second; |
| 691 | } |
| 692 | } |
| 693 | } |
| 694 | |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 695 | void getDimmDataByService(std::shared_ptr<AsyncResp> aResp, |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 696 | const std::string& dimmId, const std::string& service, |
| 697 | const std::string& objPath) |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 698 | { |
James Feist | 35e257a | 2020-06-05 13:30:51 -0700 | [diff] [blame] | 699 | auto health = std::make_shared<HealthPopulate>(aResp); |
| 700 | health->selfPath = objPath; |
| 701 | health->populate(); |
| 702 | |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 703 | BMCWEB_LOG_DEBUG << "Get available system components."; |
| 704 | crow::connections::systemBus->async_method_call( |
James Feist | c50e7c6 | 2020-07-27 15:39:36 -0700 | [diff] [blame^] | 705 | [dimmId, aResp{std::move(aResp)}](const boost::system::error_code ec, |
| 706 | const DimmProperties& properties) { |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 707 | if (ec) |
| 708 | { |
| 709 | BMCWEB_LOG_DEBUG << "DBUS response error"; |
| 710 | messages::internalError(aResp->res); |
| 711 | |
| 712 | return; |
| 713 | } |
| 714 | aResp->res.jsonValue["Id"] = dimmId; |
| 715 | aResp->res.jsonValue["Name"] = "DIMM Slot"; |
| 716 | |
| 717 | const auto memorySizeProperty = properties.find("MemorySizeInKB"); |
Gunnar Mills | aceb7fc | 2018-12-10 15:17:20 -0600 | [diff] [blame] | 718 | if (memorySizeProperty != properties.end()) |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 719 | { |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 720 | const uint32_t* memorySize = |
Ed Tanous | abf2add | 2019-01-22 16:40:12 -0800 | [diff] [blame] | 721 | std::get_if<uint32_t>(&memorySizeProperty->second); |
Gunnar Mills | aceb7fc | 2018-12-10 15:17:20 -0600 | [diff] [blame] | 722 | if (memorySize == nullptr) |
| 723 | { |
| 724 | // Important property not in desired type |
| 725 | messages::internalError(aResp->res); |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 726 | |
Gunnar Mills | aceb7fc | 2018-12-10 15:17:20 -0600 | [diff] [blame] | 727 | return; |
| 728 | } |
| 729 | if (*memorySize == 0) |
| 730 | { |
| 731 | // Slot is not populated, set status end return |
| 732 | aResp->res.jsonValue["Status"]["State"] = "Absent"; |
| 733 | aResp->res.jsonValue["Status"]["Health"] = "OK"; |
| 734 | // HTTP Code will be set up automatically, just return |
| 735 | return; |
| 736 | } |
| 737 | aResp->res.jsonValue["CapacityMiB"] = (*memorySize >> 10); |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 738 | } |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 739 | aResp->res.jsonValue["Status"]["State"] = "Enabled"; |
| 740 | aResp->res.jsonValue["Status"]["Health"] = "OK"; |
| 741 | |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 742 | for (const auto& property : properties) |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 743 | { |
| 744 | if (property.first == "MemoryDataWidth") |
| 745 | { |
| 746 | aResp->res.jsonValue["DataWidthBits"] = property.second; |
| 747 | } |
Manojkiran Eda | 7e236ca | 2019-06-25 23:06:32 +0530 | [diff] [blame] | 748 | else if (property.first == "PartNumber") |
| 749 | { |
| 750 | aResp->res.jsonValue["PartNumber"] = property.second; |
| 751 | } |
| 752 | else if (property.first == "SerialNumber") |
| 753 | { |
| 754 | aResp->res.jsonValue["SerialNumber"] = property.second; |
| 755 | } |
| 756 | else if (property.first == "Manufacturer") |
| 757 | { |
| 758 | aResp->res.jsonValue["Manufacturer"] = property.second; |
| 759 | } |
James Feist | c50e7c6 | 2020-07-27 15:39:36 -0700 | [diff] [blame^] | 760 | else if (property.first == "RevisionCode") |
| 761 | { |
| 762 | const uint16_t* value = |
| 763 | std::get_if<uint16_t>(&property.second); |
| 764 | |
| 765 | if (value == nullptr) |
| 766 | { |
| 767 | messages::internalError(aResp->res); |
| 768 | BMCWEB_LOG_DEBUG |
| 769 | << "Invalid property type for RevisionCode"; |
| 770 | continue; |
| 771 | } |
| 772 | aResp->res.jsonValue["FirmwareRevision"] = |
| 773 | std::to_string(*value); |
| 774 | } |
| 775 | else if (property.first == "MemoryTotalWidth") |
| 776 | { |
| 777 | aResp->res.jsonValue["BusWidthBits"] = property.second; |
| 778 | } |
| 779 | else if (property.first == "ECC") |
| 780 | { |
| 781 | const std::string* value = |
| 782 | std::get_if<std::string>(&property.second); |
| 783 | if (value == nullptr) |
| 784 | { |
| 785 | messages::internalError(aResp->res); |
| 786 | BMCWEB_LOG_DEBUG << "Invalid property type for ECC"; |
| 787 | continue; |
| 788 | } |
| 789 | constexpr const std::array<const char*, 4> values{ |
| 790 | "NoECC", "SingleBitECC", "MultiBitECC", |
| 791 | "AddressParity"}; |
| 792 | |
| 793 | for (const char* v : values) |
| 794 | { |
| 795 | if (boost::ends_with(*value, v)) |
| 796 | { |
| 797 | aResp->res.jsonValue["ErrorCorrection"] = v; |
| 798 | break; |
| 799 | } |
| 800 | } |
| 801 | } |
| 802 | else if (property.first == "FormFactor") |
| 803 | { |
| 804 | const std::string* value = |
| 805 | std::get_if<std::string>(&property.second); |
| 806 | if (value == nullptr) |
| 807 | { |
| 808 | messages::internalError(aResp->res); |
| 809 | BMCWEB_LOG_DEBUG |
| 810 | << "Invalid property type for FormFactor"; |
| 811 | continue; |
| 812 | } |
| 813 | constexpr const std::array<const char*, 11> values{ |
| 814 | "RDIMM", "UDIMM", "SO_DIMM", |
| 815 | "LRDIMM", "Mini_RDIMM", "Mini_UDIMM", |
| 816 | "SO_RDIMM_72b", "SO_UDIMM_72b", "SO_DIMM_16b", |
| 817 | "SO_DIMM_32b", "Die"}; |
| 818 | |
| 819 | for (const char* v : values) |
| 820 | { |
| 821 | if (boost::ends_with(*value, v)) |
| 822 | { |
| 823 | aResp->res.jsonValue["BaseModuleType"] = v; |
| 824 | break; |
| 825 | } |
| 826 | } |
| 827 | } |
| 828 | else if (property.first == "AllowedSpeedsMT") |
| 829 | { |
| 830 | aResp->res.jsonValue["AllowedSpeedsMHz"] = property.second; |
| 831 | } |
| 832 | else if (property.first == "MemoryAttributes") |
| 833 | { |
| 834 | const uint8_t* value = |
| 835 | std::get_if<uint8_t>(&property.second); |
| 836 | |
| 837 | if (value == nullptr) |
| 838 | { |
| 839 | messages::internalError(aResp->res); |
| 840 | BMCWEB_LOG_DEBUG |
| 841 | << "Invalid property type for MemoryAttributes"; |
| 842 | continue; |
| 843 | } |
| 844 | aResp->res.jsonValue["RankCount"] = |
| 845 | static_cast<uint64_t>(*value); |
| 846 | } |
| 847 | else if (property.first == "MemoryConfiguredSpeedInMhz") |
| 848 | { |
| 849 | aResp->res.jsonValue["OperatingSpeedMhz"] = property.second; |
| 850 | } |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 851 | else if (property.first == "MemoryType") |
| 852 | { |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 853 | const auto* value = |
Ed Tanous | abf2add | 2019-01-22 16:40:12 -0800 | [diff] [blame] | 854 | std::get_if<std::string>(&property.second); |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 855 | if (value != nullptr) |
| 856 | { |
James Feist | c50e7c6 | 2020-07-27 15:39:36 -0700 | [diff] [blame^] | 857 | size_t idx = value->rfind("."); |
| 858 | if (idx == std::string::npos || |
| 859 | idx + 1 >= value->size()) |
| 860 | { |
| 861 | messages::internalError(aResp->res); |
| 862 | BMCWEB_LOG_DEBUG << "Invalid property type for " |
| 863 | "MemoryType"; |
| 864 | } |
| 865 | std::string result = value->substr(idx + 1); |
| 866 | aResp->res.jsonValue["MemoryDeviceType"] = result; |
| 867 | if (value->find("DDR") != std::string::npos) |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 868 | { |
| 869 | aResp->res.jsonValue["MemoryType"] = "DRAM"; |
| 870 | } |
James Feist | c50e7c6 | 2020-07-27 15:39:36 -0700 | [diff] [blame^] | 871 | else if (boost::ends_with(*value, "Logical")) |
| 872 | { |
| 873 | aResp->res.jsonValue["MemoryType"] = "IntelOptane"; |
| 874 | } |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 875 | } |
| 876 | } |
James Feist | c50e7c6 | 2020-07-27 15:39:36 -0700 | [diff] [blame^] | 877 | // memory location interface |
| 878 | else if (property.first == "Channel" || |
| 879 | property.first == "MemoryController" || |
| 880 | property.first == "Slot" || property.first == "Socket") |
| 881 | { |
| 882 | aResp->res.jsonValue["MemoryLocation"][property.first] = |
| 883 | property.second; |
| 884 | } |
| 885 | else |
| 886 | { |
| 887 | getPersistentMemoryProperties(aResp, properties); |
| 888 | } |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 889 | } |
| 890 | }, |
| 891 | service, objPath, "org.freedesktop.DBus.Properties", "GetAll", ""); |
| 892 | } |
| 893 | |
James Feist | 45094ad | 2020-04-29 14:02:30 -0700 | [diff] [blame] | 894 | void getDimmPartitionData(std::shared_ptr<AsyncResp> aResp, |
| 895 | const std::string& service, const std::string& path) |
| 896 | { |
| 897 | crow::connections::systemBus->async_method_call( |
| 898 | [aResp{std::move(aResp)}]( |
| 899 | const boost::system::error_code ec, |
| 900 | const boost::container::flat_map< |
| 901 | std::string, std::variant<std::string, uint64_t, uint32_t, |
| 902 | bool>>& properties) { |
| 903 | if (ec) |
| 904 | { |
| 905 | BMCWEB_LOG_DEBUG << "DBUS response error"; |
| 906 | messages::internalError(aResp->res); |
| 907 | |
| 908 | return; |
| 909 | } |
| 910 | |
| 911 | nlohmann::json& partition = |
| 912 | aResp->res.jsonValue["Regions"].emplace_back( |
| 913 | nlohmann::json::object()); |
| 914 | for (const auto& [key, val] : properties) |
| 915 | { |
| 916 | if (key == "MemoryClassification") |
| 917 | { |
| 918 | partition[key] = val; |
| 919 | } |
| 920 | else if (key == "OffsetInKiB") |
| 921 | { |
| 922 | const uint64_t* value = std::get_if<uint64_t>(&val); |
| 923 | if (value == nullptr) |
| 924 | { |
| 925 | messages::internalError(aResp->res); |
| 926 | BMCWEB_LOG_DEBUG |
| 927 | << "Invalid property type for OffsetInKiB"; |
| 928 | continue; |
| 929 | } |
| 930 | |
| 931 | partition["OffsetMiB"] = (*value >> 10); |
| 932 | } |
| 933 | else if (key == "PartitionId") |
| 934 | { |
| 935 | partition["RegionId"] = val; |
| 936 | } |
| 937 | |
| 938 | else if (key == "PassphraseState") |
| 939 | { |
| 940 | partition["PassphraseEnabled"] = val; |
| 941 | } |
| 942 | else if (key == "SizeInKiB") |
| 943 | { |
| 944 | const uint64_t* value = std::get_if<uint64_t>(&val); |
| 945 | if (value == nullptr) |
| 946 | { |
| 947 | messages::internalError(aResp->res); |
| 948 | BMCWEB_LOG_DEBUG |
| 949 | << "Invalid property type for SizeInKiB"; |
| 950 | continue; |
| 951 | } |
| 952 | partition["SizeMiB"] = (*value >> 10); |
| 953 | } |
| 954 | } |
| 955 | }, |
| 956 | |
| 957 | service, path, "org.freedesktop.DBus.Properties", "GetAll", |
| 958 | "xyz.openbmc_project.Inventory.Item.PersistentMemory.Partition"); |
| 959 | } |
| 960 | |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 961 | void getDimmData(std::shared_ptr<AsyncResp> aResp, const std::string& dimmId) |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 962 | { |
| 963 | BMCWEB_LOG_DEBUG << "Get available system dimm resources."; |
| 964 | crow::connections::systemBus->async_method_call( |
Ed Tanous | 029573d | 2019-02-01 10:57:49 -0800 | [diff] [blame] | 965 | [dimmId, aResp{std::move(aResp)}]( |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 966 | const boost::system::error_code ec, |
| 967 | const boost::container::flat_map< |
| 968 | std::string, boost::container::flat_map< |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 969 | std::string, std::vector<std::string>>>& |
| 970 | subtree) { |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 971 | if (ec) |
| 972 | { |
| 973 | BMCWEB_LOG_DEBUG << "DBUS response error"; |
| 974 | messages::internalError(aResp->res); |
| 975 | |
| 976 | return; |
| 977 | } |
James Feist | 45094ad | 2020-04-29 14:02:30 -0700 | [diff] [blame] | 978 | bool found = false; |
| 979 | for (const auto& [path, object] : subtree) |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 980 | { |
James Feist | 45094ad | 2020-04-29 14:02:30 -0700 | [diff] [blame] | 981 | if (path.find(dimmId) != std::string::npos) |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 982 | { |
James Feist | 45094ad | 2020-04-29 14:02:30 -0700 | [diff] [blame] | 983 | for (const auto& [service, interfaces] : object) |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 984 | { |
James Feist | 45094ad | 2020-04-29 14:02:30 -0700 | [diff] [blame] | 985 | if (!found && |
| 986 | (std::find( |
| 987 | interfaces.begin(), interfaces.end(), |
| 988 | "xyz.openbmc_project.Inventory.Item.Dimm") != |
| 989 | interfaces.end())) |
| 990 | { |
| 991 | getDimmDataByService(aResp, dimmId, service, path); |
| 992 | found = true; |
| 993 | } |
| 994 | |
| 995 | // partitions are separate as there can be multiple per |
| 996 | // device, i.e. |
| 997 | // /xyz/openbmc_project/Inventory/Item/Dimm1/Partition1 |
| 998 | // /xyz/openbmc_project/Inventory/Item/Dimm1/Partition2 |
| 999 | if (std::find(interfaces.begin(), interfaces.end(), |
| 1000 | "xyz.openbmc_project.Inventory.Item." |
| 1001 | "PersistentMemory.Partition") != |
| 1002 | interfaces.end()) |
| 1003 | { |
| 1004 | getDimmPartitionData(aResp, service, path); |
| 1005 | } |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 1006 | } |
| 1007 | } |
| 1008 | } |
| 1009 | // Object not found |
James Feist | 45094ad | 2020-04-29 14:02:30 -0700 | [diff] [blame] | 1010 | if (!found) |
| 1011 | { |
| 1012 | messages::resourceNotFound(aResp->res, "Memory", dimmId); |
| 1013 | } |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 1014 | return; |
| 1015 | }, |
| 1016 | "xyz.openbmc_project.ObjectMapper", |
| 1017 | "/xyz/openbmc_project/object_mapper", |
| 1018 | "xyz.openbmc_project.ObjectMapper", "GetSubTree", |
Ed Tanous | 271584a | 2019-07-09 16:24:22 -0700 | [diff] [blame] | 1019 | "/xyz/openbmc_project/inventory", 0, |
James Feist | 45094ad | 2020-04-29 14:02:30 -0700 | [diff] [blame] | 1020 | std::array<const char*, 2>{ |
| 1021 | "xyz.openbmc_project.Inventory.Item.Dimm", |
| 1022 | "xyz.openbmc_project.Inventory.Item.PersistentMemory.Partition"}); |
Ed Tanous | 271584a | 2019-07-09 16:24:22 -0700 | [diff] [blame] | 1023 | } |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 1024 | |
| 1025 | class ProcessorCollection : public Node |
| 1026 | { |
| 1027 | public: |
| 1028 | /* |
| 1029 | * Default Constructor |
| 1030 | */ |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 1031 | ProcessorCollection(CrowApp& app) : |
Ed Tanous | 029573d | 2019-02-01 10:57:49 -0800 | [diff] [blame] | 1032 | Node(app, "/redfish/v1/Systems/system/Processors/") |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 1033 | { |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 1034 | entityPrivileges = { |
| 1035 | {boost::beast::http::verb::get, {{"Login"}}}, |
| 1036 | {boost::beast::http::verb::head, {{"Login"}}}, |
| 1037 | {boost::beast::http::verb::patch, {{"ConfigureComponents"}}}, |
| 1038 | {boost::beast::http::verb::put, {{"ConfigureComponents"}}}, |
| 1039 | {boost::beast::http::verb::delete_, {{"ConfigureComponents"}}}, |
| 1040 | {boost::beast::http::verb::post, {{"ConfigureComponents"}}}}; |
| 1041 | } |
| 1042 | |
| 1043 | private: |
| 1044 | /** |
| 1045 | * Functions triggers appropriate requests on DBus |
| 1046 | */ |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 1047 | void doGet(crow::Response& res, const crow::Request& req, |
| 1048 | const std::vector<std::string>& params) override |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 1049 | { |
Ed Tanous | 0f74e64 | 2018-11-12 15:17:05 -0800 | [diff] [blame] | 1050 | res.jsonValue["@odata.type"] = |
| 1051 | "#ProcessorCollection.ProcessorCollection"; |
| 1052 | res.jsonValue["Name"] = "Processor Collection"; |
Ed Tanous | 0f74e64 | 2018-11-12 15:17:05 -0800 | [diff] [blame] | 1053 | |
Ed Tanous | 029573d | 2019-02-01 10:57:49 -0800 | [diff] [blame] | 1054 | res.jsonValue["@odata.id"] = "/redfish/v1/Systems/system/Processors/"; |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 1055 | auto asyncResp = std::make_shared<AsyncResp>(res); |
| 1056 | |
Ed Tanous | 029573d | 2019-02-01 10:57:49 -0800 | [diff] [blame] | 1057 | getResourceList(asyncResp, "Processors", |
Alpana Kumari | 32bee76 | 2019-04-25 04:47:57 -0500 | [diff] [blame] | 1058 | {"xyz.openbmc_project.Inventory.Item.Cpu", |
| 1059 | "xyz.openbmc_project.Inventory.Item.Accelerator"}); |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 1060 | } |
| 1061 | }; |
| 1062 | |
| 1063 | class Processor : public Node |
| 1064 | { |
| 1065 | public: |
| 1066 | /* |
| 1067 | * Default Constructor |
| 1068 | */ |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 1069 | Processor(CrowApp& app) : |
Ed Tanous | 029573d | 2019-02-01 10:57:49 -0800 | [diff] [blame] | 1070 | Node(app, "/redfish/v1/Systems/system/Processors/<str>/", std::string()) |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 1071 | { |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 1072 | entityPrivileges = { |
| 1073 | {boost::beast::http::verb::get, {{"Login"}}}, |
| 1074 | {boost::beast::http::verb::head, {{"Login"}}}, |
| 1075 | {boost::beast::http::verb::patch, {{"ConfigureComponents"}}}, |
| 1076 | {boost::beast::http::verb::put, {{"ConfigureComponents"}}}, |
| 1077 | {boost::beast::http::verb::delete_, {{"ConfigureComponents"}}}, |
| 1078 | {boost::beast::http::verb::post, {{"ConfigureComponents"}}}}; |
| 1079 | } |
| 1080 | |
| 1081 | private: |
| 1082 | /** |
| 1083 | * Functions triggers appropriate requests on DBus |
| 1084 | */ |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 1085 | void doGet(crow::Response& res, const crow::Request& req, |
| 1086 | const std::vector<std::string>& params) override |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 1087 | { |
| 1088 | // Check if there is required param, truly entering this shall be |
| 1089 | // impossible |
| 1090 | if (params.size() != 1) |
| 1091 | { |
| 1092 | messages::internalError(res); |
| 1093 | |
| 1094 | res.end(); |
| 1095 | return; |
| 1096 | } |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 1097 | const std::string& processorId = params[0]; |
Gunnar Mills | f9dcc11 | 2020-02-13 13:19:43 -0600 | [diff] [blame] | 1098 | res.jsonValue["@odata.type"] = "#Processor.v1_7_0.Processor"; |
Ed Tanous | 029573d | 2019-02-01 10:57:49 -0800 | [diff] [blame] | 1099 | res.jsonValue["@odata.id"] = |
Alpana Kumari | 32bee76 | 2019-04-25 04:47:57 -0500 | [diff] [blame] | 1100 | "/redfish/v1/Systems/system/Processors/" + processorId; |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 1101 | |
Ed Tanous | 029573d | 2019-02-01 10:57:49 -0800 | [diff] [blame] | 1102 | auto asyncResp = std::make_shared<AsyncResp>(res); |
| 1103 | |
Alpana Kumari | 32bee76 | 2019-04-25 04:47:57 -0500 | [diff] [blame] | 1104 | getCpuData(asyncResp, processorId, |
| 1105 | {"xyz.openbmc_project.Inventory.Item.Cpu", |
Zhikui Ren | 5e54a36 | 2020-07-13 15:31:38 -0700 | [diff] [blame] | 1106 | "xyz.openbmc_project.Inventory.Decorator.Asset", |
Alpana Kumari | 32bee76 | 2019-04-25 04:47:57 -0500 | [diff] [blame] | 1107 | "xyz.openbmc_project.Inventory.Item.Accelerator"}); |
Ed Tanous | 029573d | 2019-02-01 10:57:49 -0800 | [diff] [blame] | 1108 | } |
| 1109 | }; |
| 1110 | |
| 1111 | class MemoryCollection : public Node |
| 1112 | { |
| 1113 | public: |
| 1114 | /* |
| 1115 | * Default Constructor |
| 1116 | */ |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 1117 | MemoryCollection(CrowApp& app) : |
Ed Tanous | 029573d | 2019-02-01 10:57:49 -0800 | [diff] [blame] | 1118 | Node(app, "/redfish/v1/Systems/system/Memory/") |
| 1119 | { |
| 1120 | entityPrivileges = { |
| 1121 | {boost::beast::http::verb::get, {{"Login"}}}, |
| 1122 | {boost::beast::http::verb::head, {{"Login"}}}, |
| 1123 | {boost::beast::http::verb::patch, {{"ConfigureComponents"}}}, |
| 1124 | {boost::beast::http::verb::put, {{"ConfigureComponents"}}}, |
| 1125 | {boost::beast::http::verb::delete_, {{"ConfigureComponents"}}}, |
| 1126 | {boost::beast::http::verb::post, {{"ConfigureComponents"}}}}; |
| 1127 | } |
| 1128 | |
| 1129 | private: |
| 1130 | /** |
| 1131 | * Functions triggers appropriate requests on DBus |
| 1132 | */ |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 1133 | void doGet(crow::Response& res, const crow::Request& req, |
| 1134 | const std::vector<std::string>& params) override |
Ed Tanous | 029573d | 2019-02-01 10:57:49 -0800 | [diff] [blame] | 1135 | { |
Ed Tanous | 0f74e64 | 2018-11-12 15:17:05 -0800 | [diff] [blame] | 1136 | res.jsonValue["@odata.type"] = "#MemoryCollection.MemoryCollection"; |
| 1137 | res.jsonValue["Name"] = "Memory Module Collection"; |
James Feist | c50e7c6 | 2020-07-27 15:39:36 -0700 | [diff] [blame^] | 1138 | res.jsonValue["@odata.id"] = "/redfish/v1/Systems/system/Memory"; |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 1139 | auto asyncResp = std::make_shared<AsyncResp>(res); |
| 1140 | |
Ed Tanous | 029573d | 2019-02-01 10:57:49 -0800 | [diff] [blame] | 1141 | getResourceList(asyncResp, "Memory", |
Alpana Kumari | 32bee76 | 2019-04-25 04:47:57 -0500 | [diff] [blame] | 1142 | {"xyz.openbmc_project.Inventory.Item.Dimm"}); |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 1143 | } |
| 1144 | }; |
| 1145 | |
| 1146 | class Memory : public Node |
| 1147 | { |
| 1148 | public: |
| 1149 | /* |
| 1150 | * Default Constructor |
| 1151 | */ |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 1152 | Memory(CrowApp& app) : |
Ed Tanous | 029573d | 2019-02-01 10:57:49 -0800 | [diff] [blame] | 1153 | Node(app, "/redfish/v1/Systems/system/Memory/<str>/", std::string()) |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 1154 | { |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 1155 | entityPrivileges = { |
| 1156 | {boost::beast::http::verb::get, {{"Login"}}}, |
| 1157 | {boost::beast::http::verb::head, {{"Login"}}}, |
| 1158 | {boost::beast::http::verb::patch, {{"ConfigureComponents"}}}, |
| 1159 | {boost::beast::http::verb::put, {{"ConfigureComponents"}}}, |
| 1160 | {boost::beast::http::verb::delete_, {{"ConfigureComponents"}}}, |
| 1161 | {boost::beast::http::verb::post, {{"ConfigureComponents"}}}}; |
| 1162 | } |
| 1163 | |
| 1164 | private: |
| 1165 | /** |
| 1166 | * Functions triggers appropriate requests on DBus |
| 1167 | */ |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 1168 | void doGet(crow::Response& res, const crow::Request& req, |
| 1169 | const std::vector<std::string>& params) override |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 1170 | { |
| 1171 | // Check if there is required param, truly entering this shall be |
| 1172 | // impossible |
Ed Tanous | 029573d | 2019-02-01 10:57:49 -0800 | [diff] [blame] | 1173 | if (params.size() != 1) |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 1174 | { |
| 1175 | messages::internalError(res); |
| 1176 | res.end(); |
| 1177 | return; |
| 1178 | } |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 1179 | const std::string& dimmId = params[0]; |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 1180 | |
James Feist | c50e7c6 | 2020-07-27 15:39:36 -0700 | [diff] [blame^] | 1181 | res.jsonValue["@odata.type"] = "#Memory.v1_7_0.Memory"; |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 1182 | res.jsonValue["@odata.id"] = |
Ed Tanous | 029573d | 2019-02-01 10:57:49 -0800 | [diff] [blame] | 1183 | "/redfish/v1/Systems/system/Memory/" + dimmId; |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 1184 | auto asyncResp = std::make_shared<AsyncResp>(res); |
| 1185 | |
Ed Tanous | 029573d | 2019-02-01 10:57:49 -0800 | [diff] [blame] | 1186 | getDimmData(asyncResp, dimmId); |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 1187 | } |
| 1188 | }; |
| 1189 | |
| 1190 | } // namespace redfish |