summaryrefslogtreecommitdiff
path: root/redfish-core/lib/fabric_adapters.hpp
diff options
context:
space:
mode:
authorEd Tanous <edtanous@google.com>2023-06-07 19:24:59 +0300
committerEd Tanous <ed@tanous.net>2023-06-09 19:02:42 +0300
commitac106bf6d10841a25088ed14105a73636ba71519 (patch)
treef8a3994884fc9ad2ce1df6f8ab50590b707c3ff7 /redfish-core/lib/fabric_adapters.hpp
parent69c3cf09a67041de8084b5f7fa7b0f54725a27fa (diff)
downloadbmcweb-ac106bf6d10841a25088ed14105a73636ba71519.tar.xz
Consistently name AsyncResp variables
In about half of our code, AsyncResp objects take the name asyncResp, and in the other half they take the name aResp. While the difference between them is negligeble and arbitrary, having two naming conventions makes it more difficult to do automated changes over time via grep. This commit was generated automtatically with the command: git grep -l 'aResp' | xargs sed -i 's|aResp|asyncResp|g' Tested: Code compiles. Change-Id: Id363437b6a78f51e91cbf60aa0a0c2286f36a037 Signed-off-by: Ed Tanous <edtanous@google.com>
Diffstat (limited to 'redfish-core/lib/fabric_adapters.hpp')
-rw-r--r--redfish-core/lib/fabric_adapters.hpp141
1 files changed, 73 insertions, 68 deletions
diff --git a/redfish-core/lib/fabric_adapters.hpp b/redfish-core/lib/fabric_adapters.hpp
index 16174bf4bd..2b4b4aefba 100644
--- a/redfish-core/lib/fabric_adapters.hpp
+++ b/redfish-core/lib/fabric_adapters.hpp
@@ -37,48 +37,47 @@ inline void handleAdapterError(const boost::system::error_code& ec,
messages::internalError(res);
}
-inline void
- getFabricAdapterLocation(const std::shared_ptr<bmcweb::AsyncResp>& aResp,
- const std::string& serviceName,
- const std::string& fabricAdapterPath)
+inline void getFabricAdapterLocation(
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& serviceName, const std::string& fabricAdapterPath)
{
sdbusplus::asio::getProperty<std::string>(
*crow::connections::systemBus, serviceName, fabricAdapterPath,
"xyz.openbmc_project.Inventory.Decorator.LocationCode", "LocationCode",
- [aResp](const boost::system::error_code& ec,
- const std::string& property) {
+ [asyncResp](const boost::system::error_code& ec,
+ const std::string& property) {
if (ec)
{
if (ec.value() != EBADR)
{
BMCWEB_LOG_ERROR << "DBUS response error for Location";
- messages::internalError(aResp->res);
+ messages::internalError(asyncResp->res);
}
return;
}
- aResp->res.jsonValue["Location"]["PartLocation"]["ServiceLabel"] =
+ asyncResp->res.jsonValue["Location"]["PartLocation"]["ServiceLabel"] =
property;
});
}
inline void
- getFabricAdapterAsset(const std::shared_ptr<bmcweb::AsyncResp>& aResp,
+ getFabricAdapterAsset(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& serviceName,
const std::string& fabricAdapterPath)
{
sdbusplus::asio::getAllProperties(
*crow::connections::systemBus, serviceName, fabricAdapterPath,
"xyz.openbmc_project.Inventory.Decorator.Asset",
- [fabricAdapterPath,
- aResp{aResp}](const boost::system::error_code& ec,
- const dbus::utility::DBusPropertiesMap& propertiesList) {
+ [fabricAdapterPath, asyncResp{asyncResp}](
+ const boost::system::error_code& ec,
+ const dbus::utility::DBusPropertiesMap& propertiesList) {
if (ec)
{
if (ec.value() != EBADR)
{
BMCWEB_LOG_ERROR << "DBUS response error for Properties";
- messages::internalError(aResp->res);
+ messages::internalError(asyncResp->res);
}
return;
}
@@ -95,106 +94,108 @@ inline void
if (!success)
{
- messages::internalError(aResp->res);
+ messages::internalError(asyncResp->res);
return;
}
if (serialNumber != nullptr)
{
- aResp->res.jsonValue["SerialNumber"] = *serialNumber;
+ asyncResp->res.jsonValue["SerialNumber"] = *serialNumber;
}
if (model != nullptr)
{
- aResp->res.jsonValue["Model"] = *model;
+ asyncResp->res.jsonValue["Model"] = *model;
}
if (partNumber != nullptr)
{
- aResp->res.jsonValue["PartNumber"] = *partNumber;
+ asyncResp->res.jsonValue["PartNumber"] = *partNumber;
}
if (sparePartNumber != nullptr && !sparePartNumber->empty())
{
- aResp->res.jsonValue["SparePartNumber"] = *sparePartNumber;
+ asyncResp->res.jsonValue["SparePartNumber"] = *sparePartNumber;
}
});
}
inline void
- getFabricAdapterState(const std::shared_ptr<bmcweb::AsyncResp>& aResp,
+ getFabricAdapterState(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& serviceName,
const std::string& fabricAdapterPath)
{
sdbusplus::asio::getProperty<bool>(
*crow::connections::systemBus, serviceName, fabricAdapterPath,
"xyz.openbmc_project.Inventory.Item", "Present",
- [aResp](const boost::system::error_code& ec, const bool present) {
+ [asyncResp](const boost::system::error_code& ec, const bool present) {
if (ec)
{
if (ec.value() != EBADR)
{
BMCWEB_LOG_ERROR << "DBUS response error for State";
- messages::internalError(aResp->res);
+ messages::internalError(asyncResp->res);
}
return;
}
if (!present)
{
- aResp->res.jsonValue["Status"]["State"] = "Absent";
+ asyncResp->res.jsonValue["Status"]["State"] = "Absent";
}
});
}
inline void
- getFabricAdapterHealth(const std::shared_ptr<bmcweb::AsyncResp>& aResp,
+ getFabricAdapterHealth(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& serviceName,
const std::string& fabricAdapterPath)
{
sdbusplus::asio::getProperty<bool>(
*crow::connections::systemBus, serviceName, fabricAdapterPath,
"xyz.openbmc_project.State.Decorator.OperationalStatus", "Functional",
- [aResp](const boost::system::error_code& ec, const bool functional) {
+ [asyncResp](const boost::system::error_code& ec,
+ const bool functional) {
if (ec)
{
if (ec.value() != EBADR)
{
BMCWEB_LOG_ERROR << "DBUS response error for Health";
- messages::internalError(aResp->res);
+ messages::internalError(asyncResp->res);
}
return;
}
if (!functional)
{
- aResp->res.jsonValue["Status"]["Health"] = "Critical";
+ asyncResp->res.jsonValue["Status"]["Health"] = "Critical";
}
});
}
-inline void doAdapterGet(const std::shared_ptr<bmcweb::AsyncResp>& aResp,
+inline void doAdapterGet(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& systemName,
const std::string& adapterId,
const std::string& fabricAdapterPath,
const std::string& serviceName)
{
- aResp->res.addHeader(
+ asyncResp->res.addHeader(
boost::beast::http::field::link,
"</redfish/v1/JsonSchemas/FabricAdapter/FabricAdapter.json>; rel=describedby");
- aResp->res.jsonValue["@odata.type"] = "#FabricAdapter.v1_4_0.FabricAdapter";
- aResp->res.jsonValue["Name"] = "Fabric Adapter";
- aResp->res.jsonValue["Id"] = adapterId;
- aResp->res.jsonValue["@odata.id"] = boost::urls::format(
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#FabricAdapter.v1_4_0.FabricAdapter";
+ asyncResp->res.jsonValue["Name"] = "Fabric Adapter";
+ asyncResp->res.jsonValue["Id"] = adapterId;
+ asyncResp->res.jsonValue["@odata.id"] = boost::urls::format(
"/redfish/v1/Systems/{}/FabricAdapters/{}", systemName, adapterId);
- aResp->res.jsonValue["Status"]["State"] = "Enabled";
- aResp->res.jsonValue["Status"]["Health"] = "OK";
+ asyncResp->res.jsonValue["Status"]["State"] = "Enabled";
+ asyncResp->res.jsonValue["Status"]["Health"] = "OK";
- getFabricAdapterLocation(aResp, serviceName, fabricAdapterPath);
- getFabricAdapterAsset(aResp, serviceName, fabricAdapterPath);
- getFabricAdapterState(aResp, serviceName, fabricAdapterPath);
- getFabricAdapterHealth(aResp, serviceName, fabricAdapterPath);
+ getFabricAdapterLocation(asyncResp, serviceName, fabricAdapterPath);
+ getFabricAdapterAsset(asyncResp, serviceName, fabricAdapterPath);
+ getFabricAdapterState(asyncResp, serviceName, fabricAdapterPath);
+ getFabricAdapterHealth(asyncResp, serviceName, fabricAdapterPath);
}
inline bool checkFabricAdapterId(const std::string& adapterPath,
@@ -208,13 +209,14 @@ inline bool checkFabricAdapterId(const std::string& adapterPath,
inline void getValidFabricAdapterPath(
const std::string& adapterId, const std::string& systemName,
- const std::shared_ptr<bmcweb::AsyncResp>& aResp,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
std::function<void(const std::string& fabricAdapterPath,
const std::string& serviceName)>&& callback)
{
if (systemName != "system")
{
- messages::resourceNotFound(aResp->res, "ComputerSystem", systemName);
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
return;
}
constexpr std::array<std::string_view, 1> interfaces{
@@ -222,12 +224,12 @@ inline void getValidFabricAdapterPath(
dbus::utility::getSubTree(
"/xyz/openbmc_project/inventory", 0, interfaces,
- [adapterId, aResp,
+ [adapterId, asyncResp,
callback](const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
if (ec)
{
- handleAdapterError(ec, aResp->res, adapterId);
+ handleAdapterError(ec, asyncResp->res, adapterId);
return;
}
for (const auto& [adapterPath, serviceMap] : subtree)
@@ -239,98 +241,101 @@ inline void getValidFabricAdapterPath(
}
}
BMCWEB_LOG_WARNING << "Adapter not found";
- messages::resourceNotFound(aResp->res, "FabricAdapter", adapterId);
+ messages::resourceNotFound(asyncResp->res, "FabricAdapter", adapterId);
});
}
inline void
handleFabricAdapterGet(App& app, const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& aResp,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& systemName,
const std::string& adapterId)
{
- if (!redfish::setUpRedfishRoute(app, req, aResp))
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
{
return;
}
getValidFabricAdapterPath(
- adapterId, systemName, aResp,
- [aResp, systemName, adapterId](const std::string& fabricAdapterPath,
- const std::string& serviceName) {
- doAdapterGet(aResp, systemName, adapterId, fabricAdapterPath,
+ adapterId, systemName, asyncResp,
+ [asyncResp, systemName, adapterId](const std::string& fabricAdapterPath,
+ const std::string& serviceName) {
+ doAdapterGet(asyncResp, systemName, adapterId, fabricAdapterPath,
serviceName);
});
}
inline void handleFabricAdapterCollectionGet(
crow::App& app, const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& aResp,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& systemName)
{
- if (!redfish::setUpRedfishRoute(app, req, aResp))
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
{
return;
}
if (systemName != "system")
{
- messages::resourceNotFound(aResp->res, "ComputerSystem", systemName);
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
return;
}
- aResp->res.addHeader(
+ asyncResp->res.addHeader(
boost::beast::http::field::link,
"</redfish/v1/JsonSchemas/FabricAdapterCollection/FabricAdapterCollection.json>; rel=describedby");
- aResp->res.jsonValue["@odata.type"] =
+ asyncResp->res.jsonValue["@odata.type"] =
"#FabricAdapterCollection.FabricAdapterCollection";
- aResp->res.jsonValue["Name"] = "Fabric Adapter Collection";
- aResp->res.jsonValue["@odata.id"] = boost::urls::format(
+ asyncResp->res.jsonValue["Name"] = "Fabric Adapter Collection";
+ asyncResp->res.jsonValue["@odata.id"] = boost::urls::format(
"/redfish/v1/Systems/{}/FabricAdapters", systemName);
constexpr std::array<std::string_view, 1> interfaces{
"xyz.openbmc_project.Inventory.Item.FabricAdapter"};
collection_util::getCollectionMembers(
- aResp, boost::urls::url("/redfish/v1/Systems/system/FabricAdapters"),
+ asyncResp,
+ boost::urls::url("/redfish/v1/Systems/system/FabricAdapters"),
interfaces);
}
inline void handleFabricAdapterCollectionHead(
crow::App& app, const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& aResp,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& systemName)
{
- if (!redfish::setUpRedfishRoute(app, req, aResp))
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
{
return;
}
if (systemName != "system")
{
- messages::resourceNotFound(aResp->res, "ComputerSystem", systemName);
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
return;
}
- aResp->res.addHeader(
+ asyncResp->res.addHeader(
boost::beast::http::field::link,
"</redfish/v1/JsonSchemas/FabricAdapterCollection/FabricAdapterCollection.json>; rel=describedby");
}
inline void
handleFabricAdapterHead(crow::App& app, const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& aResp,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& systemName,
const std::string& adapterId)
{
- if (!redfish::setUpRedfishRoute(app, req, aResp))
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
{
return;
}
- getValidFabricAdapterPath(
- adapterId, systemName, aResp,
- [aResp, systemName, adapterId](const std::string&, const std::string&) {
- aResp->res.addHeader(
+ getValidFabricAdapterPath(adapterId, systemName, asyncResp,
+ [asyncResp, systemName, adapterId](
+ const std::string&, const std::string&) {
+ asyncResp->res.addHeader(
boost::beast::http::field::link,
"</redfish/v1/JsonSchemas/FabricAdapter/FabricAdapter.json>; rel=describedby");
- });
+ });
}
inline void requestRoutesFabricAdapterCollection(App& app)