1 #pragma once 2 3 #include "interfaces/trigger_action.hpp" 4 #include "types/trigger_types.hpp" 5 6 #include <boost/asio/io_context.hpp> 7 8 namespace action 9 { 10 11 namespace redfish_message_ids 12 { 13 constexpr const char* TriggerNumericWarning = 14 "OpenBMC.0.1.TriggerNumericWarning"; 15 constexpr const char* TriggerNumericCritical = 16 "OpenBMC.0.1.TriggerNumericCritical"; 17 constexpr const char* TriggerDiscreteOK = "OpenBMC.0.1.TriggerDiscreteOK"; 18 constexpr const char* TriggerDiscreteWarning = 19 "OpenBMC.0.1.TriggerDiscreteWarning"; 20 constexpr const char* TriggerDiscreteCritical = 21 "OpenBMC.0.1.TriggerDiscreteCritical"; 22 } // namespace redfish_message_ids 23 24 namespace numeric 25 { 26 class LogToJournal : public interfaces::TriggerAction 27 { 28 public: 29 LogToJournal(::numeric::Type type, double val) : type(type), threshold(val) 30 {} 31 32 void commit(const std::string& triggerId, const ThresholdName thresholdName, 33 const std::string& sensorName, const Milliseconds timestamp, 34 const TriggerValue value) override; 35 36 private: 37 const ::numeric::Type type; 38 const double threshold; 39 }; 40 41 class LogToRedfishEventLog : public interfaces::TriggerAction 42 { 43 public: 44 LogToRedfishEventLog(::numeric::Type type, double val) : 45 type(type), threshold(val) 46 {} 47 48 void commit(const std::string& triggerId, const ThresholdName thresholdName, 49 const std::string& sensorName, const Milliseconds timestamp, 50 const TriggerValue value) override; 51 52 private: 53 const ::numeric::Type type; 54 const double threshold; 55 56 const char* getRedfishMessageId() const; 57 }; 58 59 void fillActions( 60 std::vector<std::unique_ptr<interfaces::TriggerAction>>& actionsIf, 61 const std::vector<TriggerAction>& ActionsEnum, ::numeric::Type type, 62 double thresholdValue, boost::asio::io_context& ioc, 63 const std::shared_ptr<std::vector<std::string>>& reportIds); 64 } // namespace numeric 65 66 namespace discrete 67 { 68 class LogToJournal : public interfaces::TriggerAction 69 { 70 public: 71 explicit LogToJournal(::discrete::Severity severity) : severity(severity) {} 72 73 void commit(const std::string& triggerId, const ThresholdName thresholdName, 74 const std::string& sensorName, const Milliseconds timestamp, 75 const TriggerValue value) override; 76 77 private: 78 const ::discrete::Severity severity; 79 }; 80 81 class LogToRedfishEventLog : public interfaces::TriggerAction 82 { 83 public: 84 explicit LogToRedfishEventLog(::discrete::Severity severity) : 85 severity(severity) 86 {} 87 88 void commit(const std::string& triggerId, const ThresholdName thresholdName, 89 const std::string& sensorName, const Milliseconds timestamp, 90 const TriggerValue value) override; 91 92 private: 93 const ::discrete::Severity severity; 94 95 const char* getRedfishMessageId() const; 96 }; 97 98 void fillActions( 99 std::vector<std::unique_ptr<interfaces::TriggerAction>>& actionsIf, 100 const std::vector<TriggerAction>& ActionsEnum, 101 ::discrete::Severity severity, boost::asio::io_context& ioc, 102 const std::shared_ptr<std::vector<std::string>>& reportIds); 103 104 namespace onChange 105 { 106 class LogToJournal : public interfaces::TriggerAction 107 { 108 public: 109 LogToJournal() {} 110 111 void commit(const std::string& triggerId, const ThresholdName thresholdName, 112 const std::string& sensorName, const Milliseconds timestamp, 113 const TriggerValue value) override; 114 }; 115 116 class LogToRedfishEventLog : public interfaces::TriggerAction 117 { 118 public: 119 LogToRedfishEventLog() {} 120 121 void commit(const std::string& triggerId, const ThresholdName thresholdName, 122 const std::string& sensorName, const Milliseconds timestamp, 123 const TriggerValue value) override; 124 }; 125 126 void fillActions( 127 std::vector<std::unique_ptr<interfaces::TriggerAction>>& actionsIf, 128 const std::vector<TriggerAction>& ActionsEnum, boost::asio::io_context& ioc, 129 const std::shared_ptr<std::vector<std::string>>& reportIds); 130 } // namespace onChange 131 132 } // namespace discrete 133 134 class UpdateReport : public interfaces::TriggerAction 135 { 136 public: 137 UpdateReport(boost::asio::io_context& ioc, 138 std::shared_ptr<std::vector<std::string>> ids) : 139 ioc(ioc), 140 reportIds(std::move(ids)) 141 {} 142 143 void commit(const std::string& triggerId, const ThresholdName thresholdName, 144 const std::string& sensorName, const Milliseconds timestamp, 145 const TriggerValue value) override; 146 147 private: 148 boost::asio::io_context& ioc; 149 std::shared_ptr<std::vector<std::string>> reportIds; 150 }; 151 } // namespace action 152