blob: fc89d0356ae56c3617076d116619ed1cd698652a [file] [log] [blame]
Rapkiewicz, Pawele37f8452018-03-09 13:49:50 +01001/*
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
Willy Tu13451e32023-05-24 16:08:18 -070018#include "bmcweb_config.h"
19
Ed Tanous3ccb3ad2023-01-13 17:40:03 -080020#include "app.hpp"
George Liu7a1dbc42022-12-07 16:03:22 +080021#include "dbus_utility.hpp"
James Feistb49ac872019-05-21 15:12:01 -070022#include "health.hpp"
James Feist1c8fba92019-12-20 15:12:07 -080023#include "led.hpp"
Ed Tanous3ccb3ad2023-01-13 17:40:03 -080024#include "query.hpp"
25#include "registries/privilege_registry.hpp"
26#include "utils/collection.hpp"
27#include "utils/dbus_utils.hpp"
Nan Zhoucf7eba02022-07-21 23:53:20 +000028#include "utils/json_utils.hpp"
Ed Tanous1abe55e2018-09-05 08:30:59 -070029
George Liue99073f2022-12-09 11:06:16 +080030#include <boost/system/error_code.hpp>
Ed Tanousef4c65b2023-04-24 15:28:50 -070031#include <boost/url/format.hpp>
Jonathan Doman1e1e5982021-06-11 09:36:17 -070032#include <sdbusplus/asio/property.hpp>
Andrew Geisslerfc903b32023-05-31 14:15:42 -040033#include <sdbusplus/message.hpp>
Krzysztof Grobelny86d89ed2022-08-29 14:49:20 +020034#include <sdbusplus/unpack_properties.hpp>
Gunnar Mills1214b7e2020-06-04 10:11:30 -050035
George Liu7a1dbc42022-12-07 16:03:22 +080036#include <array>
37#include <string_view>
38
Ed Tanous1abe55e2018-09-05 08:30:59 -070039namespace redfish
40{
Rapkiewicz, Pawele37f8452018-03-09 13:49:50 +010041
42/**
Willy Tu5e577bc2022-07-26 00:41:55 +000043 * @brief Retrieves resources over dbus to link to the chassis
44 *
45 * @param[in] asyncResp - Shared pointer for completing asynchronous
46 * calls
47 * @param[in] path - Chassis dbus path to look for the storage.
48 *
49 * Calls the Association endpoints on the path + "/storage" and add the link of
50 * json["Links"]["Storage@odata.count"] =
51 * {"@odata.id", "/redfish/v1/Storage/" + resourceId}
52 *
53 * @return None.
54 */
55inline void getStorageLink(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
56 const sdbusplus::message::object_path& path)
57{
58 sdbusplus::asio::getProperty<std::vector<std::string>>(
59 *crow::connections::systemBus, "xyz.openbmc_project.ObjectMapper",
60 (path / "storage").str, "xyz.openbmc_project.Association", "endpoints",
Willy Tud4b054c2023-06-12 15:18:45 -070061 [asyncResp](const boost::system::error_code& ec,
Willy Tu5e577bc2022-07-26 00:41:55 +000062 const std::vector<std::string>& storageList) {
63 if (ec)
64 {
65 BMCWEB_LOG_DEBUG << "getStorageLink got DBUS response error";
66 return;
67 }
68
69 nlohmann::json::array_t storages;
70 for (const std::string& storagePath : storageList)
71 {
72 std::string id =
73 sdbusplus::message::object_path(storagePath).filename();
74 if (id.empty())
75 {
76 continue;
77 }
78
79 nlohmann::json::object_t storage;
80 storage["@odata.id"] = boost::urls::format(
81 "/redfish/v1/Systems/system/Storage/{}", id);
82 storages.emplace_back(std::move(storage));
83 }
84 asyncResp->res.jsonValue["Links"]["Storage@odata.count"] =
85 storages.size();
86 asyncResp->res.jsonValue["Links"]["Storage"] = std::move(storages);
87 });
88}
89
90/**
Gunnar Millsbeeca0a2019-02-14 16:30:45 -060091 * @brief Retrieves chassis state properties over dbus
92 *
Ed Tanousac106bf2023-06-07 09:24:59 -070093 * @param[in] asyncResp - Shared pointer for completing asynchronous calls.
Gunnar Millsbeeca0a2019-02-14 16:30:45 -060094 *
95 * @return None.
96 */
Ed Tanousac106bf2023-06-07 09:24:59 -070097inline void getChassisState(std::shared_ptr<bmcweb::AsyncResp> asyncResp)
Gunnar Millsbeeca0a2019-02-14 16:30:45 -060098{
Jonathan Doman1e1e5982021-06-11 09:36:17 -070099 // crow::connections::systemBus->async_method_call(
100 sdbusplus::asio::getProperty<std::string>(
101 *crow::connections::systemBus, "xyz.openbmc_project.State.Chassis",
102 "/xyz/openbmc_project/state/chassis0",
103 "xyz.openbmc_project.State.Chassis", "CurrentPowerState",
Ed Tanousac106bf2023-06-07 09:24:59 -0700104 [asyncResp{std::move(asyncResp)}](const boost::system::error_code& ec,
105 const std::string& chassisState) {
Ed Tanous002d39b2022-05-31 08:59:27 -0700106 if (ec)
107 {
108 if (ec == boost::system::errc::host_unreachable)
Gunnar Millsbeeca0a2019-02-14 16:30:45 -0600109 {
Ed Tanous002d39b2022-05-31 08:59:27 -0700110 // Service not available, no error, just don't return
111 // chassis state info
112 BMCWEB_LOG_DEBUG << "Service not available " << ec;
Gunnar Millsbeeca0a2019-02-14 16:30:45 -0600113 return;
114 }
Ed Tanousac106bf2023-06-07 09:24:59 -0700115 BMCWEB_LOG_DEBUG << "DBUS response error " << ec;
116 messages::internalError(asyncResp->res);
Ed Tanous002d39b2022-05-31 08:59:27 -0700117 return;
118 }
Gunnar Millsbeeca0a2019-02-14 16:30:45 -0600119
Ed Tanous002d39b2022-05-31 08:59:27 -0700120 BMCWEB_LOG_DEBUG << "Chassis state: " << chassisState;
121 // Verify Chassis State
122 if (chassisState == "xyz.openbmc_project.State.Chassis.PowerState.On")
123 {
Ed Tanousac106bf2023-06-07 09:24:59 -0700124 asyncResp->res.jsonValue["PowerState"] = "On";
125 asyncResp->res.jsonValue["Status"]["State"] = "Enabled";
Ed Tanous002d39b2022-05-31 08:59:27 -0700126 }
127 else if (chassisState ==
128 "xyz.openbmc_project.State.Chassis.PowerState.Off")
129 {
Ed Tanousac106bf2023-06-07 09:24:59 -0700130 asyncResp->res.jsonValue["PowerState"] = "Off";
131 asyncResp->res.jsonValue["Status"]["State"] = "StandbyOffline";
Ed Tanous002d39b2022-05-31 08:59:27 -0700132 }
Jonathan Doman1e1e5982021-06-11 09:36:17 -0700133 });
Gunnar Millsbeeca0a2019-02-14 16:30:45 -0600134}
135
Ed Tanousac106bf2023-06-07 09:24:59 -0700136inline void getIntrusionByService(std::shared_ptr<bmcweb::AsyncResp> asyncResp,
Ed Tanous23a21a12020-07-25 04:45:05 +0000137 const std::string& service,
138 const std::string& objPath)
Qiang XUc1819422019-02-27 13:51:32 +0800139{
140 BMCWEB_LOG_DEBUG << "Get intrusion status by service \n";
141
Jonathan Doman1e1e5982021-06-11 09:36:17 -0700142 sdbusplus::asio::getProperty<std::string>(
143 *crow::connections::systemBus, service, objPath,
144 "xyz.openbmc_project.Chassis.Intrusion", "Status",
Ed Tanousac106bf2023-06-07 09:24:59 -0700145 [asyncResp{std::move(asyncResp)}](const boost::system::error_code& ec,
146 const std::string& value) {
Ed Tanous002d39b2022-05-31 08:59:27 -0700147 if (ec)
148 {
149 // do not add err msg in redfish response, because this is not
150 // mandatory property
151 BMCWEB_LOG_ERROR << "DBUS response error " << ec << "\n";
152 return;
153 }
Qiang XUc1819422019-02-27 13:51:32 +0800154
Ed Tanousac106bf2023-06-07 09:24:59 -0700155 asyncResp->res.jsonValue["PhysicalSecurity"]["IntrusionSensorNumber"] =
156 1;
157 asyncResp->res.jsonValue["PhysicalSecurity"]["IntrusionSensor"] = value;
Jonathan Doman1e1e5982021-06-11 09:36:17 -0700158 });
Qiang XUc1819422019-02-27 13:51:32 +0800159}
160
161/**
162 * Retrieves physical security properties over dbus
163 */
Ed Tanousac106bf2023-06-07 09:24:59 -0700164inline void
165 getPhysicalSecurityData(std::shared_ptr<bmcweb::AsyncResp> asyncResp)
Qiang XUc1819422019-02-27 13:51:32 +0800166{
George Liue99073f2022-12-09 11:06:16 +0800167 constexpr std::array<std::string_view, 1> interfaces = {
168 "xyz.openbmc_project.Chassis.Intrusion"};
169 dbus::utility::getSubTree(
170 "/xyz/openbmc_project/Intrusion", 1, interfaces,
Ed Tanousac106bf2023-06-07 09:24:59 -0700171 [asyncResp{std::move(asyncResp)}](
George Liue99073f2022-12-09 11:06:16 +0800172 const boost::system::error_code& ec,
Ed Tanousb9d36b42022-02-26 21:42:46 -0800173 const dbus::utility::MapperGetSubTreeResponse& subtree) {
Ed Tanous002d39b2022-05-31 08:59:27 -0700174 if (ec)
175 {
176 // do not add err msg in redfish response, because this is not
177 // mandatory property
178 BMCWEB_LOG_INFO << "DBUS error: no matched iface " << ec << "\n";
179 return;
180 }
181 // Iterate over all retrieved ObjectPaths.
182 for (const auto& object : subtree)
183 {
Patrick Williams840a9ff2023-05-12 10:18:43 -0500184 if (!object.second.empty())
Qiang XUc1819422019-02-27 13:51:32 +0800185 {
Patrick Williams840a9ff2023-05-12 10:18:43 -0500186 const auto service = object.second.front();
Ed Tanousac106bf2023-06-07 09:24:59 -0700187 getIntrusionByService(asyncResp, service.first, object.first);
Qiang XUc1819422019-02-27 13:51:32 +0800188 return;
189 }
Ed Tanous002d39b2022-05-31 08:59:27 -0700190 }
George Liue99073f2022-12-09 11:06:16 +0800191 });
Qiang XUc1819422019-02-27 13:51:32 +0800192}
193
Nan Zhoucf7eba02022-07-21 23:53:20 +0000194inline void handleChassisCollectionGet(
195 App& app, const crow::Request& req,
196 const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
197{
198 if (!redfish::setUpRedfishRoute(app, req, asyncResp))
199 {
200 return;
201 }
202 asyncResp->res.jsonValue["@odata.type"] =
203 "#ChassisCollection.ChassisCollection";
204 asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/Chassis";
205 asyncResp->res.jsonValue["Name"] = "Chassis Collection";
206
George Liu7a1dbc42022-12-07 16:03:22 +0800207 constexpr std::array<std::string_view, 2> interfaces{
208 "xyz.openbmc_project.Inventory.Item.Board",
209 "xyz.openbmc_project.Inventory.Item.Chassis"};
Nan Zhoucf7eba02022-07-21 23:53:20 +0000210 collection_util::getCollectionMembers(
George Liu7a1dbc42022-12-07 16:03:22 +0800211 asyncResp, boost::urls::url("/redfish/v1/Chassis"), interfaces);
Nan Zhoucf7eba02022-07-21 23:53:20 +0000212}
213
Jie Yanga5617492021-06-29 12:59:14 -0700214inline void getChassisContainedBy(
215 const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
216 const std::string& chassisId, const boost::system::error_code& ec,
217 const dbus::utility::MapperEndPoints& upstreamChassisPaths)
218{
219 if (ec)
220 {
221 if (ec.value() != EBADR)
222 {
223 BMCWEB_LOG_ERROR << "DBUS response error " << ec;
224 messages::internalError(asyncResp->res);
225 }
226 return;
227 }
228 if (upstreamChassisPaths.empty())
229 {
230 return;
231 }
232 if (upstreamChassisPaths.size() > 1)
233 {
234 BMCWEB_LOG_ERROR << chassisId << " is contained by mutliple chassis";
235 messages::internalError(asyncResp->res);
236 return;
237 }
238
239 sdbusplus::message::object_path upstreamChassisPath(
240 upstreamChassisPaths[0]);
241 std::string upstreamChassis = upstreamChassisPath.filename();
242 if (upstreamChassis.empty())
243 {
244 BMCWEB_LOG_WARNING << "Malformed upstream Chassis path "
245 << upstreamChassisPath.str << " on " << chassisId;
246 return;
247 }
248
249 asyncResp->res.jsonValue["Links"]["ContainedBy"]["@odata.id"] =
250 boost::urls::format("/redfish/v1/Chassis/{}", upstreamChassis);
251}
252
253inline void getChassisContains(
254 const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
255 const std::string& chassisId, const boost::system::error_code& ec,
256 const dbus::utility::MapperEndPoints& downstreamChassisPaths)
257{
258 if (ec)
259 {
260 if (ec.value() != EBADR)
261 {
262 BMCWEB_LOG_ERROR << "DBUS response error " << ec;
263 messages::internalError(asyncResp->res);
264 }
265 return;
266 }
267 if (downstreamChassisPaths.empty())
268 {
269 return;
270 }
271 nlohmann::json& jValue = asyncResp->res.jsonValue["Links"]["Contains"];
272 if (!jValue.is_array())
273 {
274 // Create the array if it was empty
275 jValue = nlohmann::json::array();
276 }
277 for (const auto& p : downstreamChassisPaths)
278 {
279 sdbusplus::message::object_path downstreamChassisPath(p);
280 std::string downstreamChassis = downstreamChassisPath.filename();
281 if (downstreamChassis.empty())
282 {
283 BMCWEB_LOG_WARNING << "Malformed downstream Chassis path "
284 << downstreamChassisPath.str << " on "
285 << chassisId;
286 continue;
287 }
288 nlohmann::json link;
289 link["@odata.id"] = boost::urls::format("/redfish/v1/Chassis/{}",
290 downstreamChassis);
291 jValue.push_back(std::move(link));
292 }
293 asyncResp->res.jsonValue["Links"]["Contains@odata.count"] = jValue.size();
294}
295
296inline void
297 getChassisConnectivity(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
298 const std::string& chassisId,
299 const std::string& chassisPath)
300{
301 BMCWEB_LOG_DEBUG << "Get chassis connectivity";
302
303 dbus::utility::getAssociationEndPoints(
304 chassisPath + "/contained_by",
305 std::bind_front(getChassisContainedBy, asyncResp, chassisId));
306
307 dbus::utility::getAssociationEndPoints(
308 chassisPath + "/containing",
309 std::bind_front(getChassisContains, asyncResp, chassisId));
310}
311
Rapkiewicz, Pawele37f8452018-03-09 13:49:50 +0100312/**
Rapkiewicz, Pawele37f8452018-03-09 13:49:50 +0100313 * ChassisCollection derived class for delivering Chassis Collection Schema
John Edward Broadbent7e860f12021-04-08 15:57:16 -0700314 * Functions triggers appropriate requests on DBus
Rapkiewicz, Pawele37f8452018-03-09 13:49:50 +0100315 */
John Edward Broadbent7e860f12021-04-08 15:57:16 -0700316inline void requestRoutesChassisCollection(App& app)
Ed Tanous1abe55e2018-09-05 08:30:59 -0700317{
John Edward Broadbent7e860f12021-04-08 15:57:16 -0700318 BMCWEB_ROUTE(app, "/redfish/v1/Chassis/")
Ed Tanoused398212021-06-09 17:05:54 -0700319 .privileges(redfish::privileges::getChassisCollection)
John Edward Broadbent7e860f12021-04-08 15:57:16 -0700320 .methods(boost::beast::http::verb::get)(
Nan Zhoucf7eba02022-07-21 23:53:20 +0000321 std::bind_front(handleChassisCollectionGet, std::ref(app)));
John Edward Broadbent7e860f12021-04-08 15:57:16 -0700322}
Rapkiewicz, Pawele37f8452018-03-09 13:49:50 +0100323
Willy Tu308f70c2021-09-28 20:24:52 -0700324inline void
325 getChassisLocationCode(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
326 const std::string& connectionName,
327 const std::string& path)
328{
Jonathan Doman1e1e5982021-06-11 09:36:17 -0700329 sdbusplus::asio::getProperty<std::string>(
330 *crow::connections::systemBus, connectionName, path,
331 "xyz.openbmc_project.Inventory.Decorator.LocationCode", "LocationCode",
Ed Tanous5e7e2dc2023-02-16 10:37:01 -0800332 [asyncResp](const boost::system::error_code& ec,
Jonathan Doman1e1e5982021-06-11 09:36:17 -0700333 const std::string& property) {
Ed Tanous002d39b2022-05-31 08:59:27 -0700334 if (ec)
335 {
Andrew Geissler51dab2a2023-05-30 15:07:46 -0400336 BMCWEB_LOG_ERROR << "DBUS response error for Location";
Ed Tanous002d39b2022-05-31 08:59:27 -0700337 messages::internalError(asyncResp->res);
338 return;
339 }
Willy Tu308f70c2021-09-28 20:24:52 -0700340
Ed Tanous002d39b2022-05-31 08:59:27 -0700341 asyncResp->res.jsonValue["Location"]["PartLocation"]["ServiceLabel"] =
342 property;
Jonathan Doman1e1e5982021-06-11 09:36:17 -0700343 });
Willy Tu308f70c2021-09-28 20:24:52 -0700344}
345
346inline void getChassisUUID(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
347 const std::string& connectionName,
348 const std::string& path)
349{
Jonathan Doman1e1e5982021-06-11 09:36:17 -0700350 sdbusplus::asio::getProperty<std::string>(
351 *crow::connections::systemBus, connectionName, path,
352 "xyz.openbmc_project.Common.UUID", "UUID",
Ed Tanous5e7e2dc2023-02-16 10:37:01 -0800353 [asyncResp](const boost::system::error_code& ec,
Jonathan Doman1e1e5982021-06-11 09:36:17 -0700354 const std::string& chassisUUID) {
Ed Tanous002d39b2022-05-31 08:59:27 -0700355 if (ec)
356 {
Andrew Geissler51dab2a2023-05-30 15:07:46 -0400357 BMCWEB_LOG_ERROR << "DBUS response error for UUID";
Ed Tanous002d39b2022-05-31 08:59:27 -0700358 messages::internalError(asyncResp->res);
359 return;
360 }
361 asyncResp->res.jsonValue["UUID"] = chassisUUID;
Jonathan Doman1e1e5982021-06-11 09:36:17 -0700362 });
Willy Tu308f70c2021-09-28 20:24:52 -0700363}
364
Nan Zhoucf7eba02022-07-21 23:53:20 +0000365inline void
366 handleChassisGet(App& app, const crow::Request& req,
367 const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
368 const std::string& chassisId)
369{
370 if (!redfish::setUpRedfishRoute(app, req, asyncResp))
371 {
372 return;
373 }
George Liue99073f2022-12-09 11:06:16 +0800374 constexpr std::array<std::string_view, 2> interfaces = {
Nan Zhoucf7eba02022-07-21 23:53:20 +0000375 "xyz.openbmc_project.Inventory.Item.Board",
376 "xyz.openbmc_project.Inventory.Item.Chassis"};
377
George Liue99073f2022-12-09 11:06:16 +0800378 dbus::utility::getSubTree(
379 "/xyz/openbmc_project/inventory", 0, interfaces,
Nan Zhoucf7eba02022-07-21 23:53:20 +0000380 [asyncResp, chassisId(std::string(chassisId))](
George Liue99073f2022-12-09 11:06:16 +0800381 const boost::system::error_code& ec,
Nan Zhoucf7eba02022-07-21 23:53:20 +0000382 const dbus::utility::MapperGetSubTreeResponse& subtree) {
383 if (ec)
384 {
Andrew Geissler51dab2a2023-05-30 15:07:46 -0400385 BMCWEB_LOG_ERROR << "DBUS response error " << ec;
Nan Zhoucf7eba02022-07-21 23:53:20 +0000386 messages::internalError(asyncResp->res);
387 return;
388 }
389 // Iterate over all retrieved ObjectPaths.
390 for (const std::pair<
391 std::string,
392 std::vector<std::pair<std::string, std::vector<std::string>>>>&
393 object : subtree)
394 {
395 const std::string& path = object.first;
396 const std::vector<std::pair<std::string, std::vector<std::string>>>&
397 connectionNames = object.second;
398
399 sdbusplus::message::object_path objPath(path);
400 if (objPath.filename() != chassisId)
401 {
402 continue;
403 }
404
Jie Yanga5617492021-06-29 12:59:14 -0700405 getChassisConnectivity(asyncResp, chassisId, path);
406
Nan Zhoucf7eba02022-07-21 23:53:20 +0000407 auto health = std::make_shared<HealthPopulate>(asyncResp);
408
Willy Tu13451e32023-05-24 16:08:18 -0700409 if constexpr (bmcwebEnableHealthPopulate)
410 {
411 dbus::utility::getAssociationEndPoints(
412 path + "/all_sensors",
413 [health](const boost::system::error_code& ec2,
414 const dbus::utility::MapperEndPoints& resp) {
415 if (ec2)
416 {
417 return; // no sensors = no failures
418 }
419 health->inventory = resp;
420 });
Nan Zhoucf7eba02022-07-21 23:53:20 +0000421
Willy Tu13451e32023-05-24 16:08:18 -0700422 health->populate();
423 }
Nan Zhoucf7eba02022-07-21 23:53:20 +0000424
425 if (connectionNames.empty())
426 {
427 BMCWEB_LOG_ERROR << "Got 0 Connection names";
428 continue;
429 }
430
431 asyncResp->res.jsonValue["@odata.type"] =
Logananth Sundararaj523d4862023-01-24 11:56:28 +0530432 "#Chassis.v1_22_0.Chassis";
Nan Zhoucf7eba02022-07-21 23:53:20 +0000433 asyncResp->res.jsonValue["@odata.id"] =
Ed Tanousef4c65b2023-04-24 15:28:50 -0700434 boost::urls::format("/redfish/v1/Chassis/{}", chassisId);
Nan Zhoucf7eba02022-07-21 23:53:20 +0000435 asyncResp->res.jsonValue["Name"] = "Chassis Collection";
436 asyncResp->res.jsonValue["ChassisType"] = "RackMount";
437 asyncResp->res.jsonValue["Actions"]["#Chassis.Reset"]["target"] =
Ed Tanousef4c65b2023-04-24 15:28:50 -0700438 boost::urls::format(
439 "/redfish/v1/Chassis/{}/Actions/Chassis.Reset", chassisId);
Nan Zhoucf7eba02022-07-21 23:53:20 +0000440 asyncResp->res
441 .jsonValue["Actions"]["#Chassis.Reset"]["@Redfish.ActionInfo"] =
Ed Tanousef4c65b2023-04-24 15:28:50 -0700442 boost::urls::format("/redfish/v1/Chassis/{}/ResetActionInfo",
443 chassisId);
Nan Zhoucf7eba02022-07-21 23:53:20 +0000444 asyncResp->res.jsonValue["PCIeDevices"]["@odata.id"] =
Ed Tanousef4c65b2023-04-24 15:28:50 -0700445 "/redfish/v1/Systems/system/PCIeDevices";
Nan Zhoucf7eba02022-07-21 23:53:20 +0000446
George Liu6c3e9452023-03-03 13:55:29 +0800447 dbus::utility::getAssociationEndPoints(
448 path + "/drive",
449 [asyncResp,
450 chassisId](const boost::system::error_code& ec3,
451 const dbus::utility::MapperEndPoints& resp) {
Nan Zhoucf7eba02022-07-21 23:53:20 +0000452 if (ec3 || resp.empty())
453 {
454 return; // no drives = no failures
455 }
456
457 nlohmann::json reference;
Ed Tanousef4c65b2023-04-24 15:28:50 -0700458 reference["@odata.id"] = boost::urls::format(
459 "/redfish/v1/Chassis/{}/Drives", chassisId);
Nan Zhoucf7eba02022-07-21 23:53:20 +0000460 asyncResp->res.jsonValue["Drives"] = std::move(reference);
461 });
462
463 const std::string& connectionName = connectionNames[0].first;
464
465 const std::vector<std::string>& interfaces2 =
466 connectionNames[0].second;
467 const std::array<const char*, 2> hasIndicatorLed = {
468 "xyz.openbmc_project.Inventory.Item.Panel",
469 "xyz.openbmc_project.Inventory.Item.Board.Motherboard"};
470
471 const std::string assetTagInterface =
472 "xyz.openbmc_project.Inventory.Decorator.AssetTag";
Logananth Sundararaj523d4862023-01-24 11:56:28 +0530473 const std::string replaceableInterface =
474 "xyz.openbmc_project.Inventory.Decorator.Replaceable";
475 for (const auto& interface : interfaces2)
Nan Zhoucf7eba02022-07-21 23:53:20 +0000476 {
Logananth Sundararaj523d4862023-01-24 11:56:28 +0530477 if (interface == assetTagInterface)
478 {
479 sdbusplus::asio::getProperty<std::string>(
480 *crow::connections::systemBus, connectionName, path,
481 assetTagInterface, "AssetTag",
482 [asyncResp,
483 chassisId](const boost::system::error_code& ec2,
484 const std::string& property) {
485 if (ec2)
486 {
487 BMCWEB_LOG_ERROR
488 << "DBus response error for AssetTag: " << ec2;
489 messages::internalError(asyncResp->res);
490 return;
491 }
492 asyncResp->res.jsonValue["AssetTag"] = property;
493 });
494 }
495 else if (interface == replaceableInterface)
496 {
497 sdbusplus::asio::getProperty<bool>(
498 *crow::connections::systemBus, connectionName, path,
499 replaceableInterface, "HotPluggable",
500 [asyncResp,
501 chassisId](const boost::system::error_code& ec2,
502 const bool property) {
503 if (ec2)
504 {
505 BMCWEB_LOG_ERROR
506 << "DBus response error for HotPluggable: "
507 << ec2;
508 messages::internalError(asyncResp->res);
509 return;
510 }
511 asyncResp->res.jsonValue["HotPluggable"] = property;
512 });
513 }
Nan Zhoucf7eba02022-07-21 23:53:20 +0000514 }
515
516 for (const char* interface : hasIndicatorLed)
517 {
518 if (std::find(interfaces2.begin(), interfaces2.end(),
519 interface) != interfaces2.end())
520 {
521 getIndicatorLedState(asyncResp);
522 getLocationIndicatorActive(asyncResp);
523 break;
524 }
525 }
526
Krzysztof Grobelny86d89ed2022-08-29 14:49:20 +0200527 sdbusplus::asio::getAllProperties(
528 *crow::connections::systemBus, connectionName, path,
529 "xyz.openbmc_project.Inventory.Decorator.Asset",
Willy Tu5e577bc2022-07-26 00:41:55 +0000530 [asyncResp, chassisId(std::string(chassisId)),
531 path](const boost::system::error_code& /*ec2*/,
532 const dbus::utility::DBusPropertiesMap& propertiesList) {
Krzysztof Grobelny86d89ed2022-08-29 14:49:20 +0200533 const std::string* partNumber = nullptr;
534 const std::string* serialNumber = nullptr;
535 const std::string* manufacturer = nullptr;
536 const std::string* model = nullptr;
537 const std::string* sparePartNumber = nullptr;
538
539 const bool success = sdbusplus::unpackPropertiesNoThrow(
540 dbus_utils::UnpackErrorPrinter(), propertiesList,
541 "PartNumber", partNumber, "SerialNumber", serialNumber,
542 "Manufacturer", manufacturer, "Model", model,
543 "SparePartNumber", sparePartNumber);
544
545 if (!success)
Nan Zhoucf7eba02022-07-21 23:53:20 +0000546 {
Krzysztof Grobelny86d89ed2022-08-29 14:49:20 +0200547 messages::internalError(asyncResp->res);
548 return;
Nan Zhoucf7eba02022-07-21 23:53:20 +0000549 }
Krzysztof Grobelny86d89ed2022-08-29 14:49:20 +0200550
551 if (partNumber != nullptr)
552 {
553 asyncResp->res.jsonValue["PartNumber"] = *partNumber;
554 }
555
556 if (serialNumber != nullptr)
557 {
558 asyncResp->res.jsonValue["SerialNumber"] = *serialNumber;
559 }
560
561 if (manufacturer != nullptr)
562 {
563 asyncResp->res.jsonValue["Manufacturer"] = *manufacturer;
564 }
565
566 if (model != nullptr)
567 {
568 asyncResp->res.jsonValue["Model"] = *model;
569 }
570
571 // SparePartNumber is optional on D-Bus
572 // so skip if it is empty
573 if (sparePartNumber != nullptr && !sparePartNumber->empty())
574 {
575 asyncResp->res.jsonValue["SparePartNumber"] =
576 *sparePartNumber;
577 }
578
Nan Zhoucf7eba02022-07-21 23:53:20 +0000579 asyncResp->res.jsonValue["Name"] = chassisId;
580 asyncResp->res.jsonValue["Id"] = chassisId;
581#ifdef BMCWEB_ALLOW_DEPRECATED_POWER_THERMAL
582 asyncResp->res.jsonValue["Thermal"]["@odata.id"] =
Ed Tanousef4c65b2023-04-24 15:28:50 -0700583 boost::urls::format("/redfish/v1/Chassis/{}/Thermal",
584 chassisId);
Nan Zhoucf7eba02022-07-21 23:53:20 +0000585 // Power object
586 asyncResp->res.jsonValue["Power"]["@odata.id"] =
Ed Tanousef4c65b2023-04-24 15:28:50 -0700587 boost::urls::format("/redfish/v1/Chassis/{}/Power",
588 chassisId);
Nan Zhoucf7eba02022-07-21 23:53:20 +0000589#endif
Xiaochao Ma29739632021-03-02 15:53:13 +0800590#ifdef BMCWEB_NEW_POWERSUBSYSTEM_THERMALSUBSYSTEM
591 asyncResp->res.jsonValue["ThermalSubsystem"]["@odata.id"] =
Ed Tanousef4c65b2023-04-24 15:28:50 -0700592 boost::urls::format(
593 "/redfish/v1/Chassis/{}/ThermalSubsystem", chassisId);
Chicago Duan77b36432021-02-05 15:48:26 +0800594 asyncResp->res.jsonValue["PowerSubsystem"]["@odata.id"] =
Ed Tanousef4c65b2023-04-24 15:28:50 -0700595 boost::urls::format("/redfish/v1/Chassis/{}/PowerSubsystem",
596 chassisId);
Albert Zhang4ca3ec32021-06-13 14:39:38 +0800597 asyncResp->res.jsonValue["EnvironmentMetrics"]["@odata.id"] =
Ed Tanousef4c65b2023-04-24 15:28:50 -0700598 boost::urls::format(
599 "/redfish/v1/Chassis/{}/EnvironmentMetrics", chassisId);
Xiaochao Ma29739632021-03-02 15:53:13 +0800600#endif
Nan Zhoucf7eba02022-07-21 23:53:20 +0000601 // SensorCollection
602 asyncResp->res.jsonValue["Sensors"]["@odata.id"] =
Ed Tanousef4c65b2023-04-24 15:28:50 -0700603 boost::urls::format("/redfish/v1/Chassis/{}/Sensors",
604 chassisId);
Nan Zhoucf7eba02022-07-21 23:53:20 +0000605 asyncResp->res.jsonValue["Status"]["State"] = "Enabled";
606
607 nlohmann::json::array_t computerSystems;
608 nlohmann::json::object_t system;
609 system["@odata.id"] = "/redfish/v1/Systems/system";
Patrick Williamsad539542023-05-12 10:10:08 -0500610 computerSystems.emplace_back(std::move(system));
Nan Zhoucf7eba02022-07-21 23:53:20 +0000611 asyncResp->res.jsonValue["Links"]["ComputerSystems"] =
612 std::move(computerSystems);
613
614 nlohmann::json::array_t managedBy;
615 nlohmann::json::object_t manager;
616 manager["@odata.id"] = "/redfish/v1/Managers/bmc";
Patrick Williamsad539542023-05-12 10:10:08 -0500617 managedBy.emplace_back(std::move(manager));
Nan Zhoucf7eba02022-07-21 23:53:20 +0000618 asyncResp->res.jsonValue["Links"]["ManagedBy"] =
619 std::move(managedBy);
620 getChassisState(asyncResp);
Willy Tu5e577bc2022-07-26 00:41:55 +0000621 getStorageLink(asyncResp, path);
Krzysztof Grobelny86d89ed2022-08-29 14:49:20 +0200622 });
Nan Zhoucf7eba02022-07-21 23:53:20 +0000623
624 for (const auto& interface : interfaces2)
625 {
626 if (interface == "xyz.openbmc_project.Common.UUID")
627 {
628 getChassisUUID(asyncResp, connectionName, path);
629 }
630 else if (interface ==
631 "xyz.openbmc_project.Inventory.Decorator.LocationCode")
632 {
633 getChassisLocationCode(asyncResp, connectionName, path);
634 }
635 }
636
637 return;
638 }
639
640 // Couldn't find an object with that name. return an error
Jiaqing Zhaod8a5d5d2022-08-05 16:21:51 +0800641 messages::resourceNotFound(asyncResp->res, "Chassis", chassisId);
George Liue99073f2022-12-09 11:06:16 +0800642 });
Nan Zhoucf7eba02022-07-21 23:53:20 +0000643
644 getPhysicalSecurityData(asyncResp);
645}
646
647inline void
648 handleChassisPatch(App& app, const crow::Request& req,
649 const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
650 const std::string& param)
651{
652 if (!redfish::setUpRedfishRoute(app, req, asyncResp))
653 {
654 return;
655 }
656 std::optional<bool> locationIndicatorActive;
657 std::optional<std::string> indicatorLed;
658
659 if (param.empty())
660 {
661 return;
662 }
663
664 if (!json_util::readJsonPatch(
665 req, asyncResp->res, "LocationIndicatorActive",
666 locationIndicatorActive, "IndicatorLED", indicatorLed))
667 {
668 return;
669 }
670
671 // TODO (Gunnar): Remove IndicatorLED after enough time has passed
672 if (!locationIndicatorActive && !indicatorLed)
673 {
674 return; // delete this when we support more patch properties
675 }
676 if (indicatorLed)
677 {
678 asyncResp->res.addHeader(
679 boost::beast::http::field::warning,
680 "299 - \"IndicatorLED is deprecated. Use LocationIndicatorActive instead.\"");
681 }
682
George Liue99073f2022-12-09 11:06:16 +0800683 constexpr std::array<std::string_view, 2> interfaces = {
Nan Zhoucf7eba02022-07-21 23:53:20 +0000684 "xyz.openbmc_project.Inventory.Item.Board",
685 "xyz.openbmc_project.Inventory.Item.Chassis"};
686
687 const std::string& chassisId = param;
688
George Liue99073f2022-12-09 11:06:16 +0800689 dbus::utility::getSubTree(
690 "/xyz/openbmc_project/inventory", 0, interfaces,
Nan Zhoucf7eba02022-07-21 23:53:20 +0000691 [asyncResp, chassisId, locationIndicatorActive,
Ed Tanous5e7e2dc2023-02-16 10:37:01 -0800692 indicatorLed](const boost::system::error_code& ec,
Nan Zhoucf7eba02022-07-21 23:53:20 +0000693 const dbus::utility::MapperGetSubTreeResponse& subtree) {
694 if (ec)
695 {
Andrew Geissler51dab2a2023-05-30 15:07:46 -0400696 BMCWEB_LOG_ERROR << "DBUS response error " << ec;
Nan Zhoucf7eba02022-07-21 23:53:20 +0000697 messages::internalError(asyncResp->res);
698 return;
699 }
700
701 // Iterate over all retrieved ObjectPaths.
702 for (const std::pair<
703 std::string,
704 std::vector<std::pair<std::string, std::vector<std::string>>>>&
705 object : subtree)
706 {
707 const std::string& path = object.first;
708 const std::vector<std::pair<std::string, std::vector<std::string>>>&
709 connectionNames = object.second;
710
711 sdbusplus::message::object_path objPath(path);
712 if (objPath.filename() != chassisId)
713 {
714 continue;
715 }
716
717 if (connectionNames.empty())
718 {
719 BMCWEB_LOG_ERROR << "Got 0 Connection names";
720 continue;
721 }
722
723 const std::vector<std::string>& interfaces3 =
724 connectionNames[0].second;
725
726 const std::array<const char*, 2> hasIndicatorLed = {
727 "xyz.openbmc_project.Inventory.Item.Panel",
728 "xyz.openbmc_project.Inventory.Item.Board.Motherboard"};
729 bool indicatorChassis = false;
730 for (const char* interface : hasIndicatorLed)
731 {
732 if (std::find(interfaces3.begin(), interfaces3.end(),
733 interface) != interfaces3.end())
734 {
735 indicatorChassis = true;
736 break;
737 }
738 }
739 if (locationIndicatorActive)
740 {
741 if (indicatorChassis)
742 {
743 setLocationIndicatorActive(asyncResp,
744 *locationIndicatorActive);
745 }
746 else
747 {
748 messages::propertyUnknown(asyncResp->res,
749 "LocationIndicatorActive");
750 }
751 }
752 if (indicatorLed)
753 {
754 if (indicatorChassis)
755 {
756 setIndicatorLedState(asyncResp, *indicatorLed);
757 }
758 else
759 {
760 messages::propertyUnknown(asyncResp->res, "IndicatorLED");
761 }
762 }
763 return;
764 }
765
Jiaqing Zhaod8a5d5d2022-08-05 16:21:51 +0800766 messages::resourceNotFound(asyncResp->res, "Chassis", chassisId);
George Liue99073f2022-12-09 11:06:16 +0800767 });
Nan Zhoucf7eba02022-07-21 23:53:20 +0000768}
769
Rapkiewicz, Pawele37f8452018-03-09 13:49:50 +0100770/**
771 * Chassis override class for delivering Chassis Schema
John Edward Broadbent7e860f12021-04-08 15:57:16 -0700772 * Functions triggers appropriate requests on DBus
Rapkiewicz, Pawele37f8452018-03-09 13:49:50 +0100773 */
John Edward Broadbent7e860f12021-04-08 15:57:16 -0700774inline void requestRoutesChassis(App& app)
Ed Tanous1abe55e2018-09-05 08:30:59 -0700775{
John Edward Broadbent7e860f12021-04-08 15:57:16 -0700776 BMCWEB_ROUTE(app, "/redfish/v1/Chassis/<str>/")
Ed Tanoused398212021-06-09 17:05:54 -0700777 .privileges(redfish::privileges::getChassis)
Ed Tanous002d39b2022-05-31 08:59:27 -0700778 .methods(boost::beast::http::verb::get)(
Nan Zhoucf7eba02022-07-21 23:53:20 +0000779 std::bind_front(handleChassisGet, std::ref(app)));
John Edward Broadbent7e860f12021-04-08 15:57:16 -0700780
781 BMCWEB_ROUTE(app, "/redfish/v1/Chassis/<str>/")
Ed Tanoused398212021-06-09 17:05:54 -0700782 .privileges(redfish::privileges::patchChassis)
Ed Tanous002d39b2022-05-31 08:59:27 -0700783 .methods(boost::beast::http::verb::patch)(
Nan Zhoucf7eba02022-07-21 23:53:20 +0000784 std::bind_front(handleChassisPatch, std::ref(app)));
John Edward Broadbent7e860f12021-04-08 15:57:16 -0700785}
P.K. Leedd99e042020-06-17 19:43:16 +0800786
Andrew Geisslerfc903b32023-05-31 14:15:42 -0400787/**
788 * Handle error responses from d-bus for chassis power cycles
789 */
790inline void handleChassisPowerCycleError(const boost::system::error_code& ec,
791 const sdbusplus::message_t& eMsg,
792 crow::Response& res)
793{
794 if (eMsg.get_error() == nullptr)
795 {
796 BMCWEB_LOG_ERROR << "D-Bus response error: " << ec;
797 messages::internalError(res);
798 return;
799 }
800 std::string_view errorMessage = eMsg.get_error()->name;
801
802 // If operation failed due to BMC not being in Ready state, tell
803 // user to retry in a bit
804 if (errorMessage ==
805 std::string_view("xyz.openbmc_project.State.Chassis.Error.BMCNotReady"))
806 {
807 BMCWEB_LOG_DEBUG << "BMC not ready, operation not allowed right now";
808 messages::serviceTemporarilyUnavailable(res, "10");
809 return;
810 }
811
812 BMCWEB_LOG_ERROR << "Chassis Power Cycle fail " << ec
813 << " sdbusplus:" << errorMessage;
814 messages::internalError(res);
815}
816
zhanghch058d1b46d2021-04-01 11:18:24 +0800817inline void
818 doChassisPowerCycle(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
P.K. Leedd99e042020-06-17 19:43:16 +0800819{
George Liu7a1dbc42022-12-07 16:03:22 +0800820 constexpr std::array<std::string_view, 1> interfaces = {
Vijay Khemkac3b3c922020-09-22 23:00:12 -0700821 "xyz.openbmc_project.State.Chassis"};
822
823 // Use mapper to get subtree paths.
George Liu7a1dbc42022-12-07 16:03:22 +0800824 dbus::utility::getSubTreePaths(
825 "/", 0, interfaces,
Ed Tanousb9d36b42022-02-26 21:42:46 -0800826 [asyncResp](
George Liu7a1dbc42022-12-07 16:03:22 +0800827 const boost::system::error_code& ec,
Ed Tanousb9d36b42022-02-26 21:42:46 -0800828 const dbus::utility::MapperGetSubTreePathsResponse& chassisList) {
Ed Tanous002d39b2022-05-31 08:59:27 -0700829 if (ec)
830 {
Andrew Geissler51dab2a2023-05-30 15:07:46 -0400831 BMCWEB_LOG_ERROR << "[mapper] Bad D-Bus request error: " << ec;
Ed Tanous002d39b2022-05-31 08:59:27 -0700832 messages::internalError(asyncResp->res);
833 return;
834 }
835
836 const char* processName = "xyz.openbmc_project.State.Chassis";
837 const char* interfaceName = "xyz.openbmc_project.State.Chassis";
838 const char* destProperty = "RequestedPowerTransition";
839 const std::string propertyValue =
840 "xyz.openbmc_project.State.Chassis.Transition.PowerCycle";
841 std::string objectPath = "/xyz/openbmc_project/state/chassis_system0";
842
843 /* Look for system reset chassis path */
844 if ((std::find(chassisList.begin(), chassisList.end(), objectPath)) ==
845 chassisList.end())
846 {
847 /* We prefer to reset the full chassis_system, but if it doesn't
848 * exist on some platforms, fall back to a host-only power reset
849 */
850 objectPath = "/xyz/openbmc_project/state/chassis0";
851 }
852
George Liu9ae226f2023-06-21 17:56:46 +0800853 sdbusplus::asio::setProperty(
854 *crow::connections::systemBus, processName, objectPath,
855 interfaceName, destProperty, propertyValue,
Andrew Geisslerfc903b32023-05-31 14:15:42 -0400856 [asyncResp](const boost::system::error_code& ec2,
857 sdbusplus::message_t& sdbusErrMsg) {
Ed Tanous002d39b2022-05-31 08:59:27 -0700858 // Use "Set" method to set the property value.
Ed Tanous8a592812022-06-04 09:06:59 -0700859 if (ec2)
P.K. Leedd99e042020-06-17 19:43:16 +0800860 {
Andrew Geisslerfc903b32023-05-31 14:15:42 -0400861 handleChassisPowerCycleError(ec2, sdbusErrMsg, asyncResp->res);
862
P.K. Leedd99e042020-06-17 19:43:16 +0800863 return;
864 }
865
Ed Tanous002d39b2022-05-31 08:59:27 -0700866 messages::success(asyncResp->res);
George Liu9ae226f2023-06-21 17:56:46 +0800867 });
George Liu7a1dbc42022-12-07 16:03:22 +0800868 });
P.K. Leedd99e042020-06-17 19:43:16 +0800869}
870
Nan Zhoucf7eba02022-07-21 23:53:20 +0000871inline void handleChassisResetActionInfoPost(
872 App& app, const crow::Request& req,
873 const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
874 const std::string& /*chassisId*/)
875{
876 if (!redfish::setUpRedfishRoute(app, req, asyncResp))
877 {
878 return;
879 }
880 BMCWEB_LOG_DEBUG << "Post Chassis Reset.";
881
882 std::string resetType;
883
884 if (!json_util::readJsonAction(req, asyncResp->res, "ResetType", resetType))
885 {
886 return;
887 }
888
889 if (resetType != "PowerCycle")
890 {
891 BMCWEB_LOG_DEBUG << "Invalid property value for ResetType: "
892 << resetType;
893 messages::actionParameterNotSupported(asyncResp->res, resetType,
894 "ResetType");
895
896 return;
897 }
898 doChassisPowerCycle(asyncResp);
899}
900
P.K. Leedd99e042020-06-17 19:43:16 +0800901/**
902 * ChassisResetAction class supports the POST method for the Reset
903 * action.
John Edward Broadbent7e860f12021-04-08 15:57:16 -0700904 * Function handles POST method request.
905 * Analyzes POST body before sending Reset request data to D-Bus.
P.K. Leedd99e042020-06-17 19:43:16 +0800906 */
John Edward Broadbent7e860f12021-04-08 15:57:16 -0700907
908inline void requestRoutesChassisResetAction(App& app)
P.K. Leedd99e042020-06-17 19:43:16 +0800909{
John Edward Broadbent7e860f12021-04-08 15:57:16 -0700910 BMCWEB_ROUTE(app, "/redfish/v1/Chassis/<str>/Actions/Chassis.Reset/")
Ed Tanoused398212021-06-09 17:05:54 -0700911 .privileges(redfish::privileges::postChassis)
John Edward Broadbent7e860f12021-04-08 15:57:16 -0700912 .methods(boost::beast::http::verb::post)(
Nan Zhoucf7eba02022-07-21 23:53:20 +0000913 std::bind_front(handleChassisResetActionInfoPost, std::ref(app)));
914}
P.K. Leedd99e042020-06-17 19:43:16 +0800915
Nan Zhoucf7eba02022-07-21 23:53:20 +0000916inline void handleChassisResetActionInfoGet(
917 App& app, const crow::Request& req,
918 const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
919 const std::string& chassisId)
920{
921 if (!redfish::setUpRedfishRoute(app, req, asyncResp))
922 {
923 return;
924 }
925 asyncResp->res.jsonValue["@odata.type"] = "#ActionInfo.v1_1_2.ActionInfo";
Ed Tanousef4c65b2023-04-24 15:28:50 -0700926 asyncResp->res.jsonValue["@odata.id"] = boost::urls::format(
927 "/redfish/v1/Chassis/{}/ResetActionInfo", chassisId);
Nan Zhoucf7eba02022-07-21 23:53:20 +0000928 asyncResp->res.jsonValue["Name"] = "Reset Action Info";
P.K. Leedd99e042020-06-17 19:43:16 +0800929
Nan Zhoucf7eba02022-07-21 23:53:20 +0000930 asyncResp->res.jsonValue["Id"] = "ResetActionInfo";
931 nlohmann::json::array_t parameters;
932 nlohmann::json::object_t parameter;
933 parameter["Name"] = "ResetType";
934 parameter["Required"] = true;
935 parameter["DataType"] = "String";
936 nlohmann::json::array_t allowed;
Patrick Williamsad539542023-05-12 10:10:08 -0500937 allowed.emplace_back("PowerCycle");
Nan Zhoucf7eba02022-07-21 23:53:20 +0000938 parameter["AllowableValues"] = std::move(allowed);
Patrick Williamsad539542023-05-12 10:10:08 -0500939 parameters.emplace_back(std::move(parameter));
P.K. Leedd99e042020-06-17 19:43:16 +0800940
Nan Zhoucf7eba02022-07-21 23:53:20 +0000941 asyncResp->res.jsonValue["Parameters"] = std::move(parameters);
John Edward Broadbent7e860f12021-04-08 15:57:16 -0700942}
AppaRao Puli1cb1a9e2020-07-17 23:38:57 +0530943
944/**
945 * ChassisResetActionInfo derived class for delivering Chassis
946 * ResetType AllowableValues using ResetInfo schema.
947 */
John Edward Broadbent7e860f12021-04-08 15:57:16 -0700948inline void requestRoutesChassisResetActionInfo(App& app)
AppaRao Puli1cb1a9e2020-07-17 23:38:57 +0530949{
John Edward Broadbent7e860f12021-04-08 15:57:16 -0700950 BMCWEB_ROUTE(app, "/redfish/v1/Chassis/<str>/ResetActionInfo/")
Ed Tanoused398212021-06-09 17:05:54 -0700951 .privileges(redfish::privileges::getActionInfo)
John Edward Broadbent7e860f12021-04-08 15:57:16 -0700952 .methods(boost::beast::http::verb::get)(
Nan Zhoucf7eba02022-07-21 23:53:20 +0000953 std::bind_front(handleChassisResetActionInfoGet, std::ref(app)));
John Edward Broadbent7e860f12021-04-08 15:57:16 -0700954}
AppaRao Puli1cb1a9e2020-07-17 23:38:57 +0530955
Ed Tanous1abe55e2018-09-05 08:30:59 -0700956} // namespace redfish