Carol Wang | d82a3ac | 2019-11-21 13:56:38 +0800 | [diff] [blame] | 1 | #pragma once |
| 2 | |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame^] | 3 | #include <app.hpp> |
Gunnar Mills | 72d566d | 2020-07-21 12:44:00 -0500 | [diff] [blame] | 4 | #include <utils/fw_utils.hpp> |
Carol Wang | d82a3ac | 2019-11-21 13:56:38 +0800 | [diff] [blame] | 5 | namespace redfish |
| 6 | { |
| 7 | /** |
| 8 | * BiosService class supports handle get method for bios. |
| 9 | */ |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame^] | 10 | inline void requestRoutesBiosService(App& app) |
Carol Wang | d82a3ac | 2019-11-21 13:56:38 +0800 | [diff] [blame] | 11 | { |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame^] | 12 | 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 Wang | d82a3ac | 2019-11-21 13:56:38 +0800 | [diff] [blame] | 27 | |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame^] | 28 | // Get the ActiveSoftwareImage and SoftwareImages |
| 29 | fw_util::populateFirmwareInformation( |
| 30 | asyncResp, fw_util::biosPurpose, "", true); |
| 31 | }); |
| 32 | } |
Carol Wang | d82a3ac | 2019-11-21 13:56:38 +0800 | [diff] [blame] | 33 | /** |
| 34 | * BiosReset class supports handle POST method for Reset bios. |
| 35 | * The class retrieves and sends data directly to D-Bus. |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame^] | 36 | * |
| 37 | * Function handles POST method request. |
| 38 | * Analyzes POST body message before sends Reset request data to D-Bus. |
Carol Wang | d82a3ac | 2019-11-21 13:56:38 +0800 | [diff] [blame] | 39 | */ |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame^] | 40 | |
| 41 | inline void requestRoutesBiosReset(App& app) |
Carol Wang | d82a3ac | 2019-11-21 13:56:38 +0800 | [diff] [blame] | 42 | { |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame^] | 43 | 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 Mills | 72d566d | 2020-07-21 12:44:00 -0500 | [diff] [blame] | 62 | } // namespace redfish |