xref: /openbmc/bmcweb/features/redfish/lib/chassis.hpp (revision 997093eb732dc889bd76f7aaa65e16a2aa4d7224)
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 
182308f70c7SWilly Tu inline void
183308f70c7SWilly Tu     getChassisLocationCode(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
184308f70c7SWilly Tu                            const std::string& connectionName,
185308f70c7SWilly Tu                            const std::string& path)
186308f70c7SWilly Tu {
187308f70c7SWilly Tu     crow::connections::systemBus->async_method_call(
188308f70c7SWilly Tu         [asyncResp](const boost::system::error_code ec,
189308f70c7SWilly Tu                     const std::variant<std::string>& property) {
190308f70c7SWilly Tu             if (ec)
191308f70c7SWilly Tu             {
192308f70c7SWilly Tu                 BMCWEB_LOG_DEBUG << "DBUS response error for "
193308f70c7SWilly Tu                                     "Location";
194308f70c7SWilly Tu                 messages::internalError(asyncResp->res);
195308f70c7SWilly Tu                 return;
196308f70c7SWilly Tu             }
197308f70c7SWilly Tu 
198308f70c7SWilly Tu             const std::string* value = std::get_if<std::string>(&property);
199308f70c7SWilly Tu             if (value == nullptr)
200308f70c7SWilly Tu             {
201308f70c7SWilly Tu                 BMCWEB_LOG_DEBUG << "Null value returned "
202308f70c7SWilly Tu                                     "for locaton code";
203308f70c7SWilly Tu                 messages::internalError(asyncResp->res);
204308f70c7SWilly Tu                 return;
205308f70c7SWilly Tu             }
206308f70c7SWilly Tu             asyncResp->res
207308f70c7SWilly Tu                 .jsonValue["Location"]["PartLocation"]["ServiceLabel"] = *value;
208308f70c7SWilly Tu         },
209308f70c7SWilly Tu         connectionName, path, "org.freedesktop.DBus.Properties", "Get",
210308f70c7SWilly Tu         "xyz.openbmc_project.Inventory.Decorator.LocationCode", "LocationCode");
211308f70c7SWilly Tu }
212308f70c7SWilly Tu 
213308f70c7SWilly Tu inline void getChassisUUID(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
214308f70c7SWilly Tu                            const std::string& connectionName,
215308f70c7SWilly Tu                            const std::string& path)
216308f70c7SWilly Tu {
217308f70c7SWilly Tu     crow::connections::systemBus->async_method_call(
218308f70c7SWilly Tu         [asyncResp](const boost::system::error_code ec,
219308f70c7SWilly Tu                     const std::variant<std::string>& chassisUUID) {
220308f70c7SWilly Tu             if (ec)
221308f70c7SWilly Tu             {
222308f70c7SWilly Tu                 BMCWEB_LOG_DEBUG << "DBUS response error for "
223308f70c7SWilly Tu                                     "UUID";
224308f70c7SWilly Tu                 messages::internalError(asyncResp->res);
225308f70c7SWilly Tu                 return;
226308f70c7SWilly Tu             }
227308f70c7SWilly Tu             const std::string* value = std::get_if<std::string>(&chassisUUID);
228308f70c7SWilly Tu             if (value == nullptr)
229308f70c7SWilly Tu             {
230308f70c7SWilly Tu                 BMCWEB_LOG_DEBUG << "Null value returned "
231308f70c7SWilly Tu                                     "for UUID";
232308f70c7SWilly Tu                 messages::internalError(asyncResp->res);
233308f70c7SWilly Tu                 return;
234308f70c7SWilly Tu             }
235308f70c7SWilly Tu             asyncResp->res.jsonValue["UUID"] = *value;
236308f70c7SWilly Tu         },
237308f70c7SWilly Tu         connectionName, path, "org.freedesktop.DBus.Properties", "Get",
238308f70c7SWilly Tu         "xyz.openbmc_project.Common.UUID", "UUID");
239308f70c7SWilly Tu }
240308f70c7SWilly 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 
279*997093ebSGeorge Liu                         sdbusplus::message::object_path objPath(path);
280*997093ebSGeorge Liu                         if (objPath.filename() != chassisId)
2811abe55efSEd Tanous                         {
282daf36e2eSEd Tanous                             continue;
283daf36e2eSEd Tanous                         }
28426f03899SShawn McCarney 
2857e860f15SJohn Edward Broadbent                         auto health =
2867e860f15SJohn Edward Broadbent                             std::make_shared<HealthPopulate>(asyncResp);
287b49ac873SJames Feist 
288b49ac873SJames Feist                         crow::connections::systemBus->async_method_call(
2897e860f15SJohn Edward Broadbent                             [health](
2907e860f15SJohn Edward Broadbent                                 const boost::system::error_code ec2,
291b49ac873SJames Feist                                 std::variant<std::vector<std::string>>& resp) {
29223a21a1cSEd Tanous                                 if (ec2)
293b49ac873SJames Feist                                 {
294b49ac873SJames Feist                                     return; // no sensors = no failures
295b49ac873SJames Feist                                 }
296b49ac873SJames Feist                                 std::vector<std::string>* data =
2977e860f15SJohn Edward Broadbent                                     std::get_if<std::vector<std::string>>(
2987e860f15SJohn Edward Broadbent                                         &resp);
299b49ac873SJames Feist                                 if (data == nullptr)
300b49ac873SJames Feist                                 {
301b49ac873SJames Feist                                     return;
302b49ac873SJames Feist                                 }
303b49ac873SJames Feist                                 health->inventory = std::move(*data);
304b49ac873SJames Feist                             },
305b49ac873SJames Feist                             "xyz.openbmc_project.ObjectMapper",
306b49ac873SJames Feist                             path + "/all_sensors",
307b49ac873SJames Feist                             "org.freedesktop.DBus.Properties", "Get",
308b49ac873SJames Feist                             "xyz.openbmc_project.Association", "endpoints");
309b49ac873SJames Feist 
310b49ac873SJames Feist                         health->populate();
311b49ac873SJames Feist 
3121abe55efSEd Tanous                         if (connectionNames.size() < 1)
3131abe55efSEd Tanous                         {
3141c8fba97SJames Feist                             BMCWEB_LOG_ERROR << "Got 0 Connection names";
315e0d918bcSEd Tanous                             continue;
316daf36e2eSEd Tanous                         }
317e0d918bcSEd Tanous 
31849c53ac9SJohnathan Mantey                         asyncResp->res.jsonValue["@odata.type"] =
3199f8bfa7cSGunnar Mills                             "#Chassis.v1_14_0.Chassis";
32049c53ac9SJohnathan Mantey                         asyncResp->res.jsonValue["@odata.id"] =
32149c53ac9SJohnathan Mantey                             "/redfish/v1/Chassis/" + chassisId;
32249c53ac9SJohnathan Mantey                         asyncResp->res.jsonValue["Name"] = "Chassis Collection";
32349c53ac9SJohnathan Mantey                         asyncResp->res.jsonValue["ChassisType"] = "RackMount";
3247e860f15SJohn Edward Broadbent                         asyncResp->res.jsonValue["Actions"]["#Chassis.Reset"] =
3257e860f15SJohn Edward Broadbent                             {{"target", "/redfish/v1/Chassis/" + chassisId +
326dd99e04bSP.K. Lee                                             "/Actions/Chassis.Reset"},
3271cb1a9e6SAppaRao Puli                              {"@Redfish.ActionInfo", "/redfish/v1/Chassis/" +
3281cb1a9e6SAppaRao Puli                                                          chassisId +
3291cb1a9e6SAppaRao Puli                                                          "/ResetActionInfo"}};
330adbe192aSJason M. Bills                         asyncResp->res.jsonValue["PCIeDevices"] = {
331adbe192aSJason M. Bills                             {"@odata.id",
332adbe192aSJason M. Bills                              "/redfish/v1/Systems/system/PCIeDevices"}};
33349c53ac9SJohnathan Mantey 
33449c53ac9SJohnathan Mantey                         const std::string& connectionName =
33549c53ac9SJohnathan Mantey                             connectionNames[0].first;
3361c8fba97SJames Feist 
33723a21a1cSEd Tanous                         const std::vector<std::string>& interfaces2 =
3381c8fba97SJames Feist                             connectionNames[0].second;
3391c8fba97SJames Feist                         const std::array<const char*, 2> hasIndicatorLed = {
3401c8fba97SJames Feist                             "xyz.openbmc_project.Inventory.Item.Panel",
3417e860f15SJohn Edward Broadbent                             "xyz.openbmc_project.Inventory.Item.Board."
3427e860f15SJohn Edward Broadbent                             "Motherboard"};
3431c8fba97SJames Feist 
344476b9cc5STejas Patil                         const std::string assetTagInterface =
345476b9cc5STejas Patil                             "xyz.openbmc_project.Inventory.Decorator."
346476b9cc5STejas Patil                             "AssetTag";
347476b9cc5STejas Patil                         if (std::find(interfaces2.begin(), interfaces2.end(),
348476b9cc5STejas Patil                                       assetTagInterface) != interfaces2.end())
349476b9cc5STejas Patil                         {
350476b9cc5STejas Patil                             crow::connections::systemBus->async_method_call(
351476b9cc5STejas Patil                                 [asyncResp, chassisId(std::string(chassisId))](
352476b9cc5STejas Patil                                     const boost::system::error_code ec,
353476b9cc5STejas Patil                                     const std::variant<std::string>& property) {
354476b9cc5STejas Patil                                     if (ec)
355476b9cc5STejas Patil                                     {
356476b9cc5STejas Patil                                         BMCWEB_LOG_DEBUG
357476b9cc5STejas Patil                                             << "DBus response error for "
358476b9cc5STejas Patil                                                "AssetTag";
359476b9cc5STejas Patil                                         messages::internalError(asyncResp->res);
360476b9cc5STejas Patil                                         return;
361476b9cc5STejas Patil                                     }
362476b9cc5STejas Patil 
363476b9cc5STejas Patil                                     const std::string* assetTag =
364476b9cc5STejas Patil                                         std::get_if<std::string>(&property);
365476b9cc5STejas Patil                                     if (assetTag == nullptr)
366476b9cc5STejas Patil                                     {
367476b9cc5STejas Patil                                         BMCWEB_LOG_DEBUG
368476b9cc5STejas Patil                                             << "Null value returned "
369476b9cc5STejas Patil                                                "for Chassis AssetTag";
370476b9cc5STejas Patil                                         messages::internalError(asyncResp->res);
371476b9cc5STejas Patil                                         return;
372476b9cc5STejas Patil                                     }
373476b9cc5STejas Patil                                     asyncResp->res.jsonValue["AssetTag"] =
374476b9cc5STejas Patil                                         *assetTag;
375476b9cc5STejas Patil                                 },
376476b9cc5STejas Patil                                 connectionName, path,
377476b9cc5STejas Patil                                 "org.freedesktop.DBus.Properties", "Get",
378476b9cc5STejas Patil                                 assetTagInterface, "AssetTag");
379476b9cc5STejas Patil                         }
380476b9cc5STejas Patil 
3811c8fba97SJames Feist                         for (const char* interface : hasIndicatorLed)
3821c8fba97SJames Feist                         {
3837e860f15SJohn Edward Broadbent                             if (std::find(interfaces2.begin(),
3847e860f15SJohn Edward Broadbent                                           interfaces2.end(),
38523a21a1cSEd Tanous                                           interface) != interfaces2.end())
3861c8fba97SJames Feist                             {
3871c8fba97SJames Feist                                 getIndicatorLedState(asyncResp);
3889f8bfa7cSGunnar Mills                                 getLocationIndicatorActive(asyncResp);
3891c8fba97SJames Feist                                 break;
3901c8fba97SJames Feist                             }
3911c8fba97SJames Feist                         }
3921c8fba97SJames Feist 
39355c7b7a2SEd Tanous                         crow::connections::systemBus->async_method_call(
39462d5e2e4SEd Tanous                             [asyncResp, chassisId(std::string(chassisId))](
39590728b54SEd Tanous                                 const boost::system::error_code /*ec2*/,
3967e860f15SJohn Edward Broadbent                                 const std::vector<
3977e860f15SJohn Edward Broadbent                                     std::pair<std::string, VariantType>>&
3987e860f15SJohn Edward Broadbent                                     propertiesList) {
3991214b7e7SGunnar Mills                                 for (const std::pair<std::string, VariantType>&
4001214b7e7SGunnar Mills                                          property : propertiesList)
4011abe55efSEd Tanous                                 {
4027e860f15SJohn Edward Broadbent                                     // Store DBus properties that are also
4037e860f15SJohn Edward Broadbent                                     // Redfish properties with same name and a
4047e860f15SJohn Edward Broadbent                                     // string value
40599cffd7fSShawn McCarney                                     const std::string& propertyName =
40699cffd7fSShawn McCarney                                         property.first;
40799cffd7fSShawn McCarney                                     if ((propertyName == "PartNumber") ||
40899cffd7fSShawn McCarney                                         (propertyName == "SerialNumber") ||
40999cffd7fSShawn McCarney                                         (propertyName == "Manufacturer") ||
41099cffd7fSShawn McCarney                                         (propertyName == "Model"))
41199cffd7fSShawn McCarney                                     {
412daf36e2eSEd Tanous                                         const std::string* value =
41399cffd7fSShawn McCarney                                             std::get_if<std::string>(
41499cffd7fSShawn McCarney                                                 &property.second);
4151abe55efSEd Tanous                                         if (value != nullptr)
4161abe55efSEd Tanous                                         {
4177e860f15SJohn Edward Broadbent                                             asyncResp->res
4187e860f15SJohn Edward Broadbent                                                 .jsonValue[propertyName] =
41962d5e2e4SEd Tanous                                                 *value;
420daf36e2eSEd Tanous                                         }
421daf36e2eSEd Tanous                                     }
42299cffd7fSShawn McCarney                                 }
42362d5e2e4SEd Tanous                                 asyncResp->res.jsonValue["Name"] = chassisId;
42462d5e2e4SEd Tanous                                 asyncResp->res.jsonValue["Id"] = chassisId;
4250256b694Szhanghch05 #ifdef BMCWEB_ALLOW_DEPRECATED_POWER_THERMAL
42662d5e2e4SEd Tanous                                 asyncResp->res.jsonValue["Thermal"] = {
4271abe55efSEd Tanous                                     {"@odata.id", "/redfish/v1/Chassis/" +
4281abe55efSEd Tanous                                                       chassisId + "/Thermal"}};
4292474adfaSEd Tanous                                 // Power object
4302474adfaSEd Tanous                                 asyncResp->res.jsonValue["Power"] = {
4312474adfaSEd Tanous                                     {"@odata.id", "/redfish/v1/Chassis/" +
4322474adfaSEd Tanous                                                       chassisId + "/Power"}};
4330256b694Szhanghch05 #endif
43495a3ecadSAnthony Wilson                                 // SensorCollection
43595a3ecadSAnthony Wilson                                 asyncResp->res.jsonValue["Sensors"] = {
43695a3ecadSAnthony Wilson                                     {"@odata.id", "/redfish/v1/Chassis/" +
43795a3ecadSAnthony Wilson                                                       chassisId + "/Sensors"}};
438029573d4SEd Tanous                                 asyncResp->res.jsonValue["Status"] = {
439029573d4SEd Tanous                                     {"State", "Enabled"},
440029573d4SEd Tanous                                 };
4412474adfaSEd Tanous 
442029573d4SEd Tanous                                 asyncResp->res
443029573d4SEd Tanous                                     .jsonValue["Links"]["ComputerSystems"] = {
4447e860f15SJohn Edward Broadbent                                     {{"@odata.id",
4457e860f15SJohn Edward Broadbent                                       "/redfish/v1/Systems/system"}}};
4467e860f15SJohn Edward Broadbent                                 asyncResp->res.jsonValue["Links"]["ManagedBy"] =
4477e860f15SJohn Edward Broadbent                                     {{{"@odata.id",
4487e860f15SJohn Edward Broadbent                                        "/redfish/v1/Managers/bmc"}}};
449beeca0aeSGunnar Mills                                 getChassisState(asyncResp);
450daf36e2eSEd Tanous                             },
4517e860f15SJohn Edward Broadbent                             connectionName, path,
4527e860f15SJohn Edward Broadbent                             "org.freedesktop.DBus.Properties", "GetAll",
4531abe55efSEd Tanous                             "xyz.openbmc_project.Inventory.Decorator.Asset");
4542c37b4b0SSharad Yadav 
455308f70c7SWilly Tu                         for (const auto& interface : interfaces2)
4562c37b4b0SSharad Yadav                         {
457308f70c7SWilly Tu                             if (interface == "xyz.openbmc_project.Common.UUID")
4582c37b4b0SSharad Yadav                             {
459308f70c7SWilly Tu                                 getChassisUUID(asyncResp, connectionName, path);
4602c37b4b0SSharad Yadav                             }
461308f70c7SWilly Tu                             else if (interface ==
462308f70c7SWilly Tu                                      "xyz.openbmc_project.Inventory."
463308f70c7SWilly Tu                                      "Decorator.LocationCode")
4642c37b4b0SSharad Yadav                             {
465308f70c7SWilly Tu                                 getChassisLocationCode(asyncResp,
466308f70c7SWilly Tu                                                        connectionName, path);
4672c37b4b0SSharad Yadav                             }
4682c37b4b0SSharad Yadav                         }
4692c37b4b0SSharad Yadav 
470daf36e2eSEd Tanous                         return;
471daf36e2eSEd Tanous                     }
472e0d918bcSEd Tanous 
473daf36e2eSEd Tanous                     // Couldn't find an object with that name.  return an error
474f12894f8SJason M. Bills                     messages::resourceNotFound(
4759f8bfa7cSGunnar Mills                         asyncResp->res, "#Chassis.v1_14_0.Chassis", chassisId);
476daf36e2eSEd Tanous                 },
477daf36e2eSEd Tanous                 "xyz.openbmc_project.ObjectMapper",
478daf36e2eSEd Tanous                 "/xyz/openbmc_project/object_mapper",
479daf36e2eSEd Tanous                 "xyz.openbmc_project.ObjectMapper", "GetSubTree",
480271584abSEd Tanous                 "/xyz/openbmc_project/inventory", 0, interfaces);
481c181942fSQiang XU 
482c181942fSQiang XU             getPhysicalSecurityData(asyncResp);
4837e860f15SJohn Edward Broadbent         });
4841c8fba97SJames Feist 
4857e860f15SJohn Edward Broadbent     BMCWEB_ROUTE(app, "/redfish/v1/Chassis/<str>/")
486ed398213SEd Tanous         .privileges(redfish::privileges::patchChassis)
4877e860f15SJohn Edward Broadbent         .methods(
4887e860f15SJohn Edward Broadbent             boost::beast::http::verb::
4897e860f15SJohn Edward Broadbent                 patch)([](const crow::Request& req,
4907e860f15SJohn Edward Broadbent                           const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
4917e860f15SJohn Edward Broadbent                           const std::string& param) {
4929f8bfa7cSGunnar Mills             std::optional<bool> locationIndicatorActive;
4931c8fba97SJames Feist             std::optional<std::string> indicatorLed;
4941c8fba97SJames Feist 
4957e860f15SJohn Edward Broadbent             if (param.empty())
4961c8fba97SJames Feist             {
4971c8fba97SJames Feist                 return;
4981c8fba97SJames Feist             }
4991c8fba97SJames Feist 
5007e860f15SJohn Edward Broadbent             if (!json_util::readJson(
5017e860f15SJohn Edward Broadbent                     req, asyncResp->res, "LocationIndicatorActive",
5027e860f15SJohn Edward Broadbent                     locationIndicatorActive, "IndicatorLED", indicatorLed))
5031c8fba97SJames Feist             {
5041c8fba97SJames Feist                 return;
5051c8fba97SJames Feist             }
5061c8fba97SJames Feist 
5079f8bfa7cSGunnar Mills             // TODO (Gunnar): Remove IndicatorLED after enough time has passed
5089f8bfa7cSGunnar Mills             if (!locationIndicatorActive && !indicatorLed)
5091c8fba97SJames Feist             {
5101c8fba97SJames Feist                 return; // delete this when we support more patch properties
5111c8fba97SJames Feist             }
512d6aa0093SGunnar Mills             if (indicatorLed)
513d6aa0093SGunnar Mills             {
5147e860f15SJohn Edward Broadbent                 asyncResp->res.addHeader(
5157e860f15SJohn Edward Broadbent                     boost::beast::http::field::warning,
516d6aa0093SGunnar Mills                     "299 - \"IndicatorLED is deprecated. Use "
517d6aa0093SGunnar Mills                     "LocationIndicatorActive instead.\"");
518d6aa0093SGunnar Mills             }
5191c8fba97SJames Feist 
5201c8fba97SJames Feist             const std::array<const char*, 2> interfaces = {
5211c8fba97SJames Feist                 "xyz.openbmc_project.Inventory.Item.Board",
5221c8fba97SJames Feist                 "xyz.openbmc_project.Inventory.Item.Chassis"};
5231c8fba97SJames Feist 
5247e860f15SJohn Edward Broadbent             const std::string& chassisId = param;
5251c8fba97SJames Feist 
5261c8fba97SJames Feist             crow::connections::systemBus->async_method_call(
5279f8bfa7cSGunnar Mills                 [asyncResp, chassisId, locationIndicatorActive, indicatorLed](
5281c8fba97SJames Feist                     const boost::system::error_code ec,
5291c8fba97SJames Feist                     const crow::openbmc_mapper::GetSubTreeType& subtree) {
5301c8fba97SJames Feist                     if (ec)
5311c8fba97SJames Feist                     {
5321c8fba97SJames Feist                         messages::internalError(asyncResp->res);
5331c8fba97SJames Feist                         return;
5341c8fba97SJames Feist                     }
5351c8fba97SJames Feist 
5361c8fba97SJames Feist                     // Iterate over all retrieved ObjectPaths.
5371c8fba97SJames Feist                     for (const std::pair<
5381c8fba97SJames Feist                              std::string,
5397e860f15SJohn Edward Broadbent                              std::vector<std::pair<std::string,
5407e860f15SJohn Edward Broadbent                                                    std::vector<std::string>>>>&
5411214b7e7SGunnar Mills                              object : subtree)
5421c8fba97SJames Feist                     {
5431c8fba97SJames Feist                         const std::string& path = object.first;
5441c8fba97SJames Feist                         const std::vector<
5451214b7e7SGunnar Mills                             std::pair<std::string, std::vector<std::string>>>&
5461214b7e7SGunnar Mills                             connectionNames = object.second;
5471c8fba97SJames Feist 
548*997093ebSGeorge Liu                         sdbusplus::message::object_path objPath(path);
549*997093ebSGeorge Liu                         if (objPath.filename() != chassisId)
5501c8fba97SJames Feist                         {
5511c8fba97SJames Feist                             continue;
5521c8fba97SJames Feist                         }
5531c8fba97SJames Feist 
5541c8fba97SJames Feist                         if (connectionNames.size() < 1)
5551c8fba97SJames Feist                         {
5561c8fba97SJames Feist                             BMCWEB_LOG_ERROR << "Got 0 Connection names";
5571c8fba97SJames Feist                             continue;
5581c8fba97SJames Feist                         }
5591c8fba97SJames Feist 
56023a21a1cSEd Tanous                         const std::vector<std::string>& interfaces3 =
5611c8fba97SJames Feist                             connectionNames[0].second;
5621c8fba97SJames Feist 
5631c8fba97SJames Feist                         const std::array<const char*, 2> hasIndicatorLed = {
5641c8fba97SJames Feist                             "xyz.openbmc_project.Inventory.Item.Panel",
5651c8fba97SJames Feist                             "xyz.openbmc_project.Inventory.Item.Board."
5661c8fba97SJames Feist                             "Motherboard"};
5671c8fba97SJames Feist                         bool indicatorChassis = false;
5681c8fba97SJames Feist                         for (const char* interface : hasIndicatorLed)
5691c8fba97SJames Feist                         {
5707e860f15SJohn Edward Broadbent                             if (std::find(interfaces3.begin(),
5717e860f15SJohn Edward Broadbent                                           interfaces3.end(),
57223a21a1cSEd Tanous                                           interface) != interfaces3.end())
5731c8fba97SJames Feist                             {
5741c8fba97SJames Feist                                 indicatorChassis = true;
5751c8fba97SJames Feist                                 break;
5761c8fba97SJames Feist                             }
5771c8fba97SJames Feist                         }
5789f8bfa7cSGunnar Mills                         if (locationIndicatorActive)
5799f8bfa7cSGunnar Mills                         {
5809f8bfa7cSGunnar Mills                             if (indicatorChassis)
5819f8bfa7cSGunnar Mills                             {
5829f8bfa7cSGunnar Mills                                 setLocationIndicatorActive(
5839f8bfa7cSGunnar Mills                                     asyncResp, *locationIndicatorActive);
5849f8bfa7cSGunnar Mills                             }
5859f8bfa7cSGunnar Mills                             else
5869f8bfa7cSGunnar Mills                             {
5879f8bfa7cSGunnar Mills                                 messages::propertyUnknown(
5889f8bfa7cSGunnar Mills                                     asyncResp->res, "LocationIndicatorActive");
5899f8bfa7cSGunnar Mills                             }
5909f8bfa7cSGunnar Mills                         }
5919f8bfa7cSGunnar Mills                         if (indicatorLed)
5929f8bfa7cSGunnar Mills                         {
5931c8fba97SJames Feist                             if (indicatorChassis)
5941c8fba97SJames Feist                             {
595f23b7296SEd Tanous                                 setIndicatorLedState(asyncResp, *indicatorLed);
5961c8fba97SJames Feist                             }
5971c8fba97SJames Feist                             else
5981c8fba97SJames Feist                             {
5991c8fba97SJames Feist                                 messages::propertyUnknown(asyncResp->res,
6001c8fba97SJames Feist                                                           "IndicatorLED");
6011c8fba97SJames Feist                             }
6021c8fba97SJames Feist                         }
6031c8fba97SJames Feist                         return;
6041c8fba97SJames Feist                     }
6051c8fba97SJames Feist 
6061c8fba97SJames Feist                     messages::resourceNotFound(
6079f8bfa7cSGunnar Mills                         asyncResp->res, "#Chassis.v1_14_0.Chassis", chassisId);
6081c8fba97SJames Feist                 },
6091c8fba97SJames Feist                 "xyz.openbmc_project.ObjectMapper",
6101c8fba97SJames Feist                 "/xyz/openbmc_project/object_mapper",
6111c8fba97SJames Feist                 "xyz.openbmc_project.ObjectMapper", "GetSubTree",
6121c8fba97SJames Feist                 "/xyz/openbmc_project/inventory", 0, interfaces);
6137e860f15SJohn Edward Broadbent         });
6141c8fba97SJames Feist }
615dd99e04bSP.K. Lee 
6168d1b46d7Szhanghch05 inline void
6178d1b46d7Szhanghch05     doChassisPowerCycle(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
618dd99e04bSP.K. Lee {
619c3b3c92aSVijay Khemka     const char* busName = "xyz.openbmc_project.ObjectMapper";
620c3b3c92aSVijay Khemka     const char* path = "/xyz/openbmc_project/object_mapper";
621c3b3c92aSVijay Khemka     const char* interface = "xyz.openbmc_project.ObjectMapper";
622c3b3c92aSVijay Khemka     const char* method = "GetSubTreePaths";
623c3b3c92aSVijay Khemka 
624c3b3c92aSVijay Khemka     const std::array<const char*, 1> interfaces = {
625c3b3c92aSVijay Khemka         "xyz.openbmc_project.State.Chassis"};
626c3b3c92aSVijay Khemka 
627c3b3c92aSVijay Khemka     // Use mapper to get subtree paths.
628c3b3c92aSVijay Khemka     crow::connections::systemBus->async_method_call(
629c3b3c92aSVijay Khemka         [asyncResp](const boost::system::error_code ec,
630c3b3c92aSVijay Khemka                     const std::vector<std::string>& chassisList) {
631c3b3c92aSVijay Khemka             if (ec)
632c3b3c92aSVijay Khemka             {
633c3b3c92aSVijay Khemka                 BMCWEB_LOG_DEBUG << "[mapper] Bad D-Bus request error: " << ec;
634c3b3c92aSVijay Khemka                 messages::internalError(asyncResp->res);
635c3b3c92aSVijay Khemka                 return;
636c3b3c92aSVijay Khemka             }
637c3b3c92aSVijay Khemka 
638dd99e04bSP.K. Lee             const char* processName = "xyz.openbmc_project.State.Chassis";
639dd99e04bSP.K. Lee             const char* interfaceName = "xyz.openbmc_project.State.Chassis";
640dd99e04bSP.K. Lee             const char* destProperty = "RequestedPowerTransition";
641dd99e04bSP.K. Lee             const std::string propertyValue =
642dd99e04bSP.K. Lee                 "xyz.openbmc_project.State.Chassis.Transition.PowerCycle";
643c3b3c92aSVijay Khemka             std::string objectPath =
644c3b3c92aSVijay Khemka                 "/xyz/openbmc_project/state/chassis_system0";
645c3b3c92aSVijay Khemka 
646c3b3c92aSVijay Khemka             /* Look for system reset chassis path */
647c3b3c92aSVijay Khemka             if ((std::find(chassisList.begin(), chassisList.end(),
648c3b3c92aSVijay Khemka                            objectPath)) == chassisList.end())
649c3b3c92aSVijay Khemka             {
650c3b3c92aSVijay Khemka                 /* We prefer to reset the full chassis_system, but if it doesn't
651c3b3c92aSVijay Khemka                  * exist on some platforms, fall back to a host-only power reset
652c3b3c92aSVijay Khemka                  */
653c3b3c92aSVijay Khemka                 objectPath = "/xyz/openbmc_project/state/chassis0";
654c3b3c92aSVijay Khemka             }
655dd99e04bSP.K. Lee 
656dd99e04bSP.K. Lee             crow::connections::systemBus->async_method_call(
657dd99e04bSP.K. Lee                 [asyncResp](const boost::system::error_code ec) {
658dd99e04bSP.K. Lee                     // Use "Set" method to set the property value.
659dd99e04bSP.K. Lee                     if (ec)
660dd99e04bSP.K. Lee                     {
661c3b3c92aSVijay Khemka                         BMCWEB_LOG_DEBUG << "[Set] Bad D-Bus request error: "
662c3b3c92aSVijay Khemka                                          << ec;
663dd99e04bSP.K. Lee                         messages::internalError(asyncResp->res);
664dd99e04bSP.K. Lee                         return;
665dd99e04bSP.K. Lee                     }
666dd99e04bSP.K. Lee 
667dd99e04bSP.K. Lee                     messages::success(asyncResp->res);
668dd99e04bSP.K. Lee                 },
669c3b3c92aSVijay Khemka                 processName, objectPath, "org.freedesktop.DBus.Properties",
670c3b3c92aSVijay Khemka                 "Set", interfaceName, destProperty,
671c3b3c92aSVijay Khemka                 std::variant<std::string>{propertyValue});
672c3b3c92aSVijay Khemka         },
673c3b3c92aSVijay Khemka         busName, path, interface, method, "/", 0, interfaces);
674dd99e04bSP.K. Lee }
675dd99e04bSP.K. Lee 
676dd99e04bSP.K. Lee /**
677dd99e04bSP.K. Lee  * ChassisResetAction class supports the POST method for the Reset
678dd99e04bSP.K. Lee  * action.
679dd99e04bSP.K. Lee  * Function handles POST method request.
680dd99e04bSP.K. Lee  * Analyzes POST body before sending Reset request data to D-Bus.
681dd99e04bSP.K. Lee  */
6827e860f15SJohn Edward Broadbent 
6837e860f15SJohn Edward Broadbent inline void requestRoutesChassisResetAction(App& app)
684dd99e04bSP.K. Lee {
6857e860f15SJohn Edward Broadbent     BMCWEB_ROUTE(app, "/redfish/v1/Chassis/<str>/Actions/Chassis.Reset/")
686ed398213SEd Tanous         .privileges(redfish::privileges::postChassis)
6877e860f15SJohn Edward Broadbent         .methods(boost::beast::http::verb::post)(
6887e860f15SJohn Edward Broadbent             [](const crow::Request& req,
6897e860f15SJohn Edward Broadbent                const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
6907e860f15SJohn Edward Broadbent                const std::string&) {
691dd99e04bSP.K. Lee                 BMCWEB_LOG_DEBUG << "Post Chassis Reset.";
692dd99e04bSP.K. Lee 
693dd99e04bSP.K. Lee                 std::string resetType;
694dd99e04bSP.K. Lee 
6957e860f15SJohn Edward Broadbent                 if (!json_util::readJson(req, asyncResp->res, "ResetType",
6967e860f15SJohn Edward Broadbent                                          resetType))
697dd99e04bSP.K. Lee                 {
698dd99e04bSP.K. Lee                     return;
699dd99e04bSP.K. Lee                 }
700dd99e04bSP.K. Lee 
701dd99e04bSP.K. Lee                 if (resetType != "PowerCycle")
702dd99e04bSP.K. Lee                 {
703dd99e04bSP.K. Lee                     BMCWEB_LOG_DEBUG << "Invalid property value for ResetType: "
704dd99e04bSP.K. Lee                                      << resetType;
7057e860f15SJohn Edward Broadbent                     messages::actionParameterNotSupported(
7067e860f15SJohn Edward Broadbent                         asyncResp->res, resetType, "ResetType");
707dd99e04bSP.K. Lee 
708dd99e04bSP.K. Lee                     return;
709dd99e04bSP.K. Lee                 }
710dd99e04bSP.K. Lee                 doChassisPowerCycle(asyncResp);
7117e860f15SJohn Edward Broadbent             });
712dd99e04bSP.K. Lee }
7131cb1a9e6SAppaRao Puli 
7141cb1a9e6SAppaRao Puli /**
7151cb1a9e6SAppaRao Puli  * ChassisResetActionInfo derived class for delivering Chassis
7161cb1a9e6SAppaRao Puli  * ResetType AllowableValues using ResetInfo schema.
7171cb1a9e6SAppaRao Puli  */
7187e860f15SJohn Edward Broadbent inline void requestRoutesChassisResetActionInfo(App& app)
7191cb1a9e6SAppaRao Puli {
7207e860f15SJohn Edward Broadbent     BMCWEB_ROUTE(app, "/redfish/v1/Chassis/<str>/ResetActionInfo/")
721ed398213SEd Tanous         .privileges(redfish::privileges::getActionInfo)
7227e860f15SJohn Edward Broadbent         .methods(boost::beast::http::verb::get)(
7237e860f15SJohn Edward Broadbent             [](const crow::Request&,
7247e860f15SJohn Edward Broadbent                const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
7257e860f15SJohn Edward Broadbent                const std::string& chassisId)
7261cb1a9e6SAppaRao Puli 
7271cb1a9e6SAppaRao Puli             {
7288d1b46d7Szhanghch05                 asyncResp->res.jsonValue = {
7298d1b46d7Szhanghch05                     {"@odata.type", "#ActionInfo.v1_1_2.ActionInfo"},
7308d1b46d7Szhanghch05                     {"@odata.id",
7318d1b46d7Szhanghch05                      "/redfish/v1/Chassis/" + chassisId + "/ResetActionInfo"},
7321cb1a9e6SAppaRao Puli                     {"Name", "Reset Action Info"},
7331cb1a9e6SAppaRao Puli                     {"Id", "ResetActionInfo"},
7341cb1a9e6SAppaRao Puli                     {"Parameters",
7351cb1a9e6SAppaRao Puli                      {{{"Name", "ResetType"},
7361cb1a9e6SAppaRao Puli                        {"Required", true},
7371cb1a9e6SAppaRao Puli                        {"DataType", "String"},
7381cb1a9e6SAppaRao Puli                        {"AllowableValues", {"PowerCycle"}}}}}};
7397e860f15SJohn Edward Broadbent             });
7401cb1a9e6SAppaRao Puli }
7411cb1a9e6SAppaRao Puli 
742e37f8451SRapkiewicz, Pawel } // namespace redfish
743