Fix low verbosity levels in htools
authorIustin Pop <iustin@google.com>
Mon, 4 Mar 2013 10:24:51 +0000 (11:24 +0100)
committerIustin Pop <iustin@google.com>
Mon, 4 Mar 2013 10:35:44 +0000 (11:35 +0100)
In a few cases, we tested the verbosity level for (== 0), instead of
higher/lower than a certain value. If the user passes multiple
"--quiet" options, this can result in negative verbosity levels, which
behave like "extra verbosity".

Sigh for plain data types as opposed to proper verbosity levels…

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>

src/Ganeti/HTools/Program/Hbal.hs
src/Ganeti/HTools/Program/Hcheck.hs

index be10c1a..26b1e3c 100644 (file)
@@ -319,7 +319,7 @@ checkGroup verbose gname nl il = do
   putStrLn $ "Selected node group: " ++ gname
 
   let (bad_nodes, bad_instances) = Cluster.computeBadItems nl il
-  unless (verbose == 0) $ printf
+  unless (verbose < 1) $ printf
              "Initial check done: %d bad nodes, %d bad instances.\n"
              (length bad_nodes) (length bad_instances)
 
@@ -399,7 +399,7 @@ main opts args = do
 
   putStr sol_msg
 
-  unless (verbose == 0) $
+  unless (verbose < 1) $
          printf "Solution length=%d\n" (length ord_plc)
 
   let cmd_jobs = Cluster.splitJobs cmd_strs
index b86dc5d..35f32ef 100644 (file)
@@ -4,7 +4,7 @@
 
 {-
 
-Copyright (C) 2012 Google Inc.
+Copyright (C) 2012, 2013 Google Inc.
 
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
@@ -191,7 +191,7 @@ printStats _ True level phase values = do
 printStats verbose False level phase values = do
   let prefix = phaseLevelDescr phase level
       descr = descrData level
-  unless (verbose == 0) $ do
+  unless (verbose < 1) $ do
     putStrLn ""
     putStr prefix
     mapM_ (uncurry (printf "    %s: %s\n")) (zip descr values)
@@ -311,7 +311,7 @@ main opts args = do
       clusterstats = map sum . transpose . map snd $ groupsstats
       needrebalance = clusterNeedsRebalance clusterstats
 
-  unless (verbose == 0 || machineread) .
+  unless (verbose < 1 || machineread) .
     putStrLn $ if nosimulation
                  then "Running in no-simulation mode."
                  else if needrebalance