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")]
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:"
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