Improve readability for hcheck-related changes
authorAgata Murawska <agatamurawska@google.com>
Tue, 26 Jun 2012 08:14:53 +0000 (10:14 +0200)
committerAgata Murawska <agatamurawska@google.com>
Wed, 27 Jun 2012 14:17:29 +0000 (16:17 +0200)
As suggested by Rene, I added comments to types for printKeys
and printFinal. Also, realigned some lines in Hspace.

Signed-off-by: Agata Murawska <agatamurawska@google.com>
Reviewed-by: RenĂ© Nussbaumer <rn@google.com>

htools/Ganeti/HTools/CLI.hs
htools/Ganeti/HTools/Program/Hspace.hs

index 308fe6d..a3b9a0c 100644 (file)
@@ -567,12 +567,17 @@ maybeShowWarnings fix_msgs =
     hPutStrLn stderr . unlines . map (printf "  - %s") $ fix_msgs
 
 -- | Format a list of key, value as a shell fragment.
-printKeys :: String -> [(String, String)] -> IO ()
+printKeys :: String              -- ^ Prefix to printed variables
+          -> [(String, String)]  -- ^ List of (key, value) pairs to be printed
+          -> IO ()
 printKeys prefix = mapM_ (\(k, v) ->
                        printf "%s_%s=%s\n" prefix (map toUpper k) (ensureQuoted v))
 
 -- | Prints the final @OK@ marker in machine readable output.
-printFinal :: String -> Bool -> IO ()
+printFinal :: String    -- ^ Prefix to printed variable
+           -> Bool      -- ^ Whether output should be machine readable
+                        -- Note: if not, there is nothing to print
+           -> IO ()
 printFinal prefix True =
   -- this should be the final entry
   printKeys prefix [("OK", "1")]
index e7c5928..2c20ab1 100644 (file)
@@ -183,13 +183,13 @@ printResults True _ fin_nl num_instances allocs sreason = do
 
   printKeysHTS $ printStats PFinal fin_stats
   printKeysHTS [ ("ALLOC_USAGE", printf "%.8f"
-                                ((fromIntegral num_instances::Double) /
-                                 fromIntegral fin_instances))
-            , ("ALLOC_INSTANCES", printf "%d" allocs)
-            , ("ALLOC_FAIL_REASON", map toUpper . show . fst $ head sreason)
-            ]
+                                   ((fromIntegral num_instances::Double) /
+                                   fromIntegral fin_instances))
+               , ("ALLOC_INSTANCES", printf "%d" allocs)
+               , ("ALLOC_FAIL_REASON", map toUpper . show . fst $ head sreason)
+               ]
   printKeysHTS $ map (\(x, y) -> (printf "ALLOC_%s_CNT" (show x),
-                               printf "%d" y)) sreason
+                                  printf "%d" y)) sreason
 
 printResults False ini_nl fin_nl _ allocs sreason = do
   putStrLn "Normal (fixed-size) allocation results:"
@@ -290,7 +290,7 @@ printISpec True ispec spec disk_template = do
   printKeysHTS $ map (\(a, fn) -> (prefix ++ "_" ++ a, fn ispec)) specData
   printKeysHTS [ (prefix ++ "_RQN", printf "%d" req_nodes) ]
   printKeysHTS [ (prefix ++ "_DISK_TEMPLATE",
-               diskTemplateToRaw disk_template) ]
+                  diskTemplateToRaw disk_template) ]
       where req_nodes = Instance.requiredNodes disk_template
             prefix = specPrefix spec