blob: dcd2bfcb9eafe3eb7b024a1ebd59f69d23340375 [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
36 private:
Wludzik, Jozef2f9f9b82020-10-13 09:07:45 +020037 std::unique_ptr<interfaces::ReportFactory> reportFactory;
Wludzik, Jozefe2362792020-10-27 17:23:55 +010038 std::unique_ptr<interfaces::JsonStorage> reportStorage;
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020039 std::shared_ptr<sdbusplus::asio::object_server> objServer;
Wludzik, Jozefcb88cfd2020-09-28 16:38:57 +020040 std::unique_ptr<sdbusplus::asio::dbus_interface> reportManagerIface;
Wludzik, Jozef2f9f9b82020-10-13 09:07:45 +020041 std::vector<std::unique_ptr<interfaces::Report>> reports;
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020042
Krzysztof Grobelnydcc4e192021-03-08 09:09:34 +000043 void verifyAddReport(
Krzysztof Grobelnyb8cc78d2021-11-29 15:54:53 +010044 const std::string& reportId, const std::string& reportName,
45 const ReportingType reportingType, Milliseconds interval,
Ankita Vilas Gawadecd5b0b72022-01-20 20:55:04 +000046 const ReportUpdates reportUpdates, const uint64_t appendLimit,
Krzysztof Grobelnydcc4e192021-03-08 09:09:34 +000047 const std::vector<LabeledMetricParameters>& readingParams);
Lukasz Kazmierczak7e098e92021-09-16 15:59:56 +020048 interfaces::Report& addReport(
Krzysztof Grobelnyb8cc78d2021-11-29 15:54:53 +010049 boost::asio::yield_context& yield, const std::string& reportId,
50 const std::string& reportName, const ReportingType reportingType,
Krzysztof Grobelny51497a02021-11-09 14:56:22 +010051 const std::vector<ReportAction>& reportActions, Milliseconds interval,
52 const uint64_t appendLimit, const ReportUpdates reportUpdates,
Lukasz Kazmierczak7e098e92021-09-16 15:59:56 +020053 ReadingParameters metricParams, const bool enabled);
Krzysztof Grobelny493e62e2022-02-14 10:55:50 +010054 interfaces::Report&
55 addReport(const std::string& reportId, const std::string& reportName,
56 const ReportingType reportingType,
57 const std::vector<ReportAction>& reportActions,
58 Milliseconds interval, const uint64_t appendLimit,
59 const ReportUpdates reportUpdates,
60 std::vector<LabeledMetricParameters> metricParams,
61 const bool enabled, Readings);
Wludzik, Jozefe2362792020-10-27 17:23:55 +010062 void loadFromPersistent();
63
Wludzik, Jozefcb88cfd2020-09-28 16:38:57 +020064 public:
Wludzik, Jozef503c1582020-12-11 14:48:01 +010065 static constexpr size_t maxReports{TELEMETRY_MAX_REPORTS};
Ankita Vilas Gawadecd5b0b72022-01-20 20:55:04 +000066 static constexpr size_t maxNumberMetrics{TELEMETRY_MAX_READING_PARAMS};
Krzysztof Grobelnydcc4e192021-03-08 09:09:34 +000067 static constexpr Milliseconds minInterval{TELEMETRY_MIN_INTERVAL};
Ankita Vilas Gawadecd5b0b72022-01-20 20:55:04 +000068 static constexpr size_t maxAppendLimit{TELEMETRY_MAX_APPEND_LIMIT};
Wludzik, Jozef2f9f9b82020-10-13 09:07:45 +020069 static constexpr const char* reportManagerIfaceName =
70 "xyz.openbmc_project.Telemetry.ReportManager";
71 static constexpr const char* reportManagerPath =
72 "/xyz/openbmc_project/Telemetry/Reports";
Szymon Dompke32305f12022-07-05 15:37:21 +020073 static constexpr std::string_view reportNameDefault = "Report";
74
75 static_assert(!reportNameDefault.empty(),
76 "Default report name cannot be empty.");
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020077};