Krzysztof Grobelny | 64b75a5 | 2020-09-18 10:17:16 +0200 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 3 | #include "interfaces/json_storage.hpp" |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 4 | #include "interfaces/report.hpp" |
| 5 | #include "interfaces/report_factory.hpp" |
| 6 | #include "interfaces/report_manager.hpp" |
Wludzik, Jozef | cb88cfd | 2020-09-28 16:38:57 +0200 | [diff] [blame] | 7 | |
Krzysztof Grobelny | 64b75a5 | 2020-09-18 10:17:16 +0200 | [diff] [blame] | 8 | #include <sdbusplus/asio/object_server.hpp> |
| 9 | |
| 10 | #include <chrono> |
| 11 | #include <memory> |
| 12 | #include <vector> |
| 13 | |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 14 | class ReportManager : public interfaces::ReportManager |
Krzysztof Grobelny | 64b75a5 | 2020-09-18 10:17:16 +0200 | [diff] [blame] | 15 | { |
| 16 | public: |
| 17 | ReportManager( |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 18 | std::unique_ptr<interfaces::ReportFactory> reportFactory, |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 19 | std::unique_ptr<interfaces::JsonStorage> reportStorage, |
Krzysztof Grobelny | 64b75a5 | 2020-09-18 10:17:16 +0200 | [diff] [blame] | 20 | const std::shared_ptr<sdbusplus::asio::object_server>& objServer); |
Wludzik, Jozef | cb88cfd | 2020-09-28 16:38:57 +0200 | [diff] [blame] | 21 | ~ReportManager() = default; |
Krzysztof Grobelny | 64b75a5 | 2020-09-18 10:17:16 +0200 | [diff] [blame] | 22 | |
Wludzik, Jozef | cb88cfd | 2020-09-28 16:38:57 +0200 | [diff] [blame] | 23 | ReportManager(ReportManager&) = delete; |
| 24 | ReportManager(ReportManager&&) = delete; |
| 25 | ReportManager& operator=(ReportManager&) = delete; |
| 26 | ReportManager& operator=(ReportManager&&) = delete; |
| 27 | |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 28 | void removeReport(const interfaces::Report* report) override; |
Wludzik, Jozef | cb88cfd | 2020-09-28 16:38:57 +0200 | [diff] [blame] | 29 | static bool verifyScanPeriod(const uint64_t scanPeriod); |
Krzysztof Grobelny | 64b75a5 | 2020-09-18 10:17:16 +0200 | [diff] [blame] | 30 | |
| 31 | private: |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 32 | std::unique_ptr<interfaces::ReportFactory> reportFactory; |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 33 | std::unique_ptr<interfaces::JsonStorage> reportStorage; |
Krzysztof Grobelny | 64b75a5 | 2020-09-18 10:17:16 +0200 | [diff] [blame] | 34 | std::shared_ptr<sdbusplus::asio::object_server> objServer; |
Wludzik, Jozef | cb88cfd | 2020-09-28 16:38:57 +0200 | [diff] [blame] | 35 | std::unique_ptr<sdbusplus::asio::dbus_interface> reportManagerIface; |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 36 | std::vector<std::unique_ptr<interfaces::Report>> reports; |
Krzysztof Grobelny | 64b75a5 | 2020-09-18 10:17:16 +0200 | [diff] [blame] | 37 | |
Krzysztof Grobelny | d223819 | 2020-12-02 09:27:28 +0000 | [diff] [blame] | 38 | void verifyAddReport(const std::string& reportName, |
| 39 | std::chrono::milliseconds interval); |
| 40 | interfaces::Report& addReport(boost::asio::yield_context& yield, |
| 41 | const std::string& reportName, |
| 42 | const std::string& reportingType, |
| 43 | const bool emitsReadingsUpdate, |
| 44 | const bool logToMetricReportsCollection, |
| 45 | std::chrono::milliseconds interval, |
| 46 | ReadingParameters metricParams); |
| 47 | interfaces::Report& addReport( |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 48 | const std::string& reportName, const std::string& reportingType, |
| 49 | const bool emitsReadingsUpdate, const bool logToMetricReportsCollection, |
| 50 | std::chrono::milliseconds interval, |
Krzysztof Grobelny | d223819 | 2020-12-02 09:27:28 +0000 | [diff] [blame] | 51 | std::vector<LabeledMetricParameters> metricParams); |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 52 | void loadFromPersistent(); |
| 53 | |
Wludzik, Jozef | cb88cfd | 2020-09-28 16:38:57 +0200 | [diff] [blame] | 54 | public: |
Krzysztof Grobelny | 64b75a5 | 2020-09-18 10:17:16 +0200 | [diff] [blame] | 55 | static constexpr uint32_t maxReports{20}; |
| 56 | static constexpr std::chrono::milliseconds minInterval{1000}; |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 57 | static constexpr const char* reportManagerIfaceName = |
| 58 | "xyz.openbmc_project.Telemetry.ReportManager"; |
| 59 | static constexpr const char* reportManagerPath = |
| 60 | "/xyz/openbmc_project/Telemetry/Reports"; |
Krzysztof Grobelny | 64b75a5 | 2020-09-18 10:17:16 +0200 | [diff] [blame] | 61 | }; |