diff --git a/htools/Ganeti/HTools/CLI.hs b/htools/Ganeti/HTools/CLI.hs index cc150c8e5562a36ca100f3d48418e7db1ed7b06a..464afe8713e81177c1165188f455bfe98fb658b8 100644 --- a/htools/Ganeti/HTools/CLI.hs +++ b/htools/Ganeti/HTools/CLI.hs @@ -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 diff --git a/htools/Ganeti/HTools/ExtLoader.hs b/htools/Ganeti/HTools/ExtLoader.hs index 435d3686d53fc8699b7c75783e6d246a2dfdbd78..06cd7df51bd320b12c5c555cc129789e78efea02 100644 --- a/htools/Ganeti/HTools/ExtLoader.hs +++ b/htools/Ganeti/HTools/ExtLoader.hs @@ -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}