hardware: fill alarm-inventory with velia sensor alarms

We add possible alarms our hardware processing can trigger:

 - Sensor reading is above (or below) specified thresholds, and
 - sensor is missing.

We fill the alarm-inventory with all possible alarms-components
pairs.

At first glance there is an unrelated change to when the background
polling thread is spawned.
But we need first to fill the alarm-inventory and only after that the
first alarms can be pushed into sysrepo. From my understanding of
ietf-alarms [1] alarms must be listed before they are added.
That is why the spawn of the background polling thread is delayed.

[1] https://www.rfc-editor.org/rfc/rfc8632

Change-Id: I8a83425e5a559029b29d7e2c39fbf934dedd94f0
diff --git a/src/ietf-hardware/sysrepo/Sysrepo.cpp b/src/ietf-hardware/sysrepo/Sysrepo.cpp
index c243d97..26caa95 100644
--- a/src/ietf-hardware/sysrepo/Sysrepo.cpp
+++ b/src/ietf-hardware/sysrepo/Sysrepo.cpp
@@ -8,11 +8,16 @@
 #include <regex>
 #include <sysrepo-cpp/Connection.hpp>
 #include "Sysrepo.h"
+#include "utils/alarms.h"
 #include "utils/log.h"
 #include "utils/sysrepo.h"
 
 namespace {
 
+const auto ALARM_SENSOR_MISSING = "velia-alarms:sensor-missing-alarm";
+const auto ALARM_THRESHOLD_CROSSING_LOW = "velia-alarms:sensor-low-value-alarm";
+const auto ALARM_THRESHOLD_CROSSING_HIGH = "velia-alarms:sensor-high-value-alarm";
+
 /** @brief Extracts component path prefix from an XPath under /ietf-hardware/component node
  *
  * Example input:  /ietf-hardware:hardware/component[name='ne:psu:child']/oper-state/disabled
@@ -40,7 +45,15 @@
     , m_session(std::move(session))
     , m_hwState(std::move(hwState))
     , m_quit(false)
-    , m_pollThread([&]() {
+{
+    for (const auto& sensorXPath : m_hwState->sensorsXPaths()) {
+        auto componentXPath = extractComponentPrefix(sensorXPath);
+        utils::addResourceToAlarmInventoryEntry(m_session, ALARM_THRESHOLD_CROSSING_LOW, std::nullopt, componentXPath);
+        utils::addResourceToAlarmInventoryEntry(m_session, ALARM_THRESHOLD_CROSSING_HIGH, std::nullopt, componentXPath);
+        utils::addResourceToAlarmInventoryEntry(m_session, ALARM_SENSOR_MISSING, std::nullopt, componentXPath);
+    }
+
+    m_pollThread = std::thread([&]() {
         auto conn = m_session.getConnection();
 
         DataTree prevValues;
@@ -69,8 +82,7 @@
             prevValues = std::move(hwStateValues);
             std::this_thread::sleep_for(m_pollInterval);
         }
-    })
-{
+    });
 }
 
 Sysrepo::~Sysrepo()