Revision 241cea1e
b/src/Ganeti/HTools/Backend/IAlloc.hs | ||
---|---|---|
65 | 65 |
-> JSRecord |
66 | 66 |
-> Result (String, Instance.Instance) |
67 | 67 |
parseBaseInstance n a = do |
68 |
let extract x = tryFromObj ("invalid data for instance '" ++ n ++ "'") a x |
|
68 |
let errorMessage = "invalid data for instance '" ++ n ++ "'" |
|
69 |
let extract x = tryFromObj errorMessage a x |
|
69 | 70 |
disk <- extract "disk_space_total" |
71 |
disks <- extract "disks" >>= toArray >>= asObjectList >>= |
|
72 |
mapM (flip (tryFromObj errorMessage) "size" . fromJSObject) |
|
70 | 73 |
mem <- extract "memory" |
71 | 74 |
vcpus <- extract "vcpus" |
72 | 75 |
tags <- extract "tags" |
73 | 76 |
dt <- extract "disk_template" |
74 | 77 |
su <- extract "spindle_use" |
75 |
return (n, Instance.create n mem disk vcpus Running tags True 0 0 dt su) |
|
78 |
return (n, Instance.create n mem disk disks vcpus Running tags True 0 0 dt su)
|
|
76 | 79 |
|
77 | 80 |
-- | Parses an instance as found in the cluster instance list. |
78 | 81 |
parseInstance :: NameAssoc -- ^ The node name-to-index association list |
b/src/Ganeti/HTools/Backend/Luxi.hs | ||
---|---|---|
172 | 172 |
xauto_balance <- convert "auto_balance" auto_balance |
173 | 173 |
xdt <- convert "disk_template" disk_template |
174 | 174 |
xsu <- convert "be/spindle_use" su |
175 |
let inst = Instance.create xname xmem xdisk xvcpus |
|
175 |
let inst = Instance.create xname xmem xdisk [xdisk] xvcpus
|
|
176 | 176 |
xrunning xtags xauto_balance xpnode snode xdt xsu |
177 | 177 |
return (xname, inst) |
178 | 178 |
|
b/src/Ganeti/HTools/Backend/Rapi.hs | ||
---|---|---|
130 | 130 |
let owner_name = "Instance '" ++ name ++ "', error while parsing data" |
131 | 131 |
let extract s x = tryFromObj owner_name x s |
132 | 132 |
disk <- extract "disk_usage" a |
133 |
disks <- extract "disk.sizes" a |
|
133 | 134 |
beparams <- liftM fromJSObject (extract "beparams" a) |
134 | 135 |
omem <- extract "oper_ram" a |
135 | 136 |
mem <- case omem of |
... | ... | |
146 | 147 |
auto_balance <- extract "auto_balance" beparams |
147 | 148 |
dt <- extract "disk_template" a |
148 | 149 |
su <- extract "spindle_use" beparams |
149 |
let inst = Instance.create name mem disk vcpus running tags |
|
150 |
let inst = Instance.create name mem disk disks vcpus running tags
|
|
150 | 151 |
auto_balance pnode snode dt su |
151 | 152 |
return (name, inst) |
152 | 153 |
|
b/src/Ganeti/HTools/Backend/Text.hs | ||
---|---|---|
230 | 230 |
when (sidx == pidx) . fail $ "Instance " ++ name ++ |
231 | 231 |
" has same primary and secondary node - " ++ pnode |
232 | 232 |
let vtags = commaSplit tags |
233 |
newinst = Instance.create name vmem vdsk vvcpus vstatus vtags |
|
233 |
newinst = Instance.create name vmem vdsk [vdsk] vvcpus vstatus vtags
|
|
234 | 234 |
auto_balance pidx sidx disk_template spindle_use |
235 | 235 |
return (name, newinst) |
236 | 236 |
|
b/src/Ganeti/HTools/Instance.hs | ||
---|---|---|
163 | 163 |
-- |
164 | 164 |
-- Some parameters are not initialized by function, and must be set |
165 | 165 |
-- later (via 'setIdx' for example). |
166 |
create :: String -> Int -> Int -> Int -> T.InstanceStatus |
|
166 |
create :: String -> Int -> Int -> [Int] -> Int -> T.InstanceStatus
|
|
167 | 167 |
-> [String] -> Bool -> T.Ndx -> T.Ndx -> T.DiskTemplate -> Int |
168 | 168 |
-> Instance |
169 |
create name_init mem_init dsk_init vcpus_init run_init tags_init |
|
169 |
create name_init mem_init dsk_init disks_init vcpus_init run_init tags_init
|
|
170 | 170 |
auto_balance_init pn sn dt su = |
171 | 171 |
Instance { name = name_init |
172 | 172 |
, alias = name_init |
173 | 173 |
, mem = mem_init |
174 | 174 |
, dsk = dsk_init |
175 |
, disks = [dsk_init]
|
|
175 |
, disks = disks_init
|
|
176 | 176 |
, vcpus = vcpus_init |
177 | 177 |
, runSt = run_init |
178 | 178 |
, pNode = pn |
b/src/Ganeti/HTools/Program/Hspace.hs | ||
---|---|---|
390 | 390 |
return (sortReasons reasons, new_nl, length new_ixes, tieredSpecMap new_ixes) |
391 | 391 |
|
392 | 392 |
-- | Create an instance from a given spec. |
393 |
-- For values not implied by the resorce specification (like distribution of |
|
394 |
-- of the disk space to individual disks), sensible defaults are guessed (e.g., |
|
395 |
-- having a single disk). |
|
393 | 396 |
instFromSpec :: RSpec -> DiskTemplate -> Int -> Instance.Instance |
394 | 397 |
instFromSpec spx = |
395 |
Instance.create "new" (rspecMem spx) (rspecDsk spx) |
|
398 |
Instance.create "new" (rspecMem spx) (rspecDsk spx) [rspecDsk spx]
|
|
396 | 399 |
(rspecCpu spx) Running [] True (-1) (-1) |
397 | 400 |
|
398 | 401 |
-- | Main function. |
b/test/hs/Test/Ganeti/HTools/Instance.hs | ||
---|---|---|
62 | 62 |
sn <- arbitrary |
63 | 63 |
vcpus <- choose (0, lim_cpu) |
64 | 64 |
dt <- arbitrary |
65 |
return $ Instance.create name mem dsk vcpus run_st [] True pn sn dt 1 |
|
65 |
return $ Instance.create name mem dsk [dsk] vcpus run_st [] True pn sn dt 1
|
|
66 | 66 |
|
67 | 67 |
-- | Generates an instance smaller than a node. |
68 | 68 |
genInstanceSmallerThanNode :: Node.Node -> Gen Instance.Instance |
b/test/hs/Test/Ganeti/TestHTools.hs | ||
---|---|---|
96 | 96 |
-- | Create an instance given its spec. |
97 | 97 |
createInstance :: Int -> Int -> Int -> Instance.Instance |
98 | 98 |
createInstance mem dsk vcpus = |
99 |
Instance.create "inst-unnamed" mem dsk vcpus Types.Running [] True (-1) (-1)
|
|
100 |
Types.DTDrbd8 1 |
|
99 |
Instance.create "inst-unnamed" mem dsk [dsk] vcpus Types.Running [] True (-1)
|
|
100 |
(-1) Types.DTDrbd8 1
|
|
101 | 101 |
|
102 | 102 |
-- | Create a small cluster by repeating a node spec. |
103 | 103 |
makeSmallCluster :: Node.Node -> Int -> Node.List |
Also available in: Unified diff