blob: 0e37144414237a83336e7f6885e3009f286b6a8e [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>
12#include <vector>
13
Wludzik, Jozef2f9f9b82020-10-13 09:07:45 +020014class ReportManager : public interfaces::ReportManager
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020015{
16 public:
17 ReportManager(
Wludzik, Jozef2f9f9b82020-10-13 09:07:45 +020018 std::unique_ptr<interfaces::ReportFactory> reportFactory,
Wludzik, Jozefe2362792020-10-27 17:23:55 +010019 std::unique_ptr<interfaces::JsonStorage> reportStorage,
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020020 const std::shared_ptr<sdbusplus::asio::object_server>& objServer);
Wludzik, Jozefcb88cfd2020-09-28 16:38:57 +020021 ~ReportManager() = default;
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020022
Wludzik, Jozefcb88cfd2020-09-28 16:38:57 +020023 ReportManager(ReportManager&) = delete;
24 ReportManager(ReportManager&&) = delete;
25 ReportManager& operator=(ReportManager&) = delete;
26 ReportManager& operator=(ReportManager&&) = delete;
27
Wludzik, Jozef2f9f9b82020-10-13 09:07:45 +020028 void removeReport(const interfaces::Report* report) override;
Wludzik, Jozefcb88cfd2020-09-28 16:38:57 +020029 static bool verifyScanPeriod(const uint64_t scanPeriod);
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020030
31 private:
Wludzik, Jozef2f9f9b82020-10-13 09:07:45 +020032 std::unique_ptr<interfaces::ReportFactory> reportFactory;
Wludzik, Jozefe2362792020-10-27 17:23:55 +010033 std::unique_ptr<interfaces::JsonStorage> reportStorage;
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020034 std::shared_ptr<sdbusplus::asio::object_server> objServer;
Wludzik, Jozefcb88cfd2020-09-28 16:38:57 +020035 std::unique_ptr<sdbusplus::asio::dbus_interface> reportManagerIface;
Wludzik, Jozef2f9f9b82020-10-13 09:07:45 +020036 std::vector<std::unique_ptr<interfaces::Report>> reports;
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020037
Krzysztof Grobelnyd2238192020-12-02 09:27:28 +000038 void verifyAddReport(const std::string& reportName,
39 std::chrono::milliseconds interval);
40 interfaces::Report& addReport(boost::asio::yield_context& yield,
41 const std::string& reportName,
42 const std::string& reportingType,
43 const bool emitsReadingsUpdate,
44 const bool logToMetricReportsCollection,
45 std::chrono::milliseconds interval,
46 ReadingParameters metricParams);
47 interfaces::Report& addReport(
Wludzik, Jozefe2362792020-10-27 17:23:55 +010048 const std::string& reportName, const std::string& reportingType,
49 const bool emitsReadingsUpdate, const bool logToMetricReportsCollection,
50 std::chrono::milliseconds interval,
Krzysztof Grobelnyd2238192020-12-02 09:27:28 +000051 std::vector<LabeledMetricParameters> metricParams);
Wludzik, Jozefe2362792020-10-27 17:23:55 +010052 void loadFromPersistent();
53
Wludzik, Jozefcb88cfd2020-09-28 16:38:57 +020054 public:
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020055 static constexpr uint32_t maxReports{20};
56 static constexpr std::chrono::milliseconds minInterval{1000};
Wludzik, Jozef2f9f9b82020-10-13 09:07:45 +020057 static constexpr const char* reportManagerIfaceName =
58 "xyz.openbmc_project.Telemetry.ReportManager";
59 static constexpr const char* reportManagerPath =
60 "/xyz/openbmc_project/Telemetry/Reports";
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020061};