blob: de6f9a1f56f5baea8adabcb6979236124411f903 [file] [log] [blame]
Carol Wangd82a3ac2019-11-21 13:56:38 +08001#pragma once
2
John Edward Broadbent7e860f12021-04-08 15:57:16 -07003#include <app.hpp>
Gunnar Mills72d566d2020-07-21 12:44:00 -05004#include <utils/fw_utils.hpp>
Carol Wangd82a3ac2019-11-21 13:56:38 +08005namespace redfish
6{
7/**
8 * BiosService class supports handle get method for bios.
9 */
John Edward Broadbent7e860f12021-04-08 15:57:16 -070010inline void requestRoutesBiosService(App& app)
Carol Wangd82a3ac2019-11-21 13:56:38 +080011{
John Edward Broadbent7e860f12021-04-08 15:57:16 -070012 BMCWEB_ROUTE(app, "/redfish/v1/Systems/system/Bios/")
13 .privileges({"Login"})
14 .methods(boost::beast::http::verb::get)(
15 [](const crow::Request&,
16 const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
17 asyncResp->res.jsonValue["@odata.id"] =
18 "/redfish/v1/Systems/system/Bios";
19 asyncResp->res.jsonValue["@odata.type"] = "#Bios.v1_1_0.Bios";
20 asyncResp->res.jsonValue["Name"] = "BIOS Configuration";
21 asyncResp->res.jsonValue["Description"] =
22 "BIOS Configuration Service";
23 asyncResp->res.jsonValue["Id"] = "BIOS";
24 asyncResp->res.jsonValue["Actions"]["#Bios.ResetBios"] = {
25 {"target",
26 "/redfish/v1/Systems/system/Bios/Actions/Bios.ResetBios"}};
Carol Wangd82a3ac2019-11-21 13:56:38 +080027
John Edward Broadbent7e860f12021-04-08 15:57:16 -070028 // Get the ActiveSoftwareImage and SoftwareImages
29 fw_util::populateFirmwareInformation(
30 asyncResp, fw_util::biosPurpose, "", true);
31 });
32}
Carol Wangd82a3ac2019-11-21 13:56:38 +080033/**
34 * BiosReset class supports handle POST method for Reset bios.
35 * The class retrieves and sends data directly to D-Bus.
John Edward Broadbent7e860f12021-04-08 15:57:16 -070036 *
37 * Function handles POST method request.
38 * Analyzes POST body message before sends Reset request data to D-Bus.
Carol Wangd82a3ac2019-11-21 13:56:38 +080039 */
John Edward Broadbent7e860f12021-04-08 15:57:16 -070040
41inline void requestRoutesBiosReset(App& app)
Carol Wangd82a3ac2019-11-21 13:56:38 +080042{
John Edward Broadbent7e860f12021-04-08 15:57:16 -070043 BMCWEB_ROUTE(app, "/redfish/v1/Systems/system/Bios/Actions/Bios.ResetBios/")
44 .privileges({"ConfigureManager"})
45 .methods(boost::beast::http::verb::post)(
46 [](const crow::Request&,
47 const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
48 crow::connections::systemBus->async_method_call(
49 [asyncResp](const boost::system::error_code ec) {
50 if (ec)
51 {
52 BMCWEB_LOG_ERROR << "Failed to reset bios: " << ec;
53 messages::internalError(asyncResp->res);
54 return;
55 }
56 },
57 "org.open_power.Software.Host.Updater",
58 "/xyz/openbmc_project/software",
59 "xyz.openbmc_project.Common.FactoryReset", "Reset");
60 });
61}
Gunnar Mills72d566d2020-07-21 12:44:00 -050062} // namespace redfish