Revision 2ef8013f htools/Ganeti/HTools/Simu.hs

b/htools/Ganeti/HTools/Simu.hs
31 31
    , parseData
32 32
    ) where
33 33

  
34
import Control.Monad (mplus)
34 35
import Text.Printf (printf)
35 36

  
36 37
import Ganeti.HTools.Utils
......
40 41
import qualified Ganeti.HTools.Group as Group
41 42
import qualified Ganeti.HTools.Node as Node
42 43

  
44
-- | Parse a shortened policy string (for command line usage).
45
apolAbbrev :: String -> Result AllocPolicy
46
apolAbbrev c | c == "p"  = return AllocPreferred
47
             | c == "a"  = return AllocLastResort
48
             | c == "u"  = return AllocUnallocable
49
             | otherwise = fail $ "Cannot parse AllocPolicy abbreviation '"
50
                           ++ c ++ "'"
51

  
43 52
-- | Parse the string description into nodes.
44 53
parseDesc :: String -> Result (AllocPolicy, Int, Int, Int, Int)
45 54
parseDesc desc =
46 55
    case sepSplit ',' desc of
47 56
      [a, n, d, m, c] -> do
48
        apol <- apolFromString a
57
        apol <- apolFromString a `mplus` apolAbbrev a
49 58
        ncount <- tryRead "node count" n
50 59
        disk <- annotateResult "disk size" (parseUnit d)
51 60
        mem <- annotateResult "memory size" (parseUnit m)

Also available in: Unified diff