summaryrefslogtreecommitdiff
path: root/redfish-core/lib/bios.hpp
diff options
context:
space:
mode:
authorJohn Edward Broadbent <jebr@google.com>2021-07-02 20:15:48 +0300
committerEd Tanous <ed@tanous.net>2021-09-29 19:57:22 +0300
commit58eaf5f0d456c1dd777d5484993e5a4603efc72b (patch)
tree2fd85c734eddd53d2f7d3b8a6659997bdf6a0b9e /redfish-core/lib/bios.hpp
parentdff07827086be120fa7e13336086fbfcb1cd1143 (diff)
downloadbmcweb-58eaf5f0d456c1dd777d5484993e5a4603efc72b.tar.xz
move to free function: Bios
This change will allow for unit testing of the free function. There are no changes to logic in bios logic response. Tested: no change to curl --user root:0penBmc -k https://${bmc}/redfish/v1/Systems/system/Bios Signed-off-by: John Edward Broadbent <jebr@google.com> Change-Id: I1de7d2f250e381863a071b9e45e7bf8e8538af87
Diffstat (limited to 'redfish-core/lib/bios.hpp')
-rw-r--r--redfish-core/lib/bios.hpp72
1 files changed, 37 insertions, 35 deletions
diff --git a/redfish-core/lib/bios.hpp b/redfish-core/lib/bios.hpp
index 3cf6077c4b..f4e2dc085a 100644
--- a/redfish-core/lib/bios.hpp
+++ b/redfish-core/lib/bios.hpp
@@ -8,29 +8,29 @@ namespace redfish
/**
* BiosService class supports handle get method for bios.
*/
+inline void
+ handleBiosServiceGet(const crow::Request&,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
+{
+ asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/Systems/system/Bios";
+ asyncResp->res.jsonValue["@odata.type"] = "#Bios.v1_1_0.Bios";
+ asyncResp->res.jsonValue["Name"] = "BIOS Configuration";
+ asyncResp->res.jsonValue["Description"] = "BIOS Configuration Service";
+ asyncResp->res.jsonValue["Id"] = "BIOS";
+ asyncResp->res.jsonValue["Actions"]["#Bios.ResetBios"] = {
+ {"target", "/redfish/v1/Systems/system/Bios/Actions/Bios.ResetBios"}};
+
+ // Get the ActiveSoftwareImage and SoftwareImages
+ fw_util::populateFirmwareInformation(asyncResp, fw_util::biosPurpose, "",
+ true);
+}
inline void requestRoutesBiosService(App& app)
{
BMCWEB_ROUTE(app, "/redfish/v1/Systems/system/Bios/")
.privileges(redfish::privileges::getBios)
- .methods(boost::beast::http::verb::get)(
- [](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
- asyncResp->res.jsonValue["@odata.id"] =
- "/redfish/v1/Systems/system/Bios";
- asyncResp->res.jsonValue["@odata.type"] = "#Bios.v1_1_0.Bios";
- asyncResp->res.jsonValue["Name"] = "BIOS Configuration";
- asyncResp->res.jsonValue["Description"] =
- "BIOS Configuration Service";
- asyncResp->res.jsonValue["Id"] = "BIOS";
- asyncResp->res.jsonValue["Actions"]["#Bios.ResetBios"] = {
- {"target",
- "/redfish/v1/Systems/system/Bios/Actions/Bios.ResetBios"}};
-
- // Get the ActiveSoftwareImage and SoftwareImages
- fw_util::populateFirmwareInformation(
- asyncResp, fw_util::biosPurpose, "", true);
- });
+ .methods(boost::beast::http::verb::get)(handleBiosServiceGet);
}
+
/**
* BiosReset class supports handle POST method for Reset bios.
* The class retrieves and sends data directly to D-Bus.
@@ -38,26 +38,28 @@ inline void requestRoutesBiosService(App& app)
* Function handles POST method request.
* Analyzes POST body message before sends Reset request data to D-Bus.
*/
+inline void
+ handleBiosResetPost(const crow::Request&,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
+{
+ crow::connections::systemBus->async_method_call(
+ [asyncResp](const boost::system::error_code ec) {
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR << "Failed to reset bios: " << ec;
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ },
+ "org.open_power.Software.Host.Updater", "/xyz/openbmc_project/software",
+ "xyz.openbmc_project.Common.FactoryReset", "Reset");
+}
inline void requestRoutesBiosReset(App& app)
{
BMCWEB_ROUTE(app, "/redfish/v1/Systems/system/Bios/Actions/Bios.ResetBios/")
- .privileges(redfish::privileges::postBios)
- .methods(boost::beast::http::verb::post)(
- [](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
- crow::connections::systemBus->async_method_call(
- [asyncResp](const boost::system::error_code ec) {
- if (ec)
- {
- BMCWEB_LOG_ERROR << "Failed to reset bios: " << ec;
- messages::internalError(asyncResp->res);
- return;
- }
- },
- "org.open_power.Software.Host.Updater",
- "/xyz/openbmc_project/software",
- "xyz.openbmc_project.Common.FactoryReset", "Reset");
- });
+ .privileges({{"redfish::privileges::postBios"}})
+ .methods(boost::beast::http::verb::post)(handleBiosResetPost);
}
+
} // namespace redfish