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/roles.hpp b/redfish-core/lib/roles.hpp
index 258eed3..5e711b1 100644
--- a/redfish-core/lib/roles.hpp
+++ b/redfish-core/lib/roles.hpp
@@ -26,18 +26,6 @@
Roles(CrowApp& app) :
Node(app, "/redfish/v1/AccountService/Roles/Administrator/")
{
- Node::json["@odata.id"] =
- "/redfish/v1/AccountService/Roles/Administrator";
- Node::json["@odata.type"] = "#Role.v1_0_2.Role";
- Node::json["@odata.context"] = "/redfish/v1/$metadata#Role.Role";
- Node::json["Id"] = "Administrator";
- Node::json["Name"] = "User Role";
- Node::json["Description"] = "Administrator User Role";
- Node::json["IsPredefined"] = true;
- Node::json["AssignedPrivileges"] = {"Login", "ConfigureManager",
- "ConfigureUsers", "ConfigureSelf",
- "ConfigureComponents"};
- Node::json["OemPrivileges"] = nlohmann::json::array();
entityPrivileges = {
{boost::beast::http::verb::get, {{"Login"}}},
{boost::beast::http::verb::head, {{"Login"}}},
@@ -51,7 +39,18 @@
void doGet(crow::Response& res, const crow::Request& req,
const std::vector<std::string>& params) override
{
- res.jsonValue = Node::json;
+ res.jsonValue["@odata.id"] =
+ "/redfish/v1/AccountService/Roles/Administrator";
+ res.jsonValue["@odata.type"] = "#Role.v1_0_2.Role";
+ res.jsonValue["@odata.context"] = "/redfish/v1/$metadata#Role.Role";
+ res.jsonValue["Id"] = "Administrator";
+ res.jsonValue["Name"] = "User Role";
+ res.jsonValue["Description"] = "Administrator User Role";
+ res.jsonValue["IsPredefined"] = true;
+ res.jsonValue["AssignedPrivileges"] = {
+ "Login", "ConfigureManager", "ConfigureUsers", "ConfigureSelf",
+ "ConfigureComponents"};
+ res.jsonValue["OemPrivileges"] = nlohmann::json::array();
res.end();
}
};
@@ -62,16 +61,6 @@
RoleCollection(CrowApp& app) :
Node(app, "/redfish/v1/AccountService/Roles/")
{
- Node::json["@odata.id"] = "/redfish/v1/AccountService/Roles";
- Node::json["@odata.type"] = "#RoleCollection.RoleCollection";
- Node::json["@odata.context"] =
- "/redfish/v1/$metadata#RoleCollection.RoleCollection";
- Node::json["Name"] = "Roles Collection";
- Node::json["Description"] = "BMC User Roles";
- Node::json["Members@odata.count"] = 1;
- Node::json["Members"] = {
- {{"@odata.id", "/redfish/v1/AccountService/Roles/Administrator"}}};
-
entityPrivileges = {
{boost::beast::http::verb::get, {{"Login"}}},
{boost::beast::http::verb::head, {{"Login"}}},
@@ -85,12 +74,15 @@
void doGet(crow::Response& res, const crow::Request& req,
const std::vector<std::string>& params) override
{
- res.jsonValue = Node::json;
- // This is a short term solution to work around a bug. GetSubroutes
- // accidentally recognizes the Roles/Administrator route as a subroute
- // (because it's hardcoded to a single entity). Remove this line when
- // that is resolved
- res.jsonValue.erase("Administrator");
+ res.jsonValue["@odata.id"] = "/redfish/v1/AccountService/Roles";
+ res.jsonValue["@odata.type"] = "#RoleCollection.RoleCollection";
+ res.jsonValue["@odata.context"] =
+ "/redfish/v1/$metadata#RoleCollection.RoleCollection";
+ res.jsonValue["Name"] = "Roles Collection";
+ res.jsonValue["Description"] = "BMC User Roles";
+ res.jsonValue["Members@odata.count"] = 1;
+ res.jsonValue["Members"] = {
+ {{"@odata.id", "/redfish/v1/AccountService/Roles/Administrator"}}};
res.end();
}
};