utils: put alarms into separate namespace
The interface for managing alarms and also the identifiers are somewhat
complicated. I want to make it simpler and more readable. Let's start
with moving the alarms into their own velia::alarms namespace to clean
things up. The function names can be made shorter then.
Change-Id: Iee8902a68d3f837cf11a21776f54c7f7637aa3b0
diff --git a/src/health/SystemdUnits.cpp b/src/health/SystemdUnits.cpp
index 49634b9..de9b5a8 100644
--- a/src/health/SystemdUnits.cpp
+++ b/src/health/SystemdUnits.cpp
@@ -42,7 +42,7 @@
// First, fetch all currently loaded units, register to their PropertiesChanged signal and create the alarm-inventory entries in a *single* edit
m_proxyManager->callMethod("ListUnits").onInterface(managerIface).storeResultsTo(units);
std::transform(units.begin(), units.end(), std::back_inserter(unitNames), [](const auto& unit) { return unit.template get<0>(); });
- utils::createOrUpdateAlarmInventoryEntry(m_srSession, ALARM_ID, std::nullopt, {ALARM_SEVERITY}, true, ALARM_INVENTORY_DESCRIPTION, unitNames);
+ alarms::pushInventory(m_srSession, ALARM_ID, std::nullopt, {ALARM_SEVERITY}, true, ALARM_INVENTORY_DESCRIPTION, unitNames);
for (const auto& unit : units) {
registerSystemdUnit(connection, unit.get<0>(), unit.get<6>(), UnitState{unit.get<3>(), unit.get<4>()}, RegisterAlarmInventory::No);
@@ -83,7 +83,7 @@
}
if (registerAlarmInventory == RegisterAlarmInventory::Yes) {
- utils::addResourceToAlarmInventoryEntry(m_srSession, ALARM_ID, std::nullopt, unitName);
+ alarms::addResourceToInventory(m_srSession, ALARM_ID, std::nullopt, unitName);
}
proxyUnit = m_proxyUnits.emplace(unitObjectPath, sdbus::createProxy(connection, m_busName, unitObjectPath)).first->second.get();
@@ -143,7 +143,7 @@
m_log->debug("Systemd unit '{}' changed state ({} {})", name, activeState, subState);
lastState->second = state;
- utils::createOrUpdateAlarm(m_srSession, ALARM_ID, std::nullopt, name, alarmSeverity, "systemd unit state: (" + activeState + ", " + subState + ")");
+ alarms::push(m_srSession, ALARM_ID, std::nullopt, name, alarmSeverity, "systemd unit state: (" + activeState + ", " + subState + ")");
}
SystemdUnits::~SystemdUnits() = default;