common: extract handleInterfaceAdded
The function is extracted from initDevices to decouple it from iterating
over the object mapper response.
Code is only moved and not changed.
Tested: Unit Tests Pass
Change-Id: I5d776818ca1bd7fb335bc540b07ff12993c1125e
Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com>
diff --git a/common/include/software_manager.hpp b/common/include/software_manager.hpp
index 1e0a427..4cf3419 100644
--- a/common/include/software_manager.hpp
+++ b/common/include/software_manager.hpp
@@ -53,6 +53,10 @@
sdbusplus::async::context& ctx;
private:
+ sdbusplus::async::task<void> handleInterfaceAdded(
+ const std::string& service, const std::string& path,
+ const std::string& interface);
+
// this is appended to the common prefix to construct the dbus name
std::string serviceNameSuffix;
diff --git a/common/src/software_manager.cpp b/common/src/software_manager.cpp
index c3cf718..0d0bc17 100644
--- a/common/src/software_manager.cpp
+++ b/common/src/software_manager.cpp
@@ -129,22 +129,31 @@
continue;
}
- debug(
- "[config] found configuration interface at {SERVICE}, {OBJPATH}",
- "SERVICE", service, "OBJPATH", path);
-
- auto optConfig =
- co_await getConfig(ctx, service, path, interfaceFound);
- if (!optConfig.has_value())
- {
- error("Error fetching common configuration from {PATH}", "PATH",
- path);
- continue;
- }
-
- co_await initDevice(service, path, optConfig.value());
+ co_await handleInterfaceAdded(service, path, interfaceFound);
}
}
debug("Done with initial configuration");
}
+
+// NOLINTBEGIN(readability-static-accessed-through-instance)
+sdbusplus::async::task<void> SoftwareManager::handleInterfaceAdded(
+ const std::string& service, const std::string& path,
+ const std::string& interface)
+// NOLINTEND(readability-static-accessed-through-instance)
+{
+ debug("Found configuration interface at {SERVICE}, {PATH}", "SERVICE",
+ service, "PATH", path);
+
+ auto optConfig = co_await getConfig(ctx, service, path, interface);
+
+ if (!optConfig.has_value())
+ {
+ error("Failed to get configuration from {PATH}", "PATH", path);
+ co_return;
+ }
+
+ co_await initDevice(service, path, optConfig.value());
+
+ co_return;
+}