blob: 604b8e7edd12186b8da7a9f89e546880206929fb [file] [log] [blame]
Carol Wangd82a3ac2019-11-21 13:56:38 +08001#pragma once
2
John Edward Broadbent7e860f12021-04-08 15:57:16 -07003#include <app.hpp>
Ed Tanoused398212021-06-09 17:05:54 -07004#include <registries/privilege_registry.hpp>
Gunnar Mills72d566d2020-07-21 12:44:00 -05005#include <utils/fw_utils.hpp>
Carol Wangd82a3ac2019-11-21 13:56:38 +08006namespace redfish
7{
8/**
9 * BiosService class supports handle get method for bios.
10 */
John Edward Broadbent7e860f12021-04-08 15:57:16 -070011inline void requestRoutesBiosService(App& app)
Carol Wangd82a3ac2019-11-21 13:56:38 +080012{
John Edward Broadbent7e860f12021-04-08 15:57:16 -070013 BMCWEB_ROUTE(app, "/redfish/v1/Systems/system/Bios/")
Ed Tanoused398212021-06-09 17:05:54 -070014 .privileges(redfish::privileges::getBios)
John Edward Broadbent7e860f12021-04-08 15:57:16 -070015 .methods(boost::beast::http::verb::get)(
16 [](const crow::Request&,
17 const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
18 asyncResp->res.jsonValue["@odata.id"] =
19 "/redfish/v1/Systems/system/Bios";
20 asyncResp->res.jsonValue["@odata.type"] = "#Bios.v1_1_0.Bios";
21 asyncResp->res.jsonValue["Name"] = "BIOS Configuration";
22 asyncResp->res.jsonValue["Description"] =
23 "BIOS Configuration Service";
24 asyncResp->res.jsonValue["Id"] = "BIOS";
25 asyncResp->res.jsonValue["Actions"]["#Bios.ResetBios"] = {
26 {"target",
27 "/redfish/v1/Systems/system/Bios/Actions/Bios.ResetBios"}};
Carol Wangd82a3ac2019-11-21 13:56:38 +080028
John Edward Broadbent7e860f12021-04-08 15:57:16 -070029 // Get the ActiveSoftwareImage and SoftwareImages
30 fw_util::populateFirmwareInformation(
31 asyncResp, fw_util::biosPurpose, "", true);
32 });
33}
Carol Wangd82a3ac2019-11-21 13:56:38 +080034/**
35 * BiosReset class supports handle POST method for Reset bios.
36 * The class retrieves and sends data directly to D-Bus.
John Edward Broadbent7e860f12021-04-08 15:57:16 -070037 *
38 * Function handles POST method request.
39 * Analyzes POST body message before sends Reset request data to D-Bus.
Carol Wangd82a3ac2019-11-21 13:56:38 +080040 */
John Edward Broadbent7e860f12021-04-08 15:57:16 -070041
42inline void requestRoutesBiosReset(App& app)
Carol Wangd82a3ac2019-11-21 13:56:38 +080043{
John Edward Broadbent7e860f12021-04-08 15:57:16 -070044 BMCWEB_ROUTE(app, "/redfish/v1/Systems/system/Bios/Actions/Bios.ResetBios/")
Ed Tanoused398212021-06-09 17:05:54 -070045 // Incorrect Privilege; Should be ConfigureComponents
46 //.privileges(redfish::privileges::postBios)
Ed Tanous432a8902021-06-14 15:28:56 -070047 .privileges({{"ConfigureManager"}})
John Edward Broadbent7e860f12021-04-08 15:57:16 -070048 .methods(boost::beast::http::verb::post)(
49 [](const crow::Request&,
50 const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
51 crow::connections::systemBus->async_method_call(
52 [asyncResp](const boost::system::error_code ec) {
53 if (ec)
54 {
55 BMCWEB_LOG_ERROR << "Failed to reset bios: " << ec;
56 messages::internalError(asyncResp->res);
57 return;
58 }
59 },
60 "org.open_power.Software.Host.Updater",
61 "/xyz/openbmc_project/software",
62 "xyz.openbmc_project.Common.FactoryReset", "Reset");
63 });
64}
Gunnar Mills72d566d2020-07-21 12:44:00 -050065} // namespace redfish