Skip to content
Snippets Groups Projects
Commit 2ef8013f authored by Iustin Pop's avatar Iustin Pop Committed by Michael Hanselmann
Browse files

hspace: add short forms for the group policy


This adds a shortened versions of the allocation policies, as writing
out the whole name in the command line can become tedious.

Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarAgata Murawska <agatamurawska@google.com>
parent 1d8a7812
No related merge requests found
......@@ -31,6 +31,7 @@ module Ganeti.HTools.Simu
, parseData
) where
import Control.Monad (mplus)
import Text.Printf (printf)
import Ganeti.HTools.Utils
......@@ -40,12 +41,20 @@ import qualified Ganeti.HTools.Container as Container
import qualified Ganeti.HTools.Group as Group
import qualified Ganeti.HTools.Node as Node
-- | Parse a shortened policy string (for command line usage).
apolAbbrev :: String -> Result AllocPolicy
apolAbbrev c | c == "p" = return AllocPreferred
| c == "a" = return AllocLastResort
| c == "u" = return AllocUnallocable
| otherwise = fail $ "Cannot parse AllocPolicy abbreviation '"
++ c ++ "'"
-- | Parse the string description into nodes.
parseDesc :: String -> Result (AllocPolicy, Int, Int, Int, Int)
parseDesc desc =
case sepSplit ',' desc of
[a, n, d, m, c] -> do
apol <- apolFromString a
apol <- apolFromString a `mplus` apolAbbrev a
ncount <- tryRead "node count" n
disk <- annotateResult "disk size" (parseUnit d)
mem <- annotateResult "memory size" (parseUnit m)
......
......@@ -282,7 +282,8 @@ The options that can be passed to the program are as follows:
description. The *description* parameter must be a comma-separated
list of five elements, describing in order:
- the allocation policy for this node group
- the allocation policy for this node group (*preferred*, *allocable*
or *unallocable*, or alternatively the short forms *p*, *a* or *u*)
- the number of nodes in the cluster
- the disk size of the nodes (default in mebibytes, units can be used)
- the memory size of the nodes (default in mebibytes, units can be used)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment