blob: 14f6294eecd71db95fc3e61019dbc1e871fc79de [file] [log] [blame]
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +01001#pragma once
2
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +01003#include "interfaces/trigger_action.hpp"
Krzysztof Grobelnydcc4e192021-03-08 09:09:34 +00004#include "types/trigger_types.hpp"
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +01005
Krzysztof Grobelnye6d48872022-02-08 13:41:30 +01006#include <boost/asio/io_context.hpp>
7
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +01008namespace action
9{
10
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +020011namespace redfish_message_ids
12{
13constexpr const char* TriggerNumericWarning =
14 "OpenBMC.0.1.TriggerNumericWarning";
15constexpr const char* TriggerNumericCritical =
16 "OpenBMC.0.1.TriggerNumericCritical";
17constexpr const char* TriggerDiscreteOK = "OpenBMC.0.1.TriggerDiscreteOK";
18constexpr const char* TriggerDiscreteWarning =
19 "OpenBMC.0.1.TriggerDiscreteWarning";
20constexpr const char* TriggerDiscreteCritical =
21 "OpenBMC.0.1.TriggerDiscreteCritical";
22} // namespace redfish_message_ids
23
Szymon Dompkef763c9e2021-03-12 09:19:22 +010024namespace numeric
25{
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +010026class LogToJournal : public interfaces::TriggerAction
27{
28 public:
Szymon Dompkef763c9e2021-03-12 09:19:22 +010029 LogToJournal(::numeric::Type type, double val) : type(type), threshold(val)
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +010030 {}
31
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +020032 void commit(const std::string& triggerId, const ThresholdName thresholdName,
33 const std::string& sensorName, const Milliseconds timestamp,
34 const TriggerValue value) override;
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +010035
36 private:
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +020037 const ::numeric::Type type;
38 const double threshold;
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +010039};
40
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +020041class LogToRedfishEventLog : public interfaces::TriggerAction
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +010042{
43 public:
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +020044 LogToRedfishEventLog(::numeric::Type type, double val) :
45 type(type), threshold(val)
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +010046 {}
47
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +020048 void commit(const std::string& triggerId, const ThresholdName thresholdName,
49 const std::string& sensorName, const Milliseconds timestamp,
50 const TriggerValue value) override;
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +010051
52 private:
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +020053 const ::numeric::Type type;
54 const double threshold;
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +010055
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +020056 const char* getRedfishMessageId() const;
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +010057};
Szymon Dompke20013012021-07-23 09:54:20 +020058
59void fillActions(
60 std::vector<std::unique_ptr<interfaces::TriggerAction>>& actionsIf,
61 const std::vector<TriggerAction>& ActionsEnum, ::numeric::Type type,
Krzysztof Grobelnye6d48872022-02-08 13:41:30 +010062 double thresholdValue, boost::asio::io_context& ioc,
Szymon Dompke94f71c52021-12-10 07:16:33 +010063 const std::shared_ptr<std::vector<std::string>>& reportIds);
Szymon Dompkef763c9e2021-03-12 09:19:22 +010064} // namespace numeric
65
66namespace discrete
67{
68class LogToJournal : public interfaces::TriggerAction
69{
70 public:
Patrick Williams3a1c2972023-05-10 07:51:04 -050071 explicit LogToJournal(::discrete::Severity severity) : severity(severity) {}
Szymon Dompkef763c9e2021-03-12 09:19:22 +010072
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +020073 void commit(const std::string& triggerId, const ThresholdName thresholdName,
74 const std::string& sensorName, const Milliseconds timestamp,
75 const TriggerValue value) override;
Szymon Dompkef763c9e2021-03-12 09:19:22 +010076
77 private:
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +020078 const ::discrete::Severity severity;
Szymon Dompkef763c9e2021-03-12 09:19:22 +010079};
80
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +020081class LogToRedfishEventLog : public interfaces::TriggerAction
Szymon Dompkef763c9e2021-03-12 09:19:22 +010082{
83 public:
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +020084 explicit LogToRedfishEventLog(::discrete::Severity severity) :
85 severity(severity)
Szymon Dompkef763c9e2021-03-12 09:19:22 +010086 {}
87
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +020088 void commit(const std::string& triggerId, const ThresholdName thresholdName,
89 const std::string& sensorName, const Milliseconds timestamp,
90 const TriggerValue value) override;
Szymon Dompkef763c9e2021-03-12 09:19:22 +010091
92 private:
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +020093 const ::discrete::Severity severity;
Szymon Dompkef763c9e2021-03-12 09:19:22 +010094
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +020095 const char* getRedfishMessageId() const;
Szymon Dompkef763c9e2021-03-12 09:19:22 +010096};
97
Szymon Dompke20013012021-07-23 09:54:20 +020098void fillActions(
99 std::vector<std::unique_ptr<interfaces::TriggerAction>>& actionsIf,
100 const std::vector<TriggerAction>& ActionsEnum,
Krzysztof Grobelnye6d48872022-02-08 13:41:30 +0100101 ::discrete::Severity severity, boost::asio::io_context& ioc,
Szymon Dompke94f71c52021-12-10 07:16:33 +0100102 const std::shared_ptr<std::vector<std::string>>& reportIds);
Szymon Dompke20013012021-07-23 09:54:20 +0200103
Szymon Dompkef763c9e2021-03-12 09:19:22 +0100104namespace onChange
105{
106class LogToJournal : public interfaces::TriggerAction
107{
108 public:
Patrick Williams3a1c2972023-05-10 07:51:04 -0500109 LogToJournal() {}
Szymon Dompkef763c9e2021-03-12 09:19:22 +0100110
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +0200111 void commit(const std::string& triggerId, const ThresholdName thresholdName,
112 const std::string& sensorName, const Milliseconds timestamp,
113 const TriggerValue value) override;
Szymon Dompkef763c9e2021-03-12 09:19:22 +0100114};
115
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +0200116class LogToRedfishEventLog : public interfaces::TriggerAction
Szymon Dompkef763c9e2021-03-12 09:19:22 +0100117{
118 public:
Patrick Williams3a1c2972023-05-10 07:51:04 -0500119 LogToRedfishEventLog() {}
Szymon Dompkef763c9e2021-03-12 09:19:22 +0100120
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +0200121 void commit(const std::string& triggerId, const ThresholdName thresholdName,
122 const std::string& sensorName, const Milliseconds timestamp,
123 const TriggerValue value) override;
Szymon Dompkef763c9e2021-03-12 09:19:22 +0100124};
Szymon Dompke20013012021-07-23 09:54:20 +0200125
126void fillActions(
127 std::vector<std::unique_ptr<interfaces::TriggerAction>>& actionsIf,
Krzysztof Grobelnye6d48872022-02-08 13:41:30 +0100128 const std::vector<TriggerAction>& ActionsEnum, boost::asio::io_context& ioc,
Szymon Dompke94f71c52021-12-10 07:16:33 +0100129 const std::shared_ptr<std::vector<std::string>>& reportIds);
Szymon Dompkef763c9e2021-03-12 09:19:22 +0100130} // namespace onChange
131
132} // namespace discrete
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +0100133
134class UpdateReport : public interfaces::TriggerAction
135{
136 public:
Krzysztof Grobelnye6d48872022-02-08 13:41:30 +0100137 UpdateReport(boost::asio::io_context& ioc,
Szymon Dompke94f71c52021-12-10 07:16:33 +0100138 std::shared_ptr<std::vector<std::string>> ids) :
Krzysztof Grobelnye6d48872022-02-08 13:41:30 +0100139 ioc(ioc),
Krzysztof Grobelnyb8cc78d2021-11-29 15:54:53 +0100140 reportIds(std::move(ids))
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +0100141 {}
142
Szymon Dompkeb7b7e1b2022-05-19 10:15:48 +0200143 void commit(const std::string& triggerId, const ThresholdName thresholdName,
144 const std::string& sensorName, const Milliseconds timestamp,
145 const TriggerValue value) override;
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +0100146
147 private:
Krzysztof Grobelnye6d48872022-02-08 13:41:30 +0100148 boost::asio::io_context& ioc;
Szymon Dompke94f71c52021-12-10 07:16:33 +0100149 std::shared_ptr<std::vector<std::string>> reportIds;
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +0100150};
151} // namespace action