control: Actions use list of groups set on base object
Remove the reference to a group given when running an action and instead
have each action iterate over the list of groups configured/set on the
base action object. The group configured/set on the base action object
is the only set of groups that the action should use based on its
configuration in an event.
Change-Id: Ia298d270e782ad729b5a29f9cdfe9b6c9ea4bc45
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/control/json/actions/request_target_base.cpp b/control/json/actions/request_target_base.cpp
index 5000ea8..4bcaabb 100644
--- a/control/json/actions/request_target_base.cpp
+++ b/control/json/actions/request_target_base.cpp
@@ -39,51 +39,54 @@
// There are no JSON configuration parameters for this action
}
-void RequestTargetBase::run(Zone& zone, const Group& group)
+void RequestTargetBase::run(Zone& zone)
{
uint64_t base = 0;
- for (const auto& member : group.getMembers())
+ for (const auto& group : _groups)
{
- try
+ for (const auto& member : group.getMembers())
{
- auto value = Manager::getObjValueVariant(
- member, group.getInterface(), group.getProperty());
- if (auto intPtr = std::get_if<int64_t>(&value))
+ try
{
- // Throw out any negative values as those are not valid
- // to use as a fan target base
- if (*intPtr < 0)
+ auto value = Manager::getObjValueVariant(
+ member, group.getInterface(), group.getProperty());
+ if (auto intPtr = std::get_if<int64_t>(&value))
{
- continue;
+ // Throw out any negative values as those are not valid
+ // to use as a fan target base
+ if (*intPtr < 0)
+ {
+ continue;
+ }
+ base = std::max(base, static_cast<uint64_t>(*intPtr));
}
- base = std::max(base, static_cast<uint64_t>(*intPtr));
- }
- else if (auto dblPtr = std::get_if<double>(&value))
- {
- // Throw out any negative values as those are not valid
- // to use as a fan target base
- if (*dblPtr < 0)
+ else if (auto dblPtr = std::get_if<double>(&value))
{
- continue;
+ // Throw out any negative values as those are not valid
+ // to use as a fan target base
+ if (*dblPtr < 0)
+ {
+ continue;
+ }
+ // Precision of a double not a concern with fan targets
+ base = std::max(base, static_cast<uint64_t>(*dblPtr));
}
- // Precision of a double not a concern with fan targets
- base = std::max(base, static_cast<uint64_t>(*dblPtr));
+ else
+ {
+ // Unsupported group member type for this action
+ log<level::ERR>(
+ fmt::format("Action {}: Unsupported group member type "
+ "given. [object = {} : {} : {}]",
+ getName(), member, group.getInterface(),
+ group.getProperty())
+ .c_str());
+ }
}
- else
+ catch (const std::out_of_range& oore)
{
- // Unsupported group member type for this action
- log<level::ERR>(
- fmt::format("Action {}: Unsupported group member type "
- "given. [object = {} : {} : {}]",
- getName(), member, group.getInterface(),
- group.getProperty())
- .c_str());
+ // Property value not found, base request target unchanged
}
}
- catch (const std::out_of_range& oore)
- {
- // Property value not found, base request target unchanged
- }
}
// A request target base of 0 defaults to the current target