diff --git a/htools/Ganeti/HTools/CLI.hs b/htools/Ganeti/HTools/CLI.hs index 308fe6db39ecd4d5351c904fb09597808bcb7d05..a3b9a0c6e4d89f088627a6486b63490239c369aa 100644 --- a/htools/Ganeti/HTools/CLI.hs +++ b/htools/Ganeti/HTools/CLI.hs @@ -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")] diff --git a/htools/Ganeti/HTools/Program/Hspace.hs b/htools/Ganeti/HTools/Program/Hspace.hs index e7c592869a7f1257194556afd9e03131af1478b0..2c20ab1432d7950ac08395d2f81e8a0be45b0127 100644 --- a/htools/Ganeti/HTools/Program/Hspace.hs +++ b/htools/Ganeti/HTools/Program/Hspace.hs @@ -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