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> |
Wludzik, Jozef | bc766b4 | 2020-12-08 16:06:22 +0100 | [diff] [blame] | 12 | #include <string> |
Krzysztof Grobelny | 64b75a5 | 2020-09-18 10:17:16 +0200 | [diff] [blame] | 13 | #include <vector> |
| 14 | |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 15 | class ReportManager : public interfaces::ReportManager |
Krzysztof Grobelny | 64b75a5 | 2020-09-18 10:17:16 +0200 | [diff] [blame] | 16 | { |
| 17 | public: |
| 18 | ReportManager( |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 19 | std::unique_ptr<interfaces::ReportFactory> reportFactory, |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 20 | std::unique_ptr<interfaces::JsonStorage> reportStorage, |
Krzysztof Grobelny | 64b75a5 | 2020-09-18 10:17:16 +0200 | [diff] [blame] | 21 | const std::shared_ptr<sdbusplus::asio::object_server>& objServer); |
Wludzik, Jozef | cb88cfd | 2020-09-28 16:38:57 +0200 | [diff] [blame] | 22 | ~ReportManager() = default; |
Krzysztof Grobelny | 64b75a5 | 2020-09-18 10:17:16 +0200 | [diff] [blame] | 23 | |
Wludzik, Jozef | cb88cfd | 2020-09-28 16:38:57 +0200 | [diff] [blame] | 24 | ReportManager(ReportManager&) = delete; |
| 25 | ReportManager(ReportManager&&) = delete; |
| 26 | ReportManager& operator=(ReportManager&) = delete; |
| 27 | ReportManager& operator=(ReportManager&&) = delete; |
| 28 | |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 29 | void removeReport(const interfaces::Report* report) override; |
Wludzik, Jozef | cb88cfd | 2020-09-28 16:38:57 +0200 | [diff] [blame] | 30 | static bool verifyScanPeriod(const uint64_t scanPeriod); |
Krzysztof Grobelny | 64b75a5 | 2020-09-18 10:17:16 +0200 | [diff] [blame] | 31 | |
| 32 | private: |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 33 | std::unique_ptr<interfaces::ReportFactory> reportFactory; |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 34 | std::unique_ptr<interfaces::JsonStorage> reportStorage; |
Krzysztof Grobelny | 64b75a5 | 2020-09-18 10:17:16 +0200 | [diff] [blame] | 35 | std::shared_ptr<sdbusplus::asio::object_server> objServer; |
Wludzik, Jozef | cb88cfd | 2020-09-28 16:38:57 +0200 | [diff] [blame] | 36 | std::unique_ptr<sdbusplus::asio::dbus_interface> reportManagerIface; |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 37 | std::vector<std::unique_ptr<interfaces::Report>> reports; |
Krzysztof Grobelny | 64b75a5 | 2020-09-18 10:17:16 +0200 | [diff] [blame] | 38 | |
Krzysztof Grobelny | d223819 | 2020-12-02 09:27:28 +0000 | [diff] [blame] | 39 | void verifyAddReport(const std::string& reportName, |
Wludzik, Jozef | bc766b4 | 2020-12-08 16:06:22 +0100 | [diff] [blame] | 40 | const std::string& reportingType, |
| 41 | std::chrono::milliseconds interval, |
| 42 | const ReadingParameters& readingParams); |
Krzysztof Grobelny | d223819 | 2020-12-02 09:27:28 +0000 | [diff] [blame] | 43 | interfaces::Report& addReport(boost::asio::yield_context& yield, |
| 44 | const std::string& reportName, |
| 45 | const std::string& reportingType, |
| 46 | const bool emitsReadingsUpdate, |
| 47 | const bool logToMetricReportsCollection, |
| 48 | std::chrono::milliseconds interval, |
| 49 | ReadingParameters metricParams); |
| 50 | interfaces::Report& addReport( |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 51 | const std::string& reportName, const std::string& reportingType, |
| 52 | const bool emitsReadingsUpdate, const bool logToMetricReportsCollection, |
| 53 | std::chrono::milliseconds interval, |
Krzysztof Grobelny | d223819 | 2020-12-02 09:27:28 +0000 | [diff] [blame] | 54 | std::vector<LabeledMetricParameters> metricParams); |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 55 | void loadFromPersistent(); |
| 56 | |
Wludzik, Jozef | cb88cfd | 2020-09-28 16:38:57 +0200 | [diff] [blame] | 57 | public: |
Wludzik, Jozef | 503c158 | 2020-12-11 14:48:01 +0100 | [diff] [blame^] | 58 | static constexpr size_t maxReports{TELEMETRY_MAX_REPORTS}; |
| 59 | static constexpr size_t maxReadingParams{TELEMETRY_MAX_READING_PARAMS}; |
| 60 | static constexpr std::chrono::milliseconds minInterval{ |
| 61 | TELEMETRY_MIN_INTERVAL}; |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 62 | static constexpr const char* reportManagerIfaceName = |
| 63 | "xyz.openbmc_project.Telemetry.ReportManager"; |
| 64 | static constexpr const char* reportManagerPath = |
| 65 | "/xyz/openbmc_project/Telemetry/Reports"; |
Wludzik, Jozef | bc766b4 | 2020-12-08 16:06:22 +0100 | [diff] [blame] | 66 | static constexpr std::array<std::string_view, 2> supportedReportingType = { |
| 67 | "Periodic", "OnRequest"}; |
Krzysztof Grobelny | 64b75a5 | 2020-09-18 10:17:16 +0200 | [diff] [blame] | 68 | }; |