blob: 3da35dad8471d36e870b869f05dc409c31bb3ee2 [file] [log] [blame]
Tomáš Peckaccd80c32020-06-22 14:44:32 +02001/*
2 * Copyright (C) 2020 CESNET, https://photonics.cesnet.cz/
3 *
4 * Written by Tomáš Pecka <tomas.pecka@fit.cvut.cz>
5 *
6*/
7#pragma once
8
9#include <memory>
10#include <sdbus-c++/sdbus-c++.h>
11#include <set>
12#include "inputs/AbstractInput.h"
13#include "manager/StateManager.h"
14
15namespace velia {
16
17/**
18 * Register
19 */
20class DbusSystemdInput : public AbstractInput {
21public:
22 DbusSystemdInput(std::shared_ptr<AbstractManager> manager, sdbus::IConnection& connection);
23 DbusSystemdInput(std::shared_ptr<AbstractManager> manager, sdbus::IConnection& connection, const std::string& busname, const std::string& managerObjectPath, const std::string& managerIface, const std::string& unitIface);
24 ~DbusSystemdInput() override;
25
26private:
27 velia::Log m_log;
28
29 std::string m_busName;
30 std::string m_unitIface;
31 std::unique_ptr<sdbus::IProxy> m_proxyManager;
32
33 /** List of registered unit watchers */
34 std::map<sdbus::ObjectPath, std::unique_ptr<sdbus::IProxy>> m_proxyUnits;
35
36 /** List of units in failed state. */
37 std::set<std::string> m_failedUnits;
38
39 void registerSystemdUnit(sdbus::IConnection& connection, const std::string& unitName, const sdbus::ObjectPath& unitObjectPath);
40 void onUnitStateChange(const std::string& name, const std::string& activeState, const std::string& nSubState);
41};
42
43}