read_fru_data: move and rename constants
Moved the DBus constants, used for reading FRU records
from the Inventory, to the read_fru_data.hpp header file.
Renamed these constants to comply with the
lowerCamelCase convention.
Moved and renamed constants remain within the ipmi::fru namespace.
Change-Id: If32c4a9c176453c414d9813c801ecc11ff81c038
Signed-off-by: Kirill Pakhomov <k.pakhomov@yadro.com>
diff --git a/read_fru_data.cpp b/read_fru_data.cpp
index 270accf..740a140 100644
--- a/read_fru_data.cpp
+++ b/read_fru_data.cpp
@@ -23,11 +23,6 @@
std::unique_ptr<sdbusplus::bus::match_t> matchPtr
__attribute__((init_priority(101)));
-static constexpr auto XYZ_PREFIX = "/xyz/openbmc_project/";
-static constexpr auto INV_INTF = "xyz.openbmc_project.Inventory.Manager";
-static constexpr auto OBJ_PATH = "/xyz/openbmc_project/inventory";
-static constexpr auto PROP_INTF = "org.freedesktop.DBus.Properties";
-
namespace cache
{
// User initiate read FRU info area command followed by
@@ -54,19 +49,19 @@
std::string objPath;
// Is the path the full dbus path?
- if (path.find(XYZ_PREFIX) != std::string::npos)
+ if (path.find(xyzPrefix) != std::string::npos)
{
service = ipmi::getService(bus, intf, path);
objPath = path;
}
else
{
- service = ipmi::getService(bus, INV_INTF, OBJ_PATH);
- objPath = OBJ_PATH + path;
+ service = ipmi::getService(bus, invMgrInterface, invObjPath);
+ objPath = invObjPath + path;
}
auto method = bus.new_method_call(service.c_str(), objPath.c_str(),
- PROP_INTF, "GetAll");
+ propInterface, "GetAll");
method.append(intf);
try
{
@@ -93,9 +88,9 @@
}
std::string path = msg.get_path();
// trim the object base path, if found at the beginning
- if (path.compare(0, strlen(OBJ_PATH), OBJ_PATH) == 0)
+ if (path.compare(0, strlen(invObjPath), invObjPath) == 0)
{
- path.erase(0, strlen(OBJ_PATH));
+ path.erase(0, strlen(invObjPath));
}
for (const auto& [fruId, instanceList] : frus)
{
@@ -120,8 +115,8 @@
sdbusplus::bus::bus bus{ipmid_get_sd_bus_connection()};
matchPtr = std::make_unique<sdbusplus::bus::match_t>(
bus,
- path_namespace(OBJ_PATH) + type::signal() +
- member("PropertiesChanged") + interface(PROP_INTF),
+ path_namespace(invObjPath) + type::signal() +
+ member("PropertiesChanged") + interface(propInterface),
std::bind(processFruPropChange, std::placeholders::_1));
}
return 0;
diff --git a/read_fru_data.hpp b/read_fru_data.hpp
index d3268b8..d89646c 100644
--- a/read_fru_data.hpp
+++ b/read_fru_data.hpp
@@ -10,6 +10,12 @@
{
using FRUId = uint8_t;
using FRUAreaMap = std::map<FRUId, FruAreaData>;
+
+static constexpr auto xyzPrefix = "/xyz/openbmc_project/";
+static constexpr auto invMgrInterface = "xyz.openbmc_project.Inventory.Manager";
+static constexpr auto invObjPath = "/xyz/openbmc_project/inventory";
+static constexpr auto propInterface = "org.freedesktop.DBus.Properties";
+
/**
* @brief Get fru area data as per IPMI specification
*