Revision c324da14 src/Ganeti/HTools/Backend/Simu.hs
b/src/Ganeti/HTools/Backend/Simu.hs | ||
---|---|---|
6 | 6 |
|
7 | 7 |
{- |
8 | 8 |
|
9 |
Copyright (C) 2009, 2010, 2011, 2012 Google Inc. |
|
9 |
Copyright (C) 2009, 2010, 2011, 2012, 2013 Google Inc.
|
|
10 | 10 |
|
11 | 11 |
This program is free software; you can redistribute it and/or modify |
12 | 12 |
it under the terms of the GNU General Public License as published by |
... | ... | |
51 | 51 |
|
52 | 52 |
-- | Parse the string description into nodes. |
53 | 53 |
parseDesc :: String -> [String] |
54 |
-> Result (AllocPolicy, Int, Int, Int, Int, Int) |
|
55 |
parseDesc _ [a, n, d, m, c, s] = do |
|
54 |
-> Result (AllocPolicy, Int, Int, Int, Int, Int, Bool)
|
|
55 |
parseDesc _ [a, n, d, m, c, s, exstor] = do
|
|
56 | 56 |
apol <- allocPolicyFromRaw a `mplus` apolAbbrev a |
57 | 57 |
ncount <- tryRead "node count" n |
58 | 58 |
disk <- annotateResult "disk size" (parseUnit d) |
59 | 59 |
mem <- annotateResult "memory size" (parseUnit m) |
60 | 60 |
cpu <- tryRead "cpu count" c |
61 | 61 |
spindles <- tryRead "spindles" s |
62 |
return (apol, ncount, disk, mem, cpu, spindles) |
|
62 |
excl_stor <- tryRead "exclusive storage" exstor |
|
63 |
return (apol, ncount, disk, mem, cpu, spindles, excl_stor) |
|
63 | 64 |
|
64 | 65 |
parseDesc desc [a, n, d, m, c] = parseDesc desc [a, n, d, m, c, "1"] |
65 | 66 |
|
67 |
parseDesc desc [a, n, d, m, c, s] = parseDesc desc [a, n, d, m, c, s, "False"] |
|
68 |
|
|
66 | 69 |
parseDesc desc es = |
67 | 70 |
fail $ printf |
68 | 71 |
"Invalid cluster specification, expected 6 comma-separated\ |
... | ... | |
75 | 78 |
-> String -- ^ The group specification |
76 | 79 |
-> Result (Group.Group, [Node.Node]) |
77 | 80 |
createGroup grpIndex spec = do |
78 |
(apol, ncount, disk, mem, cpu, spindles) <- parseDesc spec $ |
|
79 |
sepSplit ',' spec |
|
81 |
(apol, ncount, disk, mem, cpu, spindles, excl_stor) <- parseDesc spec $
|
|
82 |
sepSplit ',' spec
|
|
80 | 83 |
let nodes = map (\idx -> |
81 | 84 |
flip Node.setMaster (grpIndex == 1 && idx == 1) $ |
82 | 85 |
Node.create (printf "node-%02d-%03d" grpIndex idx) |
83 | 86 |
(fromIntegral mem) 0 mem |
84 | 87 |
(fromIntegral disk) disk |
85 |
(fromIntegral cpu) False spindles grpIndex |
|
88 |
(fromIntegral cpu) False spindles grpIndex excl_stor
|
|
86 | 89 |
) [1..ncount] |
87 | 90 |
-- TODO: parse networks to which this group is connected |
88 | 91 |
grp = Group.create (printf "group-%02d" grpIndex) |
Also available in: Unified diff