Revision 79eef90b htools/Ganeti/HTools/CLI.hs
b/htools/Ganeti/HTools/CLI.hs | ||
---|---|---|
39 | 39 |
, maybePrintNodes |
40 | 40 |
, maybePrintInsts |
41 | 41 |
, maybeShowWarnings |
42 |
, printKeys |
|
43 |
, printFinal |
|
42 | 44 |
, setNodeStatus |
43 | 45 |
-- * The options |
44 | 46 |
, oDataFile |
... | ... | |
83 | 85 |
) where |
84 | 86 |
|
85 | 87 |
import Control.Monad |
88 |
import Data.Char (toUpper) |
|
86 | 89 |
import Data.Maybe (fromMaybe) |
87 | 90 |
import qualified Data.Version |
88 | 91 |
import System.Console.GetOpt |
... | ... | |
563 | 566 |
hPutStrLn stderr "Warning: cluster has inconsistent data:" |
564 | 567 |
hPutStrLn stderr . unlines . map (printf " - %s") $ fix_msgs |
565 | 568 |
|
569 |
-- | Format a list of key, value as a shell fragment. |
|
570 |
printKeys :: String -> [(String, String)] -> IO () |
|
571 |
printKeys prefix = mapM_ (\(k, v) -> |
|
572 |
printf "%s_%s=%s\n" prefix (map toUpper k) (ensureQuoted v)) |
|
573 |
|
|
574 |
-- | Prints the final @OK@ marker in machine readable output. |
|
575 |
printFinal :: String -> Bool -> IO () |
|
576 |
printFinal prefix True = |
|
577 |
-- this should be the final entry |
|
578 |
printKeys prefix [("OK", "1")] |
|
579 |
|
|
580 |
printFinal _ False = return () |
|
581 |
|
|
566 | 582 |
-- | Potentially set the node as offline based on passed offline list. |
567 | 583 |
setNodeOffline :: [Ndx] -> Node.Node -> Node.Node |
568 | 584 |
setNodeOffline offline_indices n = |
Also available in: Unified diff