Revision e60fa4af
b/htools/Ganeti/HTools/CLI.hs | ||
---|---|---|
567 | 567 |
hPutStrLn stderr . unlines . map (printf " - %s") $ fix_msgs |
568 | 568 |
|
569 | 569 |
-- | Format a list of key, value as a shell fragment. |
570 |
printKeys :: String -> [(String, String)] -> IO () |
|
570 |
printKeys :: String -- ^ Prefix to printed variables |
|
571 |
-> [(String, String)] -- ^ List of (key, value) pairs to be printed |
|
572 |
-> IO () |
|
571 | 573 |
printKeys prefix = mapM_ (\(k, v) -> |
572 | 574 |
printf "%s_%s=%s\n" prefix (map toUpper k) (ensureQuoted v)) |
573 | 575 |
|
574 | 576 |
-- | Prints the final @OK@ marker in machine readable output. |
575 |
printFinal :: String -> Bool -> IO () |
|
577 |
printFinal :: String -- ^ Prefix to printed variable |
|
578 |
-> Bool -- ^ Whether output should be machine readable |
|
579 |
-- Note: if not, there is nothing to print |
|
580 |
-> IO () |
|
576 | 581 |
printFinal prefix True = |
577 | 582 |
-- this should be the final entry |
578 | 583 |
printKeys prefix [("OK", "1")] |
b/htools/Ganeti/HTools/Program/Hspace.hs | ||
---|---|---|
183 | 183 |
|
184 | 184 |
printKeysHTS $ printStats PFinal fin_stats |
185 | 185 |
printKeysHTS [ ("ALLOC_USAGE", printf "%.8f" |
186 |
((fromIntegral num_instances::Double) / |
|
187 |
fromIntegral fin_instances)) |
|
188 |
, ("ALLOC_INSTANCES", printf "%d" allocs) |
|
189 |
, ("ALLOC_FAIL_REASON", map toUpper . show . fst $ head sreason) |
|
190 |
] |
|
186 |
((fromIntegral num_instances::Double) /
|
|
187 |
fromIntegral fin_instances))
|
|
188 |
, ("ALLOC_INSTANCES", printf "%d" allocs)
|
|
189 |
, ("ALLOC_FAIL_REASON", map toUpper . show . fst $ head sreason)
|
|
190 |
]
|
|
191 | 191 |
printKeysHTS $ map (\(x, y) -> (printf "ALLOC_%s_CNT" (show x), |
192 |
printf "%d" y)) sreason |
|
192 |
printf "%d" y)) sreason
|
|
193 | 193 |
|
194 | 194 |
printResults False ini_nl fin_nl _ allocs sreason = do |
195 | 195 |
putStrLn "Normal (fixed-size) allocation results:" |
... | ... | |
290 | 290 |
printKeysHTS $ map (\(a, fn) -> (prefix ++ "_" ++ a, fn ispec)) specData |
291 | 291 |
printKeysHTS [ (prefix ++ "_RQN", printf "%d" req_nodes) ] |
292 | 292 |
printKeysHTS [ (prefix ++ "_DISK_TEMPLATE", |
293 |
diskTemplateToRaw disk_template) ] |
|
293 |
diskTemplateToRaw disk_template) ]
|
|
294 | 294 |
where req_nodes = Instance.requiredNodes disk_template |
295 | 295 |
prefix = specPrefix spec |
296 | 296 |
|
Also available in: Unified diff