xref: /openbmc/bmcweb/features/redfish/lib/managers.hpp (revision 79f3b6a1e088e43eb575d68198f60c5d143b909b)
140e9b92eSEd Tanous // SPDX-License-Identifier: Apache-2.0
240e9b92eSEd Tanous // SPDX-FileCopyrightText: Copyright OpenBMC Authors
340e9b92eSEd Tanous // SPDX-FileCopyrightText: Copyright 2018 Intel Corporation
49c310685SBorawski.Lukasz #pragma once
59c310685SBorawski.Lukasz 
613451e39SWilly Tu #include "bmcweb_config.h"
713451e39SWilly Tu 
8a51fc2d2SSui Chen #include "app.hpp"
9d7857201SEd Tanous #include "async_resp.hpp"
10d7857201SEd Tanous #include "dbus_singleton.hpp"
11a51fc2d2SSui Chen #include "dbus_utility.hpp"
12d7857201SEd Tanous #include "error_messages.hpp"
13539d8c6bSEd Tanous #include "generated/enums/action_info.hpp"
14539d8c6bSEd Tanous #include "generated/enums/manager.hpp"
15539d8c6bSEd Tanous #include "generated/enums/resource.hpp"
16d7857201SEd Tanous #include "http_request.hpp"
17*79f3b6a1SGeorge Liu #include "led.hpp"
18d7857201SEd Tanous #include "logging.hpp"
19d7857201SEd Tanous #include "persistent_data.hpp"
20a51fc2d2SSui Chen #include "query.hpp"
21c1a75ebcSrohitpai #include "redfish.hpp"
22c5d03ff4SJennifer Lee #include "redfish_util.hpp"
23a51fc2d2SSui Chen #include "registries/privilege_registry.hpp"
24fac6e53bSKrzysztof Grobelny #include "utils/dbus_utils.hpp"
253ccb3adbSEd Tanous #include "utils/json_utils.hpp"
26a51fc2d2SSui Chen #include "utils/sw_utils.hpp"
27a51fc2d2SSui Chen #include "utils/systemd_utils.hpp"
282b82937eSEd Tanous #include "utils/time_utils.hpp"
299c310685SBorawski.Lukasz 
30d7857201SEd Tanous #include <systemd/sd-bus.h>
31d7857201SEd Tanous 
32d7857201SEd Tanous #include <boost/beast/http/status.hpp>
33d7857201SEd Tanous #include <boost/beast/http/verb.hpp>
34e99073f5SGeorge Liu #include <boost/system/error_code.hpp>
35ef4c65b7SEd Tanous #include <boost/url/format.hpp>
36d7857201SEd Tanous #include <boost/url/url.hpp>
37d7857201SEd Tanous #include <nlohmann/json.hpp>
38fac6e53bSKrzysztof Grobelny #include <sdbusplus/asio/property.hpp>
39d7857201SEd Tanous #include <sdbusplus/message.hpp>
40d7857201SEd Tanous #include <sdbusplus/message/native_types.hpp>
41fac6e53bSKrzysztof Grobelny #include <sdbusplus/unpack_properties.hpp>
421214b7e7SGunnar Mills 
43e99073f5SGeorge Liu #include <array>
44d7857201SEd Tanous #include <cstddef>
454bfefa74SGunnar Mills #include <cstdint>
46d7857201SEd Tanous #include <format>
47d7857201SEd Tanous #include <functional>
48d7857201SEd Tanous #include <map>
491214b7e7SGunnar Mills #include <memory>
509970e93fSKonstantin Aladyshev #include <optional>
513544d2a7SEd Tanous #include <ranges>
529970e93fSKonstantin Aladyshev #include <string>
53e99073f5SGeorge Liu #include <string_view>
54d7857201SEd Tanous #include <utility>
55d7857201SEd Tanous #include <vector>
565b4aa86bSJames Feist 
571abe55efSEd Tanous namespace redfish
581abe55efSEd Tanous {
59ed5befbdSJennifer Lee 
60*79f3b6a1SGeorge Liu inline void handleSetLocationIndicatorActive(
61*79f3b6a1SGeorge Liu     const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
62*79f3b6a1SGeorge Liu     bool locationIndicatorActive, const std::string& managerId,
63*79f3b6a1SGeorge Liu     const boost::system::error_code& ec,
64*79f3b6a1SGeorge Liu     const dbus::utility::MapperGetSubTreePathsResponse& subtreePaths)
65*79f3b6a1SGeorge Liu {
66*79f3b6a1SGeorge Liu     if (ec)
67*79f3b6a1SGeorge Liu     {
68*79f3b6a1SGeorge Liu         if (ec == boost::system::errc::io_error)
69*79f3b6a1SGeorge Liu         {
70*79f3b6a1SGeorge Liu             // Not found
71*79f3b6a1SGeorge Liu             BMCWEB_LOG_WARNING("Manager {} not found", managerId);
72*79f3b6a1SGeorge Liu             messages::resourceNotFound(asyncResp->res, "Manager", managerId);
73*79f3b6a1SGeorge Liu             return;
74*79f3b6a1SGeorge Liu         }
75*79f3b6a1SGeorge Liu         BMCWEB_LOG_ERROR("D-Bus response error {}", ec.value());
76*79f3b6a1SGeorge Liu         messages::internalError(asyncResp->res);
77*79f3b6a1SGeorge Liu         return;
78*79f3b6a1SGeorge Liu     }
79*79f3b6a1SGeorge Liu     if (subtreePaths.empty())
80*79f3b6a1SGeorge Liu     {
81*79f3b6a1SGeorge Liu         BMCWEB_LOG_WARNING("Manager {} not found", managerId);
82*79f3b6a1SGeorge Liu         messages::resourceNotFound(asyncResp->res, "Manager", managerId);
83*79f3b6a1SGeorge Liu         return;
84*79f3b6a1SGeorge Liu     }
85*79f3b6a1SGeorge Liu     // Assume only 1 bmc D-Bus object
86*79f3b6a1SGeorge Liu     // Throw an error if there is more than 1
87*79f3b6a1SGeorge Liu     if (subtreePaths.size() != 1)
88*79f3b6a1SGeorge Liu     {
89*79f3b6a1SGeorge Liu         BMCWEB_LOG_ERROR("Found {} Bmc D-Bus paths", subtreePaths.size());
90*79f3b6a1SGeorge Liu         messages::internalError(asyncResp->res);
91*79f3b6a1SGeorge Liu         return;
92*79f3b6a1SGeorge Liu     }
93*79f3b6a1SGeorge Liu 
94*79f3b6a1SGeorge Liu     setLocationIndicatorActive(asyncResp, subtreePaths[0],
95*79f3b6a1SGeorge Liu                                locationIndicatorActive);
96*79f3b6a1SGeorge Liu }
97*79f3b6a1SGeorge Liu 
98*79f3b6a1SGeorge Liu /**
99*79f3b6a1SGeorge Liu  * Set the locationIndicatorActive.
100*79f3b6a1SGeorge Liu  *
101*79f3b6a1SGeorge Liu  * @param[in,out]   asyncResp                   Async HTTP response.
102*79f3b6a1SGeorge Liu  * @param[in]       locationIndicatorActive     Value of the property
103*79f3b6a1SGeorge Liu  */
104*79f3b6a1SGeorge Liu inline void setLocationIndicatorActiveState(
105*79f3b6a1SGeorge Liu     const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
106*79f3b6a1SGeorge Liu     bool locationIndicatorActive, const std::string& managerId)
107*79f3b6a1SGeorge Liu {
108*79f3b6a1SGeorge Liu     // GetSubTree on all interfaces which provide info about a Manager
109*79f3b6a1SGeorge Liu     constexpr std::array<std::string_view, 1> interfaces = {
110*79f3b6a1SGeorge Liu         "xyz.openbmc_project.Inventory.Item.Bmc"};
111*79f3b6a1SGeorge Liu     dbus::utility::getSubTreePaths(
112*79f3b6a1SGeorge Liu         "/xyz/openbmc_project/inventory", 0, interfaces,
113*79f3b6a1SGeorge Liu         std::bind_front(handleSetLocationIndicatorActive, asyncResp,
114*79f3b6a1SGeorge Liu                         locationIndicatorActive, managerId));
115*79f3b6a1SGeorge Liu }
116*79f3b6a1SGeorge Liu 
117d27c31e9SJagpal Singh Gill inline std::string getBMCUpdateServiceName()
118d27c31e9SJagpal Singh Gill {
119d27c31e9SJagpal Singh Gill     if constexpr (BMCWEB_REDFISH_UPDATESERVICE_USE_DBUS)
120d27c31e9SJagpal Singh Gill     {
121d27c31e9SJagpal Singh Gill         return "xyz.openbmc_project.Software.Manager";
122d27c31e9SJagpal Singh Gill     }
123d27c31e9SJagpal Singh Gill     return "xyz.openbmc_project.Software.BMC.Updater";
124d27c31e9SJagpal Singh Gill }
125d27c31e9SJagpal Singh Gill 
126d27c31e9SJagpal Singh Gill inline std::string getBMCUpdateServicePath()
127d27c31e9SJagpal Singh Gill {
128d27c31e9SJagpal Singh Gill     if constexpr (BMCWEB_REDFISH_UPDATESERVICE_USE_DBUS)
129d27c31e9SJagpal Singh Gill     {
130d27c31e9SJagpal Singh Gill         return "/xyz/openbmc_project/software/bmc";
131d27c31e9SJagpal Singh Gill     }
132d27c31e9SJagpal Singh Gill     return "/xyz/openbmc_project/software";
133d27c31e9SJagpal Singh Gill }
134d27c31e9SJagpal Singh Gill 
135ed5befbdSJennifer Lee /**
1362a5c4407SGunnar Mills  * Function reboots the BMC.
1372a5c4407SGunnar Mills  *
1382a5c4407SGunnar Mills  * @param[in] asyncResp - Shared pointer for completing asynchronous calls
139ed5befbdSJennifer Lee  */
140504af5a0SPatrick Williams inline void doBMCGracefulRestart(
141504af5a0SPatrick Williams     const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
142ed5befbdSJennifer Lee {
143ed5befbdSJennifer Lee     const char* processName = "xyz.openbmc_project.State.BMC";
144ed5befbdSJennifer Lee     const char* objectPath = "/xyz/openbmc_project/state/bmc0";
145ed5befbdSJennifer Lee     const char* interfaceName = "xyz.openbmc_project.State.BMC";
146ed5befbdSJennifer Lee     const std::string& propertyValue =
147ed5befbdSJennifer Lee         "xyz.openbmc_project.State.BMC.Transition.Reboot";
148ed5befbdSJennifer Lee     const char* destProperty = "RequestedBMCTransition";
149ed5befbdSJennifer Lee 
150ed5befbdSJennifer Lee     // Create the D-Bus variant for D-Bus call.
1519ae226faSGeorge Liu     sdbusplus::asio::setProperty(
1529ae226faSGeorge Liu         *crow::connections::systemBus, processName, objectPath, interfaceName,
1539ae226faSGeorge Liu         destProperty, propertyValue,
1545e7e2dc5SEd Tanous         [asyncResp](const boost::system::error_code& ec) {
155ed5befbdSJennifer Lee             // Use "Set" method to set the property value.
156ed5befbdSJennifer Lee             if (ec)
157ed5befbdSJennifer Lee             {
15862598e31SEd Tanous                 BMCWEB_LOG_DEBUG("[Set] Bad D-Bus request error: {}", ec);
159ed5befbdSJennifer Lee                 messages::internalError(asyncResp->res);
160ed5befbdSJennifer Lee                 return;
161ed5befbdSJennifer Lee             }
162ed5befbdSJennifer Lee 
163ed5befbdSJennifer Lee             messages::success(asyncResp->res);
1649ae226faSGeorge Liu         });
165ed5befbdSJennifer Lee }
1662a5c4407SGunnar Mills 
167504af5a0SPatrick Williams inline void doBMCForceRestart(
168504af5a0SPatrick Williams     const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
169f92af389SJayaprakash Mutyala {
170f92af389SJayaprakash Mutyala     const char* processName = "xyz.openbmc_project.State.BMC";
171f92af389SJayaprakash Mutyala     const char* objectPath = "/xyz/openbmc_project/state/bmc0";
172f92af389SJayaprakash Mutyala     const char* interfaceName = "xyz.openbmc_project.State.BMC";
173f92af389SJayaprakash Mutyala     const std::string& propertyValue =
174f92af389SJayaprakash Mutyala         "xyz.openbmc_project.State.BMC.Transition.HardReboot";
175f92af389SJayaprakash Mutyala     const char* destProperty = "RequestedBMCTransition";
176f92af389SJayaprakash Mutyala 
177f92af389SJayaprakash Mutyala     // Create the D-Bus variant for D-Bus call.
1789ae226faSGeorge Liu     sdbusplus::asio::setProperty(
1799ae226faSGeorge Liu         *crow::connections::systemBus, processName, objectPath, interfaceName,
1809ae226faSGeorge Liu         destProperty, propertyValue,
1815e7e2dc5SEd Tanous         [asyncResp](const boost::system::error_code& ec) {
182f92af389SJayaprakash Mutyala             // Use "Set" method to set the property value.
183f92af389SJayaprakash Mutyala             if (ec)
184f92af389SJayaprakash Mutyala             {
18562598e31SEd Tanous                 BMCWEB_LOG_DEBUG("[Set] Bad D-Bus request error: {}", ec);
186f92af389SJayaprakash Mutyala                 messages::internalError(asyncResp->res);
187f92af389SJayaprakash Mutyala                 return;
188f92af389SJayaprakash Mutyala             }
189f92af389SJayaprakash Mutyala 
190f92af389SJayaprakash Mutyala             messages::success(asyncResp->res);
1919ae226faSGeorge Liu         });
192f92af389SJayaprakash Mutyala }
193f92af389SJayaprakash Mutyala 
1942a5c4407SGunnar Mills /**
1952a5c4407SGunnar Mills  * ManagerResetAction class supports the POST method for the Reset (reboot)
1962a5c4407SGunnar Mills  * action.
1972a5c4407SGunnar Mills  */
1987e860f15SJohn Edward Broadbent inline void requestRoutesManagerResetAction(App& app)
1992a5c4407SGunnar Mills {
2002a5c4407SGunnar Mills     /**
2012a5c4407SGunnar Mills      * Function handles POST method request.
2022a5c4407SGunnar Mills      * Analyzes POST body before sending Reset (Reboot) request data to D-Bus.
203f92af389SJayaprakash Mutyala      * OpenBMC supports ResetType "GracefulRestart" and "ForceRestart".
2042a5c4407SGunnar Mills      */
2057e860f15SJohn Edward Broadbent 
206253f11b8SEd Tanous     BMCWEB_ROUTE(app, "/redfish/v1/Managers/<str>/Actions/Manager.Reset/")
207ed398213SEd Tanous         .privileges(redfish::privileges::postManager)
2087e860f15SJohn Edward Broadbent         .methods(boost::beast::http::verb::post)(
20945ca1b86SEd Tanous             [&app](const crow::Request& req,
210253f11b8SEd Tanous                    const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
211253f11b8SEd Tanous                    const std::string& managerId) {
2123ba00073SCarson Labrado                 if (!redfish::setUpRedfishRoute(app, req, asyncResp))
21345ca1b86SEd Tanous                 {
21445ca1b86SEd Tanous                     return;
21545ca1b86SEd Tanous                 }
216253f11b8SEd Tanous                 if (managerId != BMCWEB_REDFISH_MANAGER_URI_NAME)
217253f11b8SEd Tanous                 {
218bd79bce8SPatrick Williams                     messages::resourceNotFound(asyncResp->res, "Manager",
219bd79bce8SPatrick Williams                                                managerId);
220253f11b8SEd Tanous                     return;
221253f11b8SEd Tanous                 }
222253f11b8SEd Tanous 
22362598e31SEd Tanous                 BMCWEB_LOG_DEBUG("Post Manager Reset.");
2242a5c4407SGunnar Mills 
2252a5c4407SGunnar Mills                 std::string resetType;
2262a5c4407SGunnar Mills 
22715ed6780SWilly Tu                 if (!json_util::readJsonAction(req, asyncResp->res, "ResetType",
2287e860f15SJohn Edward Broadbent                                                resetType))
2292a5c4407SGunnar Mills                 {
2302a5c4407SGunnar Mills                     return;
2312a5c4407SGunnar Mills                 }
2322a5c4407SGunnar Mills 
233f92af389SJayaprakash Mutyala                 if (resetType == "GracefulRestart")
234f92af389SJayaprakash Mutyala                 {
23562598e31SEd Tanous                     BMCWEB_LOG_DEBUG("Proceeding with {}", resetType);
236f92af389SJayaprakash Mutyala                     doBMCGracefulRestart(asyncResp);
237f92af389SJayaprakash Mutyala                     return;
238f92af389SJayaprakash Mutyala                 }
2393174e4dfSEd Tanous                 if (resetType == "ForceRestart")
240f92af389SJayaprakash Mutyala                 {
24162598e31SEd Tanous                     BMCWEB_LOG_DEBUG("Proceeding with {}", resetType);
242f92af389SJayaprakash Mutyala                     doBMCForceRestart(asyncResp);
243f92af389SJayaprakash Mutyala                     return;
244f92af389SJayaprakash Mutyala                 }
245bd79bce8SPatrick Williams                 BMCWEB_LOG_DEBUG("Invalid property value for ResetType: {}",
246bd79bce8SPatrick Williams                                  resetType);
2472a5c4407SGunnar Mills                 messages::actionParameterNotSupported(asyncResp->res, resetType,
2482a5c4407SGunnar Mills                                                       "ResetType");
2492a5c4407SGunnar Mills 
2502a5c4407SGunnar Mills                 return;
2517e860f15SJohn Edward Broadbent             });
2522a5c4407SGunnar Mills }
253ed5befbdSJennifer Lee 
2543e40fc74SGunnar Mills /**
2553e40fc74SGunnar Mills  * ManagerResetToDefaultsAction class supports POST method for factory reset
2563e40fc74SGunnar Mills  * action.
2573e40fc74SGunnar Mills  */
2587e860f15SJohn Edward Broadbent inline void requestRoutesManagerResetToDefaultsAction(App& app)
2593e40fc74SGunnar Mills {
2603e40fc74SGunnar Mills     /**
2613e40fc74SGunnar Mills      * Function handles ResetToDefaults POST method request.
2623e40fc74SGunnar Mills      *
2633e40fc74SGunnar Mills      * Analyzes POST body message and factory resets BMC by calling
2643e40fc74SGunnar Mills      * BMC code updater factory reset followed by a BMC reboot.
2653e40fc74SGunnar Mills      *
2663e40fc74SGunnar Mills      * BMC code updater factory reset wipes the whole BMC read-write
2673e40fc74SGunnar Mills      * filesystem which includes things like the network settings.
2683e40fc74SGunnar Mills      *
26918bf4bf6SGunnar Mills      * OpenBMC only supports ResetType "ResetAll".
2703e40fc74SGunnar Mills      */
2717e860f15SJohn Edward Broadbent 
2727e860f15SJohn Edward Broadbent     BMCWEB_ROUTE(app,
273253f11b8SEd Tanous                  "/redfish/v1/Managers/<str>/Actions/Manager.ResetToDefaults/")
274ed398213SEd Tanous         .privileges(redfish::privileges::postManager)
27518bf4bf6SGunnar Mills         .methods(boost::beast::http::verb::post)(
27618bf4bf6SGunnar Mills             [&app](const crow::Request& req,
277253f11b8SEd Tanous                    const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
278253f11b8SEd Tanous                    const std::string& managerId) {
2793ba00073SCarson Labrado                 if (!redfish::setUpRedfishRoute(app, req, asyncResp))
28045ca1b86SEd Tanous                 {
28145ca1b86SEd Tanous                     return;
28245ca1b86SEd Tanous                 }
283253f11b8SEd Tanous 
284253f11b8SEd Tanous                 if (managerId != BMCWEB_REDFISH_MANAGER_URI_NAME)
285253f11b8SEd Tanous                 {
286bd79bce8SPatrick Williams                     messages::resourceNotFound(asyncResp->res, "Manager",
287bd79bce8SPatrick Williams                                                managerId);
288253f11b8SEd Tanous                     return;
289253f11b8SEd Tanous                 }
290253f11b8SEd Tanous 
29162598e31SEd Tanous                 BMCWEB_LOG_DEBUG("Post ResetToDefaults.");
2923e40fc74SGunnar Mills 
2939970e93fSKonstantin Aladyshev                 std::optional<std::string> resetType;
2943e40fc74SGunnar Mills 
295afc474aeSMyung Bae                 if (!json_util::readJsonAction( //
296afc474aeSMyung Bae                         req, asyncResp->res,    //
297afc474aeSMyung Bae                         "ResetType", resetType  //
298afc474aeSMyung Bae                         ))
2993e40fc74SGunnar Mills                 {
3009970e93fSKonstantin Aladyshev                     BMCWEB_LOG_DEBUG("Missing property ResetType.");
3013e40fc74SGunnar Mills 
302bd79bce8SPatrick Williams                     messages::actionParameterMissing(
303bd79bce8SPatrick Williams                         asyncResp->res, "ResetToDefaults", "ResetType");
3043e40fc74SGunnar Mills                     return;
3053e40fc74SGunnar Mills                 }
3063e40fc74SGunnar Mills 
3073e40fc74SGunnar Mills                 if (resetType != "ResetAll")
3083e40fc74SGunnar Mills                 {
3099970e93fSKonstantin Aladyshev                     BMCWEB_LOG_DEBUG("Invalid property value for ResetType: {}",
3109970e93fSKonstantin Aladyshev                                      *resetType);
31118bf4bf6SGunnar Mills                     messages::actionParameterNotSupported(
31218bf4bf6SGunnar Mills                         asyncResp->res, *resetType, "ResetType");
3133e40fc74SGunnar Mills                     return;
3143e40fc74SGunnar Mills                 }
3153e40fc74SGunnar Mills 
3163e40fc74SGunnar Mills                 crow::connections::systemBus->async_method_call(
3175e7e2dc5SEd Tanous                     [asyncResp](const boost::system::error_code& ec) {
3183e40fc74SGunnar Mills                         if (ec)
3193e40fc74SGunnar Mills                         {
32018bf4bf6SGunnar Mills                             BMCWEB_LOG_DEBUG("Failed to ResetToDefaults: {}",
32118bf4bf6SGunnar Mills                                              ec);
3223e40fc74SGunnar Mills                             messages::internalError(asyncResp->res);
3233e40fc74SGunnar Mills                             return;
3243e40fc74SGunnar Mills                         }
3253e40fc74SGunnar Mills                         // Factory Reset doesn't actually happen until a reboot
3263e40fc74SGunnar Mills                         // Can't erase what the BMC is running on
3273e40fc74SGunnar Mills                         doBMCGracefulRestart(asyncResp);
3283e40fc74SGunnar Mills                     },
329d27c31e9SJagpal Singh Gill                     getBMCUpdateServiceName(), getBMCUpdateServicePath(),
3303e40fc74SGunnar Mills                     "xyz.openbmc_project.Common.FactoryReset", "Reset");
3317e860f15SJohn Edward Broadbent             });
3323e40fc74SGunnar Mills }
3333e40fc74SGunnar Mills 
3341cb1a9e6SAppaRao Puli /**
3351cb1a9e6SAppaRao Puli  * ManagerResetActionInfo derived class for delivering Manager
3361cb1a9e6SAppaRao Puli  * ResetType AllowableValues using ResetInfo schema.
3371cb1a9e6SAppaRao Puli  */
3387e860f15SJohn Edward Broadbent inline void requestRoutesManagerResetActionInfo(App& app)
3391cb1a9e6SAppaRao Puli {
3401cb1a9e6SAppaRao Puli     /**
3411cb1a9e6SAppaRao Puli      * Functions triggers appropriate requests on DBus
3421cb1a9e6SAppaRao Puli      */
3437e860f15SJohn Edward Broadbent 
344253f11b8SEd Tanous     BMCWEB_ROUTE(app, "/redfish/v1/Managers/<str>/ResetActionInfo/")
345ed398213SEd Tanous         .privileges(redfish::privileges::getActionInfo)
3467e860f15SJohn Edward Broadbent         .methods(boost::beast::http::verb::get)(
34745ca1b86SEd Tanous             [&app](const crow::Request& req,
348253f11b8SEd Tanous                    const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
349253f11b8SEd Tanous                    const std::string& managerId) {
3503ba00073SCarson Labrado                 if (!redfish::setUpRedfishRoute(app, req, asyncResp))
35145ca1b86SEd Tanous                 {
35245ca1b86SEd Tanous                     return;
35345ca1b86SEd Tanous                 }
3541476687dSEd Tanous 
355253f11b8SEd Tanous                 if (managerId != BMCWEB_REDFISH_MANAGER_URI_NAME)
356253f11b8SEd Tanous                 {
357bd79bce8SPatrick Williams                     messages::resourceNotFound(asyncResp->res, "Manager",
358bd79bce8SPatrick Williams                                                managerId);
359253f11b8SEd Tanous                     return;
360253f11b8SEd Tanous                 }
361253f11b8SEd Tanous 
3621476687dSEd Tanous                 asyncResp->res.jsonValue["@odata.type"] =
3631476687dSEd Tanous                     "#ActionInfo.v1_1_2.ActionInfo";
364bd79bce8SPatrick Williams                 asyncResp->res.jsonValue["@odata.id"] = boost::urls::format(
365bd79bce8SPatrick Williams                     "/redfish/v1/Managers/{}/ResetActionInfo",
366253f11b8SEd Tanous                     BMCWEB_REDFISH_MANAGER_URI_NAME);
3671476687dSEd Tanous                 asyncResp->res.jsonValue["Name"] = "Reset Action Info";
3681476687dSEd Tanous                 asyncResp->res.jsonValue["Id"] = "ResetActionInfo";
3691476687dSEd Tanous                 nlohmann::json::object_t parameter;
3701476687dSEd Tanous                 parameter["Name"] = "ResetType";
3711476687dSEd Tanous                 parameter["Required"] = true;
372539d8c6bSEd Tanous                 parameter["DataType"] = action_info::ParameterTypes::String;
3731476687dSEd Tanous 
3741476687dSEd Tanous                 nlohmann::json::array_t allowableValues;
375ad539545SPatrick Williams                 allowableValues.emplace_back("GracefulRestart");
376ad539545SPatrick Williams                 allowableValues.emplace_back("ForceRestart");
3771476687dSEd Tanous                 parameter["AllowableValues"] = std::move(allowableValues);
3781476687dSEd Tanous 
3791476687dSEd Tanous                 nlohmann::json::array_t parameters;
380ad539545SPatrick Williams                 parameters.emplace_back(std::move(parameter));
3811476687dSEd Tanous 
3821476687dSEd Tanous                 asyncResp->res.jsonValue["Parameters"] = std::move(parameters);
3837e860f15SJohn Edward Broadbent             });
3841cb1a9e6SAppaRao Puli }
3851cb1a9e6SAppaRao Puli 
386071d8fdfSSunnySrivastava1984 /**
387071d8fdfSSunnySrivastava1984  * @brief Retrieves BMC manager location data over DBus
388071d8fdfSSunnySrivastava1984  *
389ac106bf6SEd Tanous  * @param[in] asyncResp Shared pointer for completing asynchronous calls
390071d8fdfSSunnySrivastava1984  * @param[in] connectionName - service name
391071d8fdfSSunnySrivastava1984  * @param[in] path - object path
392071d8fdfSSunnySrivastava1984  * @return none
393071d8fdfSSunnySrivastava1984  */
394ac106bf6SEd Tanous inline void getLocation(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
395071d8fdfSSunnySrivastava1984                         const std::string& connectionName,
396071d8fdfSSunnySrivastava1984                         const std::string& path)
397071d8fdfSSunnySrivastava1984 {
39862598e31SEd Tanous     BMCWEB_LOG_DEBUG("Get BMC manager Location data.");
399071d8fdfSSunnySrivastava1984 
400deae6a78SEd Tanous     dbus::utility::getProperty<std::string>(
401deae6a78SEd Tanous         connectionName, path,
4021e1e598dSJonathan Doman         "xyz.openbmc_project.Inventory.Decorator.LocationCode", "LocationCode",
403ac106bf6SEd Tanous         [asyncResp](const boost::system::error_code& ec,
4041e1e598dSJonathan Doman                     const std::string& property) {
405071d8fdfSSunnySrivastava1984             if (ec)
406071d8fdfSSunnySrivastava1984             {
40762598e31SEd Tanous                 BMCWEB_LOG_DEBUG("DBUS response error for "
40862598e31SEd Tanous                                  "Location");
409ac106bf6SEd Tanous                 messages::internalError(asyncResp->res);
410071d8fdfSSunnySrivastava1984                 return;
411071d8fdfSSunnySrivastava1984             }
412071d8fdfSSunnySrivastava1984 
413bd79bce8SPatrick Williams             asyncResp->res
414bd79bce8SPatrick Williams                 .jsonValue["Location"]["PartLocation"]["ServiceLabel"] =
4151e1e598dSJonathan Doman                 property;
4161e1e598dSJonathan Doman         });
417071d8fdfSSunnySrivastava1984 }
4187e860f15SJohn Edward Broadbent // avoid name collision systems.hpp
419504af5a0SPatrick Williams inline void managerGetLastResetTime(
420504af5a0SPatrick Williams     const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
4214bf2b033SGunnar Mills {
42262598e31SEd Tanous     BMCWEB_LOG_DEBUG("Getting Manager Last Reset Time");
4234bf2b033SGunnar Mills 
424deae6a78SEd Tanous     dbus::utility::getProperty<uint64_t>(
425deae6a78SEd Tanous         "xyz.openbmc_project.State.BMC", "/xyz/openbmc_project/state/bmc0",
426deae6a78SEd Tanous         "xyz.openbmc_project.State.BMC", "LastRebootTime",
427ac106bf6SEd Tanous         [asyncResp](const boost::system::error_code& ec,
4281e1e598dSJonathan Doman                     const uint64_t lastResetTime) {
4294bf2b033SGunnar Mills             if (ec)
4304bf2b033SGunnar Mills             {
43162598e31SEd Tanous                 BMCWEB_LOG_DEBUG("D-BUS response error {}", ec);
4324bf2b033SGunnar Mills                 return;
4334bf2b033SGunnar Mills             }
4344bf2b033SGunnar Mills 
4354bf2b033SGunnar Mills             // LastRebootTime is epoch time, in milliseconds
4364bf2b033SGunnar Mills             // https://github.com/openbmc/phosphor-dbus-interfaces/blob/7f9a128eb9296e926422ddc312c148b625890bb6/xyz/openbmc_project/State/BMC.interface.yaml#L19
4371e1e598dSJonathan Doman             uint64_t lastResetTimeStamp = lastResetTime / 1000;
4384bf2b033SGunnar Mills 
4394bf2b033SGunnar Mills             // Convert to ISO 8601 standard
440ac106bf6SEd Tanous             asyncResp->res.jsonValue["LastResetTime"] =
4412b82937eSEd Tanous                 redfish::time_utils::getDateTimeUint(lastResetTimeStamp);
4421e1e598dSJonathan Doman         });
4434bf2b033SGunnar Mills }
4444bf2b033SGunnar Mills 
4454bfefa74SGunnar Mills /**
4464bfefa74SGunnar Mills  * @brief Set the running firmware image
4474bfefa74SGunnar Mills  *
448ac106bf6SEd Tanous  * @param[i,o] asyncResp - Async response object
4494bfefa74SGunnar Mills  * @param[i] runningFirmwareTarget - Image to make the running image
4504bfefa74SGunnar Mills  *
4514bfefa74SGunnar Mills  * @return void
4524bfefa74SGunnar Mills  */
453504af5a0SPatrick Williams inline void setActiveFirmwareImage(
454504af5a0SPatrick Williams     const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
455f23b7296SEd Tanous     const std::string& runningFirmwareTarget)
4564bfefa74SGunnar Mills {
4574bfefa74SGunnar Mills     // Get the Id from /redfish/v1/UpdateService/FirmwareInventory/<Id>
458f23b7296SEd Tanous     std::string::size_type idPos = runningFirmwareTarget.rfind('/');
4594bfefa74SGunnar Mills     if (idPos == std::string::npos)
4604bfefa74SGunnar Mills     {
461ac106bf6SEd Tanous         messages::propertyValueNotInList(asyncResp->res, runningFirmwareTarget,
4624bfefa74SGunnar Mills                                          "@odata.id");
46362598e31SEd Tanous         BMCWEB_LOG_DEBUG("Can't parse firmware ID!");
4644bfefa74SGunnar Mills         return;
4654bfefa74SGunnar Mills     }
4664bfefa74SGunnar Mills     idPos++;
4674bfefa74SGunnar Mills     if (idPos >= runningFirmwareTarget.size())
4684bfefa74SGunnar Mills     {
469ac106bf6SEd Tanous         messages::propertyValueNotInList(asyncResp->res, runningFirmwareTarget,
4704bfefa74SGunnar Mills                                          "@odata.id");
47162598e31SEd Tanous         BMCWEB_LOG_DEBUG("Invalid firmware ID.");
4724bfefa74SGunnar Mills         return;
4734bfefa74SGunnar Mills     }
4744bfefa74SGunnar Mills     std::string firmwareId = runningFirmwareTarget.substr(idPos);
4754bfefa74SGunnar Mills 
4764bfefa74SGunnar Mills     // Make sure the image is valid before setting priority
4775eb468daSGeorge Liu     sdbusplus::message::object_path objPath("/xyz/openbmc_project/software");
4785eb468daSGeorge Liu     dbus::utility::getManagedObjects(
479d27c31e9SJagpal Singh Gill         getBMCUpdateServiceName(), objPath,
4805eb468daSGeorge Liu         [asyncResp, firmwareId, runningFirmwareTarget](
4815eb468daSGeorge Liu             const boost::system::error_code& ec,
4825eb468daSGeorge Liu             const dbus::utility::ManagedObjectType& subtree) {
4834bfefa74SGunnar Mills             if (ec)
4844bfefa74SGunnar Mills             {
48562598e31SEd Tanous                 BMCWEB_LOG_DEBUG("D-Bus response error getting objects.");
486ac106bf6SEd Tanous                 messages::internalError(asyncResp->res);
4874bfefa74SGunnar Mills                 return;
4884bfefa74SGunnar Mills             }
4894bfefa74SGunnar Mills 
49026f6976fSEd Tanous             if (subtree.empty())
4914bfefa74SGunnar Mills             {
49262598e31SEd Tanous                 BMCWEB_LOG_DEBUG("Can't find image!");
493ac106bf6SEd Tanous                 messages::internalError(asyncResp->res);
4944bfefa74SGunnar Mills                 return;
4954bfefa74SGunnar Mills             }
4964bfefa74SGunnar Mills 
4974bfefa74SGunnar Mills             bool foundImage = false;
49802cad96eSEd Tanous             for (const auto& object : subtree)
4994bfefa74SGunnar Mills             {
5004bfefa74SGunnar Mills                 const std::string& path =
5014bfefa74SGunnar Mills                     static_cast<const std::string&>(object.first);
502f23b7296SEd Tanous                 std::size_t idPos2 = path.rfind('/');
5034bfefa74SGunnar Mills 
5044bfefa74SGunnar Mills                 if (idPos2 == std::string::npos)
5054bfefa74SGunnar Mills                 {
5064bfefa74SGunnar Mills                     continue;
5074bfefa74SGunnar Mills                 }
5084bfefa74SGunnar Mills 
5094bfefa74SGunnar Mills                 idPos2++;
5104bfefa74SGunnar Mills                 if (idPos2 >= path.size())
5114bfefa74SGunnar Mills                 {
5124bfefa74SGunnar Mills                     continue;
5134bfefa74SGunnar Mills                 }
5144bfefa74SGunnar Mills 
5154bfefa74SGunnar Mills                 if (path.substr(idPos2) == firmwareId)
5164bfefa74SGunnar Mills                 {
5174bfefa74SGunnar Mills                     foundImage = true;
5184bfefa74SGunnar Mills                     break;
5194bfefa74SGunnar Mills                 }
5204bfefa74SGunnar Mills             }
5214bfefa74SGunnar Mills 
5224bfefa74SGunnar Mills             if (!foundImage)
5234bfefa74SGunnar Mills             {
524ac106bf6SEd Tanous                 messages::propertyValueNotInList(
525ac106bf6SEd Tanous                     asyncResp->res, runningFirmwareTarget, "@odata.id");
52662598e31SEd Tanous                 BMCWEB_LOG_DEBUG("Invalid firmware ID.");
5274bfefa74SGunnar Mills                 return;
5284bfefa74SGunnar Mills             }
5294bfefa74SGunnar Mills 
53062598e31SEd Tanous             BMCWEB_LOG_DEBUG("Setting firmware version {} to priority 0.",
53162598e31SEd Tanous                              firmwareId);
5324bfefa74SGunnar Mills 
5334bfefa74SGunnar Mills             // Only support Immediate
5344bfefa74SGunnar Mills             // An addition could be a Redfish Setting like
5354bfefa74SGunnar Mills             // ActiveSoftwareImageApplyTime and support OnReset
5369ae226faSGeorge Liu             sdbusplus::asio::setProperty(
537d27c31e9SJagpal Singh Gill                 *crow::connections::systemBus, getBMCUpdateServiceName(),
5389ae226faSGeorge Liu                 "/xyz/openbmc_project/software/" + firmwareId,
5399ae226faSGeorge Liu                 "xyz.openbmc_project.Software.RedundancyPriority", "Priority",
5409ae226faSGeorge Liu                 static_cast<uint8_t>(0),
541ac106bf6SEd Tanous                 [asyncResp](const boost::system::error_code& ec2) {
5428a592810SEd Tanous                     if (ec2)
5434bfefa74SGunnar Mills                     {
54462598e31SEd Tanous                         BMCWEB_LOG_DEBUG("D-Bus response error setting.");
545ac106bf6SEd Tanous                         messages::internalError(asyncResp->res);
5464bfefa74SGunnar Mills                         return;
5474bfefa74SGunnar Mills                     }
548ac106bf6SEd Tanous                     doBMCGracefulRestart(asyncResp);
5499ae226faSGeorge Liu                 });
5505eb468daSGeorge Liu         });
5514bfefa74SGunnar Mills }
5524bfefa74SGunnar Mills 
553bd79bce8SPatrick Williams inline void afterSetDateTime(
554bd79bce8SPatrick Williams     const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
555bd79bce8SPatrick Williams     const boost::system::error_code& ec, const sdbusplus::message_t& msg)
556c51afd54SEd Tanous {
557c51afd54SEd Tanous     if (ec)
558c51afd54SEd Tanous     {
559c51afd54SEd Tanous         BMCWEB_LOG_DEBUG("Failed to set elapsed time. DBUS response error {}",
560c51afd54SEd Tanous                          ec);
561c51afd54SEd Tanous         const sd_bus_error* dbusError = msg.get_error();
562c51afd54SEd Tanous         if (dbusError != nullptr)
563c51afd54SEd Tanous         {
564c51afd54SEd Tanous             std::string_view errorName(dbusError->name);
565c51afd54SEd Tanous             if (errorName ==
566c51afd54SEd Tanous                 "org.freedesktop.timedate1.AutomaticTimeSyncEnabled")
567c51afd54SEd Tanous             {
568c51afd54SEd Tanous                 BMCWEB_LOG_DEBUG("Setting conflict");
569c51afd54SEd Tanous                 messages::propertyValueConflict(
570c51afd54SEd Tanous                     asyncResp->res, "DateTime",
571c51afd54SEd Tanous                     "Managers/NetworkProtocol/NTPProcotolEnabled");
572c51afd54SEd Tanous                 return;
573c51afd54SEd Tanous             }
574c51afd54SEd Tanous         }
575c51afd54SEd Tanous         messages::internalError(asyncResp->res);
576c51afd54SEd Tanous         return;
577c51afd54SEd Tanous     }
578c51afd54SEd Tanous     asyncResp->res.result(boost::beast::http::status::no_content);
579c51afd54SEd Tanous }
580c51afd54SEd Tanous 
581c51afd54SEd Tanous inline void setDateTime(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
582c51afd54SEd Tanous                         const std::string& datetime)
583af5d6058SSantosh Puranik {
58462598e31SEd Tanous     BMCWEB_LOG_DEBUG("Set date time: {}", datetime);
585af5d6058SSantosh Puranik 
586c2e32007SEd Tanous     std::optional<redfish::time_utils::usSinceEpoch> us =
587c2e32007SEd Tanous         redfish::time_utils::dateStringToEpoch(datetime);
588c2e32007SEd Tanous     if (!us)
589af5d6058SSantosh Puranik     {
590ac106bf6SEd Tanous         messages::propertyValueFormatError(asyncResp->res, datetime,
591ac106bf6SEd Tanous                                            "DateTime");
592c2e32007SEd Tanous         return;
593c2e32007SEd Tanous     }
594c51afd54SEd Tanous     // Set the absolute datetime
595c51afd54SEd Tanous     bool relative = false;
596c51afd54SEd Tanous     bool interactive = false;
597c51afd54SEd Tanous     crow::connections::systemBus->async_method_call(
598c51afd54SEd Tanous         [asyncResp](const boost::system::error_code& ec,
599c51afd54SEd Tanous                     const sdbusplus::message_t& msg) {
600c51afd54SEd Tanous             afterSetDateTime(asyncResp, ec, msg);
601c51afd54SEd Tanous         },
602c51afd54SEd Tanous         "org.freedesktop.timedate1", "/org/freedesktop/timedate1",
603c51afd54SEd Tanous         "org.freedesktop.timedate1", "SetTime", us->count(), relative,
604c51afd54SEd Tanous         interactive);
60583ff9ab6SJames Feist }
6069c310685SBorawski.Lukasz 
607504af5a0SPatrick Williams inline void checkForQuiesced(
608504af5a0SPatrick Williams     const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
60975815e5cSEd Tanous {
610deae6a78SEd Tanous     dbus::utility::getProperty<std::string>(
611deae6a78SEd Tanous         "org.freedesktop.systemd1",
61275815e5cSEd Tanous         "/org/freedesktop/systemd1/unit/obmc-bmc-service-quiesce@0.target",
61375815e5cSEd Tanous         "org.freedesktop.systemd1.Unit", "ActiveState",
61475815e5cSEd Tanous         [asyncResp](const boost::system::error_code& ec,
61575815e5cSEd Tanous                     const std::string& val) {
61675815e5cSEd Tanous             if (!ec)
61775815e5cSEd Tanous             {
61875815e5cSEd Tanous                 if (val == "active")
61975815e5cSEd Tanous                 {
620539d8c6bSEd Tanous                     asyncResp->res.jsonValue["Status"]["Health"] =
621539d8c6bSEd Tanous                         resource::Health::Critical;
622539d8c6bSEd Tanous                     asyncResp->res.jsonValue["Status"]["State"] =
623539d8c6bSEd Tanous                         resource::State::Quiesced;
62475815e5cSEd Tanous                     return;
62575815e5cSEd Tanous                 }
62675815e5cSEd Tanous             }
627539d8c6bSEd Tanous             asyncResp->res.jsonValue["Status"]["Health"] = resource::Health::OK;
628bd79bce8SPatrick Williams             asyncResp->res.jsonValue["Status"]["State"] =
629bd79bce8SPatrick Williams                 resource::State::Enabled;
63075815e5cSEd Tanous         });
63175815e5cSEd Tanous }
63275815e5cSEd Tanous 
633e2cdf06fSJanet Adkins inline void getPhysicalAssets(
634e2cdf06fSJanet Adkins     const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
635e2cdf06fSJanet Adkins     const boost::system::error_code& ec,
636e2cdf06fSJanet Adkins     const dbus::utility::DBusPropertiesMap& propertiesList)
637e2cdf06fSJanet Adkins {
638e2cdf06fSJanet Adkins     if (ec)
639e2cdf06fSJanet Adkins     {
640e2cdf06fSJanet Adkins         BMCWEB_LOG_DEBUG("Can't get bmc asset!");
641e2cdf06fSJanet Adkins         return;
642e2cdf06fSJanet Adkins     }
643e2cdf06fSJanet Adkins 
644e2cdf06fSJanet Adkins     const std::string* partNumber = nullptr;
645e2cdf06fSJanet Adkins     const std::string* serialNumber = nullptr;
646e2cdf06fSJanet Adkins     const std::string* manufacturer = nullptr;
647e2cdf06fSJanet Adkins     const std::string* model = nullptr;
648e2cdf06fSJanet Adkins     const std::string* sparePartNumber = nullptr;
649e2cdf06fSJanet Adkins 
650e2cdf06fSJanet Adkins     const bool success = sdbusplus::unpackPropertiesNoThrow(
651e2cdf06fSJanet Adkins         dbus_utils::UnpackErrorPrinter(), propertiesList, "PartNumber",
652e2cdf06fSJanet Adkins         partNumber, "SerialNumber", serialNumber, "Manufacturer", manufacturer,
653e2cdf06fSJanet Adkins         "Model", model, "SparePartNumber", sparePartNumber);
654e2cdf06fSJanet Adkins 
655e2cdf06fSJanet Adkins     if (!success)
656e2cdf06fSJanet Adkins     {
657e2cdf06fSJanet Adkins         messages::internalError(asyncResp->res);
658e2cdf06fSJanet Adkins         return;
659e2cdf06fSJanet Adkins     }
660e2cdf06fSJanet Adkins 
661e2cdf06fSJanet Adkins     if (partNumber != nullptr)
662e2cdf06fSJanet Adkins     {
663e2cdf06fSJanet Adkins         asyncResp->res.jsonValue["PartNumber"] = *partNumber;
664e2cdf06fSJanet Adkins     }
665e2cdf06fSJanet Adkins 
666e2cdf06fSJanet Adkins     if (serialNumber != nullptr)
667e2cdf06fSJanet Adkins     {
668e2cdf06fSJanet Adkins         asyncResp->res.jsonValue["SerialNumber"] = *serialNumber;
669e2cdf06fSJanet Adkins     }
670e2cdf06fSJanet Adkins 
671e2cdf06fSJanet Adkins     if (manufacturer != nullptr)
672e2cdf06fSJanet Adkins     {
673e2cdf06fSJanet Adkins         asyncResp->res.jsonValue["Manufacturer"] = *manufacturer;
674e2cdf06fSJanet Adkins     }
675e2cdf06fSJanet Adkins 
676e2cdf06fSJanet Adkins     if (model != nullptr)
677e2cdf06fSJanet Adkins     {
678e2cdf06fSJanet Adkins         asyncResp->res.jsonValue["Model"] = *model;
679e2cdf06fSJanet Adkins     }
680e2cdf06fSJanet Adkins 
681e2cdf06fSJanet Adkins     if (sparePartNumber != nullptr)
682e2cdf06fSJanet Adkins     {
683e2cdf06fSJanet Adkins         asyncResp->res.jsonValue["SparePartNumber"] = *sparePartNumber;
684e2cdf06fSJanet Adkins     }
685e2cdf06fSJanet Adkins }
686e2cdf06fSJanet Adkins 
687e2cdf06fSJanet Adkins inline void getManagerData(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
688e2cdf06fSJanet Adkins                            const std::string& managerPath,
689e2cdf06fSJanet Adkins                            const dbus::utility::MapperServiceMap& serviceMap)
690e2cdf06fSJanet Adkins {
691e2cdf06fSJanet Adkins     if (managerPath.empty() || serviceMap.size() != 1)
692e2cdf06fSJanet Adkins     {
693e2cdf06fSJanet Adkins         BMCWEB_LOG_DEBUG("Error getting bmc D-Bus object!");
694e2cdf06fSJanet Adkins         messages::internalError(asyncResp->res);
695e2cdf06fSJanet Adkins         return;
696e2cdf06fSJanet Adkins     }
697e2cdf06fSJanet Adkins 
698e2cdf06fSJanet Adkins     for (const auto& [connectionName, interfaces] : serviceMap)
699e2cdf06fSJanet Adkins     {
700e2cdf06fSJanet Adkins         for (const auto& interfaceName : interfaces)
701e2cdf06fSJanet Adkins         {
702e2cdf06fSJanet Adkins             if (interfaceName ==
703e2cdf06fSJanet Adkins                 "xyz.openbmc_project.Inventory.Decorator.Asset")
704e2cdf06fSJanet Adkins             {
705e2cdf06fSJanet Adkins                 dbus::utility::getAllProperties(
706e2cdf06fSJanet Adkins                     *crow::connections::systemBus, connectionName, managerPath,
707e2cdf06fSJanet Adkins                     "xyz.openbmc_project.Inventory.Decorator.Asset",
708e2cdf06fSJanet Adkins                     std::bind_front(getPhysicalAssets, asyncResp));
709e2cdf06fSJanet Adkins             }
710e2cdf06fSJanet Adkins             else if (interfaceName ==
711e2cdf06fSJanet Adkins                      "xyz.openbmc_project.Inventory.Decorator.LocationCode")
712e2cdf06fSJanet Adkins             {
713e2cdf06fSJanet Adkins                 getLocation(asyncResp, connectionName, managerPath);
714e2cdf06fSJanet Adkins             }
715*79f3b6a1SGeorge Liu             else if (interfaceName ==
716*79f3b6a1SGeorge Liu                      "xyz.openbmc_project.Association.Definitions")
717*79f3b6a1SGeorge Liu             {
718*79f3b6a1SGeorge Liu                 getLocationIndicatorActive(asyncResp, managerPath);
719*79f3b6a1SGeorge Liu             }
720e2cdf06fSJanet Adkins         }
721e2cdf06fSJanet Adkins     }
722e2cdf06fSJanet Adkins }
723e2cdf06fSJanet Adkins 
724e2cdf06fSJanet Adkins inline void afterGetManagerObject(
725e2cdf06fSJanet Adkins     const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
726e2cdf06fSJanet Adkins     const boost::system::error_code& ec,
727e2cdf06fSJanet Adkins     const dbus::utility::MapperGetSubTreeResponse& subtree,
728e2cdf06fSJanet Adkins     const std::function<
729e2cdf06fSJanet Adkins         void(const std::string& managerPath,
730e2cdf06fSJanet Adkins              const dbus::utility::MapperServiceMap& serviceMap)>& callback)
731e2cdf06fSJanet Adkins {
732e2cdf06fSJanet Adkins     if (ec)
733e2cdf06fSJanet Adkins     {
734e2cdf06fSJanet Adkins         BMCWEB_LOG_DEBUG("D-Bus response error on GetSubTree {}", ec);
735e2cdf06fSJanet Adkins         return;
736e2cdf06fSJanet Adkins     }
737e2cdf06fSJanet Adkins     if (subtree.empty())
738e2cdf06fSJanet Adkins     {
739e2cdf06fSJanet Adkins         BMCWEB_LOG_DEBUG("Can't find bmc D-Bus object!");
740e2cdf06fSJanet Adkins         return;
741e2cdf06fSJanet Adkins     }
742e2cdf06fSJanet Adkins     // Assume only 1 bmc D-Bus object
743e2cdf06fSJanet Adkins     // Throw an error if there is more than 1
744e2cdf06fSJanet Adkins     if (subtree.size() > 1)
745e2cdf06fSJanet Adkins     {
746e2cdf06fSJanet Adkins         BMCWEB_LOG_ERROR("Found more than 1 bmc D-Bus object!");
747e2cdf06fSJanet Adkins         messages::internalError(asyncResp->res);
748e2cdf06fSJanet Adkins         return;
749e2cdf06fSJanet Adkins     }
750e2cdf06fSJanet Adkins 
751e2cdf06fSJanet Adkins     callback(subtree[0].first, subtree[0].second);
752e2cdf06fSJanet Adkins }
753e2cdf06fSJanet Adkins 
754e2cdf06fSJanet Adkins inline void getManagerObject(
755e2cdf06fSJanet Adkins     const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
756e2cdf06fSJanet Adkins     const std::string& /* managerId */,
757e2cdf06fSJanet Adkins     std::function<void(const std::string& managerPath,
758e2cdf06fSJanet Adkins                        const dbus::utility::MapperServiceMap& serviceMap)>&&
759e2cdf06fSJanet Adkins         callback)
760e2cdf06fSJanet Adkins {
761e2cdf06fSJanet Adkins     constexpr std::array<std::string_view, 1> interfaces = {
762e2cdf06fSJanet Adkins         "xyz.openbmc_project.Inventory.Item.Bmc"};
763e2cdf06fSJanet Adkins     dbus::utility::getSubTree(
764e2cdf06fSJanet Adkins         "/xyz/openbmc_project/inventory", 0, interfaces,
765e2cdf06fSJanet Adkins         [asyncResp, callback{std::move(callback)}](
766e2cdf06fSJanet Adkins             const boost::system::error_code& ec,
767e2cdf06fSJanet Adkins             const dbus::utility::MapperGetSubTreeResponse& subtree) {
768e2cdf06fSJanet Adkins             afterGetManagerObject(asyncResp, ec, subtree, callback);
769e2cdf06fSJanet Adkins         });
770e2cdf06fSJanet Adkins }
771e2cdf06fSJanet Adkins 
7727e860f15SJohn Edward Broadbent inline void requestRoutesManager(App& app)
7737e860f15SJohn Edward Broadbent {
7747e860f15SJohn Edward Broadbent     std::string uuid = persistent_data::getConfig().systemUuid;
7759c310685SBorawski.Lukasz 
776253f11b8SEd Tanous     BMCWEB_ROUTE(app, "/redfish/v1/Managers/<str>/")
777ed398213SEd Tanous         .privileges(redfish::privileges::getManager)
778bd79bce8SPatrick Williams         .methods(
779bd79bce8SPatrick Williams             boost::beast::http::verb::
780bd79bce8SPatrick Williams                 get)([&app,
781bd79bce8SPatrick Williams                       uuid](const crow::Request& req,
782253f11b8SEd Tanous                             const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
783253f11b8SEd Tanous                             const std::string& managerId) {
7843ba00073SCarson Labrado             if (!redfish::setUpRedfishRoute(app, req, asyncResp))
78545ca1b86SEd Tanous             {
78645ca1b86SEd Tanous                 return;
78745ca1b86SEd Tanous             }
788253f11b8SEd Tanous 
789253f11b8SEd Tanous             if (managerId != BMCWEB_REDFISH_MANAGER_URI_NAME)
790253f11b8SEd Tanous             {
791bd79bce8SPatrick Williams                 messages::resourceNotFound(asyncResp->res, "Manager",
792bd79bce8SPatrick Williams                                            managerId);
793253f11b8SEd Tanous                 return;
794253f11b8SEd Tanous             }
795253f11b8SEd Tanous 
796253f11b8SEd Tanous             asyncResp->res.jsonValue["@odata.id"] = boost::urls::format(
797253f11b8SEd Tanous                 "/redfish/v1/Managers/{}", BMCWEB_REDFISH_MANAGER_URI_NAME);
798bd79bce8SPatrick Williams             asyncResp->res.jsonValue["@odata.type"] =
799bd79bce8SPatrick Williams                 "#Manager.v1_14_0.Manager";
800253f11b8SEd Tanous             asyncResp->res.jsonValue["Id"] = BMCWEB_REDFISH_MANAGER_URI_NAME;
8017e860f15SJohn Edward Broadbent             asyncResp->res.jsonValue["Name"] = "OpenBmc Manager";
8027e860f15SJohn Edward Broadbent             asyncResp->res.jsonValue["Description"] =
8037e860f15SJohn Edward Broadbent                 "Baseboard Management Controller";
804539d8c6bSEd Tanous             asyncResp->res.jsonValue["PowerState"] = resource::PowerState::On;
8051476687dSEd Tanous 
806539d8c6bSEd Tanous             asyncResp->res.jsonValue["ManagerType"] = manager::ManagerType::BMC;
8077e860f15SJohn Edward Broadbent             asyncResp->res.jsonValue["UUID"] = systemd_utils::getUuid();
8087e860f15SJohn Edward Broadbent             asyncResp->res.jsonValue["ServiceEntryPointUUID"] = uuid;
809bd79bce8SPatrick Williams             asyncResp->res.jsonValue["Model"] =
810bd79bce8SPatrick Williams                 "OpenBmc"; // TODO(ed), get model
8117e860f15SJohn Edward Broadbent 
8121476687dSEd Tanous             asyncResp->res.jsonValue["LogServices"]["@odata.id"] =
813253f11b8SEd Tanous                 boost::urls::format("/redfish/v1/Managers/{}/LogServices",
814253f11b8SEd Tanous                                     BMCWEB_REDFISH_MANAGER_URI_NAME);
8151476687dSEd Tanous             asyncResp->res.jsonValue["NetworkProtocol"]["@odata.id"] =
816253f11b8SEd Tanous                 boost::urls::format("/redfish/v1/Managers/{}/NetworkProtocol",
817253f11b8SEd Tanous                                     BMCWEB_REDFISH_MANAGER_URI_NAME);
8181476687dSEd Tanous             asyncResp->res.jsonValue["EthernetInterfaces"]["@odata.id"] =
819bd79bce8SPatrick Williams                 boost::urls::format(
820bd79bce8SPatrick Williams                     "/redfish/v1/Managers/{}/EthernetInterfaces",
821253f11b8SEd Tanous                     BMCWEB_REDFISH_MANAGER_URI_NAME);
8227e860f15SJohn Edward Broadbent 
82325b54dbaSEd Tanous             if constexpr (BMCWEB_VM_NBDPROXY)
82436c0f2a3SEd Tanous             {
8251476687dSEd Tanous                 asyncResp->res.jsonValue["VirtualMedia"]["@odata.id"] =
826253f11b8SEd Tanous                     boost::urls::format("/redfish/v1/Managers/{}/VirtualMedia",
827253f11b8SEd Tanous                                         BMCWEB_REDFISH_MANAGER_URI_NAME);
82836c0f2a3SEd Tanous             }
8297e860f15SJohn Edward Broadbent 
8307e860f15SJohn Edward Broadbent             // Manager.Reset (an action) can be many values, OpenBMC only
8317e860f15SJohn Edward Broadbent             // supports BMC reboot.
8327e860f15SJohn Edward Broadbent             nlohmann::json& managerReset =
8337e860f15SJohn Edward Broadbent                 asyncResp->res.jsonValue["Actions"]["#Manager.Reset"];
834bd79bce8SPatrick Williams             managerReset["target"] = boost::urls::format(
835bd79bce8SPatrick Williams                 "/redfish/v1/Managers/{}/Actions/Manager.Reset",
836253f11b8SEd Tanous                 BMCWEB_REDFISH_MANAGER_URI_NAME);
8377e860f15SJohn Edward Broadbent             managerReset["@Redfish.ActionInfo"] =
838253f11b8SEd Tanous                 boost::urls::format("/redfish/v1/Managers/{}/ResetActionInfo",
839253f11b8SEd Tanous                                     BMCWEB_REDFISH_MANAGER_URI_NAME);
8407e860f15SJohn Edward Broadbent 
8417e860f15SJohn Edward Broadbent             // ResetToDefaults (Factory Reset) has values like
8427e860f15SJohn Edward Broadbent             // PreserveNetworkAndUsers and PreserveNetwork that aren't supported
8437e860f15SJohn Edward Broadbent             // on OpenBMC
8447e860f15SJohn Edward Broadbent             nlohmann::json& resetToDefaults =
8457e860f15SJohn Edward Broadbent                 asyncResp->res.jsonValue["Actions"]["#Manager.ResetToDefaults"];
846253f11b8SEd Tanous             resetToDefaults["target"] = boost::urls::format(
847253f11b8SEd Tanous                 "/redfish/v1/Managers/{}/Actions/Manager.ResetToDefaults",
848253f11b8SEd Tanous                 BMCWEB_REDFISH_MANAGER_URI_NAME);
849613dabeaSEd Tanous             resetToDefaults["ResetType@Redfish.AllowableValues"] =
850613dabeaSEd Tanous                 nlohmann::json::array_t({"ResetAll"});
8517e860f15SJohn Edward Broadbent 
8527c8c4058STejas Patil             std::pair<std::string, std::string> redfishDateTimeOffset =
8532b82937eSEd Tanous                 redfish::time_utils::getDateTimeOffsetNow();
8547c8c4058STejas Patil 
8557c8c4058STejas Patil             asyncResp->res.jsonValue["DateTime"] = redfishDateTimeOffset.first;
8567c8c4058STejas Patil             asyncResp->res.jsonValue["DateTimeLocalOffset"] =
8577c8c4058STejas Patil                 redfishDateTimeOffset.second;
8587e860f15SJohn Edward Broadbent 
85925b54dbaSEd Tanous             if constexpr (BMCWEB_KVM)
86025b54dbaSEd Tanous             {
8617e860f15SJohn Edward Broadbent                 // Fill in GraphicalConsole info
86225b54dbaSEd Tanous                 asyncResp->res.jsonValue["GraphicalConsole"]["ServiceEnabled"] =
86325b54dbaSEd Tanous                     true;
86425b54dbaSEd Tanous                 asyncResp->res
86525b54dbaSEd Tanous                     .jsonValue["GraphicalConsole"]["MaxConcurrentSessions"] = 4;
86625b54dbaSEd Tanous                 asyncResp->res
86725b54dbaSEd Tanous                     .jsonValue["GraphicalConsole"]["ConnectTypesSupported"] =
868613dabeaSEd Tanous                     nlohmann::json::array_t({"KVMIP"});
86925b54dbaSEd Tanous             }
87025b54dbaSEd Tanous             if constexpr (!BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
8717f3e84a1SEd Tanous             {
872bd79bce8SPatrick Williams                 asyncResp->res
873bd79bce8SPatrick Williams                     .jsonValue["Links"]["ManagerForServers@odata.count"] = 1;
8741476687dSEd Tanous 
8751476687dSEd Tanous                 nlohmann::json::array_t managerForServers;
8761476687dSEd Tanous                 nlohmann::json::object_t manager;
877bd79bce8SPatrick Williams                 manager["@odata.id"] = std::format(
878bd79bce8SPatrick Williams                     "/redfish/v1/Systems/{}", BMCWEB_REDFISH_SYSTEM_URI_NAME);
879ad539545SPatrick Williams                 managerForServers.emplace_back(std::move(manager));
8801476687dSEd Tanous 
8811476687dSEd Tanous                 asyncResp->res.jsonValue["Links"]["ManagerForServers"] =
8821476687dSEd Tanous                     std::move(managerForServers);
8837f3e84a1SEd Tanous             }
8847e860f15SJohn Edward Broadbent 
885eee0013eSWilly Tu             sw_util::populateSoftwareInformation(asyncResp, sw_util::bmcPurpose,
8867e860f15SJohn Edward Broadbent                                                  "FirmwareVersion", true);
8877e860f15SJohn Edward Broadbent 
8887e860f15SJohn Edward Broadbent             managerGetLastResetTime(asyncResp);
8897e860f15SJohn Edward Broadbent 
890a51fc2d2SSui Chen             // ManagerDiagnosticData is added for all BMCs.
891a51fc2d2SSui Chen             nlohmann::json& managerDiagnosticData =
892a51fc2d2SSui Chen                 asyncResp->res.jsonValue["ManagerDiagnosticData"];
893bd79bce8SPatrick Williams             managerDiagnosticData["@odata.id"] = boost::urls::format(
894bd79bce8SPatrick Williams                 "/redfish/v1/Managers/{}/ManagerDiagnosticData",
895253f11b8SEd Tanous                 BMCWEB_REDFISH_MANAGER_URI_NAME);
896a51fc2d2SSui Chen 
897bd79bce8SPatrick Williams             getMainChassisId(asyncResp, [](const std::string& chassisId,
898bd79bce8SPatrick Williams                                            const std::shared_ptr<
899bd79bce8SPatrick Williams                                                bmcweb::AsyncResp>& aRsp) {
900bd79bce8SPatrick Williams                 aRsp->res.jsonValue["Links"]["ManagerForChassis@odata.count"] =
901bd79bce8SPatrick Williams                     1;
9021476687dSEd Tanous                 nlohmann::json::array_t managerForChassis;
9038a592810SEd Tanous                 nlohmann::json::object_t managerObj;
904ef4c65b7SEd Tanous                 boost::urls::url chassiUrl =
905ef4c65b7SEd Tanous                     boost::urls::format("/redfish/v1/Chassis/{}", chassisId);
906eddfc437SWilly Tu                 managerObj["@odata.id"] = chassiUrl;
907ad539545SPatrick Williams                 managerForChassis.emplace_back(std::move(managerObj));
9081476687dSEd Tanous                 aRsp->res.jsonValue["Links"]["ManagerForChassis"] =
9091476687dSEd Tanous                     std::move(managerForChassis);
9101476687dSEd Tanous                 aRsp->res.jsonValue["Links"]["ManagerInChassis"]["@odata.id"] =
911eddfc437SWilly Tu                     chassiUrl;
9127e860f15SJohn Edward Broadbent             });
9137e860f15SJohn Edward Broadbent 
914deae6a78SEd Tanous             dbus::utility::getProperty<double>(
915deae6a78SEd Tanous                 "org.freedesktop.systemd1", "/org/freedesktop/systemd1",
916deae6a78SEd Tanous                 "org.freedesktop.systemd1.Manager", "Progress",
91775815e5cSEd Tanous                 [asyncResp](const boost::system::error_code& ec, double val) {
9187e860f15SJohn Edward Broadbent                     if (ec)
9191abe55efSEd Tanous                     {
92062598e31SEd Tanous                         BMCWEB_LOG_ERROR("Error while getting progress");
9217e860f15SJohn Edward Broadbent                         messages::internalError(asyncResp->res);
9227e860f15SJohn Edward Broadbent                         return;
9237e860f15SJohn Edward Broadbent                     }
9241e1e598dSJonathan Doman                     if (val < 1.0)
9257e860f15SJohn Edward Broadbent                     {
926539d8c6bSEd Tanous                         asyncResp->res.jsonValue["Status"]["Health"] =
927539d8c6bSEd Tanous                             resource::Health::OK;
928539d8c6bSEd Tanous                         asyncResp->res.jsonValue["Status"]["State"] =
929539d8c6bSEd Tanous                             resource::State::Starting;
93075815e5cSEd Tanous                         return;
9317e860f15SJohn Edward Broadbent                     }
93275815e5cSEd Tanous                     checkForQuiesced(asyncResp);
9331e1e598dSJonathan Doman                 });
9349c310685SBorawski.Lukasz 
935e2cdf06fSJanet Adkins             getManagerObject(asyncResp, managerId,
936e2cdf06fSJanet Adkins                              std::bind_front(getManagerData, asyncResp));
937c1a75ebcSrohitpai 
938c1a75ebcSrohitpai             RedfishService::getInstance(app).handleSubRoute(req, asyncResp);
9397e860f15SJohn Edward Broadbent         });
9407e860f15SJohn Edward Broadbent 
941253f11b8SEd Tanous     BMCWEB_ROUTE(app, "/redfish/v1/Managers/<str>/")
942ed398213SEd Tanous         .privileges(redfish::privileges::patchManager)
94345ca1b86SEd Tanous         .methods(boost::beast::http::verb::patch)(
94445ca1b86SEd Tanous             [&app](const crow::Request& req,
945253f11b8SEd Tanous                    const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
946253f11b8SEd Tanous                    const std::string& managerId) {
9473ba00073SCarson Labrado                 if (!redfish::setUpRedfishRoute(app, req, asyncResp))
94845ca1b86SEd Tanous                 {
94945ca1b86SEd Tanous                     return;
95045ca1b86SEd Tanous                 }
951253f11b8SEd Tanous 
952253f11b8SEd Tanous                 if (managerId != BMCWEB_REDFISH_MANAGER_URI_NAME)
953253f11b8SEd Tanous                 {
954bd79bce8SPatrick Williams                     messages::resourceNotFound(asyncResp->res, "Manager",
955bd79bce8SPatrick Williams                                                managerId);
956253f11b8SEd Tanous                     return;
957253f11b8SEd Tanous                 }
958253f11b8SEd Tanous 
9599e9b6049SEd Tanous                 std::optional<std::string> activeSoftwareImageOdataId;
9607e860f15SJohn Edward Broadbent                 std::optional<std::string> datetime;
961*79f3b6a1SGeorge Liu                 std::optional<bool> locationIndicatorActive;
9629e9b6049SEd Tanous                 std::optional<nlohmann::json::object_t> pidControllers;
9639e9b6049SEd Tanous                 std::optional<nlohmann::json::object_t> fanControllers;
9649e9b6049SEd Tanous                 std::optional<nlohmann::json::object_t> fanZones;
9659e9b6049SEd Tanous                 std::optional<nlohmann::json::object_t> stepwiseControllers;
9669e9b6049SEd Tanous                 std::optional<std::string> profile;
9677e860f15SJohn Edward Broadbent 
968afc474aeSMyung Bae                 if (!json_util::readJsonPatch(                            //
969afc474aeSMyung Bae                         req, asyncResp->res,                              //
970afc474aeSMyung Bae                         "DateTime", datetime,                             //
971afc474aeSMyung Bae                         "Links/ActiveSoftwareImage/@odata.id",
972afc474aeSMyung Bae                         activeSoftwareImageOdataId,                       //
973*79f3b6a1SGeorge Liu                         "LocationIndicatorActive",
974*79f3b6a1SGeorge Liu                         locationIndicatorActive,                          //
975afc474aeSMyung Bae                         "Oem/OpenBmc/Fan/FanControllers", fanControllers, //
976afc474aeSMyung Bae                         "Oem/OpenBmc/Fan/FanZones", fanZones,             //
977afc474aeSMyung Bae                         "Oem/OpenBmc/Fan/PidControllers", pidControllers, //
978afc474aeSMyung Bae                         "Oem/OpenBmc/Fan/Profile", profile,               //
979afc474aeSMyung Bae                         "Oem/OpenBmc/Fan/StepwiseControllers",
980afc474aeSMyung Bae                         stepwiseControllers                               //
9819e9b6049SEd Tanous                         ))
9827e860f15SJohn Edward Broadbent                 {
9837e860f15SJohn Edward Broadbent                     return;
9847e860f15SJohn Edward Broadbent                 }
9857e860f15SJohn Edward Broadbent 
9869e9b6049SEd Tanous                 if (activeSoftwareImageOdataId)
9877e860f15SJohn Edward Broadbent                 {
988bd79bce8SPatrick Williams                     setActiveFirmwareImage(asyncResp,
989bd79bce8SPatrick Williams                                            *activeSoftwareImageOdataId);
9907e860f15SJohn Edward Broadbent                 }
9917e860f15SJohn Edward Broadbent 
9927e860f15SJohn Edward Broadbent                 if (datetime)
9937e860f15SJohn Edward Broadbent                 {
994c51afd54SEd Tanous                     setDateTime(asyncResp, *datetime);
9957e860f15SJohn Edward Broadbent                 }
99684aad24dSrohitpai 
997*79f3b6a1SGeorge Liu                 if (locationIndicatorActive)
998*79f3b6a1SGeorge Liu                 {
999*79f3b6a1SGeorge Liu                     setLocationIndicatorActiveState(
1000*79f3b6a1SGeorge Liu                         asyncResp, *locationIndicatorActive, managerId);
1001*79f3b6a1SGeorge Liu                 }
1002*79f3b6a1SGeorge Liu 
100384aad24dSrohitpai                 RedfishService::getInstance(app).handleSubRoute(req, asyncResp);
10047e860f15SJohn Edward Broadbent             });
10057e860f15SJohn Edward Broadbent }
10067e860f15SJohn Edward Broadbent 
10077e860f15SJohn Edward Broadbent inline void requestRoutesManagerCollection(App& app)
10087e860f15SJohn Edward Broadbent {
10097e860f15SJohn Edward Broadbent     BMCWEB_ROUTE(app, "/redfish/v1/Managers/")
1010ed398213SEd Tanous         .privileges(redfish::privileges::getManagerCollection)
10117e860f15SJohn Edward Broadbent         .methods(boost::beast::http::verb::get)(
101245ca1b86SEd Tanous             [&app](const crow::Request& req,
10137e860f15SJohn Edward Broadbent                    const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
10143ba00073SCarson Labrado                 if (!redfish::setUpRedfishRoute(app, req, asyncResp))
101545ca1b86SEd Tanous                 {
101645ca1b86SEd Tanous                     return;
101745ca1b86SEd Tanous                 }
101883ff9ab6SJames Feist                 // Collections don't include the static data added by SubRoute
101983ff9ab6SJames Feist                 // because it has a duplicate entry for members
10208d1b46d7Szhanghch05                 asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/Managers";
10218d1b46d7Szhanghch05                 asyncResp->res.jsonValue["@odata.type"] =
10228d1b46d7Szhanghch05                     "#ManagerCollection.ManagerCollection";
10238d1b46d7Szhanghch05                 asyncResp->res.jsonValue["Name"] = "Manager Collection";
10248d1b46d7Szhanghch05                 asyncResp->res.jsonValue["Members@odata.count"] = 1;
10251476687dSEd Tanous                 nlohmann::json::array_t members;
10261476687dSEd Tanous                 nlohmann::json& bmc = members.emplace_back();
1027bd79bce8SPatrick Williams                 bmc["@odata.id"] = boost::urls::format(
1028bd79bce8SPatrick Williams                     "/redfish/v1/Managers/{}", BMCWEB_REDFISH_MANAGER_URI_NAME);
10291476687dSEd Tanous                 asyncResp->res.jsonValue["Members"] = std::move(members);
10307e860f15SJohn Edward Broadbent             });
10319c310685SBorawski.Lukasz }
10329c310685SBorawski.Lukasz } // namespace redfish
1033