xref: /openbmc/bmcweb/features/redfish/lib/chassis.hpp (revision 49c53ac9b88fbf71f55076121a1605a760fa0096)
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 /**
27beeca0aeSGunnar Mills  * @brief Retrieves chassis state properties over dbus
28beeca0aeSGunnar Mills  *
29beeca0aeSGunnar Mills  * @param[in] aResp - Shared pointer for completing asynchronous calls.
30beeca0aeSGunnar Mills  *
31beeca0aeSGunnar Mills  * @return None.
32beeca0aeSGunnar Mills  */
33beeca0aeSGunnar Mills void getChassisState(std::shared_ptr<AsyncResp> aResp)
34beeca0aeSGunnar Mills {
35beeca0aeSGunnar Mills     crow::connections::systemBus->async_method_call(
36beeca0aeSGunnar Mills         [aResp{std::move(aResp)}](
37beeca0aeSGunnar Mills             const boost::system::error_code ec,
38beeca0aeSGunnar Mills             const std::variant<std::string> &chassisState) {
39beeca0aeSGunnar Mills             if (ec)
40beeca0aeSGunnar Mills             {
41beeca0aeSGunnar Mills                 BMCWEB_LOG_DEBUG << "DBUS response error " << ec;
42beeca0aeSGunnar Mills                 messages::internalError(aResp->res);
43beeca0aeSGunnar Mills                 return;
44beeca0aeSGunnar Mills             }
45beeca0aeSGunnar Mills 
46beeca0aeSGunnar Mills             const std::string *s = std::get_if<std::string>(&chassisState);
47beeca0aeSGunnar Mills             BMCWEB_LOG_DEBUG << "Chassis state: " << *s;
48beeca0aeSGunnar Mills             if (s != nullptr)
49beeca0aeSGunnar Mills             {
50beeca0aeSGunnar Mills                 // Verify Chassis State
51beeca0aeSGunnar Mills                 if (*s == "xyz.openbmc_project.State.Chassis.PowerState.On")
52beeca0aeSGunnar Mills                 {
53beeca0aeSGunnar Mills                     aResp->res.jsonValue["PowerState"] = "On";
54beeca0aeSGunnar Mills                     aResp->res.jsonValue["Status"]["State"] = "Enabled";
55beeca0aeSGunnar Mills                 }
56beeca0aeSGunnar Mills                 else if (*s ==
57beeca0aeSGunnar Mills                          "xyz.openbmc_project.State.Chassis.PowerState.Off")
58beeca0aeSGunnar Mills                 {
59beeca0aeSGunnar Mills                     aResp->res.jsonValue["PowerState"] = "Off";
60beeca0aeSGunnar Mills                     aResp->res.jsonValue["Status"]["State"] = "StandbyOffline";
61beeca0aeSGunnar Mills                 }
62beeca0aeSGunnar Mills             }
63beeca0aeSGunnar Mills         },
64beeca0aeSGunnar Mills         "xyz.openbmc_project.State.Chassis",
65beeca0aeSGunnar Mills         "/xyz/openbmc_project/state/chassis0",
66beeca0aeSGunnar Mills         "org.freedesktop.DBus.Properties", "Get",
67beeca0aeSGunnar Mills         "xyz.openbmc_project.State.Chassis", "CurrentPowerState");
68beeca0aeSGunnar Mills }
69beeca0aeSGunnar Mills 
70beeca0aeSGunnar 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 
28262d5e2e4SEd Tanous         auto asyncResp = std::make_shared<AsyncResp>(res);
28355c7b7a2SEd Tanous         crow::connections::systemBus->async_method_call(
28462d5e2e4SEd Tanous             [asyncResp, chassisId(std::string(chassisId))](
28562d5e2e4SEd Tanous                 const boost::system::error_code ec,
286daf36e2eSEd Tanous                 const std::vector<std::pair<
2871abe55efSEd Tanous                     std::string, std::vector<std::pair<
2881abe55efSEd Tanous                                      std::string, std::vector<std::string>>>>>
289daf36e2eSEd Tanous                     &subtree) {
29062d5e2e4SEd Tanous                 if (ec)
2911abe55efSEd Tanous                 {
292f12894f8SJason M. Bills                     messages::internalError(asyncResp->res);
293daf36e2eSEd Tanous                     return;
294daf36e2eSEd Tanous                 }
295daf36e2eSEd Tanous                 // Iterate over all retrieved ObjectPaths.
2961abe55efSEd Tanous                 for (const std::pair<
2971abe55efSEd Tanous                          std::string,
2981abe55efSEd Tanous                          std::vector<
2991abe55efSEd Tanous                              std::pair<std::string, std::vector<std::string>>>>
3001abe55efSEd Tanous                          &object : subtree)
3011abe55efSEd Tanous                 {
302daf36e2eSEd Tanous                     const std::string &path = object.first;
3031abe55efSEd Tanous                     const std::vector<
3041abe55efSEd Tanous                         std::pair<std::string, std::vector<std::string>>>
305daf36e2eSEd Tanous                         &connectionNames = object.second;
306e0d918bcSEd Tanous 
307603a6640SGunnar Mills // If only one chassis, just select the first one
308603a6640SGunnar Mills #ifndef BMCWEB_ENABLE_REDFISH_ONE_CHASSIS
3091abe55efSEd Tanous                     if (!boost::ends_with(path, chassisId))
3101abe55efSEd Tanous                     {
311daf36e2eSEd Tanous                         continue;
312daf36e2eSEd Tanous                     }
313603a6640SGunnar Mills #endif
3141abe55efSEd Tanous                     if (connectionNames.size() < 1)
3151abe55efSEd Tanous                     {
3161abe55efSEd Tanous                         BMCWEB_LOG_ERROR << "Only got "
3171abe55efSEd Tanous                                          << connectionNames.size()
31855c7b7a2SEd Tanous                                          << " Connection names";
319e0d918bcSEd Tanous                         continue;
320daf36e2eSEd Tanous                     }
321e0d918bcSEd Tanous 
322*49c53ac9SJohnathan Mantey                     asyncResp->res.jsonValue["@odata.type"] =
323*49c53ac9SJohnathan Mantey                         "#Chassis.v1_4_0.Chassis";
324*49c53ac9SJohnathan Mantey                     asyncResp->res.jsonValue["@odata.id"] =
325*49c53ac9SJohnathan Mantey                         "/redfish/v1/Chassis/" + chassisId;
326*49c53ac9SJohnathan Mantey                     asyncResp->res.jsonValue["@odata.context"] =
327*49c53ac9SJohnathan Mantey                         "/redfish/v1/$metadata#Chassis.Chassis";
328*49c53ac9SJohnathan Mantey                     asyncResp->res.jsonValue["Name"] = "Chassis Collection";
329*49c53ac9SJohnathan Mantey                     asyncResp->res.jsonValue["ChassisType"] = "RackMount";
330*49c53ac9SJohnathan Mantey 
331*49c53ac9SJohnathan Mantey                     const std::string &connectionName =
332*49c53ac9SJohnathan Mantey                         connectionNames[0].first;
33355c7b7a2SEd Tanous                     crow::connections::systemBus->async_method_call(
33462d5e2e4SEd Tanous                         [asyncResp, chassisId(std::string(chassisId))](
33562d5e2e4SEd Tanous                             const boost::system::error_code ec,
3361abe55efSEd Tanous                             const std::vector<std::pair<
3371abe55efSEd Tanous                                 std::string, VariantType>> &propertiesList) {
3381abe55efSEd Tanous                             for (const std::pair<std::string, VariantType>
3391abe55efSEd Tanous                                      &property : propertiesList)
3401abe55efSEd Tanous                             {
34199cffd7fSShawn McCarney                                 // Store DBus properties that are also Redfish
34299cffd7fSShawn McCarney                                 // properties with same name and a string value
34399cffd7fSShawn McCarney                                 const std::string &propertyName =
34499cffd7fSShawn McCarney                                     property.first;
34599cffd7fSShawn McCarney                                 if ((propertyName == "PartNumber") ||
34699cffd7fSShawn McCarney                                     (propertyName == "SerialNumber") ||
34799cffd7fSShawn McCarney                                     (propertyName == "Manufacturer") ||
34899cffd7fSShawn McCarney                                     (propertyName == "Model"))
34999cffd7fSShawn McCarney                                 {
350daf36e2eSEd Tanous                                     const std::string *value =
35199cffd7fSShawn McCarney                                         std::get_if<std::string>(
35299cffd7fSShawn McCarney                                             &property.second);
3531abe55efSEd Tanous                                     if (value != nullptr)
3541abe55efSEd Tanous                                     {
35599cffd7fSShawn McCarney                                         asyncResp->res.jsonValue[propertyName] =
35662d5e2e4SEd Tanous                                             *value;
357daf36e2eSEd Tanous                                     }
358daf36e2eSEd Tanous                                 }
35999cffd7fSShawn McCarney                             }
36062d5e2e4SEd Tanous                             asyncResp->res.jsonValue["Name"] = chassisId;
36162d5e2e4SEd Tanous                             asyncResp->res.jsonValue["Id"] = chassisId;
36262d5e2e4SEd Tanous                             asyncResp->res.jsonValue["Thermal"] = {
3631abe55efSEd Tanous                                 {"@odata.id", "/redfish/v1/Chassis/" +
3641abe55efSEd Tanous                                                   chassisId + "/Thermal"}};
3652474adfaSEd Tanous                             // Power object
3662474adfaSEd Tanous                             asyncResp->res.jsonValue["Power"] = {
3672474adfaSEd Tanous                                 {"@odata.id", "/redfish/v1/Chassis/" +
3682474adfaSEd Tanous                                                   chassisId + "/Power"}};
369029573d4SEd Tanous                             asyncResp->res.jsonValue["Status"] = {
370029573d4SEd Tanous                                 {"Health", "OK"},
371029573d4SEd Tanous                                 {"State", "Enabled"},
372029573d4SEd Tanous                             };
3732474adfaSEd Tanous 
374029573d4SEd Tanous                             asyncResp->res
375029573d4SEd Tanous                                 .jsonValue["Links"]["ComputerSystems"] = {
376029573d4SEd Tanous                                 {{"@odata.id", "/redfish/v1/Systems/system"}}};
377029573d4SEd Tanous                             asyncResp->res.jsonValue["Links"]["ManagedBy"] = {
378029573d4SEd Tanous                                 {{"@odata.id", "/redfish/v1/Managers/bmc"}}};
379beeca0aeSGunnar Mills                             getChassisState(asyncResp);
380daf36e2eSEd Tanous                         },
381daf36e2eSEd Tanous                         connectionName, path, "org.freedesktop.DBus.Properties",
3821abe55efSEd Tanous                         "GetAll",
3831abe55efSEd Tanous                         "xyz.openbmc_project.Inventory.Decorator.Asset");
384daf36e2eSEd Tanous                     return;
385daf36e2eSEd Tanous                 }
386e0d918bcSEd Tanous 
387daf36e2eSEd Tanous                 // Couldn't find an object with that name.  return an error
388f12894f8SJason M. Bills                 messages::resourceNotFound(
389f12894f8SJason M. Bills                     asyncResp->res, "#Chassis.v1_4_0.Chassis", chassisId);
390daf36e2eSEd Tanous             },
391daf36e2eSEd Tanous             "xyz.openbmc_project.ObjectMapper",
392daf36e2eSEd Tanous             "/xyz/openbmc_project/object_mapper",
393daf36e2eSEd Tanous             "xyz.openbmc_project.ObjectMapper", "GetSubTree",
394734bfe90SGunnar Mills             "/xyz/openbmc_project/inventory", int32_t(0), interfaces);
395c181942fSQiang XU 
396c181942fSQiang XU         getPhysicalSecurityData(asyncResp);
397e37f8451SRapkiewicz, Pawel     }
39862d5e2e4SEd Tanous };
399e37f8451SRapkiewicz, Pawel } // namespace redfish
400