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