blob: 85358ccaf904dbbc59297becbad5f6d180ef3d6a [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, Jozefcb88cfd2020-09-28 16:38:57 +020030 static bool verifyScanPeriod(const uint64_t scanPeriod);
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:
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020058 static constexpr uint32_t maxReports{20};
Wludzik, Jozefbc766b42020-12-08 16:06:22 +010059 static constexpr uint32_t maxReadingParams{200};
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020060 static constexpr std::chrono::milliseconds minInterval{1000};
Wludzik, Jozef2f9f9b82020-10-13 09:07:45 +020061 static constexpr const char* reportManagerIfaceName =
62 "xyz.openbmc_project.Telemetry.ReportManager";
63 static constexpr const char* reportManagerPath =
64 "/xyz/openbmc_project/Telemetry/Reports";
Wludzik, Jozefbc766b42020-12-08 16:06:22 +010065 static constexpr std::array<std::string_view, 2> supportedReportingType = {
66 "Periodic", "OnRequest"};
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020067};