xref: /openbmc/bmcweb/features/redfish/lib/chassis.hpp (revision 6c3e94511027133db407f9e1c3c628927ec1332f)
1e37f8451SRapkiewicz, Pawel /*
2e37f8451SRapkiewicz, Pawel // Copyright (c) 2018 Intel Corporation
3e37f8451SRapkiewicz, Pawel //
4e37f8451SRapkiewicz, Pawel // Licensed under the Apache License, Version 2.0 (the "License");
5e37f8451SRapkiewicz, Pawel // you may not use this file except in compliance with the License.
6e37f8451SRapkiewicz, Pawel // You may obtain a copy of the License at
7e37f8451SRapkiewicz, Pawel //
8e37f8451SRapkiewicz, Pawel //      http://www.apache.org/licenses/LICENSE-2.0
9e37f8451SRapkiewicz, Pawel //
10e37f8451SRapkiewicz, Pawel // Unless required by applicable law or agreed to in writing, software
11e37f8451SRapkiewicz, Pawel // distributed under the License is distributed on an "AS IS" BASIS,
12e37f8451SRapkiewicz, Pawel // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13e37f8451SRapkiewicz, Pawel // See the License for the specific language governing permissions and
14e37f8451SRapkiewicz, Pawel // limitations under the License.
15e37f8451SRapkiewicz, Pawel */
16e37f8451SRapkiewicz, Pawel #pragma once
17e37f8451SRapkiewicz, Pawel 
183ccb3adbSEd Tanous #include "app.hpp"
197a1dbc48SGeorge Liu #include "dbus_utility.hpp"
20b49ac873SJames Feist #include "health.hpp"
211c8fba97SJames Feist #include "led.hpp"
223ccb3adbSEd Tanous #include "query.hpp"
233ccb3adbSEd Tanous #include "registries/privilege_registry.hpp"
243ccb3adbSEd Tanous #include "utils/collection.hpp"
253ccb3adbSEd Tanous #include "utils/dbus_utils.hpp"
26cf7eba09SNan Zhou #include "utils/json_utils.hpp"
271abe55efSEd Tanous 
28e99073f5SGeorge Liu #include <boost/system/error_code.hpp>
291e1e598dSJonathan Doman #include <sdbusplus/asio/property.hpp>
3086d89ed7SKrzysztof Grobelny #include <sdbusplus/unpack_properties.hpp>
311214b7e7SGunnar Mills 
327a1dbc48SGeorge Liu #include <array>
337a1dbc48SGeorge Liu #include <string_view>
347a1dbc48SGeorge Liu 
351abe55efSEd Tanous namespace redfish
361abe55efSEd Tanous {
37e37f8451SRapkiewicz, Pawel 
38e37f8451SRapkiewicz, Pawel /**
39beeca0aeSGunnar Mills  * @brief Retrieves chassis state properties over dbus
40beeca0aeSGunnar Mills  *
41beeca0aeSGunnar Mills  * @param[in] aResp - Shared pointer for completing asynchronous calls.
42beeca0aeSGunnar Mills  *
43beeca0aeSGunnar Mills  * @return None.
44beeca0aeSGunnar Mills  */
458d1b46d7Szhanghch05 inline void getChassisState(std::shared_ptr<bmcweb::AsyncResp> aResp)
46beeca0aeSGunnar Mills {
471e1e598dSJonathan Doman     // crow::connections::systemBus->async_method_call(
481e1e598dSJonathan Doman     sdbusplus::asio::getProperty<std::string>(
491e1e598dSJonathan Doman         *crow::connections::systemBus, "xyz.openbmc_project.State.Chassis",
501e1e598dSJonathan Doman         "/xyz/openbmc_project/state/chassis0",
511e1e598dSJonathan Doman         "xyz.openbmc_project.State.Chassis", "CurrentPowerState",
525e7e2dc5SEd Tanous         [aResp{std::move(aResp)}](const boost::system::error_code& ec,
531e1e598dSJonathan Doman                                   const std::string& chassisState) {
54beeca0aeSGunnar Mills         if (ec)
55beeca0aeSGunnar Mills         {
56a6e5e0abSCarson Labrado             if (ec == boost::system::errc::host_unreachable)
57a6e5e0abSCarson Labrado             {
58a6e5e0abSCarson Labrado                 // Service not available, no error, just don't return
59a6e5e0abSCarson Labrado                 // chassis state info
60a6e5e0abSCarson Labrado                 BMCWEB_LOG_DEBUG << "Service not available " << ec;
61a6e5e0abSCarson Labrado                 return;
62a6e5e0abSCarson Labrado             }
63beeca0aeSGunnar Mills             BMCWEB_LOG_DEBUG << "DBUS response error " << ec;
64beeca0aeSGunnar Mills             messages::internalError(aResp->res);
65beeca0aeSGunnar Mills             return;
66beeca0aeSGunnar Mills         }
67beeca0aeSGunnar Mills 
681e1e598dSJonathan Doman         BMCWEB_LOG_DEBUG << "Chassis state: " << chassisState;
69beeca0aeSGunnar Mills         // Verify Chassis State
70002d39b4SEd Tanous         if (chassisState == "xyz.openbmc_project.State.Chassis.PowerState.On")
71beeca0aeSGunnar Mills         {
72beeca0aeSGunnar Mills             aResp->res.jsonValue["PowerState"] = "On";
73beeca0aeSGunnar Mills             aResp->res.jsonValue["Status"]["State"] = "Enabled";
74beeca0aeSGunnar Mills         }
751e1e598dSJonathan Doman         else if (chassisState ==
76beeca0aeSGunnar Mills                  "xyz.openbmc_project.State.Chassis.PowerState.Off")
77beeca0aeSGunnar Mills         {
78beeca0aeSGunnar Mills             aResp->res.jsonValue["PowerState"] = "Off";
79beeca0aeSGunnar Mills             aResp->res.jsonValue["Status"]["State"] = "StandbyOffline";
80beeca0aeSGunnar Mills         }
811e1e598dSJonathan Doman         });
82beeca0aeSGunnar Mills }
83beeca0aeSGunnar Mills 
848d1b46d7Szhanghch05 inline void getIntrusionByService(std::shared_ptr<bmcweb::AsyncResp> aResp,
85c181942fSQiang XU                                   const std::string& service,
86c181942fSQiang XU                                   const std::string& objPath)
87c181942fSQiang XU {
88c181942fSQiang XU     BMCWEB_LOG_DEBUG << "Get intrusion status by service \n";
89c181942fSQiang XU 
901e1e598dSJonathan Doman     sdbusplus::asio::getProperty<std::string>(
911e1e598dSJonathan Doman         *crow::connections::systemBus, service, objPath,
921e1e598dSJonathan Doman         "xyz.openbmc_project.Chassis.Intrusion", "Status",
935e7e2dc5SEd Tanous         [aResp{std::move(aResp)}](const boost::system::error_code& ec,
941e1e598dSJonathan Doman                                   const std::string& value) {
95c181942fSQiang XU         if (ec)
96c181942fSQiang XU         {
974e0453b1SGunnar Mills             // do not add err msg in redfish response, because this is not
98c181942fSQiang XU             //     mandatory property
99c181942fSQiang XU             BMCWEB_LOG_ERROR << "DBUS response error " << ec << "\n";
100c181942fSQiang XU             return;
101c181942fSQiang XU         }
102c181942fSQiang XU 
103002d39b4SEd Tanous         aResp->res.jsonValue["PhysicalSecurity"]["IntrusionSensorNumber"] = 1;
1041476687dSEd Tanous         aResp->res.jsonValue["PhysicalSecurity"]["IntrusionSensor"] = value;
1051e1e598dSJonathan Doman         });
106c181942fSQiang XU }
107c181942fSQiang XU 
108c181942fSQiang XU /**
109c181942fSQiang XU  * Retrieves physical security properties over dbus
110c181942fSQiang XU  */
1118d1b46d7Szhanghch05 inline void getPhysicalSecurityData(std::shared_ptr<bmcweb::AsyncResp> aResp)
112c181942fSQiang XU {
113e99073f5SGeorge Liu     constexpr std::array<std::string_view, 1> interfaces = {
114e99073f5SGeorge Liu         "xyz.openbmc_project.Chassis.Intrusion"};
115e99073f5SGeorge Liu     dbus::utility::getSubTree(
116e99073f5SGeorge Liu         "/xyz/openbmc_project/Intrusion", 1, interfaces,
117c181942fSQiang XU         [aResp{std::move(aResp)}](
118e99073f5SGeorge Liu             const boost::system::error_code& ec,
119b9d36b47SEd Tanous             const dbus::utility::MapperGetSubTreeResponse& subtree) {
120c181942fSQiang XU         if (ec)
121c181942fSQiang XU         {
1224e0453b1SGunnar Mills             // do not add err msg in redfish response, because this is not
123c181942fSQiang XU             //     mandatory property
124002d39b4SEd Tanous             BMCWEB_LOG_INFO << "DBUS error: no matched iface " << ec << "\n";
125c181942fSQiang XU             return;
126c181942fSQiang XU         }
127c181942fSQiang XU         // Iterate over all retrieved ObjectPaths.
128c181942fSQiang XU         for (const auto& object : subtree)
129c181942fSQiang XU         {
130c181942fSQiang XU             for (const auto& service : object.second)
131c181942fSQiang XU             {
132c181942fSQiang XU                 getIntrusionByService(aResp, service.first, object.first);
133c181942fSQiang XU                 return;
134c181942fSQiang XU             }
135c181942fSQiang XU         }
136e99073f5SGeorge Liu         });
137c181942fSQiang XU }
138c181942fSQiang XU 
139cf7eba09SNan Zhou inline void handleChassisCollectionGet(
140cf7eba09SNan Zhou     App& app, const crow::Request& req,
141cf7eba09SNan Zhou     const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
1421abe55efSEd Tanous {
1433ba00073SCarson Labrado     if (!redfish::setUpRedfishRoute(app, req, asyncResp))
14445ca1b86SEd Tanous     {
14545ca1b86SEd Tanous         return;
14645ca1b86SEd Tanous     }
1478d1b46d7Szhanghch05     asyncResp->res.jsonValue["@odata.type"] =
1488d1b46d7Szhanghch05         "#ChassisCollection.ChassisCollection";
1498d1b46d7Szhanghch05     asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/Chassis";
1508d1b46d7Szhanghch05     asyncResp->res.jsonValue["Name"] = "Chassis Collection";
151e37f8451SRapkiewicz, Pawel 
1527a1dbc48SGeorge Liu     constexpr std::array<std::string_view, 2> interfaces{
1537a1dbc48SGeorge Liu         "xyz.openbmc_project.Inventory.Item.Board",
1547a1dbc48SGeorge Liu         "xyz.openbmc_project.Inventory.Item.Chassis"};
15502f6ff19SGunnar Mills     collection_util::getCollectionMembers(
1567a1dbc48SGeorge Liu         asyncResp, boost::urls::url("/redfish/v1/Chassis"), interfaces);
157cf7eba09SNan Zhou }
158cf7eba09SNan Zhou 
159cf7eba09SNan Zhou /**
160cf7eba09SNan Zhou  * ChassisCollection derived class for delivering Chassis Collection Schema
161cf7eba09SNan Zhou  *  Functions triggers appropriate requests on DBus
162cf7eba09SNan Zhou  */
163cf7eba09SNan Zhou inline void requestRoutesChassisCollection(App& app)
164cf7eba09SNan Zhou {
165cf7eba09SNan Zhou     BMCWEB_ROUTE(app, "/redfish/v1/Chassis/")
166cf7eba09SNan Zhou         .privileges(redfish::privileges::getChassisCollection)
167cf7eba09SNan Zhou         .methods(boost::beast::http::verb::get)(
168cf7eba09SNan Zhou             std::bind_front(handleChassisCollectionGet, std::ref(app)));
16962d5e2e4SEd Tanous }
170e37f8451SRapkiewicz, Pawel 
171308f70c7SWilly Tu inline void
172308f70c7SWilly Tu     getChassisLocationCode(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
173308f70c7SWilly Tu                            const std::string& connectionName,
174308f70c7SWilly Tu                            const std::string& path)
175308f70c7SWilly Tu {
1761e1e598dSJonathan Doman     sdbusplus::asio::getProperty<std::string>(
1771e1e598dSJonathan Doman         *crow::connections::systemBus, connectionName, path,
1781e1e598dSJonathan Doman         "xyz.openbmc_project.Inventory.Decorator.LocationCode", "LocationCode",
1795e7e2dc5SEd Tanous         [asyncResp](const boost::system::error_code& ec,
1801e1e598dSJonathan Doman                     const std::string& property) {
181308f70c7SWilly Tu         if (ec)
182308f70c7SWilly Tu         {
1830fda0f12SGeorge Liu             BMCWEB_LOG_DEBUG << "DBUS response error for Location";
184308f70c7SWilly Tu             messages::internalError(asyncResp->res);
185308f70c7SWilly Tu             return;
186308f70c7SWilly Tu         }
187308f70c7SWilly Tu 
188002d39b4SEd Tanous         asyncResp->res.jsonValue["Location"]["PartLocation"]["ServiceLabel"] =
1891e1e598dSJonathan Doman             property;
1901e1e598dSJonathan Doman         });
191308f70c7SWilly Tu }
192308f70c7SWilly Tu 
193308f70c7SWilly Tu inline void getChassisUUID(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
194308f70c7SWilly Tu                            const std::string& connectionName,
195308f70c7SWilly Tu                            const std::string& path)
196308f70c7SWilly Tu {
1971e1e598dSJonathan Doman     sdbusplus::asio::getProperty<std::string>(
1981e1e598dSJonathan Doman         *crow::connections::systemBus, connectionName, path,
1991e1e598dSJonathan Doman         "xyz.openbmc_project.Common.UUID", "UUID",
2005e7e2dc5SEd Tanous         [asyncResp](const boost::system::error_code& ec,
2011e1e598dSJonathan Doman                     const std::string& chassisUUID) {
202308f70c7SWilly Tu         if (ec)
203308f70c7SWilly Tu         {
2040fda0f12SGeorge Liu             BMCWEB_LOG_DEBUG << "DBUS response error for UUID";
205308f70c7SWilly Tu             messages::internalError(asyncResp->res);
206308f70c7SWilly Tu             return;
207308f70c7SWilly Tu         }
2081e1e598dSJonathan Doman         asyncResp->res.jsonValue["UUID"] = chassisUUID;
2091e1e598dSJonathan Doman         });
210308f70c7SWilly Tu }
211308f70c7SWilly Tu 
212cf7eba09SNan Zhou inline void
213cf7eba09SNan Zhou     handleChassisGet(App& app, const crow::Request& req,
21445ca1b86SEd Tanous                      const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
215cf7eba09SNan Zhou                      const std::string& chassisId)
216cf7eba09SNan Zhou {
2173ba00073SCarson Labrado     if (!redfish::setUpRedfishRoute(app, req, asyncResp))
21845ca1b86SEd Tanous     {
21945ca1b86SEd Tanous         return;
22045ca1b86SEd Tanous     }
221e99073f5SGeorge Liu     constexpr std::array<std::string_view, 2> interfaces = {
222734bfe90SGunnar Mills         "xyz.openbmc_project.Inventory.Item.Board",
223adc4f0dbSShawn McCarney         "xyz.openbmc_project.Inventory.Item.Chassis"};
224734bfe90SGunnar Mills 
225e99073f5SGeorge Liu     dbus::utility::getSubTree(
226e99073f5SGeorge Liu         "/xyz/openbmc_project/inventory", 0, interfaces,
22762d5e2e4SEd Tanous         [asyncResp, chassisId(std::string(chassisId))](
228e99073f5SGeorge Liu             const boost::system::error_code& ec,
229b9d36b47SEd Tanous             const dbus::utility::MapperGetSubTreeResponse& subtree) {
23062d5e2e4SEd Tanous         if (ec)
2311abe55efSEd Tanous         {
232f12894f8SJason M. Bills             messages::internalError(asyncResp->res);
233daf36e2eSEd Tanous             return;
234daf36e2eSEd Tanous         }
235daf36e2eSEd Tanous         // Iterate over all retrieved ObjectPaths.
236cf7eba09SNan Zhou         for (const std::pair<
237cf7eba09SNan Zhou                  std::string,
238cf7eba09SNan Zhou                  std::vector<std::pair<std::string, std::vector<std::string>>>>&
2391214b7e7SGunnar Mills                  object : subtree)
2401abe55efSEd Tanous         {
241daf36e2eSEd Tanous             const std::string& path = object.first;
242cf7eba09SNan Zhou             const std::vector<std::pair<std::string, std::vector<std::string>>>&
2431214b7e7SGunnar Mills                 connectionNames = object.second;
2447e860f15SJohn Edward Broadbent 
245997093ebSGeorge Liu             sdbusplus::message::object_path objPath(path);
246997093ebSGeorge Liu             if (objPath.filename() != chassisId)
2471abe55efSEd Tanous             {
248daf36e2eSEd Tanous                 continue;
249daf36e2eSEd Tanous             }
25026f03899SShawn McCarney 
251002d39b4SEd Tanous             auto health = std::make_shared<HealthPopulate>(asyncResp);
252b49ac873SJames Feist 
253*6c3e9451SGeorge Liu             dbus::utility::getAssociationEndPoints(
254*6c3e9451SGeorge Liu                 path + "/all_sensors",
2555e7e2dc5SEd Tanous                 [health](const boost::system::error_code& ec2,
256*6c3e9451SGeorge Liu                          const dbus::utility::MapperEndPoints& resp) {
25723a21a1cSEd Tanous                 if (ec2)
258b49ac873SJames Feist                 {
259b49ac873SJames Feist                     return; // no sensors = no failures
260b49ac873SJames Feist                 }
2611e1e598dSJonathan Doman                 health->inventory = resp;
2621e1e598dSJonathan Doman                 });
263b49ac873SJames Feist 
264b49ac873SJames Feist             health->populate();
265b49ac873SJames Feist 
26626f6976fSEd Tanous             if (connectionNames.empty())
2671abe55efSEd Tanous             {
2681c8fba97SJames Feist                 BMCWEB_LOG_ERROR << "Got 0 Connection names";
269e0d918bcSEd Tanous                 continue;
270daf36e2eSEd Tanous             }
271e0d918bcSEd Tanous 
27249c53ac9SJohnathan Mantey             asyncResp->res.jsonValue["@odata.type"] =
2735ac5a2f4SGunnar Mills                 "#Chassis.v1_16_0.Chassis";
27449c53ac9SJohnathan Mantey             asyncResp->res.jsonValue["@odata.id"] =
275eddfc437SWilly Tu                 crow::utility::urlFromPieces("redfish", "v1", "Chassis",
276eddfc437SWilly Tu                                              chassisId);
27749c53ac9SJohnathan Mantey             asyncResp->res.jsonValue["Name"] = "Chassis Collection";
27849c53ac9SJohnathan Mantey             asyncResp->res.jsonValue["ChassisType"] = "RackMount";
279cf7eba09SNan Zhou             asyncResp->res.jsonValue["Actions"]["#Chassis.Reset"]["target"] =
280eddfc437SWilly Tu                 crow::utility::urlFromPieces("redfish", "v1", "Chassis",
281eddfc437SWilly Tu                                              chassisId, "Actions",
282eddfc437SWilly Tu                                              "Chassis.Reset");
2831476687dSEd Tanous             asyncResp->res
284cf7eba09SNan Zhou                 .jsonValue["Actions"]["#Chassis.Reset"]["@Redfish.ActionInfo"] =
285eddfc437SWilly Tu                 crow::utility::urlFromPieces("redfish", "v1", "Chassis",
286eddfc437SWilly Tu                                              chassisId, "ResetActionInfo");
2871476687dSEd Tanous             asyncResp->res.jsonValue["PCIeDevices"]["@odata.id"] =
288eddfc437SWilly Tu                 crow::utility::urlFromPieces("redfish", "v1", "Systems",
289eddfc437SWilly Tu                                              "system", "PCIeDevices");
29049c53ac9SJohnathan Mantey 
291*6c3e9451SGeorge Liu             dbus::utility::getAssociationEndPoints(
292*6c3e9451SGeorge Liu                 path + "/drive",
293*6c3e9451SGeorge Liu                 [asyncResp,
294*6c3e9451SGeorge Liu                  chassisId](const boost::system::error_code& ec3,
295*6c3e9451SGeorge Liu                             const dbus::utility::MapperEndPoints& resp) {
29692903bd4SJohn Edward Broadbent                 if (ec3 || resp.empty())
29792903bd4SJohn Edward Broadbent                 {
29892903bd4SJohn Edward Broadbent                     return; // no drives = no failures
29992903bd4SJohn Edward Broadbent                 }
30092903bd4SJohn Edward Broadbent 
30192903bd4SJohn Edward Broadbent                 nlohmann::json reference;
302a0cb40cbSJohn Edward Broadbent                 reference["@odata.id"] = crow::utility::urlFromPieces(
30392903bd4SJohn Edward Broadbent                     "redfish", "v1", "Chassis", chassisId, "Drives");
30492903bd4SJohn Edward Broadbent                 asyncResp->res.jsonValue["Drives"] = std::move(reference);
30592903bd4SJohn Edward Broadbent                 });
30692903bd4SJohn Edward Broadbent 
307002d39b4SEd Tanous             const std::string& connectionName = connectionNames[0].first;
3081c8fba97SJames Feist 
30923a21a1cSEd Tanous             const std::vector<std::string>& interfaces2 =
3101c8fba97SJames Feist                 connectionNames[0].second;
3111c8fba97SJames Feist             const std::array<const char*, 2> hasIndicatorLed = {
3121c8fba97SJames Feist                 "xyz.openbmc_project.Inventory.Item.Panel",
3130fda0f12SGeorge Liu                 "xyz.openbmc_project.Inventory.Item.Board.Motherboard"};
3141c8fba97SJames Feist 
315476b9cc5STejas Patil             const std::string assetTagInterface =
3160fda0f12SGeorge Liu                 "xyz.openbmc_project.Inventory.Decorator.AssetTag";
317476b9cc5STejas Patil             if (std::find(interfaces2.begin(), interfaces2.end(),
318476b9cc5STejas Patil                           assetTagInterface) != interfaces2.end())
319476b9cc5STejas Patil             {
3201e1e598dSJonathan Doman                 sdbusplus::asio::getProperty<std::string>(
321002d39b4SEd Tanous                     *crow::connections::systemBus, connectionName, path,
322002d39b4SEd Tanous                     assetTagInterface, "AssetTag",
323476b9cc5STejas Patil                     [asyncResp, chassisId(std::string(chassisId))](
3245e7e2dc5SEd Tanous                         const boost::system::error_code& ec2,
3251e1e598dSJonathan Doman                         const std::string& property) {
3268a592810SEd Tanous                     if (ec2)
327476b9cc5STejas Patil                     {
328cf7eba09SNan Zhou                         BMCWEB_LOG_DEBUG << "DBus response error for AssetTag";
329476b9cc5STejas Patil                         messages::internalError(asyncResp->res);
330476b9cc5STejas Patil                         return;
331476b9cc5STejas Patil                     }
332002d39b4SEd Tanous                     asyncResp->res.jsonValue["AssetTag"] = property;
3331e1e598dSJonathan Doman                     });
334476b9cc5STejas Patil             }
335476b9cc5STejas Patil 
3361c8fba97SJames Feist             for (const char* interface : hasIndicatorLed)
3371c8fba97SJames Feist             {
338002d39b4SEd Tanous                 if (std::find(interfaces2.begin(), interfaces2.end(),
33923a21a1cSEd Tanous                               interface) != interfaces2.end())
3401c8fba97SJames Feist                 {
3411c8fba97SJames Feist                     getIndicatorLedState(asyncResp);
3429f8bfa7cSGunnar Mills                     getLocationIndicatorActive(asyncResp);
3431c8fba97SJames Feist                     break;
3441c8fba97SJames Feist                 }
3451c8fba97SJames Feist             }
3461c8fba97SJames Feist 
34786d89ed7SKrzysztof Grobelny             sdbusplus::asio::getAllProperties(
34886d89ed7SKrzysztof Grobelny                 *crow::connections::systemBus, connectionName, path,
34986d89ed7SKrzysztof Grobelny                 "xyz.openbmc_project.Inventory.Decorator.Asset",
35062d5e2e4SEd Tanous                 [asyncResp, chassisId(std::string(chassisId))](
3515e7e2dc5SEd Tanous                     const boost::system::error_code& /*ec2*/,
352cf7eba09SNan Zhou                     const dbus::utility::DBusPropertiesMap& propertiesList) {
35386d89ed7SKrzysztof Grobelny                 const std::string* partNumber = nullptr;
35486d89ed7SKrzysztof Grobelny                 const std::string* serialNumber = nullptr;
35586d89ed7SKrzysztof Grobelny                 const std::string* manufacturer = nullptr;
35686d89ed7SKrzysztof Grobelny                 const std::string* model = nullptr;
35786d89ed7SKrzysztof Grobelny                 const std::string* sparePartNumber = nullptr;
35886d89ed7SKrzysztof Grobelny 
35986d89ed7SKrzysztof Grobelny                 const bool success = sdbusplus::unpackPropertiesNoThrow(
36086d89ed7SKrzysztof Grobelny                     dbus_utils::UnpackErrorPrinter(), propertiesList,
36186d89ed7SKrzysztof Grobelny                     "PartNumber", partNumber, "SerialNumber", serialNumber,
36286d89ed7SKrzysztof Grobelny                     "Manufacturer", manufacturer, "Model", model,
36386d89ed7SKrzysztof Grobelny                     "SparePartNumber", sparePartNumber);
36486d89ed7SKrzysztof Grobelny 
36586d89ed7SKrzysztof Grobelny                 if (!success)
3661abe55efSEd Tanous                 {
367002d39b4SEd Tanous                     messages::internalError(asyncResp->res);
368caa11f7aSAlpana Kumari                     return;
369daf36e2eSEd Tanous                 }
37086d89ed7SKrzysztof Grobelny 
37186d89ed7SKrzysztof Grobelny                 if (partNumber != nullptr)
37286d89ed7SKrzysztof Grobelny                 {
37386d89ed7SKrzysztof Grobelny                     asyncResp->res.jsonValue["PartNumber"] = *partNumber;
37486d89ed7SKrzysztof Grobelny                 }
37586d89ed7SKrzysztof Grobelny 
37686d89ed7SKrzysztof Grobelny                 if (serialNumber != nullptr)
37786d89ed7SKrzysztof Grobelny                 {
37886d89ed7SKrzysztof Grobelny                     asyncResp->res.jsonValue["SerialNumber"] = *serialNumber;
37986d89ed7SKrzysztof Grobelny                 }
38086d89ed7SKrzysztof Grobelny 
38186d89ed7SKrzysztof Grobelny                 if (manufacturer != nullptr)
38286d89ed7SKrzysztof Grobelny                 {
38386d89ed7SKrzysztof Grobelny                     asyncResp->res.jsonValue["Manufacturer"] = *manufacturer;
38486d89ed7SKrzysztof Grobelny                 }
38586d89ed7SKrzysztof Grobelny 
38686d89ed7SKrzysztof Grobelny                 if (model != nullptr)
38786d89ed7SKrzysztof Grobelny                 {
38886d89ed7SKrzysztof Grobelny                     asyncResp->res.jsonValue["Model"] = *model;
38986d89ed7SKrzysztof Grobelny                 }
39086d89ed7SKrzysztof Grobelny 
391caa11f7aSAlpana Kumari                 // SparePartNumber is optional on D-Bus
392caa11f7aSAlpana Kumari                 // so skip if it is empty
39386d89ed7SKrzysztof Grobelny                 if (sparePartNumber != nullptr && !sparePartNumber->empty())
394caa11f7aSAlpana Kumari                 {
39586d89ed7SKrzysztof Grobelny                     asyncResp->res.jsonValue["SparePartNumber"] =
39686d89ed7SKrzysztof Grobelny                         *sparePartNumber;
397caa11f7aSAlpana Kumari                 }
39886d89ed7SKrzysztof Grobelny 
39962d5e2e4SEd Tanous                 asyncResp->res.jsonValue["Name"] = chassisId;
40062d5e2e4SEd Tanous                 asyncResp->res.jsonValue["Id"] = chassisId;
4010256b694Szhanghch05 #ifdef BMCWEB_ALLOW_DEPRECATED_POWER_THERMAL
402002d39b4SEd Tanous                 asyncResp->res.jsonValue["Thermal"]["@odata.id"] =
403eddfc437SWilly Tu                     crow::utility::urlFromPieces("redfish", "v1", "Chassis",
404eddfc437SWilly Tu                                                  chassisId, "Thermal");
4052474adfaSEd Tanous                 // Power object
4061476687dSEd Tanous                 asyncResp->res.jsonValue["Power"]["@odata.id"] =
407eddfc437SWilly Tu                     crow::utility::urlFromPieces("redfish", "v1", "Chassis",
408eddfc437SWilly Tu                                                  chassisId, "Power");
4090256b694Szhanghch05 #endif
4102973963eSXiaochao Ma #ifdef BMCWEB_NEW_POWERSUBSYSTEM_THERMALSUBSYSTEM
4112973963eSXiaochao Ma                 asyncResp->res.jsonValue["ThermalSubsystem"]["@odata.id"] =
4122973963eSXiaochao Ma                     crow::utility::urlFromPieces("redfish", "v1", "Chassis",
4132973963eSXiaochao Ma                                                  chassisId, "ThermalSubsystem");
41477b36437SChicago Duan                 asyncResp->res.jsonValue["PowerSubsystem"]["@odata.id"] =
41577b36437SChicago Duan                     crow::utility::urlFromPieces("redfish", "v1", "Chassis",
41677b36437SChicago Duan                                                  chassisId, "PowerSubsystem");
4174ca3ec3cSAlbert Zhang                 asyncResp->res.jsonValue["EnvironmentMetrics"]["@odata.id"] =
4184ca3ec3cSAlbert Zhang                     crow::utility::urlFromPieces("redfish", "v1", "Chassis",
4194ca3ec3cSAlbert Zhang                                                  chassisId,
4204ca3ec3cSAlbert Zhang                                                  "EnvironmentMetrics");
4212973963eSXiaochao Ma #endif
42295a3ecadSAnthony Wilson                 // SensorCollection
423002d39b4SEd Tanous                 asyncResp->res.jsonValue["Sensors"]["@odata.id"] =
424eddfc437SWilly Tu                     crow::utility::urlFromPieces("redfish", "v1", "Chassis",
425eddfc437SWilly Tu                                                  chassisId, "Sensors");
426002d39b4SEd Tanous                 asyncResp->res.jsonValue["Status"]["State"] = "Enabled";
4271476687dSEd Tanous 
4281476687dSEd Tanous                 nlohmann::json::array_t computerSystems;
4291476687dSEd Tanous                 nlohmann::json::object_t system;
430002d39b4SEd Tanous                 system["@odata.id"] = "/redfish/v1/Systems/system";
4311476687dSEd Tanous                 computerSystems.push_back(std::move(system));
432002d39b4SEd Tanous                 asyncResp->res.jsonValue["Links"]["ComputerSystems"] =
4331476687dSEd Tanous                     std::move(computerSystems);
4341476687dSEd Tanous 
4351476687dSEd Tanous                 nlohmann::json::array_t managedBy;
4361476687dSEd Tanous                 nlohmann::json::object_t manager;
437002d39b4SEd Tanous                 manager["@odata.id"] = "/redfish/v1/Managers/bmc";
4381476687dSEd Tanous                 managedBy.push_back(std::move(manager));
4397e860f15SJohn Edward Broadbent                 asyncResp->res.jsonValue["Links"]["ManagedBy"] =
4401476687dSEd Tanous                     std::move(managedBy);
441beeca0aeSGunnar Mills                 getChassisState(asyncResp);
44286d89ed7SKrzysztof Grobelny                 });
4432c37b4b0SSharad Yadav 
444308f70c7SWilly Tu             for (const auto& interface : interfaces2)
4452c37b4b0SSharad Yadav             {
446308f70c7SWilly Tu                 if (interface == "xyz.openbmc_project.Common.UUID")
4472c37b4b0SSharad Yadav                 {
448308f70c7SWilly Tu                     getChassisUUID(asyncResp, connectionName, path);
4492c37b4b0SSharad Yadav                 }
450cf7eba09SNan Zhou                 else if (interface ==
4510fda0f12SGeorge Liu                          "xyz.openbmc_project.Inventory.Decorator.LocationCode")
4522c37b4b0SSharad Yadav                 {
453002d39b4SEd Tanous                     getChassisLocationCode(asyncResp, connectionName, path);
4542c37b4b0SSharad Yadav                 }
4552c37b4b0SSharad Yadav             }
4562c37b4b0SSharad Yadav 
457daf36e2eSEd Tanous             return;
458daf36e2eSEd Tanous         }
459e0d918bcSEd Tanous 
460daf36e2eSEd Tanous         // Couldn't find an object with that name.  return an error
461d8a5d5d8SJiaqing Zhao         messages::resourceNotFound(asyncResp->res, "Chassis", chassisId);
462e99073f5SGeorge Liu         });
463c181942fSQiang XU 
464c181942fSQiang XU     getPhysicalSecurityData(asyncResp);
465cf7eba09SNan Zhou }
4661c8fba97SJames Feist 
467cf7eba09SNan Zhou inline void
468cf7eba09SNan Zhou     handleChassisPatch(App& app, const crow::Request& req,
4697e860f15SJohn Edward Broadbent                        const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
470cf7eba09SNan Zhou                        const std::string& param)
471cf7eba09SNan Zhou {
4723ba00073SCarson Labrado     if (!redfish::setUpRedfishRoute(app, req, asyncResp))
47345ca1b86SEd Tanous     {
47445ca1b86SEd Tanous         return;
47545ca1b86SEd Tanous     }
4769f8bfa7cSGunnar Mills     std::optional<bool> locationIndicatorActive;
4771c8fba97SJames Feist     std::optional<std::string> indicatorLed;
4781c8fba97SJames Feist 
4797e860f15SJohn Edward Broadbent     if (param.empty())
4801c8fba97SJames Feist     {
4811c8fba97SJames Feist         return;
4821c8fba97SJames Feist     }
4831c8fba97SJames Feist 
48415ed6780SWilly Tu     if (!json_util::readJsonPatch(
4857e860f15SJohn Edward Broadbent             req, asyncResp->res, "LocationIndicatorActive",
4867e860f15SJohn Edward Broadbent             locationIndicatorActive, "IndicatorLED", indicatorLed))
4871c8fba97SJames Feist     {
4881c8fba97SJames Feist         return;
4891c8fba97SJames Feist     }
4901c8fba97SJames Feist 
4919f8bfa7cSGunnar Mills     // TODO (Gunnar): Remove IndicatorLED after enough time has passed
4929f8bfa7cSGunnar Mills     if (!locationIndicatorActive && !indicatorLed)
4931c8fba97SJames Feist     {
4941c8fba97SJames Feist         return; // delete this when we support more patch properties
4951c8fba97SJames Feist     }
496d6aa0093SGunnar Mills     if (indicatorLed)
497d6aa0093SGunnar Mills     {
4987e860f15SJohn Edward Broadbent         asyncResp->res.addHeader(
4997e860f15SJohn Edward Broadbent             boost::beast::http::field::warning,
5000fda0f12SGeorge Liu             "299 - \"IndicatorLED is deprecated. Use LocationIndicatorActive instead.\"");
501d6aa0093SGunnar Mills     }
5021c8fba97SJames Feist 
503e99073f5SGeorge Liu     constexpr std::array<std::string_view, 2> interfaces = {
5041c8fba97SJames Feist         "xyz.openbmc_project.Inventory.Item.Board",
5051c8fba97SJames Feist         "xyz.openbmc_project.Inventory.Item.Chassis"};
5061c8fba97SJames Feist 
5077e860f15SJohn Edward Broadbent     const std::string& chassisId = param;
5081c8fba97SJames Feist 
509e99073f5SGeorge Liu     dbus::utility::getSubTree(
510e99073f5SGeorge Liu         "/xyz/openbmc_project/inventory", 0, interfaces,
511cf7eba09SNan Zhou         [asyncResp, chassisId, locationIndicatorActive,
5125e7e2dc5SEd Tanous          indicatorLed](const boost::system::error_code& ec,
513b9d36b47SEd Tanous                        const dbus::utility::MapperGetSubTreeResponse& subtree) {
5141c8fba97SJames Feist         if (ec)
5151c8fba97SJames Feist         {
5161c8fba97SJames Feist             messages::internalError(asyncResp->res);
5171c8fba97SJames Feist             return;
5181c8fba97SJames Feist         }
5191c8fba97SJames Feist 
5201c8fba97SJames Feist         // Iterate over all retrieved ObjectPaths.
521cf7eba09SNan Zhou         for (const std::pair<
522cf7eba09SNan Zhou                  std::string,
523cf7eba09SNan Zhou                  std::vector<std::pair<std::string, std::vector<std::string>>>>&
5241214b7e7SGunnar Mills                  object : subtree)
5251c8fba97SJames Feist         {
5261c8fba97SJames Feist             const std::string& path = object.first;
527cf7eba09SNan Zhou             const std::vector<std::pair<std::string, std::vector<std::string>>>&
5281214b7e7SGunnar Mills                 connectionNames = object.second;
5291c8fba97SJames Feist 
530997093ebSGeorge Liu             sdbusplus::message::object_path objPath(path);
531997093ebSGeorge Liu             if (objPath.filename() != chassisId)
5321c8fba97SJames Feist             {
5331c8fba97SJames Feist                 continue;
5341c8fba97SJames Feist             }
5351c8fba97SJames Feist 
53626f6976fSEd Tanous             if (connectionNames.empty())
5371c8fba97SJames Feist             {
5381c8fba97SJames Feist                 BMCWEB_LOG_ERROR << "Got 0 Connection names";
5391c8fba97SJames Feist                 continue;
5401c8fba97SJames Feist             }
5411c8fba97SJames Feist 
54223a21a1cSEd Tanous             const std::vector<std::string>& interfaces3 =
5431c8fba97SJames Feist                 connectionNames[0].second;
5441c8fba97SJames Feist 
5451c8fba97SJames Feist             const std::array<const char*, 2> hasIndicatorLed = {
5461c8fba97SJames Feist                 "xyz.openbmc_project.Inventory.Item.Panel",
5470fda0f12SGeorge Liu                 "xyz.openbmc_project.Inventory.Item.Board.Motherboard"};
5481c8fba97SJames Feist             bool indicatorChassis = false;
5491c8fba97SJames Feist             for (const char* interface : hasIndicatorLed)
5501c8fba97SJames Feist             {
551002d39b4SEd Tanous                 if (std::find(interfaces3.begin(), interfaces3.end(),
55223a21a1cSEd Tanous                               interface) != interfaces3.end())
5531c8fba97SJames Feist                 {
5541c8fba97SJames Feist                     indicatorChassis = true;
5551c8fba97SJames Feist                     break;
5561c8fba97SJames Feist                 }
5571c8fba97SJames Feist             }
5589f8bfa7cSGunnar Mills             if (locationIndicatorActive)
5599f8bfa7cSGunnar Mills             {
5609f8bfa7cSGunnar Mills                 if (indicatorChassis)
5619f8bfa7cSGunnar Mills                 {
562002d39b4SEd Tanous                     setLocationIndicatorActive(asyncResp,
563002d39b4SEd Tanous                                                *locationIndicatorActive);
5649f8bfa7cSGunnar Mills                 }
5659f8bfa7cSGunnar Mills                 else
5669f8bfa7cSGunnar Mills                 {
567002d39b4SEd Tanous                     messages::propertyUnknown(asyncResp->res,
568002d39b4SEd Tanous                                               "LocationIndicatorActive");
5699f8bfa7cSGunnar Mills                 }
5709f8bfa7cSGunnar Mills             }
5719f8bfa7cSGunnar Mills             if (indicatorLed)
5729f8bfa7cSGunnar Mills             {
5731c8fba97SJames Feist                 if (indicatorChassis)
5741c8fba97SJames Feist                 {
575f23b7296SEd Tanous                     setIndicatorLedState(asyncResp, *indicatorLed);
5761c8fba97SJames Feist                 }
5771c8fba97SJames Feist                 else
5781c8fba97SJames Feist                 {
579cf7eba09SNan Zhou                     messages::propertyUnknown(asyncResp->res, "IndicatorLED");
5801c8fba97SJames Feist                 }
5811c8fba97SJames Feist             }
5821c8fba97SJames Feist             return;
5831c8fba97SJames Feist         }
5841c8fba97SJames Feist 
585d8a5d5d8SJiaqing Zhao         messages::resourceNotFound(asyncResp->res, "Chassis", chassisId);
586e99073f5SGeorge Liu         });
587cf7eba09SNan Zhou }
588cf7eba09SNan Zhou 
589cf7eba09SNan Zhou /**
590cf7eba09SNan Zhou  * Chassis override class for delivering Chassis Schema
591cf7eba09SNan Zhou  * Functions triggers appropriate requests on DBus
592cf7eba09SNan Zhou  */
593cf7eba09SNan Zhou inline void requestRoutesChassis(App& app)
594cf7eba09SNan Zhou {
595cf7eba09SNan Zhou     BMCWEB_ROUTE(app, "/redfish/v1/Chassis/<str>/")
596cf7eba09SNan Zhou         .privileges(redfish::privileges::getChassis)
597cf7eba09SNan Zhou         .methods(boost::beast::http::verb::get)(
598cf7eba09SNan Zhou             std::bind_front(handleChassisGet, std::ref(app)));
599cf7eba09SNan Zhou 
600cf7eba09SNan Zhou     BMCWEB_ROUTE(app, "/redfish/v1/Chassis/<str>/")
601cf7eba09SNan Zhou         .privileges(redfish::privileges::patchChassis)
602cf7eba09SNan Zhou         .methods(boost::beast::http::verb::patch)(
603cf7eba09SNan Zhou             std::bind_front(handleChassisPatch, std::ref(app)));
6041c8fba97SJames Feist }
605dd99e04bSP.K. Lee 
6068d1b46d7Szhanghch05 inline void
6078d1b46d7Szhanghch05     doChassisPowerCycle(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
608dd99e04bSP.K. Lee {
6097a1dbc48SGeorge Liu     constexpr std::array<std::string_view, 1> interfaces = {
610c3b3c92aSVijay Khemka         "xyz.openbmc_project.State.Chassis"};
611c3b3c92aSVijay Khemka 
612c3b3c92aSVijay Khemka     // Use mapper to get subtree paths.
6137a1dbc48SGeorge Liu     dbus::utility::getSubTreePaths(
6147a1dbc48SGeorge Liu         "/", 0, interfaces,
615b9d36b47SEd Tanous         [asyncResp](
6167a1dbc48SGeorge Liu             const boost::system::error_code& ec,
617b9d36b47SEd Tanous             const dbus::utility::MapperGetSubTreePathsResponse& chassisList) {
618c3b3c92aSVijay Khemka         if (ec)
619c3b3c92aSVijay Khemka         {
620c3b3c92aSVijay Khemka             BMCWEB_LOG_DEBUG << "[mapper] Bad D-Bus request error: " << ec;
621c3b3c92aSVijay Khemka             messages::internalError(asyncResp->res);
622c3b3c92aSVijay Khemka             return;
623c3b3c92aSVijay Khemka         }
624c3b3c92aSVijay Khemka 
625dd99e04bSP.K. Lee         const char* processName = "xyz.openbmc_project.State.Chassis";
626dd99e04bSP.K. Lee         const char* interfaceName = "xyz.openbmc_project.State.Chassis";
627dd99e04bSP.K. Lee         const char* destProperty = "RequestedPowerTransition";
628dd99e04bSP.K. Lee         const std::string propertyValue =
629dd99e04bSP.K. Lee             "xyz.openbmc_project.State.Chassis.Transition.PowerCycle";
630002d39b4SEd Tanous         std::string objectPath = "/xyz/openbmc_project/state/chassis_system0";
631c3b3c92aSVijay Khemka 
632c3b3c92aSVijay Khemka         /* Look for system reset chassis path */
633002d39b4SEd Tanous         if ((std::find(chassisList.begin(), chassisList.end(), objectPath)) ==
634002d39b4SEd Tanous             chassisList.end())
635c3b3c92aSVijay Khemka         {
636c3b3c92aSVijay Khemka             /* We prefer to reset the full chassis_system, but if it doesn't
637c3b3c92aSVijay Khemka              * exist on some platforms, fall back to a host-only power reset
638c3b3c92aSVijay Khemka              */
639c3b3c92aSVijay Khemka             objectPath = "/xyz/openbmc_project/state/chassis0";
640c3b3c92aSVijay Khemka         }
641dd99e04bSP.K. Lee 
642dd99e04bSP.K. Lee         crow::connections::systemBus->async_method_call(
6435e7e2dc5SEd Tanous             [asyncResp](const boost::system::error_code& ec2) {
644dd99e04bSP.K. Lee             // Use "Set" method to set the property value.
6458a592810SEd Tanous             if (ec2)
646dd99e04bSP.K. Lee             {
6478a592810SEd Tanous                 BMCWEB_LOG_DEBUG << "[Set] Bad D-Bus request error: " << ec2;
648dd99e04bSP.K. Lee                 messages::internalError(asyncResp->res);
649dd99e04bSP.K. Lee                 return;
650dd99e04bSP.K. Lee             }
651dd99e04bSP.K. Lee 
652dd99e04bSP.K. Lee             messages::success(asyncResp->res);
653dd99e04bSP.K. Lee             },
654002d39b4SEd Tanous             processName, objectPath, "org.freedesktop.DBus.Properties", "Set",
655002d39b4SEd Tanous             interfaceName, destProperty,
656168e20c1SEd Tanous             dbus::utility::DbusVariantType{propertyValue});
6577a1dbc48SGeorge Liu         });
658dd99e04bSP.K. Lee }
659dd99e04bSP.K. Lee 
660cf7eba09SNan Zhou inline void handleChassisResetActionInfoPost(
661cf7eba09SNan Zhou     App& app, const crow::Request& req,
6627e860f15SJohn Edward Broadbent     const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
663cf7eba09SNan Zhou     const std::string& /*chassisId*/)
664cf7eba09SNan Zhou {
6653ba00073SCarson Labrado     if (!redfish::setUpRedfishRoute(app, req, asyncResp))
66645ca1b86SEd Tanous     {
66745ca1b86SEd Tanous         return;
66845ca1b86SEd Tanous     }
669dd99e04bSP.K. Lee     BMCWEB_LOG_DEBUG << "Post Chassis Reset.";
670dd99e04bSP.K. Lee 
671dd99e04bSP.K. Lee     std::string resetType;
672dd99e04bSP.K. Lee 
673cf7eba09SNan Zhou     if (!json_util::readJsonAction(req, asyncResp->res, "ResetType", resetType))
674dd99e04bSP.K. Lee     {
675dd99e04bSP.K. Lee         return;
676dd99e04bSP.K. Lee     }
677dd99e04bSP.K. Lee 
678dd99e04bSP.K. Lee     if (resetType != "PowerCycle")
679dd99e04bSP.K. Lee     {
680dd99e04bSP.K. Lee         BMCWEB_LOG_DEBUG << "Invalid property value for ResetType: "
681dd99e04bSP.K. Lee                          << resetType;
682002d39b4SEd Tanous         messages::actionParameterNotSupported(asyncResp->res, resetType,
683002d39b4SEd Tanous                                               "ResetType");
684dd99e04bSP.K. Lee 
685dd99e04bSP.K. Lee         return;
686dd99e04bSP.K. Lee     }
687dd99e04bSP.K. Lee     doChassisPowerCycle(asyncResp);
688dd99e04bSP.K. Lee }
6891cb1a9e6SAppaRao Puli 
6901cb1a9e6SAppaRao Puli /**
691cf7eba09SNan Zhou  * ChassisResetAction class supports the POST method for the Reset
692cf7eba09SNan Zhou  * action.
693cf7eba09SNan Zhou  * Function handles POST method request.
694cf7eba09SNan Zhou  * Analyzes POST body before sending Reset request data to D-Bus.
6951cb1a9e6SAppaRao Puli  */
696cf7eba09SNan Zhou 
697cf7eba09SNan Zhou inline void requestRoutesChassisResetAction(App& app)
6981cb1a9e6SAppaRao Puli {
699cf7eba09SNan Zhou     BMCWEB_ROUTE(app, "/redfish/v1/Chassis/<str>/Actions/Chassis.Reset/")
700cf7eba09SNan Zhou         .privileges(redfish::privileges::postChassis)
701cf7eba09SNan Zhou         .methods(boost::beast::http::verb::post)(
702cf7eba09SNan Zhou             std::bind_front(handleChassisResetActionInfoPost, std::ref(app)));
703cf7eba09SNan Zhou }
704cf7eba09SNan Zhou 
705cf7eba09SNan Zhou inline void handleChassisResetActionInfoGet(
706cf7eba09SNan Zhou     App& app, const crow::Request& req,
7077e860f15SJohn Edward Broadbent     const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
708cf7eba09SNan Zhou     const std::string& chassisId)
709cf7eba09SNan Zhou {
7103ba00073SCarson Labrado     if (!redfish::setUpRedfishRoute(app, req, asyncResp))
7111cb1a9e6SAppaRao Puli     {
71245ca1b86SEd Tanous         return;
71345ca1b86SEd Tanous     }
714cf7eba09SNan Zhou     asyncResp->res.jsonValue["@odata.type"] = "#ActionInfo.v1_1_2.ActionInfo";
715eddfc437SWilly Tu     asyncResp->res.jsonValue["@odata.id"] = crow::utility::urlFromPieces(
716eddfc437SWilly Tu         "redfish", "v1", "Chassis", chassisId, "ResetActionInfo");
7171476687dSEd Tanous     asyncResp->res.jsonValue["Name"] = "Reset Action Info";
7181476687dSEd Tanous 
7191476687dSEd Tanous     asyncResp->res.jsonValue["Id"] = "ResetActionInfo";
7205b9e95a1SNan Zhou     nlohmann::json::array_t parameters;
7215b9e95a1SNan Zhou     nlohmann::json::object_t parameter;
7225b9e95a1SNan Zhou     parameter["Name"] = "ResetType";
7235b9e95a1SNan Zhou     parameter["Required"] = true;
7245b9e95a1SNan Zhou     parameter["DataType"] = "String";
7251476687dSEd Tanous     nlohmann::json::array_t allowed;
7261476687dSEd Tanous     allowed.push_back("PowerCycle");
7275b9e95a1SNan Zhou     parameter["AllowableValues"] = std::move(allowed);
7285b9e95a1SNan Zhou     parameters.push_back(std::move(parameter));
7295b9e95a1SNan Zhou 
7301476687dSEd Tanous     asyncResp->res.jsonValue["Parameters"] = std::move(parameters);
731cf7eba09SNan Zhou }
732cf7eba09SNan Zhou 
733cf7eba09SNan Zhou /**
734cf7eba09SNan Zhou  * ChassisResetActionInfo derived class for delivering Chassis
735cf7eba09SNan Zhou  * ResetType AllowableValues using ResetInfo schema.
736cf7eba09SNan Zhou  */
737cf7eba09SNan Zhou inline void requestRoutesChassisResetActionInfo(App& app)
738cf7eba09SNan Zhou {
739cf7eba09SNan Zhou     BMCWEB_ROUTE(app, "/redfish/v1/Chassis/<str>/ResetActionInfo/")
740cf7eba09SNan Zhou         .privileges(redfish::privileges::getActionInfo)
741cf7eba09SNan Zhou         .methods(boost::beast::http::verb::get)(
742cf7eba09SNan Zhou             std::bind_front(handleChassisResetActionInfoGet, std::ref(app)));
7431cb1a9e6SAppaRao Puli }
7441cb1a9e6SAppaRao Puli 
745e37f8451SRapkiewicz, Pawel } // namespace redfish
746