blob: 572156d75d95be0b37b188da70b834348644724a [file] [log] [blame]
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +02001/*
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
18#include <boost/container/flat_map.hpp>
19#include <node.hpp>
20#include <utils/json_utils.hpp>
Ed Tanousabf2add2019-01-22 16:40:12 -080021#include <variant>
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +020022
23namespace redfish
24{
25
Ed Tanous029573d2019-02-01 10:57:49 -080026void getResourceList(std::shared_ptr<AsyncResp> aResp,
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +020027 const std::string &subclass,
Alpana Kumari32bee762019-04-25 04:47:57 -050028 const std::vector<const char *> &collectionName)
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +020029{
30 BMCWEB_LOG_DEBUG << "Get available system cpu/mem resources.";
31 crow::connections::systemBus->async_method_call(
Ed Tanous029573d2019-02-01 10:57:49 -080032 [subclass, aResp{std::move(aResp)}](
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +020033 const boost::system::error_code ec,
34 const boost::container::flat_map<
35 std::string, boost::container::flat_map<
36 std::string, std::vector<std::string>>>
37 &subtree) {
38 if (ec)
39 {
40 BMCWEB_LOG_DEBUG << "DBUS response error";
41 messages::internalError(aResp->res);
42 return;
43 }
44 nlohmann::json &members = aResp->res.jsonValue["Members"];
45 members = nlohmann::json::array();
46
47 for (const auto &object : subtree)
48 {
49 auto iter = object.first.rfind("/");
50 if ((iter != std::string::npos) && (iter < object.first.size()))
51 {
52 members.push_back(
Ed Tanous029573d2019-02-01 10:57:49 -080053 {{"@odata.id", "/redfish/v1/Systems/system/" +
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +020054 subclass + "/" +
55 object.first.substr(iter + 1)}});
56 }
57 }
58 aResp->res.jsonValue["Members@odata.count"] = members.size();
59 },
60 "xyz.openbmc_project.ObjectMapper",
61 "/xyz/openbmc_project/object_mapper",
62 "xyz.openbmc_project.ObjectMapper", "GetSubTree",
Alpana Kumari32bee762019-04-25 04:47:57 -050063 "/xyz/openbmc_project/inventory", int32_t(0), collectionName);
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +020064}
65
66void getCpuDataByService(std::shared_ptr<AsyncResp> aResp,
Ed Tanous029573d2019-02-01 10:57:49 -080067 const std::string &cpuId, const std::string &service,
68 const std::string &objPath)
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +020069{
70 BMCWEB_LOG_DEBUG << "Get available system cpu resources by service.";
71 crow::connections::systemBus->async_method_call(
Ed Tanous029573d2019-02-01 10:57:49 -080072 [cpuId, aResp{std::move(aResp)}](
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +020073 const boost::system::error_code ec,
74 const boost::container::flat_map<
Ed Tanousabf2add2019-01-22 16:40:12 -080075 std::string, std::variant<std::string, uint32_t, uint16_t>>
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +020076 &properties) {
77 if (ec)
78 {
79 BMCWEB_LOG_DEBUG << "DBUS response error";
80 messages::internalError(aResp->res);
81
82 return;
83 }
84 aResp->res.jsonValue["Id"] = cpuId;
85 aResp->res.jsonValue["Name"] = "Processor";
86 const auto coresCountProperty =
87 properties.find("ProcessorCoreCount");
Ed Tanous883b3112018-12-06 16:13:35 -080088 if (coresCountProperty != properties.end())
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +020089 {
Ed Tanous883b3112018-12-06 16:13:35 -080090 const uint16_t *coresCount =
Ed Tanousabf2add2019-01-22 16:40:12 -080091 std::get_if<uint16_t>(&coresCountProperty->second);
Ed Tanous883b3112018-12-06 16:13:35 -080092 if (coresCount == nullptr)
93 {
94 // Important property not in desired type
95 messages::internalError(aResp->res);
96 return;
97 }
98 if (*coresCount == 0)
99 {
100 // Slot is not populated, set status end return
101 aResp->res.jsonValue["Status"]["State"] = "Absent";
102 aResp->res.jsonValue["Status"]["Health"] = "OK";
103 // HTTP Code will be set up automatically, just return
104 return;
105 }
106
107 aResp->res.jsonValue["TotalCores"] = *coresCount;
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +0200108 }
109
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +0200110 aResp->res.jsonValue["Status"]["State"] = "Enabled";
111 aResp->res.jsonValue["Status"]["Health"] = "OK";
112
113 for (const auto &property : properties)
114 {
115 if (property.first == "ProcessorType")
116 {
117 aResp->res.jsonValue["Name"] = property.second;
118 }
119 else if (property.first == "ProcessorManufacturer")
120 {
121 aResp->res.jsonValue["Manufacturer"] = property.second;
122 const std::string *value =
Ed Tanousabf2add2019-01-22 16:40:12 -0800123 std::get_if<std::string>(&property.second);
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +0200124 if (value != nullptr)
125 {
126 // Otherwise would be unexpected.
127 if (value->find("Intel") != std::string::npos)
128 {
129 aResp->res.jsonValue["ProcessorArchitecture"] =
130 "x86";
131 aResp->res.jsonValue["InstructionSet"] = "x86-64";
132 }
Gunnar Millsb957ba52019-01-31 15:58:15 -0600133 else if (value->find("IBM") != std::string::npos)
134 {
135 aResp->res.jsonValue["ProcessorArchitecture"] =
136 "Power";
137 aResp->res.jsonValue["InstructionSet"] = "PowerISA";
138 }
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +0200139 }
140 }
141 else if (property.first == "ProcessorMaxSpeed")
142 {
143 aResp->res.jsonValue["MaxSpeedMHz"] = property.second;
144 }
145 else if (property.first == "ProcessorThreadCount")
146 {
147 aResp->res.jsonValue["TotalThreads"] = property.second;
148 }
149 else if (property.first == "ProcessorVersion")
150 {
151 aResp->res.jsonValue["Model"] = property.second;
152 }
153 }
154 },
155 service, objPath, "org.freedesktop.DBus.Properties", "GetAll", "");
156}
157
Alpana Kumari32bee762019-04-25 04:47:57 -0500158void getAcceleratorDataByService(std::shared_ptr<AsyncResp> aResp,
159 const std::string &acclrtrId,
160 const std::string &service,
161 const std::string &objPath)
162{
163 BMCWEB_LOG_DEBUG
164 << "Get available system Accelerator resources by service.";
165 crow::connections::systemBus->async_method_call(
166 [acclrtrId, aResp{std::move(aResp)}](
167 const boost::system::error_code ec,
168 const boost::container::flat_map<
169 std::string, std::variant<std::string, uint32_t, uint16_t>>
170 &properties) {
171 if (ec)
172 {
173 BMCWEB_LOG_DEBUG << "DBUS response error";
174 messages::internalError(aResp->res);
175 return;
176 }
177 aResp->res.jsonValue["Id"] = acclrtrId;
178 aResp->res.jsonValue["Name"] = "Processor";
179 const std::string *accPresent = nullptr;
180 const std::string *accFunctional = nullptr;
181 std::string state = "";
182
183 for (const auto &property : properties)
184 {
185 if (property.first == "Functional")
186 {
187 accFunctional = std::get_if<std::string>(&property.second);
188 }
189 else if (property.first == "Present")
190 {
191 accPresent = std::get_if<std::string>(&property.second);
192 }
193 }
194
195 if (!accPresent || !accFunctional)
196 {
197 BMCWEB_LOG_DEBUG << "Required properties missing in DBUS "
198 "response";
199 messages::internalError(aResp->res);
200 return;
201 }
202
203 if ((*accPresent == "Present") && (*accFunctional == "Functional"))
204 {
205 state = "Enabled";
206 }
207 else if (*accPresent == "Present")
208 {
209 state = "UnavailableOffline";
210 }
211 else
212 {
213 state = "Absent";
214 }
215 aResp->res.jsonValue["Status"]["State"] = state;
216 aResp->res.jsonValue["Status"]["Health"] = "OK";
217 aResp->res.jsonValue["ProcessorType"] = "Accelerator";
218 },
219 service, objPath, "org.freedesktop.DBus.Properties", "GetAll", "");
220}
221
222void getCpuData(std::shared_ptr<AsyncResp> aResp, const std::string &cpuId,
223 const std::vector<const char *> inventoryItems)
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +0200224{
225 BMCWEB_LOG_DEBUG << "Get available system cpu resources.";
Alpana Kumari32bee762019-04-25 04:47:57 -0500226
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +0200227 crow::connections::systemBus->async_method_call(
Ed Tanous029573d2019-02-01 10:57:49 -0800228 [cpuId, aResp{std::move(aResp)}](
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +0200229 const boost::system::error_code ec,
230 const boost::container::flat_map<
231 std::string, boost::container::flat_map<
232 std::string, std::vector<std::string>>>
233 &subtree) {
234 if (ec)
235 {
236 BMCWEB_LOG_DEBUG << "DBUS response error";
237 messages::internalError(aResp->res);
238 return;
239 }
240 for (const auto &object : subtree)
241 {
242 if (boost::ends_with(object.first, cpuId))
243 {
244 for (const auto &service : object.second)
245 {
Alpana Kumari32bee762019-04-25 04:47:57 -0500246 for (const auto &inventory : service.second)
247 if (inventory ==
248 "xyz.openbmc_project.Inventory.Item.Cpu")
249 {
250 getCpuDataByService(aResp, cpuId, service.first,
251 object.first);
252 }
253 else if (inventory == "xyz.openbmc_project."
254 "Inventory.Item.Accelerator")
255 {
256 getAcceleratorDataByService(
257 aResp, cpuId, service.first, object.first);
258 }
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +0200259 return;
260 }
261 }
262 }
263 // Object not found
264 messages::resourceNotFound(aResp->res, "Processor", cpuId);
265 return;
266 },
267 "xyz.openbmc_project.ObjectMapper",
268 "/xyz/openbmc_project/object_mapper",
269 "xyz.openbmc_project.ObjectMapper", "GetSubTree",
Alpana Kumari32bee762019-04-25 04:47:57 -0500270 "/xyz/openbmc_project/inventory", int32_t(0), inventoryItems);
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +0200271};
272
273void getDimmDataByService(std::shared_ptr<AsyncResp> aResp,
Ed Tanous029573d2019-02-01 10:57:49 -0800274 const std::string &dimmId, const std::string &service,
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +0200275 const std::string &objPath)
276{
277 BMCWEB_LOG_DEBUG << "Get available system components.";
278 crow::connections::systemBus->async_method_call(
Ed Tanous029573d2019-02-01 10:57:49 -0800279 [dimmId, aResp{std::move(aResp)}](
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +0200280 const boost::system::error_code ec,
281 const boost::container::flat_map<
Ed Tanousabf2add2019-01-22 16:40:12 -0800282 std::string, std::variant<std::string, uint32_t, uint16_t>>
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +0200283 &properties) {
284 if (ec)
285 {
286 BMCWEB_LOG_DEBUG << "DBUS response error";
287 messages::internalError(aResp->res);
288
289 return;
290 }
291 aResp->res.jsonValue["Id"] = dimmId;
292 aResp->res.jsonValue["Name"] = "DIMM Slot";
293
294 const auto memorySizeProperty = properties.find("MemorySizeInKB");
Gunnar Millsaceb7fc2018-12-10 15:17:20 -0600295 if (memorySizeProperty != properties.end())
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +0200296 {
Gunnar Millsaceb7fc2018-12-10 15:17:20 -0600297 const uint32_t *memorySize =
Ed Tanousabf2add2019-01-22 16:40:12 -0800298 std::get_if<uint32_t>(&memorySizeProperty->second);
Gunnar Millsaceb7fc2018-12-10 15:17:20 -0600299 if (memorySize == nullptr)
300 {
301 // Important property not in desired type
302 messages::internalError(aResp->res);
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +0200303
Gunnar Millsaceb7fc2018-12-10 15:17:20 -0600304 return;
305 }
306 if (*memorySize == 0)
307 {
308 // Slot is not populated, set status end return
309 aResp->res.jsonValue["Status"]["State"] = "Absent";
310 aResp->res.jsonValue["Status"]["Health"] = "OK";
311 // HTTP Code will be set up automatically, just return
312 return;
313 }
314 aResp->res.jsonValue["CapacityMiB"] = (*memorySize >> 10);
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +0200315 }
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +0200316 aResp->res.jsonValue["Status"]["State"] = "Enabled";
317 aResp->res.jsonValue["Status"]["Health"] = "OK";
318
319 for (const auto &property : properties)
320 {
321 if (property.first == "MemoryDataWidth")
322 {
323 aResp->res.jsonValue["DataWidthBits"] = property.second;
324 }
325 else if (property.first == "MemoryType")
326 {
327 const auto *value =
Ed Tanousabf2add2019-01-22 16:40:12 -0800328 std::get_if<std::string>(&property.second);
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +0200329 if (value != nullptr)
330 {
331 aResp->res.jsonValue["MemoryDeviceType"] = *value;
332 if (boost::starts_with(*value, "DDR"))
333 {
334 aResp->res.jsonValue["MemoryType"] = "DRAM";
335 }
336 }
337 }
338 }
339 },
340 service, objPath, "org.freedesktop.DBus.Properties", "GetAll", "");
341}
342
Ed Tanous029573d2019-02-01 10:57:49 -0800343void getDimmData(std::shared_ptr<AsyncResp> aResp, const std::string &dimmId)
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +0200344{
345 BMCWEB_LOG_DEBUG << "Get available system dimm resources.";
346 crow::connections::systemBus->async_method_call(
Ed Tanous029573d2019-02-01 10:57:49 -0800347 [dimmId, aResp{std::move(aResp)}](
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +0200348 const boost::system::error_code ec,
349 const boost::container::flat_map<
350 std::string, boost::container::flat_map<
351 std::string, std::vector<std::string>>>
352 &subtree) {
353 if (ec)
354 {
355 BMCWEB_LOG_DEBUG << "DBUS response error";
356 messages::internalError(aResp->res);
357
358 return;
359 }
360 for (const auto &object : subtree)
361 {
362 if (boost::ends_with(object.first, dimmId))
363 {
364 for (const auto &service : object.second)
365 {
Ed Tanous029573d2019-02-01 10:57:49 -0800366 getDimmDataByService(aResp, dimmId, service.first,
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +0200367 object.first);
368 return;
369 }
370 }
371 }
372 // Object not found
373 messages::resourceNotFound(aResp->res, "Memory", dimmId);
374 return;
375 },
376 "xyz.openbmc_project.ObjectMapper",
377 "/xyz/openbmc_project/object_mapper",
378 "xyz.openbmc_project.ObjectMapper", "GetSubTree",
379 "/xyz/openbmc_project/inventory", int32_t(0),
380 std::array<const char *, 1>{"xyz.openbmc_project.Inventory.Item.Dimm"});
381};
382
383class ProcessorCollection : public Node
384{
385 public:
386 /*
387 * Default Constructor
388 */
389 ProcessorCollection(CrowApp &app) :
Ed Tanous029573d2019-02-01 10:57:49 -0800390 Node(app, "/redfish/v1/Systems/system/Processors/")
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +0200391 {
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +0200392 entityPrivileges = {
393 {boost::beast::http::verb::get, {{"Login"}}},
394 {boost::beast::http::verb::head, {{"Login"}}},
395 {boost::beast::http::verb::patch, {{"ConfigureComponents"}}},
396 {boost::beast::http::verb::put, {{"ConfigureComponents"}}},
397 {boost::beast::http::verb::delete_, {{"ConfigureComponents"}}},
398 {boost::beast::http::verb::post, {{"ConfigureComponents"}}}};
399 }
400
401 private:
402 /**
403 * Functions triggers appropriate requests on DBus
404 */
405 void doGet(crow::Response &res, const crow::Request &req,
406 const std::vector<std::string> &params) override
407 {
Ed Tanous0f74e642018-11-12 15:17:05 -0800408 res.jsonValue["@odata.type"] =
409 "#ProcessorCollection.ProcessorCollection";
410 res.jsonValue["Name"] = "Processor Collection";
411 res.jsonValue["@odata.context"] =
412 "/redfish/v1/$metadata#ProcessorCollection.ProcessorCollection";
413
Ed Tanous029573d2019-02-01 10:57:49 -0800414 res.jsonValue["@odata.id"] = "/redfish/v1/Systems/system/Processors/";
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +0200415 auto asyncResp = std::make_shared<AsyncResp>(res);
416
Ed Tanous029573d2019-02-01 10:57:49 -0800417 getResourceList(asyncResp, "Processors",
Alpana Kumari32bee762019-04-25 04:47:57 -0500418 {"xyz.openbmc_project.Inventory.Item.Cpu",
419 "xyz.openbmc_project.Inventory.Item.Accelerator"});
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +0200420 }
421};
422
423class Processor : public Node
424{
425 public:
426 /*
427 * Default Constructor
428 */
429 Processor(CrowApp &app) :
Ed Tanous029573d2019-02-01 10:57:49 -0800430 Node(app, "/redfish/v1/Systems/system/Processors/<str>/", std::string())
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +0200431 {
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +0200432 entityPrivileges = {
433 {boost::beast::http::verb::get, {{"Login"}}},
434 {boost::beast::http::verb::head, {{"Login"}}},
435 {boost::beast::http::verb::patch, {{"ConfigureComponents"}}},
436 {boost::beast::http::verb::put, {{"ConfigureComponents"}}},
437 {boost::beast::http::verb::delete_, {{"ConfigureComponents"}}},
438 {boost::beast::http::verb::post, {{"ConfigureComponents"}}}};
439 }
440
441 private:
442 /**
443 * Functions triggers appropriate requests on DBus
444 */
445 void doGet(crow::Response &res, const crow::Request &req,
446 const std::vector<std::string> &params) override
447 {
448 // Check if there is required param, truly entering this shall be
449 // impossible
450 if (params.size() != 1)
451 {
452 messages::internalError(res);
453
454 res.end();
455 return;
456 }
Alpana Kumari32bee762019-04-25 04:47:57 -0500457 const std::string &processorId = params[0];
Ed Tanous029573d2019-02-01 10:57:49 -0800458 res.jsonValue["@odata.type"] = "#Processor.v1_3_1.Processor";
459 res.jsonValue["@odata.context"] =
460 "/redfish/v1/$metadata#Processor.Processor";
461 res.jsonValue["@odata.id"] =
Alpana Kumari32bee762019-04-25 04:47:57 -0500462 "/redfish/v1/Systems/system/Processors/" + processorId;
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +0200463
Ed Tanous029573d2019-02-01 10:57:49 -0800464 auto asyncResp = std::make_shared<AsyncResp>(res);
465
Alpana Kumari32bee762019-04-25 04:47:57 -0500466 getCpuData(asyncResp, processorId,
467 {"xyz.openbmc_project.Inventory.Item.Cpu",
468 "xyz.openbmc_project.Inventory.Item.Accelerator"});
Ed Tanous029573d2019-02-01 10:57:49 -0800469 }
470};
471
472class MemoryCollection : public Node
473{
474 public:
475 /*
476 * Default Constructor
477 */
478 MemoryCollection(CrowApp &app) :
479 Node(app, "/redfish/v1/Systems/system/Memory/")
480 {
481 entityPrivileges = {
482 {boost::beast::http::verb::get, {{"Login"}}},
483 {boost::beast::http::verb::head, {{"Login"}}},
484 {boost::beast::http::verb::patch, {{"ConfigureComponents"}}},
485 {boost::beast::http::verb::put, {{"ConfigureComponents"}}},
486 {boost::beast::http::verb::delete_, {{"ConfigureComponents"}}},
487 {boost::beast::http::verb::post, {{"ConfigureComponents"}}}};
488 }
489
490 private:
491 /**
492 * Functions triggers appropriate requests on DBus
493 */
494 void doGet(crow::Response &res, const crow::Request &req,
495 const std::vector<std::string> &params) override
496 {
Ed Tanous0f74e642018-11-12 15:17:05 -0800497 res.jsonValue["@odata.type"] = "#MemoryCollection.MemoryCollection";
498 res.jsonValue["Name"] = "Memory Module Collection";
499 res.jsonValue["@odata.context"] =
500 "/redfish/v1/$metadata#MemoryCollection.MemoryCollection";
Ed Tanous029573d2019-02-01 10:57:49 -0800501 res.jsonValue["@odata.id"] = "/redfish/v1/Systems/system/Memory/";
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +0200502 auto asyncResp = std::make_shared<AsyncResp>(res);
503
Ed Tanous029573d2019-02-01 10:57:49 -0800504 getResourceList(asyncResp, "Memory",
Alpana Kumari32bee762019-04-25 04:47:57 -0500505 {"xyz.openbmc_project.Inventory.Item.Dimm"});
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +0200506 }
507};
508
509class Memory : public Node
510{
511 public:
512 /*
513 * Default Constructor
514 */
515 Memory(CrowApp &app) :
Ed Tanous029573d2019-02-01 10:57:49 -0800516 Node(app, "/redfish/v1/Systems/system/Memory/<str>/", std::string())
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +0200517 {
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +0200518 entityPrivileges = {
519 {boost::beast::http::verb::get, {{"Login"}}},
520 {boost::beast::http::verb::head, {{"Login"}}},
521 {boost::beast::http::verb::patch, {{"ConfigureComponents"}}},
522 {boost::beast::http::verb::put, {{"ConfigureComponents"}}},
523 {boost::beast::http::verb::delete_, {{"ConfigureComponents"}}},
524 {boost::beast::http::verb::post, {{"ConfigureComponents"}}}};
525 }
526
527 private:
528 /**
529 * Functions triggers appropriate requests on DBus
530 */
531 void doGet(crow::Response &res, const crow::Request &req,
532 const std::vector<std::string> &params) override
533 {
534 // Check if there is required param, truly entering this shall be
535 // impossible
Ed Tanous029573d2019-02-01 10:57:49 -0800536 if (params.size() != 1)
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +0200537 {
538 messages::internalError(res);
539 res.end();
540 return;
541 }
Ed Tanous029573d2019-02-01 10:57:49 -0800542 const std::string &dimmId = params[0];
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +0200543
Rapkiewicz, Pawelbb3d9942018-11-22 10:59:11 +0100544 res.jsonValue["@odata.type"] = "#Memory.v1_6_0.Memory";
Ed Tanous0f74e642018-11-12 15:17:05 -0800545 res.jsonValue["@odata.context"] = "/redfish/v1/$metadata#Memory.Memory";
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +0200546 res.jsonValue["@odata.id"] =
Ed Tanous029573d2019-02-01 10:57:49 -0800547 "/redfish/v1/Systems/system/Memory/" + dimmId;
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +0200548 auto asyncResp = std::make_shared<AsyncResp>(res);
549
Ed Tanous029573d2019-02-01 10:57:49 -0800550 getDimmData(asyncResp, dimmId);
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +0200551 }
552};
553
554} // namespace redfish