blob: 5601325614f23d2ed21d8832a8798c43a8e0c953 [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 }
Manojkiran Eda7e236ca2019-06-25 23:06:32 +0530325 else if (property.first == "PartNumber")
326 {
327 aResp->res.jsonValue["PartNumber"] = property.second;
328 }
329 else if (property.first == "SerialNumber")
330 {
331 aResp->res.jsonValue["SerialNumber"] = property.second;
332 }
333 else if (property.first == "Manufacturer")
334 {
335 aResp->res.jsonValue["Manufacturer"] = property.second;
336 }
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +0200337 else if (property.first == "MemoryType")
338 {
339 const auto *value =
Ed Tanousabf2add2019-01-22 16:40:12 -0800340 std::get_if<std::string>(&property.second);
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +0200341 if (value != nullptr)
342 {
343 aResp->res.jsonValue["MemoryDeviceType"] = *value;
344 if (boost::starts_with(*value, "DDR"))
345 {
346 aResp->res.jsonValue["MemoryType"] = "DRAM";
347 }
348 }
349 }
350 }
351 },
352 service, objPath, "org.freedesktop.DBus.Properties", "GetAll", "");
353}
354
Ed Tanous029573d2019-02-01 10:57:49 -0800355void getDimmData(std::shared_ptr<AsyncResp> aResp, const std::string &dimmId)
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +0200356{
357 BMCWEB_LOG_DEBUG << "Get available system dimm resources.";
358 crow::connections::systemBus->async_method_call(
Ed Tanous029573d2019-02-01 10:57:49 -0800359 [dimmId, aResp{std::move(aResp)}](
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +0200360 const boost::system::error_code ec,
361 const boost::container::flat_map<
362 std::string, boost::container::flat_map<
363 std::string, std::vector<std::string>>>
364 &subtree) {
365 if (ec)
366 {
367 BMCWEB_LOG_DEBUG << "DBUS response error";
368 messages::internalError(aResp->res);
369
370 return;
371 }
372 for (const auto &object : subtree)
373 {
374 if (boost::ends_with(object.first, dimmId))
375 {
376 for (const auto &service : object.second)
377 {
Ed Tanous029573d2019-02-01 10:57:49 -0800378 getDimmDataByService(aResp, dimmId, service.first,
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +0200379 object.first);
380 return;
381 }
382 }
383 }
384 // Object not found
385 messages::resourceNotFound(aResp->res, "Memory", dimmId);
386 return;
387 },
388 "xyz.openbmc_project.ObjectMapper",
389 "/xyz/openbmc_project/object_mapper",
390 "xyz.openbmc_project.ObjectMapper", "GetSubTree",
391 "/xyz/openbmc_project/inventory", int32_t(0),
392 std::array<const char *, 1>{"xyz.openbmc_project.Inventory.Item.Dimm"});
393};
394
395class ProcessorCollection : public Node
396{
397 public:
398 /*
399 * Default Constructor
400 */
401 ProcessorCollection(CrowApp &app) :
Ed Tanous029573d2019-02-01 10:57:49 -0800402 Node(app, "/redfish/v1/Systems/system/Processors/")
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +0200403 {
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +0200404 entityPrivileges = {
405 {boost::beast::http::verb::get, {{"Login"}}},
406 {boost::beast::http::verb::head, {{"Login"}}},
407 {boost::beast::http::verb::patch, {{"ConfigureComponents"}}},
408 {boost::beast::http::verb::put, {{"ConfigureComponents"}}},
409 {boost::beast::http::verb::delete_, {{"ConfigureComponents"}}},
410 {boost::beast::http::verb::post, {{"ConfigureComponents"}}}};
411 }
412
413 private:
414 /**
415 * Functions triggers appropriate requests on DBus
416 */
417 void doGet(crow::Response &res, const crow::Request &req,
418 const std::vector<std::string> &params) override
419 {
Ed Tanous0f74e642018-11-12 15:17:05 -0800420 res.jsonValue["@odata.type"] =
421 "#ProcessorCollection.ProcessorCollection";
422 res.jsonValue["Name"] = "Processor Collection";
423 res.jsonValue["@odata.context"] =
424 "/redfish/v1/$metadata#ProcessorCollection.ProcessorCollection";
425
Ed Tanous029573d2019-02-01 10:57:49 -0800426 res.jsonValue["@odata.id"] = "/redfish/v1/Systems/system/Processors/";
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +0200427 auto asyncResp = std::make_shared<AsyncResp>(res);
428
Ed Tanous029573d2019-02-01 10:57:49 -0800429 getResourceList(asyncResp, "Processors",
Alpana Kumari32bee762019-04-25 04:47:57 -0500430 {"xyz.openbmc_project.Inventory.Item.Cpu",
431 "xyz.openbmc_project.Inventory.Item.Accelerator"});
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +0200432 }
433};
434
435class Processor : public Node
436{
437 public:
438 /*
439 * Default Constructor
440 */
441 Processor(CrowApp &app) :
Ed Tanous029573d2019-02-01 10:57:49 -0800442 Node(app, "/redfish/v1/Systems/system/Processors/<str>/", std::string())
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +0200443 {
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +0200444 entityPrivileges = {
445 {boost::beast::http::verb::get, {{"Login"}}},
446 {boost::beast::http::verb::head, {{"Login"}}},
447 {boost::beast::http::verb::patch, {{"ConfigureComponents"}}},
448 {boost::beast::http::verb::put, {{"ConfigureComponents"}}},
449 {boost::beast::http::verb::delete_, {{"ConfigureComponents"}}},
450 {boost::beast::http::verb::post, {{"ConfigureComponents"}}}};
451 }
452
453 private:
454 /**
455 * Functions triggers appropriate requests on DBus
456 */
457 void doGet(crow::Response &res, const crow::Request &req,
458 const std::vector<std::string> &params) override
459 {
460 // Check if there is required param, truly entering this shall be
461 // impossible
462 if (params.size() != 1)
463 {
464 messages::internalError(res);
465
466 res.end();
467 return;
468 }
Alpana Kumari32bee762019-04-25 04:47:57 -0500469 const std::string &processorId = params[0];
Ed Tanous029573d2019-02-01 10:57:49 -0800470 res.jsonValue["@odata.type"] = "#Processor.v1_3_1.Processor";
471 res.jsonValue["@odata.context"] =
472 "/redfish/v1/$metadata#Processor.Processor";
473 res.jsonValue["@odata.id"] =
Alpana Kumari32bee762019-04-25 04:47:57 -0500474 "/redfish/v1/Systems/system/Processors/" + processorId;
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +0200475
Ed Tanous029573d2019-02-01 10:57:49 -0800476 auto asyncResp = std::make_shared<AsyncResp>(res);
477
Alpana Kumari32bee762019-04-25 04:47:57 -0500478 getCpuData(asyncResp, processorId,
479 {"xyz.openbmc_project.Inventory.Item.Cpu",
480 "xyz.openbmc_project.Inventory.Item.Accelerator"});
Ed Tanous029573d2019-02-01 10:57:49 -0800481 }
482};
483
484class MemoryCollection : public Node
485{
486 public:
487 /*
488 * Default Constructor
489 */
490 MemoryCollection(CrowApp &app) :
491 Node(app, "/redfish/v1/Systems/system/Memory/")
492 {
493 entityPrivileges = {
494 {boost::beast::http::verb::get, {{"Login"}}},
495 {boost::beast::http::verb::head, {{"Login"}}},
496 {boost::beast::http::verb::patch, {{"ConfigureComponents"}}},
497 {boost::beast::http::verb::put, {{"ConfigureComponents"}}},
498 {boost::beast::http::verb::delete_, {{"ConfigureComponents"}}},
499 {boost::beast::http::verb::post, {{"ConfigureComponents"}}}};
500 }
501
502 private:
503 /**
504 * Functions triggers appropriate requests on DBus
505 */
506 void doGet(crow::Response &res, const crow::Request &req,
507 const std::vector<std::string> &params) override
508 {
Ed Tanous0f74e642018-11-12 15:17:05 -0800509 res.jsonValue["@odata.type"] = "#MemoryCollection.MemoryCollection";
510 res.jsonValue["Name"] = "Memory Module Collection";
511 res.jsonValue["@odata.context"] =
512 "/redfish/v1/$metadata#MemoryCollection.MemoryCollection";
Ed Tanous029573d2019-02-01 10:57:49 -0800513 res.jsonValue["@odata.id"] = "/redfish/v1/Systems/system/Memory/";
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +0200514 auto asyncResp = std::make_shared<AsyncResp>(res);
515
Ed Tanous029573d2019-02-01 10:57:49 -0800516 getResourceList(asyncResp, "Memory",
Alpana Kumari32bee762019-04-25 04:47:57 -0500517 {"xyz.openbmc_project.Inventory.Item.Dimm"});
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +0200518 }
519};
520
521class Memory : public Node
522{
523 public:
524 /*
525 * Default Constructor
526 */
527 Memory(CrowApp &app) :
Ed Tanous029573d2019-02-01 10:57:49 -0800528 Node(app, "/redfish/v1/Systems/system/Memory/<str>/", std::string())
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +0200529 {
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +0200530 entityPrivileges = {
531 {boost::beast::http::verb::get, {{"Login"}}},
532 {boost::beast::http::verb::head, {{"Login"}}},
533 {boost::beast::http::verb::patch, {{"ConfigureComponents"}}},
534 {boost::beast::http::verb::put, {{"ConfigureComponents"}}},
535 {boost::beast::http::verb::delete_, {{"ConfigureComponents"}}},
536 {boost::beast::http::verb::post, {{"ConfigureComponents"}}}};
537 }
538
539 private:
540 /**
541 * Functions triggers appropriate requests on DBus
542 */
543 void doGet(crow::Response &res, const crow::Request &req,
544 const std::vector<std::string> &params) override
545 {
546 // Check if there is required param, truly entering this shall be
547 // impossible
Ed Tanous029573d2019-02-01 10:57:49 -0800548 if (params.size() != 1)
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +0200549 {
550 messages::internalError(res);
551 res.end();
552 return;
553 }
Ed Tanous029573d2019-02-01 10:57:49 -0800554 const std::string &dimmId = params[0];
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +0200555
Rapkiewicz, Pawelbb3d9942018-11-22 10:59:11 +0100556 res.jsonValue["@odata.type"] = "#Memory.v1_6_0.Memory";
Ed Tanous0f74e642018-11-12 15:17:05 -0800557 res.jsonValue["@odata.context"] = "/redfish/v1/$metadata#Memory.Memory";
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +0200558 res.jsonValue["@odata.id"] =
Ed Tanous029573d2019-02-01 10:57:49 -0800559 "/redfish/v1/Systems/system/Memory/" + dimmId;
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +0200560 auto asyncResp = std::make_shared<AsyncResp>(res);
561
Ed Tanous029573d2019-02-01 10:57:49 -0800562 getDimmData(asyncResp, dimmId);
Rapkiewicz, Pawel443c2932018-10-22 15:08:49 +0200563 }
564};
565
566} // namespace redfish