common: Add getBusName function
Add this function as 'protected' to be able to call it from test code.
The alternative would be to reconstruct the bus name in test code based
on the unique suffix, duplicating the code.
Tested: Inspection only.
Change-Id: Iafed55b5869850f8e1d547e580bdaffd5cfbb6eb
Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com>
diff --git a/common/include/software_manager.hpp b/common/include/software_manager.hpp
index 59d450b..1034766 100644
--- a/common/include/software_manager.hpp
+++ b/common/include/software_manager.hpp
@@ -51,6 +51,8 @@
const std::string& path,
SoftwareConfig& config) = 0;
+ std::string getBusName();
+
sdbusplus::async::context& ctx;
private:
@@ -70,8 +72,8 @@
sdbusplus::async::match configIntfAddedMatch;
sdbusplus::async::match configIntfRemovedMatch;
- // this is appended to the common prefix to construct the dbus name
- std::string serviceNameSuffix;
+ // the dbus name
+ const std::string serviceName;
sdbusplus::server::manager_t manager;
diff --git a/common/src/software_manager.cpp b/common/src/software_manager.cpp
index d8493b7..3ef4a51 100644
--- a/common/src/software_manager.cpp
+++ b/common/src/software_manager.cpp
@@ -31,16 +31,13 @@
ctx(ctx),
configIntfAddedMatch(ctx, RulesIntf::interfacesAdded() + matchRuleSender),
configIntfRemovedMatch(ctx, RulesIntf::interfacesRemoved() + matchRulePath),
- serviceNameSuffix(serviceNameSuffix),
+ serviceName("xyz.openbmc_project.Software." + serviceNameSuffix),
manager(ctx, sdbusplus::client::xyz::openbmc_project::software::Version<>::
namespace_path)
{
- const std::string serviceNameFull =
- "xyz.openbmc_project.Software." + serviceNameSuffix;
+ debug("requesting dbus name {BUSNAME}", "BUSNAME", serviceName);
- debug("requesting dbus name {BUSNAME}", "BUSNAME", serviceNameFull);
-
- ctx.request_name(serviceNameFull.c_str());
+ ctx.request_name(serviceName.c_str());
debug("Initialized SoftwareManager");
}
@@ -148,6 +145,11 @@
debug("Done with initial configuration");
}
+std::string SoftwareManager::getBusName()
+{
+ return serviceName;
+}
+
sdbusplus::async::task<void> SoftwareManager::handleInterfaceAdded(
const std::string& service, const std::string& path,
const std::string& interface)