Carol Wang | d82a3ac | 2019-11-21 13:56:38 +0800 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include "node.hpp" |
| 4 | |
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 | */ |
| 11 | class BiosService : public Node |
| 12 | { |
| 13 | public: |
Ed Tanous | 52cc112 | 2020-07-18 13:51:21 -0700 | [diff] [blame] | 14 | BiosService(App& app) : Node(app, "/redfish/v1/Systems/system/Bios/") |
Carol Wang | d82a3ac | 2019-11-21 13:56:38 +0800 | [diff] [blame] | 15 | { |
| 16 | entityPrivileges = {{boost::beast::http::verb::get, {{"Login"}}}}; |
| 17 | } |
| 18 | |
| 19 | private: |
zhanghch05 | 8d1b46d | 2021-04-01 11:18:24 +0800 | [diff] [blame] | 20 | void doGet(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
| 21 | const crow::Request&, const std::vector<std::string>&) override |
Carol Wang | d82a3ac | 2019-11-21 13:56:38 +0800 | [diff] [blame] | 22 | { |
Carol Wang | d82a3ac | 2019-11-21 13:56:38 +0800 | [diff] [blame] | 23 | asyncResp->res.jsonValue["@odata.id"] = |
| 24 | "/redfish/v1/Systems/system/Bios"; |
| 25 | asyncResp->res.jsonValue["@odata.type"] = "#Bios.v1_1_0.Bios"; |
| 26 | asyncResp->res.jsonValue["Name"] = "BIOS Configuration"; |
| 27 | asyncResp->res.jsonValue["Description"] = "BIOS Configuration Service"; |
| 28 | asyncResp->res.jsonValue["Id"] = "BIOS"; |
| 29 | asyncResp->res.jsonValue["Actions"]["#Bios.ResetBios"] = { |
| 30 | {"target", |
| 31 | "/redfish/v1/Systems/system/Bios/Actions/Bios.ResetBios"}}; |
Gunnar Mills | 72d566d | 2020-07-21 12:44:00 -0500 | [diff] [blame] | 32 | |
Gunnar Mills | f97ddba | 2020-08-20 15:57:40 -0500 | [diff] [blame] | 33 | // Get the ActiveSoftwareImage and SoftwareImages |
| 34 | fw_util::populateFirmwareInformation(asyncResp, fw_util::biosPurpose, |
| 35 | "", true); |
Carol Wang | d82a3ac | 2019-11-21 13:56:38 +0800 | [diff] [blame] | 36 | } |
| 37 | }; |
| 38 | /** |
| 39 | * BiosReset class supports handle POST method for Reset bios. |
| 40 | * The class retrieves and sends data directly to D-Bus. |
| 41 | */ |
| 42 | class BiosReset : public Node |
| 43 | { |
| 44 | public: |
Ed Tanous | 52cc112 | 2020-07-18 13:51:21 -0700 | [diff] [blame] | 45 | BiosReset(App& app) : |
Carol Wang | d82a3ac | 2019-11-21 13:56:38 +0800 | [diff] [blame] | 46 | Node(app, "/redfish/v1/Systems/system/Bios/Actions/Bios.ResetBios/") |
| 47 | { |
| 48 | entityPrivileges = { |
| 49 | {boost::beast::http::verb::post, {{"ConfigureManager"}}}}; |
| 50 | } |
| 51 | |
| 52 | private: |
| 53 | /** |
| 54 | * Function handles POST method request. |
| 55 | * Analyzes POST body message before sends Reset request data to D-Bus. |
| 56 | */ |
zhanghch05 | 8d1b46d | 2021-04-01 11:18:24 +0800 | [diff] [blame] | 57 | void doPost(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
| 58 | const crow::Request&, const std::vector<std::string>&) override |
Carol Wang | d82a3ac | 2019-11-21 13:56:38 +0800 | [diff] [blame] | 59 | { |
Carol Wang | d82a3ac | 2019-11-21 13:56:38 +0800 | [diff] [blame] | 60 | |
| 61 | crow::connections::systemBus->async_method_call( |
| 62 | [asyncResp](const boost::system::error_code ec) { |
| 63 | if (ec) |
| 64 | { |
| 65 | BMCWEB_LOG_ERROR << "Failed to reset bios: " << ec; |
| 66 | messages::internalError(asyncResp->res); |
| 67 | return; |
| 68 | } |
| 69 | }, |
| 70 | "org.open_power.Software.Host.Updater", |
| 71 | "/xyz/openbmc_project/software", |
| 72 | "xyz.openbmc_project.Common.FactoryReset", "Reset"); |
| 73 | } |
| 74 | }; |
Gunnar Mills | 72d566d | 2020-07-21 12:44:00 -0500 | [diff] [blame] | 75 | } // namespace redfish |