From e6685c536a8b169e97c5b5d759a11f1afb702a2b Mon Sep 17 00:00:00 2001 From: Agata Murawska <agatamurawska@google.com> Date: Wed, 20 Jun 2012 17:00:57 +0200 Subject: [PATCH] Allowing rebalance to run silently MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Part of hcheck's simulation required us to silently run hbal. For that purpose we expose iterateDepth and allow it to run silently. Signed-off-by: Agata Murawska <agatamurawska@google.com> Reviewed-by: RenΓ© Nussbaumer <rn@google.com> --- htools/Ganeti/HTools/Program/Hbal.hs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/htools/Ganeti/HTools/Program/Hbal.hs b/htools/Ganeti/HTools/Program/Hbal.hs index c6cb62998..7f542a5c9 100644 --- a/htools/Ganeti/HTools/Program/Hbal.hs +++ b/htools/Ganeti/HTools/Program/Hbal.hs @@ -23,7 +23,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -} -module Ganeti.HTools.Program.Hbal (main, options) where +module Ganeti.HTools.Program.Hbal + ( main + , options + , iterateDepth + ) where import Control.Concurrent (threadDelay) import Control.Exception (bracket) @@ -90,7 +94,8 @@ options = we find a valid solution or we exceed the maximum depth. -} -iterateDepth :: Cluster.Table -- ^ The starting table +iterateDepth :: Bool -- ^ Whether to print moves + -> Cluster.Table -- ^ The starting table -> Int -- ^ Remaining length -> Bool -- ^ Allow disk moves -> Bool -- ^ Allow instance moves @@ -103,7 +108,7 @@ iterateDepth :: Cluster.Table -- ^ The starting table -> Bool -- ^ Enable evacuation mode -> IO (Cluster.Table, [MoveJob]) -- ^ The resulting table -- and commands -iterateDepth ini_tbl max_rounds disk_moves inst_moves nmlen imlen +iterateDepth printmove ini_tbl max_rounds disk_moves inst_moves nmlen imlen cmd_strs min_score mg_limit min_gain evac_mode = let Cluster.Table ini_nl ini_il _ _ = ini_tbl allowed_next = Cluster.doNextBalance ini_tbl max_rounds min_score @@ -121,9 +126,10 @@ iterateDepth ini_tbl max_rounds disk_moves inst_moves nmlen imlen nmlen imlen cur_plc fin_plc_len afn = Cluster.involvedNodes ini_il cur_plc upd_cmd_strs = (afn, idx, move, cmds):cmd_strs - putStrLn sol_line - hFlush stdout - iterateDepth fin_tbl max_rounds disk_moves inst_moves + when printmove $ do + putStrLn sol_line + hFlush stdout + iterateDepth printmove fin_tbl max_rounds disk_moves inst_moves nmlen imlen upd_cmd_strs min_score mg_limit min_gain evac_mode Nothing -> return (ini_tbl, cmd_strs) @@ -382,7 +388,7 @@ main opts args = do let imlen = maximum . map (length . Instance.alias) $ Container.elems il nmlen = maximum . map (length . Node.alias) $ Container.elems nl - (fin_tbl, cmd_strs) <- iterateDepth ini_tbl (optMaxLength opts) + (fin_tbl, cmd_strs) <- iterateDepth True ini_tbl (optMaxLength opts) (optDiskMoves opts) (optInstMoves opts) nmlen imlen [] min_cv -- GitLab