From: Iustin Pop Date: Thu, 16 Apr 2009 09:02:48 +0000 (+0200) Subject: hbal: Abort for invalid offline node names X-Git-Tag: htools-v0.0.8~8 X-Git-Url: https://code.grnet.gr/git/ganeti-local/commitdiff_plain/3d7cd10bfc799ca2a6db1899f3afb232c8064ed5 hbal: Abort for invalid offline node names Since it's easy to pass a wrong node name as offline, we should abort instead of silently ignoring it. --- diff --git a/Ganeti/HTools/Utils.hs b/Ganeti/HTools/Utils.hs index 81d5173..d1aa975 100644 --- a/Ganeti/HTools/Utils.hs +++ b/Ganeti/HTools/Utils.hs @@ -10,6 +10,7 @@ module Ganeti.HTools.Utils , swapPairs , varianceCoeff , readData + , commaJoin ) where import Data.Either diff --git a/hbal.hs b/hbal.hs index e97b512..65c5e3f 100644 --- a/hbal.hs +++ b/hbal.hs @@ -160,9 +160,16 @@ main = do putStrLn . unlines . map (\s -> printf " - %s" s) $ fix_msgs let offline_names = optOffline opts + all_names = snd . unzip $ ktn + offline_wrong = filter (\n -> not $ elem n all_names) offline_names offline_indices = fst . unzip . filter (\(_, n) -> elem n offline_names) $ ktn + when (length offline_wrong > 0) $ do + printf "Wrong node name(s) set as offline: %s\n" + (commaJoin offline_wrong) + exitWith $ ExitFailure 1 + let nl = Container.map (\n -> if elem (Node.idx n) offline_indices then Node.setOffline n True else n) fixed_nl