Ignore changes in selected systemd units
This commit implements a possibility of ignoring changes in specified
systemd unit as proposed by [1]. This can be useful in cases where
some of the units are behaving badly (but not affecting the health
of a whole system).
Add a CLI option `--systemd-ignore-unit` to let user specify which units
should be ignored.
[1]: https://github.com/CESNET/velia/issues/1
Change-Id: I5902151b4ac95bdcd9aacf29c0189fb62537497f
diff --git a/tests/dbus-helpers/dbus_systemd_server.cpp b/tests/dbus-helpers/dbus_systemd_server.cpp
index f921af3..2d461d3 100644
--- a/tests/dbus-helpers/dbus_systemd_server.cpp
+++ b/tests/dbus-helpers/dbus_systemd_server.cpp
@@ -22,9 +22,9 @@
}
/** @brief Creates a unit inside the test server. Registers dbus object and emits UnitNew signal. **/
-void DbusSystemdServer::createUnit(sdbus::IConnection& connection, const sdbus::ObjectPath& objPath, const std::string& activeState, const std::string& subState)
+void DbusSystemdServer::createUnit(sdbus::IConnection& connection, const std::string& unitName, const sdbus::ObjectPath& objPath, const std::string& activeState, const std::string& subState)
{
- m_units.insert(std::make_pair(objPath, Unit(sdbus::createObject(connection, objPath), activeState, subState)));
+ m_units.insert(std::make_pair(objPath, Unit(unitName, sdbus::createObject(connection, objPath), activeState, subState)));
Unit& unit = m_units.at(objPath);
@@ -50,8 +50,8 @@
{
std::vector<UnitStruct> res;
- for (const auto& [name, unit] : m_units) {
- res.push_back(UnitStruct(name, ""s, ""s, ""s, ""s, ""s, unit.m_object->getObjectPath(), 0, ""s, "/dummy"s));
+ for (const auto& [objPath, unit] : m_units) {
+ res.push_back(UnitStruct(unit.m_unitName, ""s, ""s, ""s, ""s, ""s, unit.m_object->getObjectPath(), 0, ""s, "/dummy"s));
}
return res;
@@ -67,9 +67,10 @@
}
}
-DbusSystemdServer::Unit::Unit(std::unique_ptr<sdbus::IObject> object, std::string activeState, std::string subState)
- : m_object(std::move(object))
+DbusSystemdServer::Unit::Unit(std::string unitName, std::unique_ptr<sdbus::IObject> object, std::string activeState, std::string subState)
+ : m_unitName(std::move(unitName))
+ , m_object(std::move(object))
, m_activeState(std::move(activeState))
, m_subState(std::move(subState))
{
-}
\ No newline at end of file
+}