control: Support state parameter on net decrease target action

The net increase target action supports the use of a parameter to
determine the state at which group members must be at to request an
increase delta. The net decrease target action should also support the
use of a parameter to determine the state for decreases.

Change-Id: Ied883c70566b19bacfa1f76cc2a6c738c1cea85a
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/control/json/actions/net_target_decrease.cpp b/control/json/actions/net_target_decrease.cpp
index 39e5521..393a273 100644
--- a/control/json/actions/net_target_decrease.cpp
+++ b/control/json/actions/net_target_decrease.cpp
@@ -44,6 +44,20 @@
 
 void NetTargetDecrease::run(Zone& zone)
 {
+    if (!_stateParameter.empty())
+    {
+        auto s = Manager::getParameter(_stateParameter);
+        if (!s)
+        {
+            log<level::DEBUG>(
+                fmt::format("Action {}: State parameter {} not found",
+                            ActionBase::getName(), _stateParameter)
+                    .c_str());
+            return;
+        }
+        _state = *s;
+    }
+
     auto netDelta = zone.getDecDelta();
     for (const auto& group : _groups)
     {
@@ -135,12 +149,20 @@
 
 void NetTargetDecrease::setState(const json& jsonObj)
 {
-    if (!jsonObj.contains("state"))
+    if (jsonObj.contains("state"))
     {
-        throw ActionParseError{ActionBase::getName(),
-                               "Missing required state value"};
+        _state = getJsonValue(jsonObj["state"]);
     }
-    _state = getJsonValue(jsonObj["state"]);
+    else if (jsonObj.contains("state_parameter_name"))
+    {
+        _stateParameter = jsonObj["state_parameter_name"].get<std::string>();
+    }
+    else
+    {
+        throw ActionParseError{
+            ActionBase::getName(),
+            "Missing required state or state_parameter_name value"};
+    }
 }
 
 void NetTargetDecrease::setDelta(const json& jsonObj)