blob: 0917cc7f477da401b1f1638fbbc234d00242d494 [file] [log] [blame]
Carol Wangd82a3ac2019-11-21 13:56:38 +08001#pragma once
2
3#include "node.hpp"
4
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 */
11class BiosService : public Node
12{
13 public:
Ed Tanous52cc1122020-07-18 13:51:21 -070014 BiosService(App& app) : Node(app, "/redfish/v1/Systems/system/Bios/")
Carol Wangd82a3ac2019-11-21 13:56:38 +080015 {
16 entityPrivileges = {{boost::beast::http::verb::get, {{"Login"}}}};
17 }
18
19 private:
zhanghch058d1b46d2021-04-01 11:18:24 +080020 void doGet(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
21 const crow::Request&, const std::vector<std::string>&) override
Carol Wangd82a3ac2019-11-21 13:56:38 +080022 {
Carol Wangd82a3ac2019-11-21 13:56:38 +080023 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 Mills72d566d2020-07-21 12:44:00 -050032
Gunnar Millsf97ddba2020-08-20 15:57:40 -050033 // Get the ActiveSoftwareImage and SoftwareImages
34 fw_util::populateFirmwareInformation(asyncResp, fw_util::biosPurpose,
35 "", true);
Carol Wangd82a3ac2019-11-21 13:56:38 +080036 }
37};
38/**
39 * BiosReset class supports handle POST method for Reset bios.
40 * The class retrieves and sends data directly to D-Bus.
41 */
42class BiosReset : public Node
43{
44 public:
Ed Tanous52cc1122020-07-18 13:51:21 -070045 BiosReset(App& app) :
Carol Wangd82a3ac2019-11-21 13:56:38 +080046 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 */
zhanghch058d1b46d2021-04-01 11:18:24 +080057 void doPost(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
58 const crow::Request&, const std::vector<std::string>&) override
Carol Wangd82a3ac2019-11-21 13:56:38 +080059 {
Carol Wangd82a3ac2019-11-21 13:56:38 +080060
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 Mills72d566d2020-07-21 12:44:00 -050075} // namespace redfish