BIOSConfig.Manager: use PDI constants
Pull property names, interface name, ... from PDI and drop a bunch of
local definitions.
The instance path is still remaining as a local definition, patch [1]
has been raised.
Tested: Inspection only.
References:
[1] https://gerrit.openbmc.org/c/openbmc/phosphor-dbus-interfaces/+/85118
Change-Id: Ia6601f1fcbe84802820f610ffc717715b85ca7ba
Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com>
diff --git a/common/utils.cpp b/common/utils.cpp
index 1e41100..374037e 100644
--- a/common/utils.cpp
+++ b/common/utils.cpp
@@ -4,6 +4,7 @@
#include <libpldm/pldm_types.h>
#include <linux/mctp.h>
+#include <xyz/openbmc_project/BIOSConfig/Manager/client.hpp>
#include <xyz/openbmc_project/Common/error.hpp>
#include <xyz/openbmc_project/Logging/Create/client.hpp>
#include <xyz/openbmc_project/ObjectMapper/client.hpp>
@@ -27,6 +28,8 @@
{
using ObjectMapper = sdbusplus::client::xyz::openbmc_project::ObjectMapper<>;
+using BIOSConfigManager =
+ sdbusplus::client::xyz::openbmc_project::bios_config::Manager<>;
constexpr const char* MCTP_INTERFACE_CC = "au.com.codeconstruct.MCTP.Endpoint1";
constexpr const char* MCTP_ENDPOINT_RECOVER_METHOD = "Recover";
@@ -915,8 +918,6 @@
{
static constexpr auto SYSTEMD_PROPERTY_INTERFACE =
"org.freedesktop.DBus.Properties";
- constexpr auto biosConfigPath = "/xyz/openbmc_project/bios_config/manager";
- constexpr auto biosConfigIntf = "xyz.openbmc_project.BIOSConfig.Manager";
for (const auto& [attrName, biosAttrDetails] : biosAttrList)
{
@@ -924,11 +925,12 @@
try
{
auto service = pldm::utils::DBusHandler().getService(
- biosConfigPath, biosConfigIntf);
+ biosConfigPath, BIOSConfigManager::interface);
auto method =
bus.new_method_call(service.c_str(), biosConfigPath,
SYSTEMD_PROPERTY_INTERFACE, "Set");
- method.append(biosConfigIntf, "PendingAttributes",
+ method.append(BIOSConfigManager::interface,
+ BIOSConfigManager::property_names::pending_attributes,
std::variant<PendingAttributesList>(biosAttrList));
bus.call_noreply(method, dbusTimeout);
}
diff --git a/common/utils.hpp b/common/utils.hpp
index 867e064..7bd57b2 100644
--- a/common/utils.hpp
+++ b/common/utils.hpp
@@ -705,6 +705,8 @@
*/
long int generateSwId();
+constexpr auto biosConfigPath = "/xyz/openbmc_project/bios_config/manager";
+
/** @brief Method to get the value from a bios attribute
*
* @param[in] dbusAttrName - the bios attribute name from
@@ -715,19 +717,19 @@
template <typename T>
std::optional<T> getBiosAttrValue(const std::string& dbusAttrName)
{
- constexpr auto biosConfigPath = "/xyz/openbmc_project/bios_config/manager";
- constexpr auto biosConfigIntf = sdbusplus::common::xyz::openbmc_project::
- bios_config::Manager::interface;
+ using BIOSConfigManager =
+ sdbusplus::common::xyz::openbmc_project::bios_config::Manager;
std::string var1;
std::variant<std::string, int64_t> var2, var3;
auto& bus = DBusHandler::getBus();
try
{
- auto service = pldm::utils::DBusHandler().getService(biosConfigPath,
- biosConfigIntf);
- auto method = bus.new_method_call(service.c_str(), biosConfigPath,
- biosConfigIntf, "GetAttribute");
+ auto service = pldm::utils::DBusHandler().getService(
+ biosConfigPath, BIOSConfigManager::interface);
+ auto method = bus.new_method_call(
+ service.c_str(), biosConfigPath, BIOSConfigManager::interface,
+ BIOSConfigManager::method_names::get_attribute);
method.append(dbusAttrName);
auto reply = bus.call(method, dbusTimeout);
reply.read(var1, var2, var3);
diff --git a/libpldmresponder/bios_config.cpp b/libpldmresponder/bios_config.cpp
index 401877c..df0d08e 100644
--- a/libpldmresponder/bios_config.cpp
+++ b/libpldmresponder/bios_config.cpp
@@ -502,11 +502,6 @@
void BIOSConfig::updateBaseBIOSTableProperty()
{
- constexpr static auto biosConfigPath =
- "/xyz/openbmc_project/bios_config/manager";
- constexpr static auto biosConfigInterface =
- "xyz.openbmc_project.BIOSConfig.Manager";
- constexpr static auto biosConfigPropertyName = "BaseBIOSTable";
constexpr static auto dbusProperties = "org.freedesktop.DBus.Properties";
if (baseBIOSTableMaps.empty())
@@ -517,8 +512,8 @@
try
{
auto& bus = dbusHandler->getBus();
- auto service =
- dbusHandler->getService(biosConfigPath, biosConfigInterface);
+ auto service = dbusHandler->getService(biosConfigPath,
+ BIOSConfigManager::interface);
auto method = bus.new_method_call(service.c_str(), biosConfigPath,
dbusProperties, "Set");
std::variant<BaseBIOSTable> value = baseBIOSTableMaps;
@@ -526,7 +521,9 @@
{
oemBiosHandler->processOEMBaseBiosTable(baseBIOSTableMaps);
}
- method.append(biosConfigInterface, biosConfigPropertyName, value);
+ method.append(BIOSConfigManager::interface,
+ BIOSConfigManager::property_names::base_bios_table,
+ value);
bus.call_noreply(method, dbusTimeout);
}
catch (const std::exception& e)
@@ -567,17 +564,17 @@
}
BaseBIOSTable biosTable{};
- constexpr auto biosObjPath = "/xyz/openbmc_project/bios_config/manager";
- constexpr auto biosInterface = "xyz.openbmc_project.BIOSConfig.Manager";
try
{
auto& bus = dbusHandler->getBus();
- auto service = dbusHandler->getService(biosObjPath, biosInterface);
+ auto service = dbusHandler->getService(biosConfigPath,
+ BIOSConfigManager::interface);
auto method =
- bus.new_method_call(service.c_str(), biosObjPath,
+ bus.new_method_call(service.c_str(), biosConfigPath,
"org.freedesktop.DBus.Properties", "Get");
- method.append(biosInterface, "BaseBIOSTable");
+ method.append(BIOSConfigManager::interface,
+ BIOSConfigManager::property_names::base_bios_table);
auto reply = bus.call(method, dbusTimeout);
std::variant<BaseBIOSTable> varBiosTable{};
reply.read(varBiosTable);
@@ -1154,16 +1151,11 @@
void BIOSConfig::listenPendingAttributes()
{
- constexpr auto objPath = "/xyz/openbmc_project/bios_config/manager";
- constexpr auto objInterface = "xyz.openbmc_project.BIOSConfig.Manager";
-
using namespace sdbusplus::bus::match::rules;
auto updateBIOSMatch = std::make_unique<sdbusplus::bus::match_t>(
pldm::utils::DBusHandler::getBus(),
- propertiesChanged(objPath, objInterface),
+ propertiesChanged(biosConfigPath, BIOSConfigManager::interface),
[this](sdbusplus::message_t& msg) {
- constexpr auto propertyName = "PendingAttributes";
-
using Value =
std::variant<std::string, PendingAttributes, BaseBIOSTable>;
using Properties = std::map<DbusProp, Value>;
@@ -1172,7 +1164,8 @@
std::string intf;
msg.read(intf, props);
- auto valPropMap = props.find(propertyName);
+ auto valPropMap = props.find(
+ BIOSConfigManager::property_names::pending_attributes);
if (valPropMap == props.end())
{
return;