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> |
Ed Tanous | ed39821 | 2021-06-09 17:05:54 -0700 | [diff] [blame] | 4 | #include <registries/privilege_registry.hpp> |
Gunnar Mills | 72d566d | 2020-07-21 12:44:00 -0500 | [diff] [blame] | 5 | #include <utils/fw_utils.hpp> |
Carol Wang | d82a3ac | 2019-11-21 13:56:38 +0800 | [diff] [blame] | 6 | namespace redfish |
| 7 | { |
| 8 | /** |
| 9 | * BiosService class supports handle get method for bios. |
| 10 | */ |
John Edward Broadbent | 58eaf5f | 2021-07-02 10:15:48 -0700 | [diff] [blame^] | 11 | inline void |
| 12 | handleBiosServiceGet(const crow::Request&, |
| 13 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) |
| 14 | { |
| 15 | asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/Systems/system/Bios"; |
| 16 | asyncResp->res.jsonValue["@odata.type"] = "#Bios.v1_1_0.Bios"; |
| 17 | asyncResp->res.jsonValue["Name"] = "BIOS Configuration"; |
| 18 | asyncResp->res.jsonValue["Description"] = "BIOS Configuration Service"; |
| 19 | asyncResp->res.jsonValue["Id"] = "BIOS"; |
| 20 | asyncResp->res.jsonValue["Actions"]["#Bios.ResetBios"] = { |
| 21 | {"target", "/redfish/v1/Systems/system/Bios/Actions/Bios.ResetBios"}}; |
| 22 | |
| 23 | // Get the ActiveSoftwareImage and SoftwareImages |
| 24 | fw_util::populateFirmwareInformation(asyncResp, fw_util::biosPurpose, "", |
| 25 | true); |
| 26 | } |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 27 | inline void requestRoutesBiosService(App& app) |
Carol Wang | d82a3ac | 2019-11-21 13:56:38 +0800 | [diff] [blame] | 28 | { |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 29 | BMCWEB_ROUTE(app, "/redfish/v1/Systems/system/Bios/") |
Ed Tanous | ed39821 | 2021-06-09 17:05:54 -0700 | [diff] [blame] | 30 | .privileges(redfish::privileges::getBios) |
John Edward Broadbent | 58eaf5f | 2021-07-02 10:15:48 -0700 | [diff] [blame^] | 31 | .methods(boost::beast::http::verb::get)(handleBiosServiceGet); |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 32 | } |
John Edward Broadbent | 58eaf5f | 2021-07-02 10:15:48 -0700 | [diff] [blame^] | 33 | |
Carol Wang | d82a3ac | 2019-11-21 13:56:38 +0800 | [diff] [blame] | 34 | /** |
| 35 | * BiosReset class supports handle POST method for Reset bios. |
| 36 | * The class retrieves and sends data directly to D-Bus. |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 37 | * |
| 38 | * Function handles POST method request. |
| 39 | * Analyzes POST body message before sends Reset request data to D-Bus. |
Carol Wang | d82a3ac | 2019-11-21 13:56:38 +0800 | [diff] [blame] | 40 | */ |
John Edward Broadbent | 58eaf5f | 2021-07-02 10:15:48 -0700 | [diff] [blame^] | 41 | inline void |
| 42 | handleBiosResetPost(const crow::Request&, |
| 43 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) |
| 44 | { |
| 45 | crow::connections::systemBus->async_method_call( |
| 46 | [asyncResp](const boost::system::error_code ec) { |
| 47 | if (ec) |
| 48 | { |
| 49 | BMCWEB_LOG_ERROR << "Failed to reset bios: " << ec; |
| 50 | messages::internalError(asyncResp->res); |
| 51 | return; |
| 52 | } |
| 53 | }, |
| 54 | "org.open_power.Software.Host.Updater", "/xyz/openbmc_project/software", |
| 55 | "xyz.openbmc_project.Common.FactoryReset", "Reset"); |
| 56 | } |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 57 | |
| 58 | inline void requestRoutesBiosReset(App& app) |
Carol Wang | d82a3ac | 2019-11-21 13:56:38 +0800 | [diff] [blame] | 59 | { |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 60 | BMCWEB_ROUTE(app, "/redfish/v1/Systems/system/Bios/Actions/Bios.ResetBios/") |
John Edward Broadbent | 58eaf5f | 2021-07-02 10:15:48 -0700 | [diff] [blame^] | 61 | .privileges({{"redfish::privileges::postBios"}}) |
| 62 | .methods(boost::beast::http::verb::post)(handleBiosResetPost); |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 63 | } |
John Edward Broadbent | 58eaf5f | 2021-07-02 10:15:48 -0700 | [diff] [blame^] | 64 | |
Gunnar Mills | 72d566d | 2020-07-21 12:44:00 -0500 | [diff] [blame] | 65 | } // namespace redfish |