blob: bb4d3958878b8e0cbdcfa04fea15270f6a6f2cbd [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"
Wludzik, Jozefcb88cfd2020-09-28 16:38:57 +02007
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +02008#include <sdbusplus/asio/object_server.hpp>
9
10#include <chrono>
11#include <memory>
Wludzik, Jozefbc766b42020-12-08 16:06:22 +010012#include <string>
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020013#include <vector>
14
Wludzik, Jozef2f9f9b82020-10-13 09:07:45 +020015class ReportManager : public interfaces::ReportManager
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020016{
17 public:
18 ReportManager(
Wludzik, Jozef2f9f9b82020-10-13 09:07:45 +020019 std::unique_ptr<interfaces::ReportFactory> reportFactory,
Wludzik, Jozefe2362792020-10-27 17:23:55 +010020 std::unique_ptr<interfaces::JsonStorage> reportStorage,
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020021 const std::shared_ptr<sdbusplus::asio::object_server>& objServer);
Wludzik, Jozefcb88cfd2020-09-28 16:38:57 +020022 ~ReportManager() = default;
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020023
Wludzik, Jozefcb88cfd2020-09-28 16:38:57 +020024 ReportManager(ReportManager&) = delete;
25 ReportManager(ReportManager&&) = delete;
26 ReportManager& operator=(ReportManager&) = delete;
27 ReportManager& operator=(ReportManager&&) = delete;
28
Wludzik, Jozef2f9f9b82020-10-13 09:07:45 +020029 void removeReport(const interfaces::Report* report) override;
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +010030 void updateReport(const std::string& name) override;
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020031
32 private:
Wludzik, Jozef2f9f9b82020-10-13 09:07:45 +020033 std::unique_ptr<interfaces::ReportFactory> reportFactory;
Wludzik, Jozefe2362792020-10-27 17:23:55 +010034 std::unique_ptr<interfaces::JsonStorage> reportStorage;
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020035 std::shared_ptr<sdbusplus::asio::object_server> objServer;
Wludzik, Jozefcb88cfd2020-09-28 16:38:57 +020036 std::unique_ptr<sdbusplus::asio::dbus_interface> reportManagerIface;
Wludzik, Jozef2f9f9b82020-10-13 09:07:45 +020037 std::vector<std::unique_ptr<interfaces::Report>> reports;
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020038
Krzysztof Grobelnyd2238192020-12-02 09:27:28 +000039 void verifyAddReport(const std::string& reportName,
Wludzik, Jozefbc766b42020-12-08 16:06:22 +010040 const std::string& reportingType,
41 std::chrono::milliseconds interval,
42 const ReadingParameters& readingParams);
Krzysztof Grobelnyd2238192020-12-02 09:27:28 +000043 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, Jozefe2362792020-10-27 17:23:55 +010051 const std::string& reportName, const std::string& reportingType,
52 const bool emitsReadingsUpdate, const bool logToMetricReportsCollection,
53 std::chrono::milliseconds interval,
Krzysztof Grobelnyd2238192020-12-02 09:27:28 +000054 std::vector<LabeledMetricParameters> metricParams);
Wludzik, Jozefe2362792020-10-27 17:23:55 +010055 void loadFromPersistent();
56
Wludzik, Jozefcb88cfd2020-09-28 16:38:57 +020057 public:
Wludzik, Jozef503c1582020-12-11 14:48:01 +010058 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, Jozef2f9f9b82020-10-13 09:07:45 +020062 static constexpr const char* reportManagerIfaceName =
63 "xyz.openbmc_project.Telemetry.ReportManager";
64 static constexpr const char* reportManagerPath =
65 "/xyz/openbmc_project/Telemetry/Reports";
Wludzik, Jozefbc766b42020-12-08 16:06:22 +010066 static constexpr std::array<std::string_view, 2> supportedReportingType = {
67 "Periodic", "OnRequest"};
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020068};