blob: 488241910d703ffde0b4153efdda95bb7f3e74d6 [file] [log] [blame]
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +02001#pragma once
2
Wludzik, Jozefe2362792020-10-27 17:23:55 +01003#include "interfaces/json_storage.hpp"
Wludzik, Jozef2f9f9b82020-10-13 09:07:45 +02004#include "interfaces/report.hpp"
5#include "interfaces/report_factory.hpp"
6#include "interfaces/report_manager.hpp"
Szymon Dompkeb4ef22e2022-02-07 15:15:12 +01007#include "interfaces/trigger_manager.hpp"
Szymon Dompkee28aa532021-10-27 12:33:12 +02008#include "report.hpp"
Szymon Dompke1cdd7e42022-06-08 14:43:13 +02009#include "utils/dbus_path_utils.hpp"
Wludzik, Jozefcb88cfd2020-09-28 16:38:57 +020010
Karol Niczyj32859b62021-05-19 10:20:46 +020011#include <systemd/sd-bus-protocol.h>
12
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020013#include <sdbusplus/asio/object_server.hpp>
14
15#include <chrono>
16#include <memory>
Wludzik, Jozefbc766b42020-12-08 16:06:22 +010017#include <string>
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020018#include <vector>
19
Wludzik, Jozef2f9f9b82020-10-13 09:07:45 +020020class ReportManager : public interfaces::ReportManager
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020021{
22 public:
23 ReportManager(
Wludzik, Jozef2f9f9b82020-10-13 09:07:45 +020024 std::unique_ptr<interfaces::ReportFactory> reportFactory,
Wludzik, Jozefe2362792020-10-27 17:23:55 +010025 std::unique_ptr<interfaces::JsonStorage> reportStorage,
Krzysztof Grobelnye6d48872022-02-08 13:41:30 +010026 const std::shared_ptr<sdbusplus::asio::object_server>& objServer);
Wludzik, Jozefcb88cfd2020-09-28 16:38:57 +020027 ~ReportManager() = default;
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020028
Krzysztof Grobelny31db7f72021-12-21 12:26:22 +010029 ReportManager(const ReportManager&) = delete;
Wludzik, Jozefcb88cfd2020-09-28 16:38:57 +020030 ReportManager(ReportManager&&) = delete;
Krzysztof Grobelny31db7f72021-12-21 12:26:22 +010031 ReportManager& operator=(const ReportManager&) = delete;
Wludzik, Jozefcb88cfd2020-09-28 16:38:57 +020032 ReportManager& operator=(ReportManager&&) = delete;
33
Wludzik, Jozef2f9f9b82020-10-13 09:07:45 +020034 void removeReport(const interfaces::Report* report) override;
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020035
Szymon Dompke32305f12022-07-05 15:37:21 +020036 static void verifyMetricParameters(
37 const std::vector<LabeledMetricParameters>& readingParams);
38
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020039 private:
Wludzik, Jozef2f9f9b82020-10-13 09:07:45 +020040 std::unique_ptr<interfaces::ReportFactory> reportFactory;
Wludzik, Jozefe2362792020-10-27 17:23:55 +010041 std::unique_ptr<interfaces::JsonStorage> reportStorage;
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020042 std::shared_ptr<sdbusplus::asio::object_server> objServer;
Wludzik, Jozefcb88cfd2020-09-28 16:38:57 +020043 std::unique_ptr<sdbusplus::asio::dbus_interface> reportManagerIface;
Wludzik, Jozef2f9f9b82020-10-13 09:07:45 +020044 std::vector<std::unique_ptr<interfaces::Report>> reports;
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020045
Krzysztof Grobelnydcc4e192021-03-08 09:09:34 +000046 void verifyAddReport(
Krzysztof Grobelnyb8cc78d2021-11-29 15:54:53 +010047 const std::string& reportId, const std::string& reportName,
48 const ReportingType reportingType, Milliseconds interval,
Ankita Vilas Gawadecd5b0b72022-01-20 20:55:04 +000049 const ReportUpdates reportUpdates, const uint64_t appendLimit,
Krzysztof Grobelnydcc4e192021-03-08 09:09:34 +000050 const std::vector<LabeledMetricParameters>& readingParams);
Lukasz Kazmierczak7e098e92021-09-16 15:59:56 +020051 interfaces::Report& addReport(
Krzysztof Grobelnyb8cc78d2021-11-29 15:54:53 +010052 boost::asio::yield_context& yield, const std::string& reportId,
53 const std::string& reportName, const ReportingType reportingType,
Krzysztof Grobelny51497a02021-11-09 14:56:22 +010054 const std::vector<ReportAction>& reportActions, Milliseconds interval,
55 const uint64_t appendLimit, const ReportUpdates reportUpdates,
Lukasz Kazmierczak7e098e92021-09-16 15:59:56 +020056 ReadingParameters metricParams, const bool enabled);
Krzysztof Grobelny493e62e2022-02-14 10:55:50 +010057 interfaces::Report&
58 addReport(const std::string& reportId, const std::string& reportName,
59 const ReportingType reportingType,
60 const std::vector<ReportAction>& reportActions,
61 Milliseconds interval, const uint64_t appendLimit,
62 const ReportUpdates reportUpdates,
63 std::vector<LabeledMetricParameters> metricParams,
64 const bool enabled, Readings);
Wludzik, Jozefe2362792020-10-27 17:23:55 +010065 void loadFromPersistent();
66
Wludzik, Jozefcb88cfd2020-09-28 16:38:57 +020067 public:
Wludzik, Jozef503c1582020-12-11 14:48:01 +010068 static constexpr size_t maxReports{TELEMETRY_MAX_REPORTS};
Ankita Vilas Gawadecd5b0b72022-01-20 20:55:04 +000069 static constexpr size_t maxNumberMetrics{TELEMETRY_MAX_READING_PARAMS};
Krzysztof Grobelnydcc4e192021-03-08 09:09:34 +000070 static constexpr Milliseconds minInterval{TELEMETRY_MIN_INTERVAL};
Ankita Vilas Gawadecd5b0b72022-01-20 20:55:04 +000071 static constexpr size_t maxAppendLimit{TELEMETRY_MAX_APPEND_LIMIT};
Wludzik, Jozef2f9f9b82020-10-13 09:07:45 +020072 static constexpr const char* reportManagerIfaceName =
73 "xyz.openbmc_project.Telemetry.ReportManager";
74 static constexpr const char* reportManagerPath =
75 "/xyz/openbmc_project/Telemetry/Reports";
Szymon Dompke32305f12022-07-05 15:37:21 +020076 static constexpr std::string_view reportNameDefault = "Report";
77
78 static_assert(!reportNameDefault.empty(),
79 "Default report name cannot be empty.");
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020080};