control: `member` signal triggers use event groups
Remove the ability to provide a `member` trigger's attributes from the
event trigger configuration in favor of using the configured event's
groups. This aligns with the recent design direction that event triggers
are setup from the event groups.
Change-Id: I304cfdffedd54317e440e7566988392a1410af6a
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/control/json/triggers/signal.cpp b/control/json/triggers/signal.cpp
index b39bc4a..526eeb3 100644
--- a/control/json/triggers/signal.cpp
+++ b/control/json/triggers/signal.cpp
@@ -201,29 +201,27 @@
}
}
-void member(Manager* mgr, const Group&, SignalActions actions,
- const json& jsonObj)
+void member(Manager* mgr, const Group& group, SignalActions actions,
+ const json&)
{
- if (!jsonObj.contains("member") || !jsonObj["member"].contains("name") ||
- !jsonObj["member"].contains("path") ||
- !jsonObj["member"].contains("interface"))
- {
- log<level::ERR>("Missing required member trigger attributes",
- entry("JSON=%s", jsonObj.dump().c_str()));
- throw std::runtime_error("Missing required member trigger attributes");
- }
- const auto match =
- rules::type::signal() +
- rules::member(jsonObj["member"]["name"].get<std::string>()) +
- rules::path(jsonObj["member"]["path"].get<std::string>()) +
- rules::interface(jsonObj["member"]["interface"].get<std::string>());
// No SignalObject required to associate to this signal
SignalPkg signalPkg = {Handlers::member, SignalObject(),
SignalActions(actions)};
// If signal match already exists, then the member signal will be the
// same so add action to be run
auto isSameSig = [](SignalPkg& pkg) { return true; };
- subscribe(match, std::move(signalPkg), isSameSig, mgr);
+
+ // Groups are optional, but a signal triggered event with no groups
+ // will do nothing since signals require a group
+ for (const auto& member : group.getMembers())
+ {
+ // Subscribe for signal from each group member
+ const auto match =
+ rules::type::signal() + rules::member(group.getProperty()) +
+ rules::path(member) + rules::interface(group.getInterface());
+
+ subscribe(match, std::move(signalPkg), isSameSig, mgr);
+ }
}
enableTrigger triggerSignal(const json& jsonObj, const std::string& eventName,
diff --git a/control/json/triggers/signal.hpp b/control/json/triggers/signal.hpp
index 881673a..6db4dbb 100644
--- a/control/json/triggers/signal.hpp
+++ b/control/json/triggers/signal.hpp
@@ -89,10 +89,9 @@
* @param[in] mgr - Pointer to manager of the trigger
* @param[in] group - Group to subscribe signal against
* @param[in] actions - Actions to be run when signal is received
- * @param[in] jsonObj - JSON object for the trigger
*/
-void member(Manager* mgr, const Group&, SignalActions actions,
- const json& jsonObj);
+void member(Manager* mgr, const Group& group, SignalActions actions,
+ const json&);
// Match setup function for signals
using SignalMatch = std::function<void(Manager*, const Group&,