bmcweb: Redfish away from json cache
In the original incarnation of bmcweb, route registration was done
automatically. This has proved to be a terrible idea, wraught with
corner cases and issues.
The route registration is currently the only user of the
redfish::Node::json element. Unfortunately, as written, this structure
consumes a lot of memory that's duplicated and not very useful. From a
performance perspective, there is almost no difference between
rebuilding the structure for each GET request, and having the "cache"
that needs to be copied into the response and modified before it can be
useful.
In the programming tradeoffs for bmc, lower memory usage is more important
than latency, especially at these levels.
Change-Id: I785e8352123e5e886acf05cd59cb23648f93839d
Signed-off-by: Ed Tanous <ed.tanous@intel.com>
diff --git a/redfish-core/lib/managers.hpp b/redfish-core/lib/managers.hpp
index d4e7344..44725b1 100644
--- a/redfish-core/lib/managers.hpp
+++ b/redfish-core/lib/managers.hpp
@@ -44,18 +44,6 @@
private:
/**
- * Function handles GET method request.
- * ManagerActionReset supports for POST method,
- * it is not required to retrieve more information in GET.
- */
- void doGet(crow::Response& res, const crow::Request& req,
- const std::vector<std::string>& params) override
- {
- res.jsonValue = Node::json;
- res.end();
- }
-
- /**
* Function handles POST method request.
* Analyzes POST body message before sends Reset request data to dbus.
* OpenBMC allows for ResetType is GracefulRestart only.
@@ -614,21 +602,8 @@
public:
Manager(CrowApp& app) : Node(app, "/redfish/v1/Managers/bmc/")
{
- Node::json["@odata.id"] = "/redfish/v1/Managers/bmc";
- Node::json["@odata.type"] = "#Manager.v1_3_0.Manager";
- Node::json["@odata.context"] = "/redfish/v1/$metadata#Manager.Manager";
- Node::json["Id"] = "bmc";
- Node::json["Name"] = "OpenBmc Manager";
- Node::json["Description"] = "Baseboard Management Controller";
- Node::json["PowerState"] = "On";
- Node::json["ManagerType"] = "BMC";
- Node::json["UUID"] =
- app.template getMiddleware<crow::persistent_data::Middleware>()
- .systemUuid;
- Node::json["Model"] = "OpenBmc"; // TODO(ed), get model
- Node::json["EthernetInterfaces"] = {
- {"@odata.id", "/redfish/v1/Managers/bmc/EthernetInterfaces"}};
-
+ uuid = app.template getMiddleware<crow::persistent_data::Middleware>()
+ .systemUuid;
entityPrivileges = {
{boost::beast::http::verb::get, {{"Login"}}},
{boost::beast::http::verb::head, {{"Login"}}},
@@ -636,17 +611,6 @@
{boost::beast::http::verb::put, {{"ConfigureManager"}}},
{boost::beast::http::verb::delete_, {{"ConfigureManager"}}},
{boost::beast::http::verb::post, {{"ConfigureManager"}}}};
-
- // default oem data
- nlohmann::json& oem = Node::json["Oem"];
- nlohmann::json& oemOpenbmc = oem["OpenBmc"];
- oem["@odata.type"] = "#OemManager.Oem";
- oem["@odata.id"] = "/redfish/v1/Managers/bmc#/Oem";
- oem["@odata.context"] = "/redfish/v1/$metadata#OemManager.Oem";
- oemOpenbmc["@odata.type"] = "#OemManager.OpenBmc";
- oemOpenbmc["@odata.id"] = "/redfish/v1/Managers/bmc#/Oem/OpenBmc";
- oemOpenbmc["@odata.context"] =
- "/redfish/v1/$metadata#OemManager.OpenBmc";
}
private:
@@ -719,16 +683,48 @@
void doGet(crow::Response& res, const crow::Request& req,
const std::vector<std::string>& params) override
{
+ res.jsonValue["@odata.id"] = "/redfish/v1/Managers/bmc";
+ res.jsonValue["@odata.type"] = "#Manager.v1_3_0.Manager";
+ res.jsonValue["@odata.context"] =
+ "/redfish/v1/$metadata#Manager.Manager";
+ res.jsonValue["Id"] = "bmc";
+ res.jsonValue["Name"] = "OpenBmc Manager";
+ res.jsonValue["Description"] = "Baseboard Management Controller";
+ res.jsonValue["PowerState"] = "On";
+ res.jsonValue["ManagerType"] = "BMC";
+ res.jsonValue["UUID"] =
+
+ res.jsonValue["Model"] = "OpenBmc"; // TODO(ed), get model
+
+ res.jsonValue["LogServices"] = {
+ {"@odata.id", "/redfish/v1/Managers/bmc/LogServices"}};
+
+ res.jsonValue["NetworkProtocol"] = {
+ {"@odata.id", "/redfish/v1/Managers/bmc/NetworkProtocol"}};
+
+ res.jsonValue["EthernetInterfaces"] = {
+ {"@odata.id", "/redfish/v1/Managers/bmc/EthernetInterfaces"}};
+ // default oem data
+ nlohmann::json& oem = res.jsonValue["Oem"];
+ nlohmann::json& oemOpenbmc = oem["OpenBmc"];
+ oem["@odata.type"] = "#OemManager.Oem";
+ oem["@odata.id"] = "/redfish/v1/Managers/bmc#/Oem";
+ oem["@odata.context"] = "/redfish/v1/$metadata#OemManager.Oem";
+ oemOpenbmc["@odata.type"] = "#OemManager.OpenBmc";
+ oemOpenbmc["@odata.id"] = "/redfish/v1/Managers/bmc#/Oem/OpenBmc";
+ oemOpenbmc["@odata.context"] =
+ "/redfish/v1/$metadata#OemManager.OpenBmc";
+
// Update Actions object.
- nlohmann::json& manager_reset = Node::json["Actions"]["#Manager.Reset"];
+ nlohmann::json& manager_reset =
+ res.jsonValue["Actions"]["#Manager.Reset"];
manager_reset["target"] =
"/redfish/v1/Managers/bmc/Actions/Manager.Reset";
manager_reset["ResetType@Redfish.AllowableValues"] = {
"GracefulRestart"};
- Node::json["DateTime"] = getDateTime();
+ res.jsonValue["DateTime"] = getDateTime();
std::shared_ptr<AsyncResp> asyncResp = std::make_shared<AsyncResp>(res);
- asyncResp->res.jsonValue = Node::json;
crow::connections::systemBus->async_method_call(
[asyncResp](const boost::system::error_code ec,
@@ -1021,6 +1017,8 @@
return redfishDateTime;
}
+
+ std::string uuid;
};
class ManagerCollection : public Node
@@ -1028,14 +1026,6 @@
public:
ManagerCollection(CrowApp& app) : Node(app, "/redfish/v1/Managers/")
{
- Node::json["@odata.id"] = "/redfish/v1/Managers";
- Node::json["@odata.type"] = "#ManagerCollection.ManagerCollection";
- Node::json["@odata.context"] =
- "/redfish/v1/$metadata#ManagerCollection.ManagerCollection";
- Node::json["Name"] = "Manager Collection";
- Node::json["Members@odata.count"] = 1;
- Node::json["Members"] = {{{"@odata.id", "/redfish/v1/Managers/bmc"}}};
-
entityPrivileges = {
{boost::beast::http::verb::get, {{"Login"}}},
{boost::beast::http::verb::head, {{"Login"}}},