1 #pragma once 2 3 #include "interfaces/json_storage.hpp" 4 #include "interfaces/report.hpp" 5 #include "interfaces/report_factory.hpp" 6 #include "interfaces/report_manager.hpp" 7 #include "interfaces/trigger_manager.hpp" 8 #include "report.hpp" 9 10 #include <systemd/sd-bus-protocol.h> 11 12 #include <sdbusplus/asio/object_server.hpp> 13 14 #include <chrono> 15 #include <memory> 16 #include <string> 17 #include <vector> 18 19 class ReportManager : public interfaces::ReportManager 20 { 21 public: 22 ReportManager( 23 std::unique_ptr<interfaces::ReportFactory> reportFactory, 24 std::unique_ptr<interfaces::JsonStorage> reportStorage, 25 const std::shared_ptr<sdbusplus::asio::object_server>& objServer); 26 ~ReportManager() = default; 27 28 ReportManager(const ReportManager&) = delete; 29 ReportManager(ReportManager&&) = delete; 30 ReportManager& operator=(const ReportManager&) = delete; 31 ReportManager& operator=(ReportManager&&) = delete; 32 33 void removeReport(const interfaces::Report* report) override; 34 35 private: 36 std::unique_ptr<interfaces::ReportFactory> reportFactory; 37 std::unique_ptr<interfaces::JsonStorage> reportStorage; 38 std::shared_ptr<sdbusplus::asio::object_server> objServer; 39 std::unique_ptr<sdbusplus::asio::dbus_interface> reportManagerIface; 40 std::vector<std::unique_ptr<interfaces::Report>> reports; 41 42 void verifyAddReport( 43 const std::string& reportId, const std::string& reportName, 44 const ReportingType reportingType, Milliseconds interval, 45 const ReportUpdates reportUpdates, const uint64_t appendLimit, 46 const std::vector<LabeledMetricParameters>& readingParams); 47 interfaces::Report& addReport( 48 boost::asio::yield_context& yield, const std::string& reportId, 49 const std::string& reportName, const ReportingType reportingType, 50 const std::vector<ReportAction>& reportActions, Milliseconds interval, 51 const uint64_t appendLimit, const ReportUpdates reportUpdates, 52 ReadingParameters metricParams, const bool enabled); 53 interfaces::Report& 54 addReport(const std::string& reportId, const std::string& reportName, 55 const ReportingType reportingType, 56 const std::vector<ReportAction>& reportActions, 57 Milliseconds interval, const uint64_t appendLimit, 58 const ReportUpdates reportUpdates, 59 std::vector<LabeledMetricParameters> metricParams, 60 const bool enabled, Readings); 61 void loadFromPersistent(); 62 63 public: 64 static constexpr size_t maxReports{TELEMETRY_MAX_REPORTS}; 65 static constexpr size_t maxNumberMetrics{TELEMETRY_MAX_READING_PARAMS}; 66 static constexpr size_t maxReportIdLength{ 67 TELEMETRY_MAX_DBUS_PATH_LENGTH - 68 std::string_view(Report::reportDir).length()}; 69 static constexpr Milliseconds minInterval{TELEMETRY_MIN_INTERVAL}; 70 static constexpr size_t maxAppendLimit{TELEMETRY_MAX_APPEND_LIMIT}; 71 static constexpr const char* reportManagerIfaceName = 72 "xyz.openbmc_project.Telemetry.ReportManager"; 73 static constexpr const char* reportManagerPath = 74 "/xyz/openbmc_project/Telemetry/Reports"; 75 static constexpr const char* reportNameDefault = "Report"; 76 }; 77