As usually the algorithmic options are exposed to the command-line
interface, add a function to get the set of algorithmic options to
use from the command-line options provided.

Signed-off-by: Klaus Aehlig <[email protected]>
---
 src/Ganeti/HTools/AlgorithmParams.hs | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/src/Ganeti/HTools/AlgorithmParams.hs 
b/src/Ganeti/HTools/AlgorithmParams.hs
index 13fb5bc..3fa2542 100644
--- a/src/Ganeti/HTools/AlgorithmParams.hs
+++ b/src/Ganeti/HTools/AlgorithmParams.hs
@@ -28,8 +28,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 
 module Ganeti.HTools.AlgorithmParams
   ( AlgorithmOptions(..)
+  , fromCLIOptions
   ) where
 
+import qualified Ganeti.HTools.CLI as CLI
+
 data AlgorithmOptions = AlgorithmOptions
   { algDiskMoves :: Bool            -- ^ Whether disk moves are allowed
   , algInstanceMoves :: Bool        -- ^ Whether instance moves are allowed
@@ -39,3 +42,15 @@ data AlgorithmOptions = AlgorithmOptions
   , algMinGain :: Double            -- ^ Minimal gain per balancing step
   , algMinGainLimit :: Double       -- ^ Limit below which minimal gain is used
   }
+
+-- | Obtain the relevant algorithmic option from the commandline options
+fromCLIOptions :: CLI.Options -> AlgorithmOptions
+fromCLIOptions opts = AlgorithmOptions
+  { algDiskMoves = CLI.optDiskMoves opts
+  , algInstanceMoves = CLI.optInstMoves opts
+  , algRestrictedMigration = CLI.optRestrictedMigrate opts
+  , algIgnoreSoftErrors = CLI.optIgnoreSoftErrors opts
+  , algEvacMode = CLI.optEvacMode opts
+  , algMinGain = CLI.optMinGain opts
+  , algMinGainLimit = CLI.optMinGainLim opts
+  }
-- 
2.0.0.526.g5318336

Reply via email to