xref: /openbmc/bmcweb/features/redfish/lib/chassis.hpp (revision caa11f7a5dfe2a47b686362468decaeff2339be2)
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             {
1920fda0f12SGeorge Liu                 BMCWEB_LOG_DEBUG << "DBUS response error for Location";
193308f70c7SWilly Tu                 messages::internalError(asyncResp->res);
194308f70c7SWilly Tu                 return;
195308f70c7SWilly Tu             }
196308f70c7SWilly Tu 
197308f70c7SWilly Tu             const std::string* value = std::get_if<std::string>(&property);
198308f70c7SWilly Tu             if (value == nullptr)
199308f70c7SWilly Tu             {
2000fda0f12SGeorge Liu                 BMCWEB_LOG_DEBUG << "Null value returned for locaton code";
201308f70c7SWilly Tu                 messages::internalError(asyncResp->res);
202308f70c7SWilly Tu                 return;
203308f70c7SWilly Tu             }
204308f70c7SWilly Tu             asyncResp->res
205308f70c7SWilly Tu                 .jsonValue["Location"]["PartLocation"]["ServiceLabel"] = *value;
206308f70c7SWilly Tu         },
207308f70c7SWilly Tu         connectionName, path, "org.freedesktop.DBus.Properties", "Get",
208308f70c7SWilly Tu         "xyz.openbmc_project.Inventory.Decorator.LocationCode", "LocationCode");
209308f70c7SWilly Tu }
210308f70c7SWilly Tu 
211308f70c7SWilly Tu inline void getChassisUUID(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
212308f70c7SWilly Tu                            const std::string& connectionName,
213308f70c7SWilly Tu                            const std::string& path)
214308f70c7SWilly Tu {
215308f70c7SWilly Tu     crow::connections::systemBus->async_method_call(
216308f70c7SWilly Tu         [asyncResp](const boost::system::error_code ec,
217308f70c7SWilly Tu                     const std::variant<std::string>& chassisUUID) {
218308f70c7SWilly Tu             if (ec)
219308f70c7SWilly Tu             {
2200fda0f12SGeorge Liu                 BMCWEB_LOG_DEBUG << "DBUS response error for UUID";
221308f70c7SWilly Tu                 messages::internalError(asyncResp->res);
222308f70c7SWilly Tu                 return;
223308f70c7SWilly Tu             }
224308f70c7SWilly Tu             const std::string* value = std::get_if<std::string>(&chassisUUID);
225308f70c7SWilly Tu             if (value == nullptr)
226308f70c7SWilly Tu             {
2270fda0f12SGeorge Liu                 BMCWEB_LOG_DEBUG << "Null value returned for UUID";
228308f70c7SWilly Tu                 messages::internalError(asyncResp->res);
229308f70c7SWilly Tu                 return;
230308f70c7SWilly Tu             }
231308f70c7SWilly Tu             asyncResp->res.jsonValue["UUID"] = *value;
232308f70c7SWilly Tu         },
233308f70c7SWilly Tu         connectionName, path, "org.freedesktop.DBus.Properties", "Get",
234308f70c7SWilly Tu         "xyz.openbmc_project.Common.UUID", "UUID");
235308f70c7SWilly Tu }
236308f70c7SWilly Tu 
237e37f8451SRapkiewicz, Pawel /**
238e37f8451SRapkiewicz, Pawel  * Chassis override class for delivering Chassis Schema
239e37f8451SRapkiewicz, Pawel  * Functions triggers appropriate requests on DBus
240e37f8451SRapkiewicz, Pawel  */
2417e860f15SJohn Edward Broadbent inline void requestRoutesChassis(App& app)
2421abe55efSEd Tanous {
2437e860f15SJohn Edward Broadbent     BMCWEB_ROUTE(app, "/redfish/v1/Chassis/<str>/")
244ed398213SEd Tanous         .privileges(redfish::privileges::getChassis)
2457e860f15SJohn Edward Broadbent         .methods(
2467e860f15SJohn Edward Broadbent             boost::beast::http::verb::get)([](const crow::Request&,
2477e860f15SJohn Edward Broadbent                                               const std::shared_ptr<
2487e860f15SJohn Edward Broadbent                                                   bmcweb::AsyncResp>& asyncResp,
2497e860f15SJohn Edward Broadbent                                               const std::string& chassisId) {
250adc4f0dbSShawn McCarney             const std::array<const char*, 2> interfaces = {
251734bfe90SGunnar Mills                 "xyz.openbmc_project.Inventory.Item.Board",
252adc4f0dbSShawn McCarney                 "xyz.openbmc_project.Inventory.Item.Chassis"};
253734bfe90SGunnar Mills 
25455c7b7a2SEd Tanous             crow::connections::systemBus->async_method_call(
25562d5e2e4SEd Tanous                 [asyncResp, chassisId(std::string(chassisId))](
25662d5e2e4SEd Tanous                     const boost::system::error_code ec,
2571c8fba97SJames Feist                     const crow::openbmc_mapper::GetSubTreeType& subtree) {
25862d5e2e4SEd Tanous                     if (ec)
2591abe55efSEd Tanous                     {
260f12894f8SJason M. Bills                         messages::internalError(asyncResp->res);
261daf36e2eSEd Tanous                         return;
262daf36e2eSEd Tanous                     }
263daf36e2eSEd Tanous                     // Iterate over all retrieved ObjectPaths.
2641abe55efSEd Tanous                     for (const std::pair<
2651abe55efSEd Tanous                              std::string,
2667e860f15SJohn Edward Broadbent                              std::vector<std::pair<std::string,
2677e860f15SJohn Edward Broadbent                                                    std::vector<std::string>>>>&
2681214b7e7SGunnar Mills                              object : subtree)
2691abe55efSEd Tanous                     {
270daf36e2eSEd Tanous                         const std::string& path = object.first;
2711abe55efSEd Tanous                         const std::vector<
2721214b7e7SGunnar Mills                             std::pair<std::string, std::vector<std::string>>>&
2731214b7e7SGunnar Mills                             connectionNames = object.second;
2747e860f15SJohn Edward Broadbent 
275997093ebSGeorge Liu                         sdbusplus::message::object_path objPath(path);
276997093ebSGeorge Liu                         if (objPath.filename() != chassisId)
2771abe55efSEd Tanous                         {
278daf36e2eSEd Tanous                             continue;
279daf36e2eSEd Tanous                         }
28026f03899SShawn McCarney 
2817e860f15SJohn Edward Broadbent                         auto health =
2827e860f15SJohn Edward Broadbent                             std::make_shared<HealthPopulate>(asyncResp);
283b49ac873SJames Feist 
284b49ac873SJames Feist                         crow::connections::systemBus->async_method_call(
2857e860f15SJohn Edward Broadbent                             [health](
2867e860f15SJohn Edward Broadbent                                 const boost::system::error_code ec2,
287b49ac873SJames Feist                                 std::variant<std::vector<std::string>>& resp) {
28823a21a1cSEd Tanous                                 if (ec2)
289b49ac873SJames Feist                                 {
290b49ac873SJames Feist                                     return; // no sensors = no failures
291b49ac873SJames Feist                                 }
292b49ac873SJames Feist                                 std::vector<std::string>* data =
2937e860f15SJohn Edward Broadbent                                     std::get_if<std::vector<std::string>>(
2947e860f15SJohn Edward Broadbent                                         &resp);
295b49ac873SJames Feist                                 if (data == nullptr)
296b49ac873SJames Feist                                 {
297b49ac873SJames Feist                                     return;
298b49ac873SJames Feist                                 }
299b49ac873SJames Feist                                 health->inventory = std::move(*data);
300b49ac873SJames Feist                             },
301b49ac873SJames Feist                             "xyz.openbmc_project.ObjectMapper",
302b49ac873SJames Feist                             path + "/all_sensors",
303b49ac873SJames Feist                             "org.freedesktop.DBus.Properties", "Get",
304b49ac873SJames Feist                             "xyz.openbmc_project.Association", "endpoints");
305b49ac873SJames Feist 
306b49ac873SJames Feist                         health->populate();
307b49ac873SJames Feist 
3081abe55efSEd Tanous                         if (connectionNames.size() < 1)
3091abe55efSEd Tanous                         {
3101c8fba97SJames Feist                             BMCWEB_LOG_ERROR << "Got 0 Connection names";
311e0d918bcSEd Tanous                             continue;
312daf36e2eSEd Tanous                         }
313e0d918bcSEd Tanous 
31449c53ac9SJohnathan Mantey                         asyncResp->res.jsonValue["@odata.type"] =
3159f8bfa7cSGunnar Mills                             "#Chassis.v1_14_0.Chassis";
31649c53ac9SJohnathan Mantey                         asyncResp->res.jsonValue["@odata.id"] =
31749c53ac9SJohnathan Mantey                             "/redfish/v1/Chassis/" + chassisId;
31849c53ac9SJohnathan Mantey                         asyncResp->res.jsonValue["Name"] = "Chassis Collection";
31949c53ac9SJohnathan Mantey                         asyncResp->res.jsonValue["ChassisType"] = "RackMount";
3207e860f15SJohn Edward Broadbent                         asyncResp->res.jsonValue["Actions"]["#Chassis.Reset"] =
3217e860f15SJohn Edward Broadbent                             {{"target", "/redfish/v1/Chassis/" + chassisId +
322dd99e04bSP.K. Lee                                             "/Actions/Chassis.Reset"},
3231cb1a9e6SAppaRao Puli                              {"@Redfish.ActionInfo", "/redfish/v1/Chassis/" +
3241cb1a9e6SAppaRao Puli                                                          chassisId +
3251cb1a9e6SAppaRao Puli                                                          "/ResetActionInfo"}};
326adbe192aSJason M. Bills                         asyncResp->res.jsonValue["PCIeDevices"] = {
327adbe192aSJason M. Bills                             {"@odata.id",
328adbe192aSJason M. Bills                              "/redfish/v1/Systems/system/PCIeDevices"}};
32949c53ac9SJohnathan Mantey 
33049c53ac9SJohnathan Mantey                         const std::string& connectionName =
33149c53ac9SJohnathan Mantey                             connectionNames[0].first;
3321c8fba97SJames Feist 
33323a21a1cSEd Tanous                         const std::vector<std::string>& interfaces2 =
3341c8fba97SJames Feist                             connectionNames[0].second;
3351c8fba97SJames Feist                         const std::array<const char*, 2> hasIndicatorLed = {
3361c8fba97SJames Feist                             "xyz.openbmc_project.Inventory.Item.Panel",
3370fda0f12SGeorge Liu                             "xyz.openbmc_project.Inventory.Item.Board.Motherboard"};
3381c8fba97SJames Feist 
339476b9cc5STejas Patil                         const std::string assetTagInterface =
3400fda0f12SGeorge Liu                             "xyz.openbmc_project.Inventory.Decorator.AssetTag";
341476b9cc5STejas Patil                         if (std::find(interfaces2.begin(), interfaces2.end(),
342476b9cc5STejas Patil                                       assetTagInterface) != interfaces2.end())
343476b9cc5STejas Patil                         {
344476b9cc5STejas Patil                             crow::connections::systemBus->async_method_call(
345476b9cc5STejas Patil                                 [asyncResp, chassisId(std::string(chassisId))](
346476b9cc5STejas Patil                                     const boost::system::error_code ec,
347476b9cc5STejas Patil                                     const std::variant<std::string>& property) {
348476b9cc5STejas Patil                                     if (ec)
349476b9cc5STejas Patil                                     {
350476b9cc5STejas Patil                                         BMCWEB_LOG_DEBUG
3510fda0f12SGeorge Liu                                             << "DBus response error for AssetTag";
352476b9cc5STejas Patil                                         messages::internalError(asyncResp->res);
353476b9cc5STejas Patil                                         return;
354476b9cc5STejas Patil                                     }
355476b9cc5STejas Patil 
356476b9cc5STejas Patil                                     const std::string* assetTag =
357476b9cc5STejas Patil                                         std::get_if<std::string>(&property);
358476b9cc5STejas Patil                                     if (assetTag == nullptr)
359476b9cc5STejas Patil                                     {
360476b9cc5STejas Patil                                         BMCWEB_LOG_DEBUG
3610fda0f12SGeorge Liu                                             << "Null value returned for Chassis AssetTag";
362476b9cc5STejas Patil                                         messages::internalError(asyncResp->res);
363476b9cc5STejas Patil                                         return;
364476b9cc5STejas Patil                                     }
365476b9cc5STejas Patil                                     asyncResp->res.jsonValue["AssetTag"] =
366476b9cc5STejas Patil                                         *assetTag;
367476b9cc5STejas Patil                                 },
368476b9cc5STejas Patil                                 connectionName, path,
369476b9cc5STejas Patil                                 "org.freedesktop.DBus.Properties", "Get",
370476b9cc5STejas Patil                                 assetTagInterface, "AssetTag");
371476b9cc5STejas Patil                         }
372476b9cc5STejas Patil 
3731c8fba97SJames Feist                         for (const char* interface : hasIndicatorLed)
3741c8fba97SJames Feist                         {
3757e860f15SJohn Edward Broadbent                             if (std::find(interfaces2.begin(),
3767e860f15SJohn Edward Broadbent                                           interfaces2.end(),
37723a21a1cSEd Tanous                                           interface) != interfaces2.end())
3781c8fba97SJames Feist                             {
3791c8fba97SJames Feist                                 getIndicatorLedState(asyncResp);
3809f8bfa7cSGunnar Mills                                 getLocationIndicatorActive(asyncResp);
3811c8fba97SJames Feist                                 break;
3821c8fba97SJames Feist                             }
3831c8fba97SJames Feist                         }
3841c8fba97SJames Feist 
38555c7b7a2SEd Tanous                         crow::connections::systemBus->async_method_call(
38662d5e2e4SEd Tanous                             [asyncResp, chassisId(std::string(chassisId))](
38790728b54SEd Tanous                                 const boost::system::error_code /*ec2*/,
3887e860f15SJohn Edward Broadbent                                 const std::vector<
3897e860f15SJohn Edward Broadbent                                     std::pair<std::string, VariantType>>&
3907e860f15SJohn Edward Broadbent                                     propertiesList) {
3911214b7e7SGunnar Mills                                 for (const std::pair<std::string, VariantType>&
3921214b7e7SGunnar Mills                                          property : propertiesList)
3931abe55efSEd Tanous                                 {
3947e860f15SJohn Edward Broadbent                                     // Store DBus properties that are also
3957e860f15SJohn Edward Broadbent                                     // Redfish properties with same name and a
3967e860f15SJohn Edward Broadbent                                     // string value
39799cffd7fSShawn McCarney                                     const std::string& propertyName =
39899cffd7fSShawn McCarney                                         property.first;
39999cffd7fSShawn McCarney                                     if ((propertyName == "PartNumber") ||
40099cffd7fSShawn McCarney                                         (propertyName == "SerialNumber") ||
40199cffd7fSShawn McCarney                                         (propertyName == "Manufacturer") ||
402*caa11f7aSAlpana Kumari                                         (propertyName == "Model") ||
403*caa11f7aSAlpana Kumari                                         (propertyName == "SparePartNumber"))
40499cffd7fSShawn McCarney                                     {
405daf36e2eSEd Tanous                                         const std::string* value =
40699cffd7fSShawn McCarney                                             std::get_if<std::string>(
40799cffd7fSShawn McCarney                                                 &property.second);
408*caa11f7aSAlpana Kumari                                         if (value == nullptr)
4091abe55efSEd Tanous                                         {
410*caa11f7aSAlpana Kumari                                             BMCWEB_LOG_ERROR
411*caa11f7aSAlpana Kumari                                                 << "Null value returned for "
412*caa11f7aSAlpana Kumari                                                 << propertyName;
413*caa11f7aSAlpana Kumari                                             messages::internalError(
414*caa11f7aSAlpana Kumari                                                 asyncResp->res);
415*caa11f7aSAlpana Kumari                                             return;
416daf36e2eSEd Tanous                                         }
417*caa11f7aSAlpana Kumari                                         // SparePartNumber is optional on D-Bus
418*caa11f7aSAlpana Kumari                                         // so skip if it is empty
419*caa11f7aSAlpana Kumari                                         if (propertyName == "SparePartNumber")
420*caa11f7aSAlpana Kumari                                         {
421*caa11f7aSAlpana Kumari                                             if (*value == "")
422*caa11f7aSAlpana Kumari                                             {
423*caa11f7aSAlpana Kumari                                                 continue;
424*caa11f7aSAlpana Kumari                                             }
425*caa11f7aSAlpana Kumari                                         }
426*caa11f7aSAlpana Kumari                                         asyncResp->res.jsonValue[propertyName] =
427*caa11f7aSAlpana Kumari                                             *value;
428daf36e2eSEd Tanous                                     }
42999cffd7fSShawn McCarney                                 }
43062d5e2e4SEd Tanous                                 asyncResp->res.jsonValue["Name"] = chassisId;
43162d5e2e4SEd Tanous                                 asyncResp->res.jsonValue["Id"] = chassisId;
4320256b694Szhanghch05 #ifdef BMCWEB_ALLOW_DEPRECATED_POWER_THERMAL
43362d5e2e4SEd Tanous                                 asyncResp->res.jsonValue["Thermal"] = {
4341abe55efSEd Tanous                                     {"@odata.id", "/redfish/v1/Chassis/" +
4351abe55efSEd Tanous                                                       chassisId + "/Thermal"}};
4362474adfaSEd Tanous                                 // Power object
4372474adfaSEd Tanous                                 asyncResp->res.jsonValue["Power"] = {
4382474adfaSEd Tanous                                     {"@odata.id", "/redfish/v1/Chassis/" +
4392474adfaSEd Tanous                                                       chassisId + "/Power"}};
4400256b694Szhanghch05 #endif
44195a3ecadSAnthony Wilson                                 // SensorCollection
44295a3ecadSAnthony Wilson                                 asyncResp->res.jsonValue["Sensors"] = {
44395a3ecadSAnthony Wilson                                     {"@odata.id", "/redfish/v1/Chassis/" +
44495a3ecadSAnthony Wilson                                                       chassisId + "/Sensors"}};
445029573d4SEd Tanous                                 asyncResp->res.jsonValue["Status"] = {
446029573d4SEd Tanous                                     {"State", "Enabled"},
447029573d4SEd Tanous                                 };
4482474adfaSEd Tanous 
449029573d4SEd Tanous                                 asyncResp->res
450029573d4SEd Tanous                                     .jsonValue["Links"]["ComputerSystems"] = {
4517e860f15SJohn Edward Broadbent                                     {{"@odata.id",
4527e860f15SJohn Edward Broadbent                                       "/redfish/v1/Systems/system"}}};
4537e860f15SJohn Edward Broadbent                                 asyncResp->res.jsonValue["Links"]["ManagedBy"] =
4547e860f15SJohn Edward Broadbent                                     {{{"@odata.id",
4557e860f15SJohn Edward Broadbent                                        "/redfish/v1/Managers/bmc"}}};
456beeca0aeSGunnar Mills                                 getChassisState(asyncResp);
457daf36e2eSEd Tanous                             },
4587e860f15SJohn Edward Broadbent                             connectionName, path,
4597e860f15SJohn Edward Broadbent                             "org.freedesktop.DBus.Properties", "GetAll",
4601abe55efSEd Tanous                             "xyz.openbmc_project.Inventory.Decorator.Asset");
4612c37b4b0SSharad Yadav 
462308f70c7SWilly Tu                         for (const auto& interface : interfaces2)
4632c37b4b0SSharad Yadav                         {
464308f70c7SWilly Tu                             if (interface == "xyz.openbmc_project.Common.UUID")
4652c37b4b0SSharad Yadav                             {
466308f70c7SWilly Tu                                 getChassisUUID(asyncResp, connectionName, path);
4672c37b4b0SSharad Yadav                             }
4680fda0f12SGeorge Liu                             else if (
4690fda0f12SGeorge Liu                                 interface ==
4700fda0f12SGeorge Liu                                 "xyz.openbmc_project.Inventory.Decorator.LocationCode")
4712c37b4b0SSharad Yadav                             {
472308f70c7SWilly Tu                                 getChassisLocationCode(asyncResp,
473308f70c7SWilly Tu                                                        connectionName, path);
4742c37b4b0SSharad Yadav                             }
4752c37b4b0SSharad Yadav                         }
4762c37b4b0SSharad Yadav 
477daf36e2eSEd Tanous                         return;
478daf36e2eSEd Tanous                     }
479e0d918bcSEd Tanous 
480daf36e2eSEd Tanous                     // Couldn't find an object with that name.  return an error
481f12894f8SJason M. Bills                     messages::resourceNotFound(
4829f8bfa7cSGunnar Mills                         asyncResp->res, "#Chassis.v1_14_0.Chassis", chassisId);
483daf36e2eSEd Tanous                 },
484daf36e2eSEd Tanous                 "xyz.openbmc_project.ObjectMapper",
485daf36e2eSEd Tanous                 "/xyz/openbmc_project/object_mapper",
486daf36e2eSEd Tanous                 "xyz.openbmc_project.ObjectMapper", "GetSubTree",
487271584abSEd Tanous                 "/xyz/openbmc_project/inventory", 0, interfaces);
488c181942fSQiang XU 
489c181942fSQiang XU             getPhysicalSecurityData(asyncResp);
4907e860f15SJohn Edward Broadbent         });
4911c8fba97SJames Feist 
4927e860f15SJohn Edward Broadbent     BMCWEB_ROUTE(app, "/redfish/v1/Chassis/<str>/")
493ed398213SEd Tanous         .privileges(redfish::privileges::patchChassis)
4947e860f15SJohn Edward Broadbent         .methods(
4957e860f15SJohn Edward Broadbent             boost::beast::http::verb::
4967e860f15SJohn Edward Broadbent                 patch)([](const crow::Request& req,
4977e860f15SJohn Edward Broadbent                           const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
4987e860f15SJohn Edward Broadbent                           const std::string& param) {
4999f8bfa7cSGunnar Mills             std::optional<bool> locationIndicatorActive;
5001c8fba97SJames Feist             std::optional<std::string> indicatorLed;
5011c8fba97SJames Feist 
5027e860f15SJohn Edward Broadbent             if (param.empty())
5031c8fba97SJames Feist             {
5041c8fba97SJames Feist                 return;
5051c8fba97SJames Feist             }
5061c8fba97SJames Feist 
5077e860f15SJohn Edward Broadbent             if (!json_util::readJson(
5087e860f15SJohn Edward Broadbent                     req, asyncResp->res, "LocationIndicatorActive",
5097e860f15SJohn Edward Broadbent                     locationIndicatorActive, "IndicatorLED", indicatorLed))
5101c8fba97SJames Feist             {
5111c8fba97SJames Feist                 return;
5121c8fba97SJames Feist             }
5131c8fba97SJames Feist 
5149f8bfa7cSGunnar Mills             // TODO (Gunnar): Remove IndicatorLED after enough time has passed
5159f8bfa7cSGunnar Mills             if (!locationIndicatorActive && !indicatorLed)
5161c8fba97SJames Feist             {
5171c8fba97SJames Feist                 return; // delete this when we support more patch properties
5181c8fba97SJames Feist             }
519d6aa0093SGunnar Mills             if (indicatorLed)
520d6aa0093SGunnar Mills             {
5217e860f15SJohn Edward Broadbent                 asyncResp->res.addHeader(
5227e860f15SJohn Edward Broadbent                     boost::beast::http::field::warning,
5230fda0f12SGeorge Liu                     "299 - \"IndicatorLED is deprecated. Use LocationIndicatorActive instead.\"");
524d6aa0093SGunnar Mills             }
5251c8fba97SJames Feist 
5261c8fba97SJames Feist             const std::array<const char*, 2> interfaces = {
5271c8fba97SJames Feist                 "xyz.openbmc_project.Inventory.Item.Board",
5281c8fba97SJames Feist                 "xyz.openbmc_project.Inventory.Item.Chassis"};
5291c8fba97SJames Feist 
5307e860f15SJohn Edward Broadbent             const std::string& chassisId = param;
5311c8fba97SJames Feist 
5321c8fba97SJames Feist             crow::connections::systemBus->async_method_call(
5339f8bfa7cSGunnar Mills                 [asyncResp, chassisId, locationIndicatorActive, indicatorLed](
5341c8fba97SJames Feist                     const boost::system::error_code ec,
5351c8fba97SJames Feist                     const crow::openbmc_mapper::GetSubTreeType& subtree) {
5361c8fba97SJames Feist                     if (ec)
5371c8fba97SJames Feist                     {
5381c8fba97SJames Feist                         messages::internalError(asyncResp->res);
5391c8fba97SJames Feist                         return;
5401c8fba97SJames Feist                     }
5411c8fba97SJames Feist 
5421c8fba97SJames Feist                     // Iterate over all retrieved ObjectPaths.
5431c8fba97SJames Feist                     for (const std::pair<
5441c8fba97SJames Feist                              std::string,
5457e860f15SJohn Edward Broadbent                              std::vector<std::pair<std::string,
5467e860f15SJohn Edward Broadbent                                                    std::vector<std::string>>>>&
5471214b7e7SGunnar Mills                              object : subtree)
5481c8fba97SJames Feist                     {
5491c8fba97SJames Feist                         const std::string& path = object.first;
5501c8fba97SJames Feist                         const std::vector<
5511214b7e7SGunnar Mills                             std::pair<std::string, std::vector<std::string>>>&
5521214b7e7SGunnar Mills                             connectionNames = object.second;
5531c8fba97SJames Feist 
554997093ebSGeorge Liu                         sdbusplus::message::object_path objPath(path);
555997093ebSGeorge Liu                         if (objPath.filename() != chassisId)
5561c8fba97SJames Feist                         {
5571c8fba97SJames Feist                             continue;
5581c8fba97SJames Feist                         }
5591c8fba97SJames Feist 
5601c8fba97SJames Feist                         if (connectionNames.size() < 1)
5611c8fba97SJames Feist                         {
5621c8fba97SJames Feist                             BMCWEB_LOG_ERROR << "Got 0 Connection names";
5631c8fba97SJames Feist                             continue;
5641c8fba97SJames Feist                         }
5651c8fba97SJames Feist 
56623a21a1cSEd Tanous                         const std::vector<std::string>& interfaces3 =
5671c8fba97SJames Feist                             connectionNames[0].second;
5681c8fba97SJames Feist 
5691c8fba97SJames Feist                         const std::array<const char*, 2> hasIndicatorLed = {
5701c8fba97SJames Feist                             "xyz.openbmc_project.Inventory.Item.Panel",
5710fda0f12SGeorge Liu                             "xyz.openbmc_project.Inventory.Item.Board.Motherboard"};
5721c8fba97SJames Feist                         bool indicatorChassis = false;
5731c8fba97SJames Feist                         for (const char* interface : hasIndicatorLed)
5741c8fba97SJames Feist                         {
5757e860f15SJohn Edward Broadbent                             if (std::find(interfaces3.begin(),
5767e860f15SJohn Edward Broadbent                                           interfaces3.end(),
57723a21a1cSEd Tanous                                           interface) != interfaces3.end())
5781c8fba97SJames Feist                             {
5791c8fba97SJames Feist                                 indicatorChassis = true;
5801c8fba97SJames Feist                                 break;
5811c8fba97SJames Feist                             }
5821c8fba97SJames Feist                         }
5839f8bfa7cSGunnar Mills                         if (locationIndicatorActive)
5849f8bfa7cSGunnar Mills                         {
5859f8bfa7cSGunnar Mills                             if (indicatorChassis)
5869f8bfa7cSGunnar Mills                             {
5879f8bfa7cSGunnar Mills                                 setLocationIndicatorActive(
5889f8bfa7cSGunnar Mills                                     asyncResp, *locationIndicatorActive);
5899f8bfa7cSGunnar Mills                             }
5909f8bfa7cSGunnar Mills                             else
5919f8bfa7cSGunnar Mills                             {
5929f8bfa7cSGunnar Mills                                 messages::propertyUnknown(
5939f8bfa7cSGunnar Mills                                     asyncResp->res, "LocationIndicatorActive");
5949f8bfa7cSGunnar Mills                             }
5959f8bfa7cSGunnar Mills                         }
5969f8bfa7cSGunnar Mills                         if (indicatorLed)
5979f8bfa7cSGunnar Mills                         {
5981c8fba97SJames Feist                             if (indicatorChassis)
5991c8fba97SJames Feist                             {
600f23b7296SEd Tanous                                 setIndicatorLedState(asyncResp, *indicatorLed);
6011c8fba97SJames Feist                             }
6021c8fba97SJames Feist                             else
6031c8fba97SJames Feist                             {
6041c8fba97SJames Feist                                 messages::propertyUnknown(asyncResp->res,
6051c8fba97SJames Feist                                                           "IndicatorLED");
6061c8fba97SJames Feist                             }
6071c8fba97SJames Feist                         }
6081c8fba97SJames Feist                         return;
6091c8fba97SJames Feist                     }
6101c8fba97SJames Feist 
6111c8fba97SJames Feist                     messages::resourceNotFound(
6129f8bfa7cSGunnar Mills                         asyncResp->res, "#Chassis.v1_14_0.Chassis", chassisId);
6131c8fba97SJames Feist                 },
6141c8fba97SJames Feist                 "xyz.openbmc_project.ObjectMapper",
6151c8fba97SJames Feist                 "/xyz/openbmc_project/object_mapper",
6161c8fba97SJames Feist                 "xyz.openbmc_project.ObjectMapper", "GetSubTree",
6171c8fba97SJames Feist                 "/xyz/openbmc_project/inventory", 0, interfaces);
6187e860f15SJohn Edward Broadbent         });
6191c8fba97SJames Feist }
620dd99e04bSP.K. Lee 
6218d1b46d7Szhanghch05 inline void
6228d1b46d7Szhanghch05     doChassisPowerCycle(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
623dd99e04bSP.K. Lee {
624c3b3c92aSVijay Khemka     const char* busName = "xyz.openbmc_project.ObjectMapper";
625c3b3c92aSVijay Khemka     const char* path = "/xyz/openbmc_project/object_mapper";
626c3b3c92aSVijay Khemka     const char* interface = "xyz.openbmc_project.ObjectMapper";
627c3b3c92aSVijay Khemka     const char* method = "GetSubTreePaths";
628c3b3c92aSVijay Khemka 
629c3b3c92aSVijay Khemka     const std::array<const char*, 1> interfaces = {
630c3b3c92aSVijay Khemka         "xyz.openbmc_project.State.Chassis"};
631c3b3c92aSVijay Khemka 
632c3b3c92aSVijay Khemka     // Use mapper to get subtree paths.
633c3b3c92aSVijay Khemka     crow::connections::systemBus->async_method_call(
634c3b3c92aSVijay Khemka         [asyncResp](const boost::system::error_code ec,
635c3b3c92aSVijay Khemka                     const std::vector<std::string>& chassisList) {
636c3b3c92aSVijay Khemka             if (ec)
637c3b3c92aSVijay Khemka             {
638c3b3c92aSVijay Khemka                 BMCWEB_LOG_DEBUG << "[mapper] Bad D-Bus request error: " << ec;
639c3b3c92aSVijay Khemka                 messages::internalError(asyncResp->res);
640c3b3c92aSVijay Khemka                 return;
641c3b3c92aSVijay Khemka             }
642c3b3c92aSVijay Khemka 
643dd99e04bSP.K. Lee             const char* processName = "xyz.openbmc_project.State.Chassis";
644dd99e04bSP.K. Lee             const char* interfaceName = "xyz.openbmc_project.State.Chassis";
645dd99e04bSP.K. Lee             const char* destProperty = "RequestedPowerTransition";
646dd99e04bSP.K. Lee             const std::string propertyValue =
647dd99e04bSP.K. Lee                 "xyz.openbmc_project.State.Chassis.Transition.PowerCycle";
648c3b3c92aSVijay Khemka             std::string objectPath =
649c3b3c92aSVijay Khemka                 "/xyz/openbmc_project/state/chassis_system0";
650c3b3c92aSVijay Khemka 
651c3b3c92aSVijay Khemka             /* Look for system reset chassis path */
652c3b3c92aSVijay Khemka             if ((std::find(chassisList.begin(), chassisList.end(),
653c3b3c92aSVijay Khemka                            objectPath)) == chassisList.end())
654c3b3c92aSVijay Khemka             {
655c3b3c92aSVijay Khemka                 /* We prefer to reset the full chassis_system, but if it doesn't
656c3b3c92aSVijay Khemka                  * exist on some platforms, fall back to a host-only power reset
657c3b3c92aSVijay Khemka                  */
658c3b3c92aSVijay Khemka                 objectPath = "/xyz/openbmc_project/state/chassis0";
659c3b3c92aSVijay Khemka             }
660dd99e04bSP.K. Lee 
661dd99e04bSP.K. Lee             crow::connections::systemBus->async_method_call(
662dd99e04bSP.K. Lee                 [asyncResp](const boost::system::error_code ec) {
663dd99e04bSP.K. Lee                     // Use "Set" method to set the property value.
664dd99e04bSP.K. Lee                     if (ec)
665dd99e04bSP.K. Lee                     {
666c3b3c92aSVijay Khemka                         BMCWEB_LOG_DEBUG << "[Set] Bad D-Bus request error: "
667c3b3c92aSVijay Khemka                                          << ec;
668dd99e04bSP.K. Lee                         messages::internalError(asyncResp->res);
669dd99e04bSP.K. Lee                         return;
670dd99e04bSP.K. Lee                     }
671dd99e04bSP.K. Lee 
672dd99e04bSP.K. Lee                     messages::success(asyncResp->res);
673dd99e04bSP.K. Lee                 },
674c3b3c92aSVijay Khemka                 processName, objectPath, "org.freedesktop.DBus.Properties",
675c3b3c92aSVijay Khemka                 "Set", interfaceName, destProperty,
676c3b3c92aSVijay Khemka                 std::variant<std::string>{propertyValue});
677c3b3c92aSVijay Khemka         },
678c3b3c92aSVijay Khemka         busName, path, interface, method, "/", 0, interfaces);
679dd99e04bSP.K. Lee }
680dd99e04bSP.K. Lee 
681dd99e04bSP.K. Lee /**
682dd99e04bSP.K. Lee  * ChassisResetAction class supports the POST method for the Reset
683dd99e04bSP.K. Lee  * action.
684dd99e04bSP.K. Lee  * Function handles POST method request.
685dd99e04bSP.K. Lee  * Analyzes POST body before sending Reset request data to D-Bus.
686dd99e04bSP.K. Lee  */
6877e860f15SJohn Edward Broadbent 
6887e860f15SJohn Edward Broadbent inline void requestRoutesChassisResetAction(App& app)
689dd99e04bSP.K. Lee {
6907e860f15SJohn Edward Broadbent     BMCWEB_ROUTE(app, "/redfish/v1/Chassis/<str>/Actions/Chassis.Reset/")
691ed398213SEd Tanous         .privileges(redfish::privileges::postChassis)
6927e860f15SJohn Edward Broadbent         .methods(boost::beast::http::verb::post)(
6937e860f15SJohn Edward Broadbent             [](const crow::Request& req,
6947e860f15SJohn Edward Broadbent                const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
6957e860f15SJohn Edward Broadbent                const std::string&) {
696dd99e04bSP.K. Lee                 BMCWEB_LOG_DEBUG << "Post Chassis Reset.";
697dd99e04bSP.K. Lee 
698dd99e04bSP.K. Lee                 std::string resetType;
699dd99e04bSP.K. Lee 
7007e860f15SJohn Edward Broadbent                 if (!json_util::readJson(req, asyncResp->res, "ResetType",
7017e860f15SJohn Edward Broadbent                                          resetType))
702dd99e04bSP.K. Lee                 {
703dd99e04bSP.K. Lee                     return;
704dd99e04bSP.K. Lee                 }
705dd99e04bSP.K. Lee 
706dd99e04bSP.K. Lee                 if (resetType != "PowerCycle")
707dd99e04bSP.K. Lee                 {
708dd99e04bSP.K. Lee                     BMCWEB_LOG_DEBUG << "Invalid property value for ResetType: "
709dd99e04bSP.K. Lee                                      << resetType;
7107e860f15SJohn Edward Broadbent                     messages::actionParameterNotSupported(
7117e860f15SJohn Edward Broadbent                         asyncResp->res, resetType, "ResetType");
712dd99e04bSP.K. Lee 
713dd99e04bSP.K. Lee                     return;
714dd99e04bSP.K. Lee                 }
715dd99e04bSP.K. Lee                 doChassisPowerCycle(asyncResp);
7167e860f15SJohn Edward Broadbent             });
717dd99e04bSP.K. Lee }
7181cb1a9e6SAppaRao Puli 
7191cb1a9e6SAppaRao Puli /**
7201cb1a9e6SAppaRao Puli  * ChassisResetActionInfo derived class for delivering Chassis
7211cb1a9e6SAppaRao Puli  * ResetType AllowableValues using ResetInfo schema.
7221cb1a9e6SAppaRao Puli  */
7237e860f15SJohn Edward Broadbent inline void requestRoutesChassisResetActionInfo(App& app)
7241cb1a9e6SAppaRao Puli {
7257e860f15SJohn Edward Broadbent     BMCWEB_ROUTE(app, "/redfish/v1/Chassis/<str>/ResetActionInfo/")
726ed398213SEd Tanous         .privileges(redfish::privileges::getActionInfo)
7277e860f15SJohn Edward Broadbent         .methods(boost::beast::http::verb::get)(
7287e860f15SJohn Edward Broadbent             [](const crow::Request&,
7297e860f15SJohn Edward Broadbent                const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
7307e860f15SJohn Edward Broadbent                const std::string& chassisId)
7311cb1a9e6SAppaRao Puli 
7321cb1a9e6SAppaRao Puli             {
7338d1b46d7Szhanghch05                 asyncResp->res.jsonValue = {
7348d1b46d7Szhanghch05                     {"@odata.type", "#ActionInfo.v1_1_2.ActionInfo"},
7358d1b46d7Szhanghch05                     {"@odata.id",
7368d1b46d7Szhanghch05                      "/redfish/v1/Chassis/" + chassisId + "/ResetActionInfo"},
7371cb1a9e6SAppaRao Puli                     {"Name", "Reset Action Info"},
7381cb1a9e6SAppaRao Puli                     {"Id", "ResetActionInfo"},
7391cb1a9e6SAppaRao Puli                     {"Parameters",
7401cb1a9e6SAppaRao Puli                      {{{"Name", "ResetType"},
7411cb1a9e6SAppaRao Puli                        {"Required", true},
7421cb1a9e6SAppaRao Puli                        {"DataType", "String"},
7431cb1a9e6SAppaRao Puli                        {"AllowableValues", {"PowerCycle"}}}}}};
7447e860f15SJohn Edward Broadbent             });
7451cb1a9e6SAppaRao Puli }
7461cb1a9e6SAppaRao Puli 
747e37f8451SRapkiewicz, Pawel } // namespace redfish
748