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" |
Szymon Dompke | b4ef22e | 2022-02-07 15:15:12 +0100 | [diff] [blame^] | 7 | #include "interfaces/trigger_manager.hpp" |
Szymon Dompke | e28aa53 | 2021-10-27 12:33:12 +0200 | [diff] [blame] | 8 | #include "report.hpp" |
Wludzik, Jozef | cb88cfd | 2020-09-28 16:38:57 +0200 | [diff] [blame] | 9 | |
Karol Niczyj | 32859b6 | 2021-05-19 10:20:46 +0200 | [diff] [blame] | 10 | #include <systemd/sd-bus-protocol.h> |
| 11 | |
Krzysztof Grobelny | 64b75a5 | 2020-09-18 10:17:16 +0200 | [diff] [blame] | 12 | #include <sdbusplus/asio/object_server.hpp> |
| 13 | |
| 14 | #include <chrono> |
| 15 | #include <memory> |
Wludzik, Jozef | bc766b4 | 2020-12-08 16:06:22 +0100 | [diff] [blame] | 16 | #include <string> |
Krzysztof Grobelny | 64b75a5 | 2020-09-18 10:17:16 +0200 | [diff] [blame] | 17 | #include <vector> |
| 18 | |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 19 | class ReportManager : public interfaces::ReportManager |
Krzysztof Grobelny | 64b75a5 | 2020-09-18 10:17:16 +0200 | [diff] [blame] | 20 | { |
| 21 | public: |
| 22 | ReportManager( |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 23 | std::unique_ptr<interfaces::ReportFactory> reportFactory, |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 24 | std::unique_ptr<interfaces::JsonStorage> reportStorage, |
Szymon Dompke | b4ef22e | 2022-02-07 15:15:12 +0100 | [diff] [blame^] | 25 | const std::shared_ptr<sdbusplus::asio::object_server>& objServer, |
| 26 | std::unique_ptr<interfaces::TriggerManager>& triggerManager); |
Wludzik, Jozef | cb88cfd | 2020-09-28 16:38:57 +0200 | [diff] [blame] | 27 | ~ReportManager() = default; |
Krzysztof Grobelny | 64b75a5 | 2020-09-18 10:17:16 +0200 | [diff] [blame] | 28 | |
Krzysztof Grobelny | 31db7f7 | 2021-12-21 12:26:22 +0100 | [diff] [blame] | 29 | ReportManager(const ReportManager&) = delete; |
Wludzik, Jozef | cb88cfd | 2020-09-28 16:38:57 +0200 | [diff] [blame] | 30 | ReportManager(ReportManager&&) = delete; |
Krzysztof Grobelny | 31db7f7 | 2021-12-21 12:26:22 +0100 | [diff] [blame] | 31 | ReportManager& operator=(const ReportManager&) = delete; |
Wludzik, Jozef | cb88cfd | 2020-09-28 16:38:57 +0200 | [diff] [blame] | 32 | ReportManager& operator=(ReportManager&&) = delete; |
| 33 | |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 34 | void removeReport(const interfaces::Report* report) override; |
Krzysztof Grobelny | b8cc78d | 2021-11-29 15:54:53 +0100 | [diff] [blame] | 35 | void updateReport(const std::string& id) override; |
Szymon Dompke | b4ef22e | 2022-02-07 15:15:12 +0100 | [diff] [blame^] | 36 | void updateTriggerIds(const std::string& reportId, |
| 37 | const std::string& triggerId, |
| 38 | TriggerIdUpdate updateType) override; |
Krzysztof Grobelny | 64b75a5 | 2020-09-18 10:17:16 +0200 | [diff] [blame] | 39 | |
| 40 | private: |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 41 | std::unique_ptr<interfaces::ReportFactory> reportFactory; |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 42 | std::unique_ptr<interfaces::JsonStorage> reportStorage; |
Krzysztof Grobelny | 64b75a5 | 2020-09-18 10:17:16 +0200 | [diff] [blame] | 43 | std::shared_ptr<sdbusplus::asio::object_server> objServer; |
Wludzik, Jozef | cb88cfd | 2020-09-28 16:38:57 +0200 | [diff] [blame] | 44 | std::unique_ptr<sdbusplus::asio::dbus_interface> reportManagerIface; |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 45 | std::vector<std::unique_ptr<interfaces::Report>> reports; |
Szymon Dompke | b4ef22e | 2022-02-07 15:15:12 +0100 | [diff] [blame^] | 46 | std::unique_ptr<interfaces::TriggerManager>& triggerManager; |
Krzysztof Grobelny | 64b75a5 | 2020-09-18 10:17:16 +0200 | [diff] [blame] | 47 | |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 48 | void verifyAddReport( |
Krzysztof Grobelny | b8cc78d | 2021-11-29 15:54:53 +0100 | [diff] [blame] | 49 | const std::string& reportId, const std::string& reportName, |
| 50 | const ReportingType reportingType, Milliseconds interval, |
Ankita Vilas Gawade | cd5b0b7 | 2022-01-20 20:55:04 +0000 | [diff] [blame] | 51 | const ReportUpdates reportUpdates, const uint64_t appendLimit, |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 52 | const std::vector<LabeledMetricParameters>& readingParams); |
Lukasz Kazmierczak | 7e098e9 | 2021-09-16 15:59:56 +0200 | [diff] [blame] | 53 | interfaces::Report& addReport( |
Krzysztof Grobelny | b8cc78d | 2021-11-29 15:54:53 +0100 | [diff] [blame] | 54 | boost::asio::yield_context& yield, const std::string& reportId, |
| 55 | const std::string& reportName, const ReportingType reportingType, |
Krzysztof Grobelny | 51497a0 | 2021-11-09 14:56:22 +0100 | [diff] [blame] | 56 | const std::vector<ReportAction>& reportActions, Milliseconds interval, |
| 57 | const uint64_t appendLimit, const ReportUpdates reportUpdates, |
Lukasz Kazmierczak | 7e098e9 | 2021-09-16 15:59:56 +0200 | [diff] [blame] | 58 | ReadingParameters metricParams, const bool enabled); |
Krzysztof Grobelny | d223819 | 2020-12-02 09:27:28 +0000 | [diff] [blame] | 59 | interfaces::Report& addReport( |
Krzysztof Grobelny | b8cc78d | 2021-11-29 15:54:53 +0100 | [diff] [blame] | 60 | const std::string& reportId, const std::string& reportName, |
| 61 | const ReportingType reportingType, |
Krzysztof Grobelny | 51497a0 | 2021-11-09 14:56:22 +0100 | [diff] [blame] | 62 | const std::vector<ReportAction>& reportActions, Milliseconds interval, |
| 63 | const uint64_t appendLimit, const ReportUpdates reportUpdates, |
Lukasz Kazmierczak | 7e098e9 | 2021-09-16 15:59:56 +0200 | [diff] [blame] | 64 | std::vector<LabeledMetricParameters> metricParams, const bool enabled); |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 65 | void loadFromPersistent(); |
| 66 | |
Wludzik, Jozef | cb88cfd | 2020-09-28 16:38:57 +0200 | [diff] [blame] | 67 | public: |
Wludzik, Jozef | 503c158 | 2020-12-11 14:48:01 +0100 | [diff] [blame] | 68 | static constexpr size_t maxReports{TELEMETRY_MAX_REPORTS}; |
Ankita Vilas Gawade | cd5b0b7 | 2022-01-20 20:55:04 +0000 | [diff] [blame] | 69 | static constexpr size_t maxNumberMetrics{TELEMETRY_MAX_READING_PARAMS}; |
Krzysztof Grobelny | b8cc78d | 2021-11-29 15:54:53 +0100 | [diff] [blame] | 70 | static constexpr size_t maxReportIdLength{ |
Szymon Dompke | e28aa53 | 2021-10-27 12:33:12 +0200 | [diff] [blame] | 71 | TELEMETRY_MAX_DBUS_PATH_LENGTH - |
| 72 | std::string_view(Report::reportDir).length()}; |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 73 | static constexpr Milliseconds minInterval{TELEMETRY_MIN_INTERVAL}; |
Ankita Vilas Gawade | cd5b0b7 | 2022-01-20 20:55:04 +0000 | [diff] [blame] | 74 | static constexpr size_t maxAppendLimit{TELEMETRY_MAX_APPEND_LIMIT}; |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 75 | static constexpr const char* reportManagerIfaceName = |
| 76 | "xyz.openbmc_project.Telemetry.ReportManager"; |
| 77 | static constexpr const char* reportManagerPath = |
| 78 | "/xyz/openbmc_project/Telemetry/Reports"; |
Krzysztof Grobelny | a950e42 | 2021-12-31 13:49:00 +0100 | [diff] [blame] | 79 | static constexpr const char* reportNameDefault = "Report"; |
Krzysztof Grobelny | 64b75a5 | 2020-09-18 10:17:16 +0200 | [diff] [blame] | 80 | }; |