Move current implementation into separate namespace
We will be moving ietf-hardware implementation from cla-sysrepo to
velia. Veliad daemon will manage not only the "system health" (the
current implementation) but it will also (in later commits) implement
ietf-hardware (RFC8348) [1] (report HW sensors readout to Sysrepo).
This commit prepares the directory structure (i.e., it moves the current
code into a namespace velia::health.
We will be adding new namespace velia::ietf_hardware throughout the next
few commits which will implement the support for ietf-hardware YANG
model.
[1] https://tools.ietf.org/html/rfc8348#appendix-A
Change-Id: I315c2575c5d50036d27cb0a11f5571ce9d615fe5
diff --git a/src/health/inputs/DbusSystemdInput.h b/src/health/inputs/DbusSystemdInput.h
new file mode 100644
index 0000000..c55d0f6
--- /dev/null
+++ b/src/health/inputs/DbusSystemdInput.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2020 CESNET, https://photonics.cesnet.cz/
+ *
+ * Written by Tomáš Pecka <tomas.pecka@fit.cvut.cz>
+ *
+*/
+#pragma once
+
+#include <memory>
+#include <sdbus-c++/sdbus-c++.h>
+#include <set>
+#include "health/inputs/AbstractInput.h"
+#include "health/manager/StateManager.h"
+
+namespace velia::health {
+
+/**
+ * Register
+ */
+class DbusSystemdInput : public AbstractInput {
+public:
+ DbusSystemdInput(std::shared_ptr<AbstractManager> manager, const std::set<std::string>& ignoredUnits, sdbus::IConnection& connection);
+ DbusSystemdInput(std::shared_ptr<AbstractManager> manager, const std::set<std::string>& ignoredUnits, sdbus::IConnection& connection, const std::string& busname, const std::string& managerObjectPath, const std::string& managerIface, const std::string& unitIface);
+ ~DbusSystemdInput() override;
+
+private:
+ velia::Log m_log;
+
+ std::string m_busName;
+ std::string m_unitIface;
+ std::unique_ptr<sdbus::IProxy> m_proxyManager;
+
+ /** List of registered unit watchers */
+ std::map<sdbus::ObjectPath, std::unique_ptr<sdbus::IProxy>> m_proxyUnits;
+
+ /** List of units in failed state. */
+ std::set<std::string> m_failedUnits;
+
+ /** Current unit state. */
+ std::map<std::string, std::pair<std::string, std::string>> m_unitState;
+
+ void registerSystemdUnit(sdbus::IConnection& connection, const std::string& unitName, const sdbus::ObjectPath& unitObjectPath);
+ void onUnitStateChange(const std::string& name, const std::string& activeState, const std::string& nSubState);
+};
+
+}