xref: /openbmc/bmcweb/features/redfish/lib/chassis.hpp (revision 308f70c77194b891c97e6f56c50adee4f39f0de7)
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 
18b49ac873SJames Feist #include "health.hpp"
191c8fba97SJames Feist #include "led.hpp"
201abe55efSEd Tanous 
217e860f15SJohn Edward Broadbent #include <app.hpp>
22e37f8451SRapkiewicz, Pawel #include <boost/container/flat_map.hpp>
23ed398213SEd Tanous #include <registries/privilege_registry.hpp>
2402f6ff19SGunnar Mills #include <utils/collection.hpp>
251214b7e7SGunnar Mills 
26abf2add6SEd Tanous #include <variant>
27e37f8451SRapkiewicz, Pawel 
281abe55efSEd Tanous namespace redfish
291abe55efSEd Tanous {
30e37f8451SRapkiewicz, Pawel 
31e37f8451SRapkiewicz, Pawel /**
32beeca0aeSGunnar Mills  * @brief Retrieves chassis state properties over dbus
33beeca0aeSGunnar Mills  *
34beeca0aeSGunnar Mills  * @param[in] aResp - Shared pointer for completing asynchronous calls.
35beeca0aeSGunnar Mills  *
36beeca0aeSGunnar Mills  * @return None.
37beeca0aeSGunnar Mills  */
388d1b46d7Szhanghch05 inline void getChassisState(std::shared_ptr<bmcweb::AsyncResp> aResp)
39beeca0aeSGunnar Mills {
40beeca0aeSGunnar Mills     crow::connections::systemBus->async_method_call(
41beeca0aeSGunnar Mills         [aResp{std::move(aResp)}](
42beeca0aeSGunnar Mills             const boost::system::error_code ec,
43beeca0aeSGunnar Mills             const std::variant<std::string>& chassisState) {
44beeca0aeSGunnar Mills             if (ec)
45beeca0aeSGunnar Mills             {
46beeca0aeSGunnar Mills                 BMCWEB_LOG_DEBUG << "DBUS response error " << ec;
47beeca0aeSGunnar Mills                 messages::internalError(aResp->res);
48beeca0aeSGunnar Mills                 return;
49beeca0aeSGunnar Mills             }
50beeca0aeSGunnar Mills 
51beeca0aeSGunnar Mills             const std::string* s = std::get_if<std::string>(&chassisState);
52beeca0aeSGunnar Mills             BMCWEB_LOG_DEBUG << "Chassis state: " << *s;
53beeca0aeSGunnar Mills             if (s != nullptr)
54beeca0aeSGunnar Mills             {
55beeca0aeSGunnar Mills                 // Verify Chassis State
56beeca0aeSGunnar Mills                 if (*s == "xyz.openbmc_project.State.Chassis.PowerState.On")
57beeca0aeSGunnar Mills                 {
58beeca0aeSGunnar Mills                     aResp->res.jsonValue["PowerState"] = "On";
59beeca0aeSGunnar Mills                     aResp->res.jsonValue["Status"]["State"] = "Enabled";
60beeca0aeSGunnar Mills                 }
61beeca0aeSGunnar Mills                 else if (*s ==
62beeca0aeSGunnar Mills                          "xyz.openbmc_project.State.Chassis.PowerState.Off")
63beeca0aeSGunnar Mills                 {
64beeca0aeSGunnar Mills                     aResp->res.jsonValue["PowerState"] = "Off";
65beeca0aeSGunnar Mills                     aResp->res.jsonValue["Status"]["State"] = "StandbyOffline";
66beeca0aeSGunnar Mills                 }
67beeca0aeSGunnar Mills             }
68beeca0aeSGunnar Mills         },
69beeca0aeSGunnar Mills         "xyz.openbmc_project.State.Chassis",
70beeca0aeSGunnar Mills         "/xyz/openbmc_project/state/chassis0",
71beeca0aeSGunnar Mills         "org.freedesktop.DBus.Properties", "Get",
72beeca0aeSGunnar Mills         "xyz.openbmc_project.State.Chassis", "CurrentPowerState");
73beeca0aeSGunnar Mills }
74beeca0aeSGunnar Mills 
75beeca0aeSGunnar Mills /**
76e37f8451SRapkiewicz, Pawel  * DBus types primitives for several generic DBus interfaces
77e37f8451SRapkiewicz, Pawel  * TODO(Pawel) consider move this to separate file into boost::dbus
78e37f8451SRapkiewicz, Pawel  */
7955c7b7a2SEd Tanous // Note, this is not a very useful Variant, but because it isn't used to get
80aa2e59c1SEd Tanous // values, it should be as simple as possible
81aa2e59c1SEd Tanous // TODO(ed) invent a nullvariant type
825fd7ba65SCheng C Yang using VariantType = std::variant<bool, std::string, uint64_t, uint32_t>;
83aa2e59c1SEd Tanous using ManagedObjectsType = std::vector<std::pair<
84aa2e59c1SEd Tanous     sdbusplus::message::object_path,
85aa2e59c1SEd Tanous     std::vector<std::pair<std::string,
86aa2e59c1SEd Tanous                           std::vector<std::pair<std::string, VariantType>>>>>>;
87e37f8451SRapkiewicz, Pawel 
88aa2e59c1SEd Tanous using PropertiesType = boost::container::flat_map<std::string, VariantType>;
89e37f8451SRapkiewicz, Pawel 
908d1b46d7Szhanghch05 inline void getIntrusionByService(std::shared_ptr<bmcweb::AsyncResp> aResp,
91c181942fSQiang XU                                   const std::string& service,
92c181942fSQiang XU                                   const std::string& objPath)
93c181942fSQiang XU {
94c181942fSQiang XU     BMCWEB_LOG_DEBUG << "Get intrusion status by service \n";
95c181942fSQiang XU 
96c181942fSQiang XU     crow::connections::systemBus->async_method_call(
97c181942fSQiang XU         [aResp{std::move(aResp)}](const boost::system::error_code ec,
98c181942fSQiang XU                                   const std::variant<std::string>& value) {
99c181942fSQiang XU             if (ec)
100c181942fSQiang XU             {
1014e0453b1SGunnar Mills                 // do not add err msg in redfish response, because this is not
102c181942fSQiang XU                 //     mandatory property
103c181942fSQiang XU                 BMCWEB_LOG_ERROR << "DBUS response error " << ec << "\n";
104c181942fSQiang XU                 return;
105c181942fSQiang XU             }
106c181942fSQiang XU 
107c181942fSQiang XU             const std::string* status = std::get_if<std::string>(&value);
108c181942fSQiang XU 
109c181942fSQiang XU             if (status == nullptr)
110c181942fSQiang XU             {
111c181942fSQiang XU                 BMCWEB_LOG_ERROR << "intrusion status read error \n";
112c181942fSQiang XU                 return;
113c181942fSQiang XU             }
114c181942fSQiang XU 
115c181942fSQiang XU             aResp->res.jsonValue["PhysicalSecurity"] = {
116c181942fSQiang XU                 {"IntrusionSensorNumber", 1}, {"IntrusionSensor", *status}};
117c181942fSQiang XU         },
118c181942fSQiang XU         service, objPath, "org.freedesktop.DBus.Properties", "Get",
119c181942fSQiang XU         "xyz.openbmc_project.Chassis.Intrusion", "Status");
120c181942fSQiang XU }
121c181942fSQiang XU 
122c181942fSQiang XU /**
123c181942fSQiang XU  * Retrieves physical security properties over dbus
124c181942fSQiang XU  */
1258d1b46d7Szhanghch05 inline void getPhysicalSecurityData(std::shared_ptr<bmcweb::AsyncResp> aResp)
126c181942fSQiang XU {
127c181942fSQiang XU     crow::connections::systemBus->async_method_call(
128c181942fSQiang XU         [aResp{std::move(aResp)}](
129c181942fSQiang XU             const boost::system::error_code ec,
130c181942fSQiang XU             const std::vector<std::pair<
131c181942fSQiang XU                 std::string,
1321214b7e7SGunnar Mills                 std::vector<std::pair<std::string, std::vector<std::string>>>>>&
1331214b7e7SGunnar Mills                 subtree) {
134c181942fSQiang XU             if (ec)
135c181942fSQiang XU             {
1364e0453b1SGunnar Mills                 // do not add err msg in redfish response, because this is not
137c181942fSQiang XU                 //     mandatory property
13854fbf177SAndrew Geissler                 BMCWEB_LOG_INFO << "DBUS error: no matched iface " << ec
139c181942fSQiang XU                                 << "\n";
140c181942fSQiang XU                 return;
141c181942fSQiang XU             }
142c181942fSQiang XU             // Iterate over all retrieved ObjectPaths.
143c181942fSQiang XU             for (const auto& object : subtree)
144c181942fSQiang XU             {
145c181942fSQiang XU                 for (const auto& service : object.second)
146c181942fSQiang XU                 {
147c181942fSQiang XU                     getIntrusionByService(aResp, service.first, object.first);
148c181942fSQiang XU                     return;
149c181942fSQiang XU                 }
150c181942fSQiang XU             }
151c181942fSQiang XU         },
152c181942fSQiang XU         "xyz.openbmc_project.ObjectMapper",
153c181942fSQiang XU         "/xyz/openbmc_project/object_mapper",
154c181942fSQiang XU         "xyz.openbmc_project.ObjectMapper", "GetSubTree",
155271584abSEd Tanous         "/xyz/openbmc_project/Intrusion", 1,
156c181942fSQiang XU         std::array<const char*, 1>{"xyz.openbmc_project.Chassis.Intrusion"});
157c181942fSQiang XU }
158c181942fSQiang XU 
159e37f8451SRapkiewicz, Pawel /**
160e37f8451SRapkiewicz, Pawel  * ChassisCollection derived class for delivering Chassis Collection Schema
161e37f8451SRapkiewicz, Pawel  *  Functions triggers appropriate requests on DBus
162e37f8451SRapkiewicz, Pawel  */
1637e860f15SJohn Edward Broadbent inline void requestRoutesChassisCollection(App& app)
1641abe55efSEd Tanous {
1657e860f15SJohn Edward Broadbent     BMCWEB_ROUTE(app, "/redfish/v1/Chassis/")
166ed398213SEd Tanous         .privileges(redfish::privileges::getChassisCollection)
1677e860f15SJohn Edward Broadbent         .methods(boost::beast::http::verb::get)(
1687e860f15SJohn Edward Broadbent             [](const crow::Request&,
1697e860f15SJohn Edward Broadbent                const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
1708d1b46d7Szhanghch05                 asyncResp->res.jsonValue["@odata.type"] =
1718d1b46d7Szhanghch05                     "#ChassisCollection.ChassisCollection";
1728d1b46d7Szhanghch05                 asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/Chassis";
1738d1b46d7Szhanghch05                 asyncResp->res.jsonValue["Name"] = "Chassis Collection";
174e37f8451SRapkiewicz, Pawel 
17502f6ff19SGunnar Mills                 collection_util::getCollectionMembers(
17602f6ff19SGunnar Mills                     asyncResp, "/redfish/v1/Chassis",
17702f6ff19SGunnar Mills                     {"xyz.openbmc_project.Inventory.Item.Board",
17802f6ff19SGunnar Mills                      "xyz.openbmc_project.Inventory.Item.Chassis"});
1797e860f15SJohn Edward Broadbent             });
18062d5e2e4SEd Tanous }
181e37f8451SRapkiewicz, Pawel 
182*308f70c7SWilly Tu inline void
183*308f70c7SWilly Tu     getChassisLocationCode(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
184*308f70c7SWilly Tu                            const std::string& connectionName,
185*308f70c7SWilly Tu                            const std::string& path)
186*308f70c7SWilly Tu {
187*308f70c7SWilly Tu     crow::connections::systemBus->async_method_call(
188*308f70c7SWilly Tu         [asyncResp](const boost::system::error_code ec,
189*308f70c7SWilly Tu                     const std::variant<std::string>& property) {
190*308f70c7SWilly Tu             if (ec)
191*308f70c7SWilly Tu             {
192*308f70c7SWilly Tu                 BMCWEB_LOG_DEBUG << "DBUS response error for "
193*308f70c7SWilly Tu                                     "Location";
194*308f70c7SWilly Tu                 messages::internalError(asyncResp->res);
195*308f70c7SWilly Tu                 return;
196*308f70c7SWilly Tu             }
197*308f70c7SWilly Tu 
198*308f70c7SWilly Tu             const std::string* value = std::get_if<std::string>(&property);
199*308f70c7SWilly Tu             if (value == nullptr)
200*308f70c7SWilly Tu             {
201*308f70c7SWilly Tu                 BMCWEB_LOG_DEBUG << "Null value returned "
202*308f70c7SWilly Tu                                     "for locaton code";
203*308f70c7SWilly Tu                 messages::internalError(asyncResp->res);
204*308f70c7SWilly Tu                 return;
205*308f70c7SWilly Tu             }
206*308f70c7SWilly Tu             asyncResp->res
207*308f70c7SWilly Tu                 .jsonValue["Location"]["PartLocation"]["ServiceLabel"] = *value;
208*308f70c7SWilly Tu         },
209*308f70c7SWilly Tu         connectionName, path, "org.freedesktop.DBus.Properties", "Get",
210*308f70c7SWilly Tu         "xyz.openbmc_project.Inventory.Decorator.LocationCode", "LocationCode");
211*308f70c7SWilly Tu }
212*308f70c7SWilly Tu 
213*308f70c7SWilly Tu inline void getChassisUUID(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
214*308f70c7SWilly Tu                            const std::string& connectionName,
215*308f70c7SWilly Tu                            const std::string& path)
216*308f70c7SWilly Tu {
217*308f70c7SWilly Tu     crow::connections::systemBus->async_method_call(
218*308f70c7SWilly Tu         [asyncResp](const boost::system::error_code ec,
219*308f70c7SWilly Tu                     const std::variant<std::string>& chassisUUID) {
220*308f70c7SWilly Tu             if (ec)
221*308f70c7SWilly Tu             {
222*308f70c7SWilly Tu                 BMCWEB_LOG_DEBUG << "DBUS response error for "
223*308f70c7SWilly Tu                                     "UUID";
224*308f70c7SWilly Tu                 messages::internalError(asyncResp->res);
225*308f70c7SWilly Tu                 return;
226*308f70c7SWilly Tu             }
227*308f70c7SWilly Tu             const std::string* value = std::get_if<std::string>(&chassisUUID);
228*308f70c7SWilly Tu             if (value == nullptr)
229*308f70c7SWilly Tu             {
230*308f70c7SWilly Tu                 BMCWEB_LOG_DEBUG << "Null value returned "
231*308f70c7SWilly Tu                                     "for UUID";
232*308f70c7SWilly Tu                 messages::internalError(asyncResp->res);
233*308f70c7SWilly Tu                 return;
234*308f70c7SWilly Tu             }
235*308f70c7SWilly Tu             asyncResp->res.jsonValue["UUID"] = *value;
236*308f70c7SWilly Tu         },
237*308f70c7SWilly Tu         connectionName, path, "org.freedesktop.DBus.Properties", "Get",
238*308f70c7SWilly Tu         "xyz.openbmc_project.Common.UUID", "UUID");
239*308f70c7SWilly Tu }
240*308f70c7SWilly Tu 
241e37f8451SRapkiewicz, Pawel /**
242e37f8451SRapkiewicz, Pawel  * Chassis override class for delivering Chassis Schema
243e37f8451SRapkiewicz, Pawel  * Functions triggers appropriate requests on DBus
244e37f8451SRapkiewicz, Pawel  */
2457e860f15SJohn Edward Broadbent inline void requestRoutesChassis(App& app)
2461abe55efSEd Tanous {
2477e860f15SJohn Edward Broadbent     BMCWEB_ROUTE(app, "/redfish/v1/Chassis/<str>/")
248ed398213SEd Tanous         .privileges(redfish::privileges::getChassis)
2497e860f15SJohn Edward Broadbent         .methods(
2507e860f15SJohn Edward Broadbent             boost::beast::http::verb::get)([](const crow::Request&,
2517e860f15SJohn Edward Broadbent                                               const std::shared_ptr<
2527e860f15SJohn Edward Broadbent                                                   bmcweb::AsyncResp>& asyncResp,
2537e860f15SJohn Edward Broadbent                                               const std::string& chassisId) {
254adc4f0dbSShawn McCarney             const std::array<const char*, 2> interfaces = {
255734bfe90SGunnar Mills                 "xyz.openbmc_project.Inventory.Item.Board",
256adc4f0dbSShawn McCarney                 "xyz.openbmc_project.Inventory.Item.Chassis"};
257734bfe90SGunnar Mills 
25855c7b7a2SEd Tanous             crow::connections::systemBus->async_method_call(
25962d5e2e4SEd Tanous                 [asyncResp, chassisId(std::string(chassisId))](
26062d5e2e4SEd Tanous                     const boost::system::error_code ec,
2611c8fba97SJames Feist                     const crow::openbmc_mapper::GetSubTreeType& subtree) {
26262d5e2e4SEd Tanous                     if (ec)
2631abe55efSEd Tanous                     {
264f12894f8SJason M. Bills                         messages::internalError(asyncResp->res);
265daf36e2eSEd Tanous                         return;
266daf36e2eSEd Tanous                     }
267daf36e2eSEd Tanous                     // Iterate over all retrieved ObjectPaths.
2681abe55efSEd Tanous                     for (const std::pair<
2691abe55efSEd Tanous                              std::string,
2707e860f15SJohn Edward Broadbent                              std::vector<std::pair<std::string,
2717e860f15SJohn Edward Broadbent                                                    std::vector<std::string>>>>&
2721214b7e7SGunnar Mills                              object : subtree)
2731abe55efSEd Tanous                     {
274daf36e2eSEd Tanous                         const std::string& path = object.first;
2751abe55efSEd Tanous                         const std::vector<
2761214b7e7SGunnar Mills                             std::pair<std::string, std::vector<std::string>>>&
2771214b7e7SGunnar Mills                             connectionNames = object.second;
2787e860f15SJohn Edward Broadbent 
2797e860f15SJohn Edward Broadbent                         if (!boost::ends_with(path, chassisId))
2801abe55efSEd Tanous                         {
281daf36e2eSEd Tanous                             continue;
282daf36e2eSEd Tanous                         }
28326f03899SShawn McCarney 
2847e860f15SJohn Edward Broadbent                         auto health =
2857e860f15SJohn Edward Broadbent                             std::make_shared<HealthPopulate>(asyncResp);
286b49ac873SJames Feist 
287b49ac873SJames Feist                         crow::connections::systemBus->async_method_call(
2887e860f15SJohn Edward Broadbent                             [health](
2897e860f15SJohn Edward Broadbent                                 const boost::system::error_code ec2,
290b49ac873SJames Feist                                 std::variant<std::vector<std::string>>& resp) {
29123a21a1cSEd Tanous                                 if (ec2)
292b49ac873SJames Feist                                 {
293b49ac873SJames Feist                                     return; // no sensors = no failures
294b49ac873SJames Feist                                 }
295b49ac873SJames Feist                                 std::vector<std::string>* data =
2967e860f15SJohn Edward Broadbent                                     std::get_if<std::vector<std::string>>(
2977e860f15SJohn Edward Broadbent                                         &resp);
298b49ac873SJames Feist                                 if (data == nullptr)
299b49ac873SJames Feist                                 {
300b49ac873SJames Feist                                     return;
301b49ac873SJames Feist                                 }
302b49ac873SJames Feist                                 health->inventory = std::move(*data);
303b49ac873SJames Feist                             },
304b49ac873SJames Feist                             "xyz.openbmc_project.ObjectMapper",
305b49ac873SJames Feist                             path + "/all_sensors",
306b49ac873SJames Feist                             "org.freedesktop.DBus.Properties", "Get",
307b49ac873SJames Feist                             "xyz.openbmc_project.Association", "endpoints");
308b49ac873SJames Feist 
309b49ac873SJames Feist                         health->populate();
310b49ac873SJames Feist 
3111abe55efSEd Tanous                         if (connectionNames.size() < 1)
3121abe55efSEd Tanous                         {
3131c8fba97SJames Feist                             BMCWEB_LOG_ERROR << "Got 0 Connection names";
314e0d918bcSEd Tanous                             continue;
315daf36e2eSEd Tanous                         }
316e0d918bcSEd Tanous 
31749c53ac9SJohnathan Mantey                         asyncResp->res.jsonValue["@odata.type"] =
3189f8bfa7cSGunnar Mills                             "#Chassis.v1_14_0.Chassis";
31949c53ac9SJohnathan Mantey                         asyncResp->res.jsonValue["@odata.id"] =
32049c53ac9SJohnathan Mantey                             "/redfish/v1/Chassis/" + chassisId;
32149c53ac9SJohnathan Mantey                         asyncResp->res.jsonValue["Name"] = "Chassis Collection";
32249c53ac9SJohnathan Mantey                         asyncResp->res.jsonValue["ChassisType"] = "RackMount";
3237e860f15SJohn Edward Broadbent                         asyncResp->res.jsonValue["Actions"]["#Chassis.Reset"] =
3247e860f15SJohn Edward Broadbent                             {{"target", "/redfish/v1/Chassis/" + chassisId +
325dd99e04bSP.K. Lee                                             "/Actions/Chassis.Reset"},
3261cb1a9e6SAppaRao Puli                              {"@Redfish.ActionInfo", "/redfish/v1/Chassis/" +
3271cb1a9e6SAppaRao Puli                                                          chassisId +
3281cb1a9e6SAppaRao Puli                                                          "/ResetActionInfo"}};
329adbe192aSJason M. Bills                         asyncResp->res.jsonValue["PCIeDevices"] = {
330adbe192aSJason M. Bills                             {"@odata.id",
331adbe192aSJason M. Bills                              "/redfish/v1/Systems/system/PCIeDevices"}};
33249c53ac9SJohnathan Mantey 
33349c53ac9SJohnathan Mantey                         const std::string& connectionName =
33449c53ac9SJohnathan Mantey                             connectionNames[0].first;
3351c8fba97SJames Feist 
33623a21a1cSEd Tanous                         const std::vector<std::string>& interfaces2 =
3371c8fba97SJames Feist                             connectionNames[0].second;
3381c8fba97SJames Feist                         const std::array<const char*, 2> hasIndicatorLed = {
3391c8fba97SJames Feist                             "xyz.openbmc_project.Inventory.Item.Panel",
3407e860f15SJohn Edward Broadbent                             "xyz.openbmc_project.Inventory.Item.Board."
3417e860f15SJohn Edward Broadbent                             "Motherboard"};
3421c8fba97SJames Feist 
343476b9cc5STejas Patil                         const std::string assetTagInterface =
344476b9cc5STejas Patil                             "xyz.openbmc_project.Inventory.Decorator."
345476b9cc5STejas Patil                             "AssetTag";
346476b9cc5STejas Patil                         if (std::find(interfaces2.begin(), interfaces2.end(),
347476b9cc5STejas Patil                                       assetTagInterface) != interfaces2.end())
348476b9cc5STejas Patil                         {
349476b9cc5STejas Patil                             crow::connections::systemBus->async_method_call(
350476b9cc5STejas Patil                                 [asyncResp, chassisId(std::string(chassisId))](
351476b9cc5STejas Patil                                     const boost::system::error_code ec,
352476b9cc5STejas Patil                                     const std::variant<std::string>& property) {
353476b9cc5STejas Patil                                     if (ec)
354476b9cc5STejas Patil                                     {
355476b9cc5STejas Patil                                         BMCWEB_LOG_DEBUG
356476b9cc5STejas Patil                                             << "DBus response error for "
357476b9cc5STejas Patil                                                "AssetTag";
358476b9cc5STejas Patil                                         messages::internalError(asyncResp->res);
359476b9cc5STejas Patil                                         return;
360476b9cc5STejas Patil                                     }
361476b9cc5STejas Patil 
362476b9cc5STejas Patil                                     const std::string* assetTag =
363476b9cc5STejas Patil                                         std::get_if<std::string>(&property);
364476b9cc5STejas Patil                                     if (assetTag == nullptr)
365476b9cc5STejas Patil                                     {
366476b9cc5STejas Patil                                         BMCWEB_LOG_DEBUG
367476b9cc5STejas Patil                                             << "Null value returned "
368476b9cc5STejas Patil                                                "for Chassis AssetTag";
369476b9cc5STejas Patil                                         messages::internalError(asyncResp->res);
370476b9cc5STejas Patil                                         return;
371476b9cc5STejas Patil                                     }
372476b9cc5STejas Patil                                     asyncResp->res.jsonValue["AssetTag"] =
373476b9cc5STejas Patil                                         *assetTag;
374476b9cc5STejas Patil                                 },
375476b9cc5STejas Patil                                 connectionName, path,
376476b9cc5STejas Patil                                 "org.freedesktop.DBus.Properties", "Get",
377476b9cc5STejas Patil                                 assetTagInterface, "AssetTag");
378476b9cc5STejas Patil                         }
379476b9cc5STejas Patil 
3801c8fba97SJames Feist                         for (const char* interface : hasIndicatorLed)
3811c8fba97SJames Feist                         {
3827e860f15SJohn Edward Broadbent                             if (std::find(interfaces2.begin(),
3837e860f15SJohn Edward Broadbent                                           interfaces2.end(),
38423a21a1cSEd Tanous                                           interface) != interfaces2.end())
3851c8fba97SJames Feist                             {
3861c8fba97SJames Feist                                 getIndicatorLedState(asyncResp);
3879f8bfa7cSGunnar Mills                                 getLocationIndicatorActive(asyncResp);
3881c8fba97SJames Feist                                 break;
3891c8fba97SJames Feist                             }
3901c8fba97SJames Feist                         }
3911c8fba97SJames Feist 
39255c7b7a2SEd Tanous                         crow::connections::systemBus->async_method_call(
39362d5e2e4SEd Tanous                             [asyncResp, chassisId(std::string(chassisId))](
39490728b54SEd Tanous                                 const boost::system::error_code /*ec2*/,
3957e860f15SJohn Edward Broadbent                                 const std::vector<
3967e860f15SJohn Edward Broadbent                                     std::pair<std::string, VariantType>>&
3977e860f15SJohn Edward Broadbent                                     propertiesList) {
3981214b7e7SGunnar Mills                                 for (const std::pair<std::string, VariantType>&
3991214b7e7SGunnar Mills                                          property : propertiesList)
4001abe55efSEd Tanous                                 {
4017e860f15SJohn Edward Broadbent                                     // Store DBus properties that are also
4027e860f15SJohn Edward Broadbent                                     // Redfish properties with same name and a
4037e860f15SJohn Edward Broadbent                                     // string value
40499cffd7fSShawn McCarney                                     const std::string& propertyName =
40599cffd7fSShawn McCarney                                         property.first;
40699cffd7fSShawn McCarney                                     if ((propertyName == "PartNumber") ||
40799cffd7fSShawn McCarney                                         (propertyName == "SerialNumber") ||
40899cffd7fSShawn McCarney                                         (propertyName == "Manufacturer") ||
40999cffd7fSShawn McCarney                                         (propertyName == "Model"))
41099cffd7fSShawn McCarney                                     {
411daf36e2eSEd Tanous                                         const std::string* value =
41299cffd7fSShawn McCarney                                             std::get_if<std::string>(
41399cffd7fSShawn McCarney                                                 &property.second);
4141abe55efSEd Tanous                                         if (value != nullptr)
4151abe55efSEd Tanous                                         {
4167e860f15SJohn Edward Broadbent                                             asyncResp->res
4177e860f15SJohn Edward Broadbent                                                 .jsonValue[propertyName] =
41862d5e2e4SEd Tanous                                                 *value;
419daf36e2eSEd Tanous                                         }
420daf36e2eSEd Tanous                                     }
42199cffd7fSShawn McCarney                                 }
42262d5e2e4SEd Tanous                                 asyncResp->res.jsonValue["Name"] = chassisId;
42362d5e2e4SEd Tanous                                 asyncResp->res.jsonValue["Id"] = chassisId;
4240256b694Szhanghch05 #ifdef BMCWEB_ALLOW_DEPRECATED_POWER_THERMAL
42562d5e2e4SEd Tanous                                 asyncResp->res.jsonValue["Thermal"] = {
4261abe55efSEd Tanous                                     {"@odata.id", "/redfish/v1/Chassis/" +
4271abe55efSEd Tanous                                                       chassisId + "/Thermal"}};
4282474adfaSEd Tanous                                 // Power object
4292474adfaSEd Tanous                                 asyncResp->res.jsonValue["Power"] = {
4302474adfaSEd Tanous                                     {"@odata.id", "/redfish/v1/Chassis/" +
4312474adfaSEd Tanous                                                       chassisId + "/Power"}};
4320256b694Szhanghch05 #endif
43395a3ecadSAnthony Wilson                                 // SensorCollection
43495a3ecadSAnthony Wilson                                 asyncResp->res.jsonValue["Sensors"] = {
43595a3ecadSAnthony Wilson                                     {"@odata.id", "/redfish/v1/Chassis/" +
43695a3ecadSAnthony Wilson                                                       chassisId + "/Sensors"}};
437029573d4SEd Tanous                                 asyncResp->res.jsonValue["Status"] = {
438029573d4SEd Tanous                                     {"State", "Enabled"},
439029573d4SEd Tanous                                 };
4402474adfaSEd Tanous 
441029573d4SEd Tanous                                 asyncResp->res
442029573d4SEd Tanous                                     .jsonValue["Links"]["ComputerSystems"] = {
4437e860f15SJohn Edward Broadbent                                     {{"@odata.id",
4447e860f15SJohn Edward Broadbent                                       "/redfish/v1/Systems/system"}}};
4457e860f15SJohn Edward Broadbent                                 asyncResp->res.jsonValue["Links"]["ManagedBy"] =
4467e860f15SJohn Edward Broadbent                                     {{{"@odata.id",
4477e860f15SJohn Edward Broadbent                                        "/redfish/v1/Managers/bmc"}}};
448beeca0aeSGunnar Mills                                 getChassisState(asyncResp);
449daf36e2eSEd Tanous                             },
4507e860f15SJohn Edward Broadbent                             connectionName, path,
4517e860f15SJohn Edward Broadbent                             "org.freedesktop.DBus.Properties", "GetAll",
4521abe55efSEd Tanous                             "xyz.openbmc_project.Inventory.Decorator.Asset");
4532c37b4b0SSharad Yadav 
454*308f70c7SWilly Tu                         for (const auto& interface : interfaces2)
4552c37b4b0SSharad Yadav                         {
456*308f70c7SWilly Tu                             if (interface == "xyz.openbmc_project.Common.UUID")
4572c37b4b0SSharad Yadav                             {
458*308f70c7SWilly Tu                                 getChassisUUID(asyncResp, connectionName, path);
4592c37b4b0SSharad Yadav                             }
460*308f70c7SWilly Tu                             else if (interface ==
461*308f70c7SWilly Tu                                      "xyz.openbmc_project.Inventory."
462*308f70c7SWilly Tu                                      "Decorator.LocationCode")
4632c37b4b0SSharad Yadav                             {
464*308f70c7SWilly Tu                                 getChassisLocationCode(asyncResp,
465*308f70c7SWilly Tu                                                        connectionName, path);
4662c37b4b0SSharad Yadav                             }
4672c37b4b0SSharad Yadav                         }
4682c37b4b0SSharad Yadav 
469daf36e2eSEd Tanous                         return;
470daf36e2eSEd Tanous                     }
471e0d918bcSEd Tanous 
472daf36e2eSEd Tanous                     // Couldn't find an object with that name.  return an error
473f12894f8SJason M. Bills                     messages::resourceNotFound(
4749f8bfa7cSGunnar Mills                         asyncResp->res, "#Chassis.v1_14_0.Chassis", chassisId);
475daf36e2eSEd Tanous                 },
476daf36e2eSEd Tanous                 "xyz.openbmc_project.ObjectMapper",
477daf36e2eSEd Tanous                 "/xyz/openbmc_project/object_mapper",
478daf36e2eSEd Tanous                 "xyz.openbmc_project.ObjectMapper", "GetSubTree",
479271584abSEd Tanous                 "/xyz/openbmc_project/inventory", 0, interfaces);
480c181942fSQiang XU 
481c181942fSQiang XU             getPhysicalSecurityData(asyncResp);
4827e860f15SJohn Edward Broadbent         });
4831c8fba97SJames Feist 
4847e860f15SJohn Edward Broadbent     BMCWEB_ROUTE(app, "/redfish/v1/Chassis/<str>/")
485ed398213SEd Tanous         .privileges(redfish::privileges::patchChassis)
4867e860f15SJohn Edward Broadbent         .methods(
4877e860f15SJohn Edward Broadbent             boost::beast::http::verb::
4887e860f15SJohn Edward Broadbent                 patch)([](const crow::Request& req,
4897e860f15SJohn Edward Broadbent                           const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
4907e860f15SJohn Edward Broadbent                           const std::string& param) {
4919f8bfa7cSGunnar Mills             std::optional<bool> locationIndicatorActive;
4921c8fba97SJames Feist             std::optional<std::string> indicatorLed;
4931c8fba97SJames Feist 
4947e860f15SJohn Edward Broadbent             if (param.empty())
4951c8fba97SJames Feist             {
4961c8fba97SJames Feist                 return;
4971c8fba97SJames Feist             }
4981c8fba97SJames Feist 
4997e860f15SJohn Edward Broadbent             if (!json_util::readJson(
5007e860f15SJohn Edward Broadbent                     req, asyncResp->res, "LocationIndicatorActive",
5017e860f15SJohn Edward Broadbent                     locationIndicatorActive, "IndicatorLED", indicatorLed))
5021c8fba97SJames Feist             {
5031c8fba97SJames Feist                 return;
5041c8fba97SJames Feist             }
5051c8fba97SJames Feist 
5069f8bfa7cSGunnar Mills             // TODO (Gunnar): Remove IndicatorLED after enough time has passed
5079f8bfa7cSGunnar Mills             if (!locationIndicatorActive && !indicatorLed)
5081c8fba97SJames Feist             {
5091c8fba97SJames Feist                 return; // delete this when we support more patch properties
5101c8fba97SJames Feist             }
511d6aa0093SGunnar Mills             if (indicatorLed)
512d6aa0093SGunnar Mills             {
5137e860f15SJohn Edward Broadbent                 asyncResp->res.addHeader(
5147e860f15SJohn Edward Broadbent                     boost::beast::http::field::warning,
515d6aa0093SGunnar Mills                     "299 - \"IndicatorLED is deprecated. Use "
516d6aa0093SGunnar Mills                     "LocationIndicatorActive instead.\"");
517d6aa0093SGunnar Mills             }
5181c8fba97SJames Feist 
5191c8fba97SJames Feist             const std::array<const char*, 2> interfaces = {
5201c8fba97SJames Feist                 "xyz.openbmc_project.Inventory.Item.Board",
5211c8fba97SJames Feist                 "xyz.openbmc_project.Inventory.Item.Chassis"};
5221c8fba97SJames Feist 
5237e860f15SJohn Edward Broadbent             const std::string& chassisId = param;
5241c8fba97SJames Feist 
5251c8fba97SJames Feist             crow::connections::systemBus->async_method_call(
5269f8bfa7cSGunnar Mills                 [asyncResp, chassisId, locationIndicatorActive, indicatorLed](
5271c8fba97SJames Feist                     const boost::system::error_code ec,
5281c8fba97SJames Feist                     const crow::openbmc_mapper::GetSubTreeType& subtree) {
5291c8fba97SJames Feist                     if (ec)
5301c8fba97SJames Feist                     {
5311c8fba97SJames Feist                         messages::internalError(asyncResp->res);
5321c8fba97SJames Feist                         return;
5331c8fba97SJames Feist                     }
5341c8fba97SJames Feist 
5351c8fba97SJames Feist                     // Iterate over all retrieved ObjectPaths.
5361c8fba97SJames Feist                     for (const std::pair<
5371c8fba97SJames Feist                              std::string,
5387e860f15SJohn Edward Broadbent                              std::vector<std::pair<std::string,
5397e860f15SJohn Edward Broadbent                                                    std::vector<std::string>>>>&
5401214b7e7SGunnar Mills                              object : subtree)
5411c8fba97SJames Feist                     {
5421c8fba97SJames Feist                         const std::string& path = object.first;
5431c8fba97SJames Feist                         const std::vector<
5441214b7e7SGunnar Mills                             std::pair<std::string, std::vector<std::string>>>&
5451214b7e7SGunnar Mills                             connectionNames = object.second;
5461c8fba97SJames Feist 
5471c8fba97SJames Feist                         if (!boost::ends_with(path, chassisId))
5481c8fba97SJames Feist                         {
5491c8fba97SJames Feist                             continue;
5501c8fba97SJames Feist                         }
5511c8fba97SJames Feist 
5521c8fba97SJames Feist                         if (connectionNames.size() < 1)
5531c8fba97SJames Feist                         {
5541c8fba97SJames Feist                             BMCWEB_LOG_ERROR << "Got 0 Connection names";
5551c8fba97SJames Feist                             continue;
5561c8fba97SJames Feist                         }
5571c8fba97SJames Feist 
55823a21a1cSEd Tanous                         const std::vector<std::string>& interfaces3 =
5591c8fba97SJames Feist                             connectionNames[0].second;
5601c8fba97SJames Feist 
5611c8fba97SJames Feist                         const std::array<const char*, 2> hasIndicatorLed = {
5621c8fba97SJames Feist                             "xyz.openbmc_project.Inventory.Item.Panel",
5631c8fba97SJames Feist                             "xyz.openbmc_project.Inventory.Item.Board."
5641c8fba97SJames Feist                             "Motherboard"};
5651c8fba97SJames Feist                         bool indicatorChassis = false;
5661c8fba97SJames Feist                         for (const char* interface : hasIndicatorLed)
5671c8fba97SJames Feist                         {
5687e860f15SJohn Edward Broadbent                             if (std::find(interfaces3.begin(),
5697e860f15SJohn Edward Broadbent                                           interfaces3.end(),
57023a21a1cSEd Tanous                                           interface) != interfaces3.end())
5711c8fba97SJames Feist                             {
5721c8fba97SJames Feist                                 indicatorChassis = true;
5731c8fba97SJames Feist                                 break;
5741c8fba97SJames Feist                             }
5751c8fba97SJames Feist                         }
5769f8bfa7cSGunnar Mills                         if (locationIndicatorActive)
5779f8bfa7cSGunnar Mills                         {
5789f8bfa7cSGunnar Mills                             if (indicatorChassis)
5799f8bfa7cSGunnar Mills                             {
5809f8bfa7cSGunnar Mills                                 setLocationIndicatorActive(
5819f8bfa7cSGunnar Mills                                     asyncResp, *locationIndicatorActive);
5829f8bfa7cSGunnar Mills                             }
5839f8bfa7cSGunnar Mills                             else
5849f8bfa7cSGunnar Mills                             {
5859f8bfa7cSGunnar Mills                                 messages::propertyUnknown(
5869f8bfa7cSGunnar Mills                                     asyncResp->res, "LocationIndicatorActive");
5879f8bfa7cSGunnar Mills                             }
5889f8bfa7cSGunnar Mills                         }
5899f8bfa7cSGunnar Mills                         if (indicatorLed)
5909f8bfa7cSGunnar Mills                         {
5911c8fba97SJames Feist                             if (indicatorChassis)
5921c8fba97SJames Feist                             {
593f23b7296SEd Tanous                                 setIndicatorLedState(asyncResp, *indicatorLed);
5941c8fba97SJames Feist                             }
5951c8fba97SJames Feist                             else
5961c8fba97SJames Feist                             {
5971c8fba97SJames Feist                                 messages::propertyUnknown(asyncResp->res,
5981c8fba97SJames Feist                                                           "IndicatorLED");
5991c8fba97SJames Feist                             }
6001c8fba97SJames Feist                         }
6011c8fba97SJames Feist                         return;
6021c8fba97SJames Feist                     }
6031c8fba97SJames Feist 
6041c8fba97SJames Feist                     messages::resourceNotFound(
6059f8bfa7cSGunnar Mills                         asyncResp->res, "#Chassis.v1_14_0.Chassis", chassisId);
6061c8fba97SJames Feist                 },
6071c8fba97SJames Feist                 "xyz.openbmc_project.ObjectMapper",
6081c8fba97SJames Feist                 "/xyz/openbmc_project/object_mapper",
6091c8fba97SJames Feist                 "xyz.openbmc_project.ObjectMapper", "GetSubTree",
6101c8fba97SJames Feist                 "/xyz/openbmc_project/inventory", 0, interfaces);
6117e860f15SJohn Edward Broadbent         });
6121c8fba97SJames Feist }
613dd99e04bSP.K. Lee 
6148d1b46d7Szhanghch05 inline void
6158d1b46d7Szhanghch05     doChassisPowerCycle(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
616dd99e04bSP.K. Lee {
617c3b3c92aSVijay Khemka     const char* busName = "xyz.openbmc_project.ObjectMapper";
618c3b3c92aSVijay Khemka     const char* path = "/xyz/openbmc_project/object_mapper";
619c3b3c92aSVijay Khemka     const char* interface = "xyz.openbmc_project.ObjectMapper";
620c3b3c92aSVijay Khemka     const char* method = "GetSubTreePaths";
621c3b3c92aSVijay Khemka 
622c3b3c92aSVijay Khemka     const std::array<const char*, 1> interfaces = {
623c3b3c92aSVijay Khemka         "xyz.openbmc_project.State.Chassis"};
624c3b3c92aSVijay Khemka 
625c3b3c92aSVijay Khemka     // Use mapper to get subtree paths.
626c3b3c92aSVijay Khemka     crow::connections::systemBus->async_method_call(
627c3b3c92aSVijay Khemka         [asyncResp](const boost::system::error_code ec,
628c3b3c92aSVijay Khemka                     const std::vector<std::string>& chassisList) {
629c3b3c92aSVijay Khemka             if (ec)
630c3b3c92aSVijay Khemka             {
631c3b3c92aSVijay Khemka                 BMCWEB_LOG_DEBUG << "[mapper] Bad D-Bus request error: " << ec;
632c3b3c92aSVijay Khemka                 messages::internalError(asyncResp->res);
633c3b3c92aSVijay Khemka                 return;
634c3b3c92aSVijay Khemka             }
635c3b3c92aSVijay Khemka 
636dd99e04bSP.K. Lee             const char* processName = "xyz.openbmc_project.State.Chassis";
637dd99e04bSP.K. Lee             const char* interfaceName = "xyz.openbmc_project.State.Chassis";
638dd99e04bSP.K. Lee             const char* destProperty = "RequestedPowerTransition";
639dd99e04bSP.K. Lee             const std::string propertyValue =
640dd99e04bSP.K. Lee                 "xyz.openbmc_project.State.Chassis.Transition.PowerCycle";
641c3b3c92aSVijay Khemka             std::string objectPath =
642c3b3c92aSVijay Khemka                 "/xyz/openbmc_project/state/chassis_system0";
643c3b3c92aSVijay Khemka 
644c3b3c92aSVijay Khemka             /* Look for system reset chassis path */
645c3b3c92aSVijay Khemka             if ((std::find(chassisList.begin(), chassisList.end(),
646c3b3c92aSVijay Khemka                            objectPath)) == chassisList.end())
647c3b3c92aSVijay Khemka             {
648c3b3c92aSVijay Khemka                 /* We prefer to reset the full chassis_system, but if it doesn't
649c3b3c92aSVijay Khemka                  * exist on some platforms, fall back to a host-only power reset
650c3b3c92aSVijay Khemka                  */
651c3b3c92aSVijay Khemka                 objectPath = "/xyz/openbmc_project/state/chassis0";
652c3b3c92aSVijay Khemka             }
653dd99e04bSP.K. Lee 
654dd99e04bSP.K. Lee             crow::connections::systemBus->async_method_call(
655dd99e04bSP.K. Lee                 [asyncResp](const boost::system::error_code ec) {
656dd99e04bSP.K. Lee                     // Use "Set" method to set the property value.
657dd99e04bSP.K. Lee                     if (ec)
658dd99e04bSP.K. Lee                     {
659c3b3c92aSVijay Khemka                         BMCWEB_LOG_DEBUG << "[Set] Bad D-Bus request error: "
660c3b3c92aSVijay Khemka                                          << ec;
661dd99e04bSP.K. Lee                         messages::internalError(asyncResp->res);
662dd99e04bSP.K. Lee                         return;
663dd99e04bSP.K. Lee                     }
664dd99e04bSP.K. Lee 
665dd99e04bSP.K. Lee                     messages::success(asyncResp->res);
666dd99e04bSP.K. Lee                 },
667c3b3c92aSVijay Khemka                 processName, objectPath, "org.freedesktop.DBus.Properties",
668c3b3c92aSVijay Khemka                 "Set", interfaceName, destProperty,
669c3b3c92aSVijay Khemka                 std::variant<std::string>{propertyValue});
670c3b3c92aSVijay Khemka         },
671c3b3c92aSVijay Khemka         busName, path, interface, method, "/", 0, interfaces);
672dd99e04bSP.K. Lee }
673dd99e04bSP.K. Lee 
674dd99e04bSP.K. Lee /**
675dd99e04bSP.K. Lee  * ChassisResetAction class supports the POST method for the Reset
676dd99e04bSP.K. Lee  * action.
677dd99e04bSP.K. Lee  * Function handles POST method request.
678dd99e04bSP.K. Lee  * Analyzes POST body before sending Reset request data to D-Bus.
679dd99e04bSP.K. Lee  */
6807e860f15SJohn Edward Broadbent 
6817e860f15SJohn Edward Broadbent inline void requestRoutesChassisResetAction(App& app)
682dd99e04bSP.K. Lee {
6837e860f15SJohn Edward Broadbent     BMCWEB_ROUTE(app, "/redfish/v1/Chassis/<str>/Actions/Chassis.Reset/")
684ed398213SEd Tanous         .privileges(redfish::privileges::postChassis)
6857e860f15SJohn Edward Broadbent         .methods(boost::beast::http::verb::post)(
6867e860f15SJohn Edward Broadbent             [](const crow::Request& req,
6877e860f15SJohn Edward Broadbent                const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
6887e860f15SJohn Edward Broadbent                const std::string&) {
689dd99e04bSP.K. Lee                 BMCWEB_LOG_DEBUG << "Post Chassis Reset.";
690dd99e04bSP.K. Lee 
691dd99e04bSP.K. Lee                 std::string resetType;
692dd99e04bSP.K. Lee 
6937e860f15SJohn Edward Broadbent                 if (!json_util::readJson(req, asyncResp->res, "ResetType",
6947e860f15SJohn Edward Broadbent                                          resetType))
695dd99e04bSP.K. Lee                 {
696dd99e04bSP.K. Lee                     return;
697dd99e04bSP.K. Lee                 }
698dd99e04bSP.K. Lee 
699dd99e04bSP.K. Lee                 if (resetType != "PowerCycle")
700dd99e04bSP.K. Lee                 {
701dd99e04bSP.K. Lee                     BMCWEB_LOG_DEBUG << "Invalid property value for ResetType: "
702dd99e04bSP.K. Lee                                      << resetType;
7037e860f15SJohn Edward Broadbent                     messages::actionParameterNotSupported(
7047e860f15SJohn Edward Broadbent                         asyncResp->res, resetType, "ResetType");
705dd99e04bSP.K. Lee 
706dd99e04bSP.K. Lee                     return;
707dd99e04bSP.K. Lee                 }
708dd99e04bSP.K. Lee                 doChassisPowerCycle(asyncResp);
7097e860f15SJohn Edward Broadbent             });
710dd99e04bSP.K. Lee }
7111cb1a9e6SAppaRao Puli 
7121cb1a9e6SAppaRao Puli /**
7131cb1a9e6SAppaRao Puli  * ChassisResetActionInfo derived class for delivering Chassis
7141cb1a9e6SAppaRao Puli  * ResetType AllowableValues using ResetInfo schema.
7151cb1a9e6SAppaRao Puli  */
7167e860f15SJohn Edward Broadbent inline void requestRoutesChassisResetActionInfo(App& app)
7171cb1a9e6SAppaRao Puli {
7187e860f15SJohn Edward Broadbent     BMCWEB_ROUTE(app, "/redfish/v1/Chassis/<str>/ResetActionInfo/")
719ed398213SEd Tanous         .privileges(redfish::privileges::getActionInfo)
7207e860f15SJohn Edward Broadbent         .methods(boost::beast::http::verb::get)(
7217e860f15SJohn Edward Broadbent             [](const crow::Request&,
7227e860f15SJohn Edward Broadbent                const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
7237e860f15SJohn Edward Broadbent                const std::string& chassisId)
7241cb1a9e6SAppaRao Puli 
7251cb1a9e6SAppaRao Puli             {
7268d1b46d7Szhanghch05                 asyncResp->res.jsonValue = {
7278d1b46d7Szhanghch05                     {"@odata.type", "#ActionInfo.v1_1_2.ActionInfo"},
7288d1b46d7Szhanghch05                     {"@odata.id",
7298d1b46d7Szhanghch05                      "/redfish/v1/Chassis/" + chassisId + "/ResetActionInfo"},
7301cb1a9e6SAppaRao Puli                     {"Name", "Reset Action Info"},
7311cb1a9e6SAppaRao Puli                     {"Id", "ResetActionInfo"},
7321cb1a9e6SAppaRao Puli                     {"Parameters",
7331cb1a9e6SAppaRao Puli                      {{{"Name", "ResetType"},
7341cb1a9e6SAppaRao Puli                        {"Required", true},
7351cb1a9e6SAppaRao Puli                        {"DataType", "String"},
7361cb1a9e6SAppaRao Puli                        {"AllowableValues", {"PowerCycle"}}}}}};
7377e860f15SJohn Edward Broadbent             });
7381cb1a9e6SAppaRao Puli }
7391cb1a9e6SAppaRao Puli 
740e37f8451SRapkiewicz, Pawel } // namespace redfish
741