xref: /openbmc/bmcweb/features/redfish/lib/chassis.hpp (revision beeca0ae7d30ea68f3e6e5841ec631ee25248ffb)
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 
18e37f8451SRapkiewicz, Pawel #include "node.hpp"
191abe55efSEd Tanous 
20e37f8451SRapkiewicz, Pawel #include <boost/container/flat_map.hpp>
21abf2add6SEd Tanous #include <variant>
22e37f8451SRapkiewicz, Pawel 
231abe55efSEd Tanous namespace redfish
241abe55efSEd Tanous {
25e37f8451SRapkiewicz, Pawel 
26e37f8451SRapkiewicz, Pawel /**
27*beeca0aeSGunnar Mills  * @brief Retrieves chassis state properties over dbus
28*beeca0aeSGunnar Mills  *
29*beeca0aeSGunnar Mills  * @param[in] aResp - Shared pointer for completing asynchronous calls.
30*beeca0aeSGunnar Mills  *
31*beeca0aeSGunnar Mills  * @return None.
32*beeca0aeSGunnar Mills  */
33*beeca0aeSGunnar Mills void getChassisState(std::shared_ptr<AsyncResp> aResp)
34*beeca0aeSGunnar Mills {
35*beeca0aeSGunnar Mills     crow::connections::systemBus->async_method_call(
36*beeca0aeSGunnar Mills         [aResp{std::move(aResp)}](
37*beeca0aeSGunnar Mills             const boost::system::error_code ec,
38*beeca0aeSGunnar Mills             const std::variant<std::string> &chassisState) {
39*beeca0aeSGunnar Mills             if (ec)
40*beeca0aeSGunnar Mills             {
41*beeca0aeSGunnar Mills                 BMCWEB_LOG_DEBUG << "DBUS response error " << ec;
42*beeca0aeSGunnar Mills                 messages::internalError(aResp->res);
43*beeca0aeSGunnar Mills                 return;
44*beeca0aeSGunnar Mills             }
45*beeca0aeSGunnar Mills 
46*beeca0aeSGunnar Mills             const std::string *s = std::get_if<std::string>(&chassisState);
47*beeca0aeSGunnar Mills             BMCWEB_LOG_DEBUG << "Chassis state: " << *s;
48*beeca0aeSGunnar Mills             if (s != nullptr)
49*beeca0aeSGunnar Mills             {
50*beeca0aeSGunnar Mills                 // Verify Chassis State
51*beeca0aeSGunnar Mills                 if (*s == "xyz.openbmc_project.State.Chassis.PowerState.On")
52*beeca0aeSGunnar Mills                 {
53*beeca0aeSGunnar Mills                     aResp->res.jsonValue["PowerState"] = "On";
54*beeca0aeSGunnar Mills                     aResp->res.jsonValue["Status"]["State"] = "Enabled";
55*beeca0aeSGunnar Mills                 }
56*beeca0aeSGunnar Mills                 else if (*s ==
57*beeca0aeSGunnar Mills                          "xyz.openbmc_project.State.Chassis.PowerState.Off")
58*beeca0aeSGunnar Mills                 {
59*beeca0aeSGunnar Mills                     aResp->res.jsonValue["PowerState"] = "Off";
60*beeca0aeSGunnar Mills                     aResp->res.jsonValue["Status"]["State"] = "StandbyOffline";
61*beeca0aeSGunnar Mills                 }
62*beeca0aeSGunnar Mills             }
63*beeca0aeSGunnar Mills         },
64*beeca0aeSGunnar Mills         "xyz.openbmc_project.State.Chassis",
65*beeca0aeSGunnar Mills         "/xyz/openbmc_project/state/chassis0",
66*beeca0aeSGunnar Mills         "org.freedesktop.DBus.Properties", "Get",
67*beeca0aeSGunnar Mills         "xyz.openbmc_project.State.Chassis", "CurrentPowerState");
68*beeca0aeSGunnar Mills }
69*beeca0aeSGunnar Mills 
70*beeca0aeSGunnar Mills /**
71e37f8451SRapkiewicz, Pawel  * DBus types primitives for several generic DBus interfaces
72e37f8451SRapkiewicz, Pawel  * TODO(Pawel) consider move this to separate file into boost::dbus
73e37f8451SRapkiewicz, Pawel  */
7455c7b7a2SEd Tanous // Note, this is not a very useful Variant, but because it isn't used to get
75aa2e59c1SEd Tanous // values, it should be as simple as possible
76aa2e59c1SEd Tanous // TODO(ed) invent a nullvariant type
77abf2add6SEd Tanous using VariantType = std::variant<bool, std::string, uint64_t>;
78aa2e59c1SEd Tanous using ManagedObjectsType = std::vector<std::pair<
79aa2e59c1SEd Tanous     sdbusplus::message::object_path,
80aa2e59c1SEd Tanous     std::vector<std::pair<std::string,
81aa2e59c1SEd Tanous                           std::vector<std::pair<std::string, VariantType>>>>>>;
82e37f8451SRapkiewicz, Pawel 
83aa2e59c1SEd Tanous using PropertiesType = boost::container::flat_map<std::string, VariantType>;
84e37f8451SRapkiewicz, Pawel 
85c181942fSQiang XU void getIntrusionByService(std::shared_ptr<AsyncResp> aResp,
86c181942fSQiang XU                            const std::string &service,
87c181942fSQiang XU                            const std::string &objPath)
88c181942fSQiang XU {
89c181942fSQiang XU     BMCWEB_LOG_DEBUG << "Get intrusion status by service \n";
90c181942fSQiang XU 
91c181942fSQiang XU     crow::connections::systemBus->async_method_call(
92c181942fSQiang XU         [aResp{std::move(aResp)}](const boost::system::error_code ec,
93c181942fSQiang XU                                   const std::variant<std::string> &value) {
94c181942fSQiang XU             if (ec)
95c181942fSQiang XU             {
96c181942fSQiang XU                 // do not add err msg in redfish response, becaues this is not
97c181942fSQiang XU                 //     mandatory property
98c181942fSQiang XU                 BMCWEB_LOG_ERROR << "DBUS response error " << ec << "\n";
99c181942fSQiang XU                 return;
100c181942fSQiang XU             }
101c181942fSQiang XU 
102c181942fSQiang XU             const std::string *status = std::get_if<std::string>(&value);
103c181942fSQiang XU 
104c181942fSQiang XU             if (status == nullptr)
105c181942fSQiang XU             {
106c181942fSQiang XU                 BMCWEB_LOG_ERROR << "intrusion status read error \n";
107c181942fSQiang XU                 return;
108c181942fSQiang XU             }
109c181942fSQiang XU 
110c181942fSQiang XU             aResp->res.jsonValue["PhysicalSecurity"] = {
111c181942fSQiang XU                 {"IntrusionSensorNumber", 1}, {"IntrusionSensor", *status}};
112c181942fSQiang XU         },
113c181942fSQiang XU         service, objPath, "org.freedesktop.DBus.Properties", "Get",
114c181942fSQiang XU         "xyz.openbmc_project.Chassis.Intrusion", "Status");
115c181942fSQiang XU }
116c181942fSQiang XU 
117c181942fSQiang XU /**
118c181942fSQiang XU  * Retrieves physical security properties over dbus
119c181942fSQiang XU  */
120c181942fSQiang XU void getPhysicalSecurityData(std::shared_ptr<AsyncResp> aResp)
121c181942fSQiang XU {
122c181942fSQiang XU     crow::connections::systemBus->async_method_call(
123c181942fSQiang XU         [aResp{std::move(aResp)}](
124c181942fSQiang XU             const boost::system::error_code ec,
125c181942fSQiang XU             const std::vector<std::pair<
126c181942fSQiang XU                 std::string,
127c181942fSQiang XU                 std::vector<std::pair<std::string, std::vector<std::string>>>>>
128c181942fSQiang XU                 &subtree) {
129c181942fSQiang XU             if (ec)
130c181942fSQiang XU             {
131c181942fSQiang XU                 // do not add err msg in redfish response, becaues this is not
132c181942fSQiang XU                 //     mandatory property
133c181942fSQiang XU                 BMCWEB_LOG_ERROR << "DBUS error: no matched iface " << ec
134c181942fSQiang XU                                  << "\n";
135c181942fSQiang XU                 return;
136c181942fSQiang XU             }
137c181942fSQiang XU             // Iterate over all retrieved ObjectPaths.
138c181942fSQiang XU             for (const auto &object : subtree)
139c181942fSQiang XU             {
140c181942fSQiang XU                 for (const auto &service : object.second)
141c181942fSQiang XU                 {
142c181942fSQiang XU                     getIntrusionByService(aResp, service.first, object.first);
143c181942fSQiang XU                     return;
144c181942fSQiang XU                 }
145c181942fSQiang XU             }
146c181942fSQiang XU         },
147c181942fSQiang XU         "xyz.openbmc_project.ObjectMapper",
148c181942fSQiang XU         "/xyz/openbmc_project/object_mapper",
149c181942fSQiang XU         "xyz.openbmc_project.ObjectMapper", "GetSubTree",
150c181942fSQiang XU         "/xyz/openbmc_project/Intrusion", int32_t(1),
151c181942fSQiang XU         std::array<const char *, 1>{"xyz.openbmc_project.Chassis.Intrusion"});
152c181942fSQiang XU }
153c181942fSQiang XU 
154e37f8451SRapkiewicz, Pawel /**
155e37f8451SRapkiewicz, Pawel  * ChassisCollection derived class for delivering Chassis Collection Schema
156e37f8451SRapkiewicz, Pawel  */
1571abe55efSEd Tanous class ChassisCollection : public Node
1581abe55efSEd Tanous {
159e37f8451SRapkiewicz, Pawel   public:
1601abe55efSEd Tanous     ChassisCollection(CrowApp &app) : Node(app, "/redfish/v1/Chassis/")
1611abe55efSEd Tanous     {
162e0d918bcSEd Tanous         entityPrivileges = {
163e0d918bcSEd Tanous             {boost::beast::http::verb::get, {{"Login"}}},
164e0d918bcSEd Tanous             {boost::beast::http::verb::head, {{"Login"}}},
165e0d918bcSEd Tanous             {boost::beast::http::verb::patch, {{"ConfigureComponents"}}},
166e0d918bcSEd Tanous             {boost::beast::http::verb::put, {{"ConfigureComponents"}}},
167e0d918bcSEd Tanous             {boost::beast::http::verb::delete_, {{"ConfigureComponents"}}},
168e0d918bcSEd Tanous             {boost::beast::http::verb::post, {{"ConfigureComponents"}}}};
169e37f8451SRapkiewicz, Pawel     }
170e37f8451SRapkiewicz, Pawel 
171e37f8451SRapkiewicz, Pawel   private:
172e37f8451SRapkiewicz, Pawel     /**
173e37f8451SRapkiewicz, Pawel      * Functions triggers appropriate requests on DBus
174e37f8451SRapkiewicz, Pawel      */
17555c7b7a2SEd Tanous     void doGet(crow::Response &res, const crow::Request &req,
1761abe55efSEd Tanous                const std::vector<std::string> &params) override
1771abe55efSEd Tanous     {
1780f74e643SEd Tanous         res.jsonValue["@odata.type"] = "#ChassisCollection.ChassisCollection";
1790f74e643SEd Tanous         res.jsonValue["@odata.id"] = "/redfish/v1/Chassis";
1800f74e643SEd Tanous         res.jsonValue["@odata.context"] =
1810f74e643SEd Tanous             "/redfish/v1/$metadata#ChassisCollection.ChassisCollection";
1820f74e643SEd Tanous         res.jsonValue["Name"] = "Chassis Collection";
1830f74e643SEd Tanous 
184603a6640SGunnar Mills #ifdef BMCWEB_ENABLE_REDFISH_ONE_CHASSIS
185603a6640SGunnar Mills         // Assume one Chassis named "chassis"
186603a6640SGunnar Mills         res.jsonValue["Members@odata.count"] = 1;
187603a6640SGunnar Mills         res.jsonValue["Members"] = {
188603a6640SGunnar Mills             {{"@odata.id", "/redfish/v1/Chassis/chassis"}}};
189603a6640SGunnar Mills         res.end();
190603a6640SGunnar Mills         return;
191603a6640SGunnar Mills #endif
192603a6640SGunnar Mills         const std::array<const char *, 3> interfaces = {
193603a6640SGunnar Mills             "xyz.openbmc_project.Inventory.Item.Board",
194603a6640SGunnar Mills             "xyz.openbmc_project.Inventory.Item.Chassis",
195603a6640SGunnar Mills             "xyz.openbmc_project.Inventory.Item.PowerSupply"};
196603a6640SGunnar Mills 
19762d5e2e4SEd Tanous         auto asyncResp = std::make_shared<AsyncResp>(res);
19862d5e2e4SEd Tanous         crow::connections::systemBus->async_method_call(
19962d5e2e4SEd Tanous             [asyncResp](const boost::system::error_code ec,
20062d5e2e4SEd Tanous                         const std::vector<std::string> &chassisList) {
20162d5e2e4SEd Tanous                 if (ec)
2021abe55efSEd Tanous                 {
203f12894f8SJason M. Bills                     messages::internalError(asyncResp->res);
20462d5e2e4SEd Tanous                     return;
205e37f8451SRapkiewicz, Pawel                 }
20662d5e2e4SEd Tanous                 nlohmann::json &chassisArray =
20762d5e2e4SEd Tanous                     asyncResp->res.jsonValue["Members"];
20862d5e2e4SEd Tanous                 chassisArray = nlohmann::json::array();
20962d5e2e4SEd Tanous                 for (const std::string &objpath : chassisList)
21062d5e2e4SEd Tanous                 {
21162d5e2e4SEd Tanous                     std::size_t lastPos = objpath.rfind("/");
21262d5e2e4SEd Tanous                     if (lastPos == std::string::npos)
21362d5e2e4SEd Tanous                     {
21462d5e2e4SEd Tanous                         BMCWEB_LOG_ERROR << "Failed to find '/' in " << objpath;
21562d5e2e4SEd Tanous                         continue;
21662d5e2e4SEd Tanous                     }
21762d5e2e4SEd Tanous                     chassisArray.push_back(
21862d5e2e4SEd Tanous                         {{"@odata.id", "/redfish/v1/Chassis/" +
21962d5e2e4SEd Tanous                                            objpath.substr(lastPos + 1)}});
220e37f8451SRapkiewicz, Pawel                 }
221e37f8451SRapkiewicz, Pawel 
22262d5e2e4SEd Tanous                 asyncResp->res.jsonValue["Members@odata.count"] =
22362d5e2e4SEd Tanous                     chassisArray.size();
22462d5e2e4SEd Tanous             },
22562d5e2e4SEd Tanous             "xyz.openbmc_project.ObjectMapper",
22662d5e2e4SEd Tanous             "/xyz/openbmc_project/object_mapper",
22762d5e2e4SEd Tanous             "xyz.openbmc_project.ObjectMapper", "GetSubTreePaths",
228734bfe90SGunnar Mills             "/xyz/openbmc_project/inventory", int32_t(0), interfaces);
22962d5e2e4SEd Tanous     }
230e37f8451SRapkiewicz, Pawel };
231e37f8451SRapkiewicz, Pawel 
232e37f8451SRapkiewicz, Pawel /**
233e37f8451SRapkiewicz, Pawel  * Chassis override class for delivering Chassis Schema
234e37f8451SRapkiewicz, Pawel  */
2351abe55efSEd Tanous class Chassis : public Node
2361abe55efSEd Tanous {
237e37f8451SRapkiewicz, Pawel   public:
2381abe55efSEd Tanous     Chassis(CrowApp &app) :
2391abe55efSEd Tanous         Node(app, "/redfish/v1/Chassis/<str>/", std::string())
2401abe55efSEd Tanous     {
241e0d918bcSEd Tanous         entityPrivileges = {
242e0d918bcSEd Tanous             {boost::beast::http::verb::get, {{"Login"}}},
243e0d918bcSEd Tanous             {boost::beast::http::verb::head, {{"Login"}}},
244e0d918bcSEd Tanous             {boost::beast::http::verb::patch, {{"ConfigureComponents"}}},
245e0d918bcSEd Tanous             {boost::beast::http::verb::put, {{"ConfigureComponents"}}},
246e0d918bcSEd Tanous             {boost::beast::http::verb::delete_, {{"ConfigureComponents"}}},
247e0d918bcSEd Tanous             {boost::beast::http::verb::post, {{"ConfigureComponents"}}}};
248e37f8451SRapkiewicz, Pawel     }
249e37f8451SRapkiewicz, Pawel 
250e37f8451SRapkiewicz, Pawel   private:
251e37f8451SRapkiewicz, Pawel     /**
252e37f8451SRapkiewicz, Pawel      * Functions triggers appropriate requests on DBus
253e37f8451SRapkiewicz, Pawel      */
25455c7b7a2SEd Tanous     void doGet(crow::Response &res, const crow::Request &req,
2551abe55efSEd Tanous                const std::vector<std::string> &params) override
2561abe55efSEd Tanous     {
257734bfe90SGunnar Mills         const std::array<const char *, 3> interfaces = {
258734bfe90SGunnar Mills             "xyz.openbmc_project.Inventory.Item.Board",
259734bfe90SGunnar Mills             "xyz.openbmc_project.Inventory.Item.Chassis",
260734bfe90SGunnar Mills             "xyz.openbmc_project.Inventory.Item.PowerSupply"};
261734bfe90SGunnar Mills 
262e37f8451SRapkiewicz, Pawel         // Check if there is required param, truly entering this shall be
263e37f8451SRapkiewicz, Pawel         // impossible.
2641abe55efSEd Tanous         if (params.size() != 1)
2651abe55efSEd Tanous         {
266f12894f8SJason M. Bills             messages::internalError(res);
267e37f8451SRapkiewicz, Pawel             res.end();
268e37f8451SRapkiewicz, Pawel             return;
269e37f8451SRapkiewicz, Pawel         }
27099cffd7fSShawn McCarney         const std::string &chassisId = params[0];
271603a6640SGunnar Mills #ifdef BMCWEB_ENABLE_REDFISH_ONE_CHASSIS
272603a6640SGunnar Mills         // In a one chassis system the only supported name is "chassis"
273603a6640SGunnar Mills         if (chassisId != "chassis")
274603a6640SGunnar Mills         {
275603a6640SGunnar Mills             messages::resourceNotFound(res, "#Chassis.v1_4_0.Chassis",
276603a6640SGunnar Mills                                        chassisId);
277603a6640SGunnar Mills             res.end();
278603a6640SGunnar Mills             return;
279603a6640SGunnar Mills         }
280603a6640SGunnar Mills #endif
281e37f8451SRapkiewicz, Pawel 
2820f74e643SEd Tanous         res.jsonValue["@odata.type"] = "#Chassis.v1_4_0.Chassis";
28399cffd7fSShawn McCarney         res.jsonValue["@odata.id"] = "/redfish/v1/Chassis/" + chassisId;
2840f74e643SEd Tanous         res.jsonValue["@odata.context"] =
2850f74e643SEd Tanous             "/redfish/v1/$metadata#Chassis.Chassis";
2860f74e643SEd Tanous         res.jsonValue["Name"] = "Chassis Collection";
2870f74e643SEd Tanous         res.jsonValue["ChassisType"] = "RackMount";
2880f74e643SEd Tanous 
28962d5e2e4SEd Tanous         auto asyncResp = std::make_shared<AsyncResp>(res);
29055c7b7a2SEd Tanous         crow::connections::systemBus->async_method_call(
29162d5e2e4SEd Tanous             [asyncResp, chassisId(std::string(chassisId))](
29262d5e2e4SEd Tanous                 const boost::system::error_code ec,
293daf36e2eSEd Tanous                 const std::vector<std::pair<
2941abe55efSEd Tanous                     std::string, std::vector<std::pair<
2951abe55efSEd Tanous                                      std::string, std::vector<std::string>>>>>
296daf36e2eSEd Tanous                     &subtree) {
29762d5e2e4SEd Tanous                 if (ec)
2981abe55efSEd Tanous                 {
299f12894f8SJason M. Bills                     messages::internalError(asyncResp->res);
300daf36e2eSEd Tanous                     return;
301daf36e2eSEd Tanous                 }
302daf36e2eSEd Tanous                 // Iterate over all retrieved ObjectPaths.
3031abe55efSEd Tanous                 for (const std::pair<
3041abe55efSEd Tanous                          std::string,
3051abe55efSEd Tanous                          std::vector<
3061abe55efSEd Tanous                              std::pair<std::string, std::vector<std::string>>>>
3071abe55efSEd Tanous                          &object : subtree)
3081abe55efSEd Tanous                 {
309daf36e2eSEd Tanous                     const std::string &path = object.first;
3101abe55efSEd Tanous                     const std::vector<
3111abe55efSEd Tanous                         std::pair<std::string, std::vector<std::string>>>
312daf36e2eSEd Tanous                         &connectionNames = object.second;
313e0d918bcSEd Tanous 
314603a6640SGunnar Mills // If only one chassis, just select the first one
315603a6640SGunnar Mills #ifndef BMCWEB_ENABLE_REDFISH_ONE_CHASSIS
3161abe55efSEd Tanous                     if (!boost::ends_with(path, chassisId))
3171abe55efSEd Tanous                     {
318daf36e2eSEd Tanous                         continue;
319daf36e2eSEd Tanous                     }
320603a6640SGunnar Mills #endif
3211abe55efSEd Tanous                     if (connectionNames.size() < 1)
3221abe55efSEd Tanous                     {
3231abe55efSEd Tanous                         BMCWEB_LOG_ERROR << "Only got "
3241abe55efSEd Tanous                                          << connectionNames.size()
32555c7b7a2SEd Tanous                                          << " Connection names";
326e0d918bcSEd Tanous                         continue;
327daf36e2eSEd Tanous                     }
328e0d918bcSEd Tanous 
329daf36e2eSEd Tanous                     const std::string connectionName = connectionNames[0].first;
33055c7b7a2SEd Tanous                     crow::connections::systemBus->async_method_call(
33162d5e2e4SEd Tanous                         [asyncResp, chassisId(std::string(chassisId))](
33262d5e2e4SEd Tanous                             const boost::system::error_code ec,
3331abe55efSEd Tanous                             const std::vector<std::pair<
3341abe55efSEd Tanous                                 std::string, VariantType>> &propertiesList) {
3351abe55efSEd Tanous                             for (const std::pair<std::string, VariantType>
3361abe55efSEd Tanous                                      &property : propertiesList)
3371abe55efSEd Tanous                             {
33899cffd7fSShawn McCarney                                 // Store DBus properties that are also Redfish
33999cffd7fSShawn McCarney                                 // properties with same name and a string value
34099cffd7fSShawn McCarney                                 const std::string &propertyName =
34199cffd7fSShawn McCarney                                     property.first;
34299cffd7fSShawn McCarney                                 if ((propertyName == "PartNumber") ||
34399cffd7fSShawn McCarney                                     (propertyName == "SerialNumber") ||
34499cffd7fSShawn McCarney                                     (propertyName == "Manufacturer") ||
34599cffd7fSShawn McCarney                                     (propertyName == "Model"))
34699cffd7fSShawn McCarney                                 {
347daf36e2eSEd Tanous                                     const std::string *value =
34899cffd7fSShawn McCarney                                         std::get_if<std::string>(
34999cffd7fSShawn McCarney                                             &property.second);
3501abe55efSEd Tanous                                     if (value != nullptr)
3511abe55efSEd Tanous                                     {
35299cffd7fSShawn McCarney                                         asyncResp->res.jsonValue[propertyName] =
35362d5e2e4SEd Tanous                                             *value;
354daf36e2eSEd Tanous                                     }
355daf36e2eSEd Tanous                                 }
35699cffd7fSShawn McCarney                             }
35762d5e2e4SEd Tanous                             asyncResp->res.jsonValue["Name"] = chassisId;
35862d5e2e4SEd Tanous                             asyncResp->res.jsonValue["Id"] = chassisId;
35962d5e2e4SEd Tanous                             asyncResp->res.jsonValue["Thermal"] = {
3601abe55efSEd Tanous                                 {"@odata.id", "/redfish/v1/Chassis/" +
3611abe55efSEd Tanous                                                   chassisId + "/Thermal"}};
3622474adfaSEd Tanous                             // Power object
3632474adfaSEd Tanous                             asyncResp->res.jsonValue["Power"] = {
3642474adfaSEd Tanous                                 {"@odata.id", "/redfish/v1/Chassis/" +
3652474adfaSEd Tanous                                                   chassisId + "/Power"}};
366029573d4SEd Tanous                             asyncResp->res.jsonValue["Status"] = {
367029573d4SEd Tanous                                 {"Health", "OK"},
368029573d4SEd Tanous                                 {"State", "Enabled"},
369029573d4SEd Tanous                             };
3702474adfaSEd Tanous 
371029573d4SEd Tanous                             asyncResp->res
372029573d4SEd Tanous                                 .jsonValue["Links"]["ComputerSystems"] = {
373029573d4SEd Tanous                                 {{"@odata.id", "/redfish/v1/Systems/system"}}};
374029573d4SEd Tanous                             asyncResp->res.jsonValue["Links"]["ManagedBy"] = {
375029573d4SEd Tanous                                 {{"@odata.id", "/redfish/v1/Managers/bmc"}}};
376*beeca0aeSGunnar Mills                             getChassisState(asyncResp);
377daf36e2eSEd Tanous                         },
378daf36e2eSEd Tanous                         connectionName, path, "org.freedesktop.DBus.Properties",
3791abe55efSEd Tanous                         "GetAll",
3801abe55efSEd Tanous                         "xyz.openbmc_project.Inventory.Decorator.Asset");
381daf36e2eSEd Tanous                     return;
382daf36e2eSEd Tanous                 }
383e0d918bcSEd Tanous 
384daf36e2eSEd Tanous                 // Couldn't find an object with that name.  return an error
385f12894f8SJason M. Bills                 messages::resourceNotFound(
386f12894f8SJason M. Bills                     asyncResp->res, "#Chassis.v1_4_0.Chassis", chassisId);
387daf36e2eSEd Tanous             },
388daf36e2eSEd Tanous             "xyz.openbmc_project.ObjectMapper",
389daf36e2eSEd Tanous             "/xyz/openbmc_project/object_mapper",
390daf36e2eSEd Tanous             "xyz.openbmc_project.ObjectMapper", "GetSubTree",
391734bfe90SGunnar Mills             "/xyz/openbmc_project/inventory", int32_t(0), interfaces);
392c181942fSQiang XU 
393c181942fSQiang XU         getPhysicalSecurityData(asyncResp);
394e37f8451SRapkiewicz, Pawel     }
39562d5e2e4SEd Tanous };
396e37f8451SRapkiewicz, Pawel } // namespace redfish
397