From 0c7d4422715c27c597da8bcc8baa3e886e36e246 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Thu, 16 Feb 2012 13:43:01 +0100 Subject: [PATCH] htools: support spindles in simu backend MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Iustin Pop <iustin@google.com> Reviewed-by: RenΓ© Nussbaumer <rn@google.com> --- htools/Ganeti/HTools/Simu.hs | 38 +++++++++++++++++++++--------------- man/htools.rst | 9 +++++---- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/htools/Ganeti/HTools/Simu.hs b/htools/Ganeti/HTools/Simu.hs index 9434e6fbf..890eae11d 100644 --- a/htools/Ganeti/HTools/Simu.hs +++ b/htools/Ganeti/HTools/Simu.hs @@ -49,32 +49,38 @@ apolAbbrev c | c == "p" = return AllocPreferred ++ 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 <- allocPolicyFromRaw a `mplus` apolAbbrev a - ncount <- tryRead "node count" n - disk <- annotateResult "disk size" (parseUnit d) - mem <- annotateResult "memory size" (parseUnit m) - cpu <- tryRead "cpu count" c - return (apol, ncount, disk, mem, cpu) - es -> fail $ printf - "Invalid cluster specification, expected 5 comma-separated\ - \ sections (allocation policy, node count, disk size,\ - \ memory size, number of CPUs) but got %d: '%s'" (length es) desc +parseDesc :: String -> [String] + -> Result (AllocPolicy, Int, Int, Int, Int, Int) +parseDesc _ [a, n, d, m, c, s] = do + apol <- allocPolicyFromRaw a `mplus` apolAbbrev a + ncount <- tryRead "node count" n + disk <- annotateResult "disk size" (parseUnit d) + mem <- annotateResult "memory size" (parseUnit m) + cpu <- tryRead "cpu count" c + spindles <- tryRead "spindles" s + return (apol, ncount, disk, mem, cpu, spindles) + +parseDesc desc [a, n, d, m, c] = parseDesc desc [a, n, d, m, c, "1"] + +parseDesc desc es = + fail $ printf + "Invalid cluster specification, expected 6 comma-separated\ + \ sections (allocation policy, node count, disk size,\ + \ memory size, number of CPUs, spindles) but got %d: '%s'" + (length es) desc -- | Creates a node group with the given specifications. createGroup :: Int -- ^ The group index -> String -- ^ The group specification -> Result (Group.Group, [Node.Node]) createGroup grpIndex spec = do - (apol, ncount, disk, mem, cpu) <- parseDesc spec + (apol, ncount, disk, mem, cpu, spindles) <- parseDesc spec $ + sepSplit ',' spec let nodes = map (\idx -> Node.create (printf "node-%02d-%03d" grpIndex idx) (fromIntegral mem) 0 mem (fromIntegral disk) disk - (fromIntegral cpu) False 1 grpIndex + (fromIntegral cpu) False spindles grpIndex ) [1..ncount] grp = Group.create (printf "group-%02d" grpIndex) (printf "fake-uuid-%02d" grpIndex) apol defIPolicy diff --git a/man/htools.rst b/man/htools.rst index 338b99c64..cc9ef3919 100644 --- a/man/htools.rst +++ b/man/htools.rst @@ -214,11 +214,12 @@ support all options. Some common options are: - 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) - the cpu core count for the nodes + - the spindle count for the nodes - An example description would be **preferred,B20,100G,16g,4** - describing a 20-node cluster where each node has 100GB of disk - space, 16GiB of memory and 4 CPU cores. Note that all nodes must - have the same specs currently. + An example description would be **preferred,B20,100G,16g,4,2** + describing a 20-node cluster where each node has 100GB of disk space, + 16GiB of memory, 4 CPU cores and 2 disk spindles. Note that all nodes + must have the same specs currently. This option can be given multiple times, and each new use defines a new node group. Hence different node groups can have different -- GitLab