control: Parameter use for set_net_increase_speed

Change the set_net_increase_speed to be able to specify a Manager
parameter to get the state value from instead of just looking up a
hardcoded value in the JSON.

The JSON now supports a 'state_parameter_name' field that can be used in
place of the 'state' field.  The code will then call
Manager::getParameter with this parameter name to get the state value to
use in the action.

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: Iaf422787c57c60a3a90c3272813e5f4eb3ca9886
diff --git a/control/json/actions/net_target_increase.cpp b/control/json/actions/net_target_increase.cpp
index 4387a4c..3d6f9f1 100644
--- a/control/json/actions/net_target_increase.cpp
+++ b/control/json/actions/net_target_increase.cpp
@@ -44,6 +44,21 @@
 
 void NetTargetIncrease::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.getIncDelta();
     for (const auto& group : _groups)
     {
@@ -129,12 +144,20 @@
 
 void NetTargetIncrease::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 NetTargetIncrease::setDelta(const json& jsonObj)
diff --git a/control/json/actions/net_target_increase.hpp b/control/json/actions/net_target_increase.hpp
index b0d77e6..0a869d1 100644
--- a/control/json/actions/net_target_increase.hpp
+++ b/control/json/actions/net_target_increase.hpp
@@ -75,14 +75,23 @@
      * dbus objects are processed, the maximum net target increase calculated is
      * requested on the zone.
      *
+     * The state value can be specified as number in the JSON, or as a Manager
+     * parameter that another action will have set.
+     *
      * @param[in] zone - Zone to run the action on
      */
     void run(Zone& zone) override;
 
   private:
-    /* State the members must be at to increase the rarget */
+    /* State the members must be at to increase the target */
     PropertyVariantType _state;
 
+    /**
+     * The Manager parameter to use to get the state value if that
+     * was the method specified in the JSON.
+     */
+    std::string _stateParameter;
+
     /* Increase delta for this action */
     uint64_t _delta;