Revision 4c18f468
b/htools/Ganeti/HTools/Node.hs | ||
---|---|---|
315 | 315 |
new_prem = fromIntegral new_rmem / tMem t |
316 | 316 |
in t {peers=pmap, failN1 = new_failN1, rMem = new_rmem, pRem = new_prem} |
317 | 317 |
|
318 |
-- | Calculate the new spindle usage |
|
319 |
calcSpindleUsage :: Node -> Instance.Instance -> Double |
|
320 |
calcSpindleUsage n i = incIf (Instance.usesLocalStorage i) (instSpindles n) |
|
321 |
(fromIntegral $ Instance.spindleUsage i) |
|
322 |
|
|
318 | 323 |
-- | Assigns an instance to a node as primary and update the used VCPU |
319 | 324 |
-- count, utilisation data and tags map. |
320 | 325 |
setPri :: Node -> Instance.Instance -> Node |
... | ... | |
323 | 328 |
, pCpu = fromIntegral new_count / tCpu t |
324 | 329 |
, utilLoad = utilLoad t `T.addUtil` Instance.util inst |
325 | 330 |
, pTags = addTags (pTags t) (Instance.tags inst) |
326 |
, instSpindles = new_spindles
|
|
331 |
, instSpindles = calcSpindleUsage t inst
|
|
327 | 332 |
} |
328 | 333 |
where new_count = Instance.applyIfOnline inst (+ Instance.vcpus inst) |
329 | 334 |
(uCpu t ) |
330 |
new_spindles = instSpindles t + if Instance.usesLocalStorage inst |
|
331 |
then 1 else 0 |
|
332 | 335 |
|
333 | 336 |
-- | Assigns an instance to a node as secondary without other updates. |
334 | 337 |
setSec :: Node -> Instance.Instance -> Node |
335 | 338 |
setSec t inst = t { sList = Instance.idx inst:sList t |
336 | 339 |
, utilLoad = old_load { T.dskWeight = T.dskWeight old_load + |
337 | 340 |
T.dskWeight (Instance.util inst) } |
338 |
, instSpindles = new_spindles
|
|
341 |
, instSpindles = calcSpindleUsage t inst
|
|
339 | 342 |
} |
340 | 343 |
where old_load = utilLoad t |
341 |
new_spindles = instSpindles t + if Instance.usesLocalStorage inst |
|
342 |
then 1 else 0 |
|
343 | 344 |
|
344 | 345 |
-- | Computes the new 'pDsk' value, handling nodes without local disk |
345 | 346 |
-- storage (we consider all their disk used). |
Also available in: Unified diff