Commit 8cd36391 authored by Iustin Pop's avatar Iustin Pop
Browse files

htools: abstract a function for displaying warnings



This will make it possible to reuse this in IAllocator too.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent 15329af5
......@@ -35,6 +35,7 @@ module Ganeti.HTools.CLI
, defaultLuxiSocket
, maybePrintNodes
, maybePrintInsts
, maybeShowWarnings
-- * The options
, oDataFile
, oDiskMoves
......@@ -490,3 +491,12 @@ maybePrintInsts do_print msg instdata =
hPutStrLn stderr ""
hPutStrLn stderr $ msg ++ " instance map:"
hPutStr stderr instdata
-- | Function to display warning messages from parsing the cluster
-- state.
maybeShowWarnings :: [String] -- ^ The warning messages
-> IO ()
maybeShowWarnings fix_msgs =
unless (null fix_msgs) $ do
hPutStrLn stderr "Warning: cluster has inconsistent data:"
hPutStrLn stderr . unlines . map (printf " - %s") $ fix_msgs
......@@ -38,7 +38,7 @@ import Data.Maybe (isJust, fromJust)
import System.FilePath
import System.IO
import System
import Text.Printf (printf, hPrintf)
import Text.Printf (hPrintf)
import qualified Ganeti.HTools.Luxi as Luxi
import qualified Ganeti.HTools.Rapi as Rapi
......@@ -123,9 +123,7 @@ loadExternalData opts = do
)
let (fix_msgs, nl) = checkData (cdNodes cdata) (cdInstances cdata)
unless (null fix_msgs || optVerbose opts == 0) $ do
hPutStrLn stderr "Warning: cluster has inconsistent data:"
hPutStrLn stderr . unlines . map (printf " - %s") $ fix_msgs
unless (optVerbose opts == 0) $ maybeShowWarnings fix_msgs
return cdata {cdNodes = nl}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment