blob: 6e62223b39727dda3ff571b2e7e8fa39a514c2b2 [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
Tomáš Pecka8ce88352020-11-04 19:14:13 +010039 /** Current unit state. */
40 std::map<std::string, std::pair<std::string, std::string>> m_unitState;
41
Tomáš Peckaccd80c32020-06-22 14:44:32 +020042 void registerSystemdUnit(sdbus::IConnection& connection, const std::string& unitName, const sdbus::ObjectPath& unitObjectPath);
43 void onUnitStateChange(const std::string& name, const std::string& activeState, const std::string& nSubState);
44};
45
Tomáš Pecka8ce88352020-11-04 19:14:13 +010046}