summaryrefslogtreecommitdiff
path: root/redfish-core/lib/storage.hpp
diff options
context:
space:
mode:
authorzhanghch05 <zhanghch05@inspur.com>2021-04-01 06:18:24 +0300
committerzhanghch05 <zhanghch05@inspur.com>2021-04-08 04:01:21 +0300
commit8d1b46d7f8d39db2ba048f9e9007106ca3a28c9b (patch)
tree821fcb9b383fdf3db22db77e154cd7f57606d402 /redfish-core/lib/storage.hpp
parentdab0604af234bdd5010407031a01343d6c242edf (diff)
downloadbmcweb-8d1b46d7f8d39db2ba048f9e9007106ca3a28c9b.tar.xz
Using AsyncResp everywhere
Get the core using AsyncResp everywhere, and not have each individual handler creating its own object.We can call app.handle() without fear of the response getting ended after the first tree is done populating. Don't use res.end() anymore. Tested: 1. Validator passed. Signed-off-by: zhanghaicheng <zhanghch05@inspur.com> Change-Id: I867367ce4a0caf8c4b3f4e07e06c11feed0782e8
Diffstat (limited to 'redfish-core/lib/storage.hpp')
-rw-r--r--redfish-core/lib/storage.hpp42
1 files changed, 22 insertions, 20 deletions
diff --git a/redfish-core/lib/storage.hpp b/redfish-core/lib/storage.hpp
index 7167503f81..c2651d5e6b 100644
--- a/redfish-core/lib/storage.hpp
+++ b/redfish-core/lib/storage.hpp
@@ -38,16 +38,17 @@ class StorageCollection : public Node
}
private:
- void doGet(crow::Response& res, const crow::Request&,
- const std::vector<std::string>&) override
+ void doGet(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const crow::Request&, const std::vector<std::string>&) override
{
- res.jsonValue["@odata.type"] = "#StorageCollection.StorageCollection";
- res.jsonValue["@odata.id"] = "/redfish/v1/Systems/system/Storage";
- res.jsonValue["Name"] = "Storage Collection";
- res.jsonValue["Members"] = {
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#StorageCollection.StorageCollection";
+ asyncResp->res.jsonValue["@odata.id"] =
+ "/redfish/v1/Systems/system/Storage";
+ asyncResp->res.jsonValue["Name"] = "Storage Collection";
+ asyncResp->res.jsonValue["Members"] = {
{{"@odata.id", "/redfish/v1/Systems/system/Storage/1"}}};
- res.jsonValue["Members@odata.count"] = 1;
- res.end();
+ asyncResp->res.jsonValue["Members@odata.count"] = 1;
}
};
@@ -66,16 +67,16 @@ class Storage : public Node
}
private:
- void doGet(crow::Response& res, const crow::Request&,
- const std::vector<std::string>&) override
+ void doGet(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const crow::Request&, const std::vector<std::string>&) override
{
- res.jsonValue["@odata.type"] = "#Storage.v1_7_1.Storage";
- res.jsonValue["@odata.id"] = "/redfish/v1/Systems/system/Storage/1";
- res.jsonValue["Name"] = "Storage";
- res.jsonValue["Id"] = "1";
- res.jsonValue["Status"]["State"] = "Enabled";
+ asyncResp->res.jsonValue["@odata.type"] = "#Storage.v1_7_1.Storage";
+ asyncResp->res.jsonValue["@odata.id"] =
+ "/redfish/v1/Systems/system/Storage/1";
+ asyncResp->res.jsonValue["Name"] = "Storage";
+ asyncResp->res.jsonValue["Id"] = "1";
+ asyncResp->res.jsonValue["Status"]["State"] = "Enabled";
- auto asyncResp = std::make_shared<AsyncResp>(res);
auto health = std::make_shared<HealthPopulate>(asyncResp);
health->populate();
@@ -289,10 +290,10 @@ class Drive : public Node
}
private:
- void doGet(crow::Response& res, const crow::Request&,
+ void doGet(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const crow::Request&,
const std::vector<std::string>& params) override
{
- auto asyncResp = std::make_shared<AsyncResp>(res);
if (params.size() != 1)
{
messages::internalError(asyncResp->res);
@@ -345,8 +346,9 @@ class Drive : public Node
}
getMainChassisId(
- asyncResp, [](const std::string& chassisId,
- const std::shared_ptr<AsyncResp>& aRsp) {
+ asyncResp,
+ [](const std::string& chassisId,
+ const std::shared_ptr<bmcweb::AsyncResp>& aRsp) {
aRsp->res.jsonValue["Links"]["Chassis"] = {
{"@odata.id", "/redfish/v1/Chassis/" + chassisId}};
});