Revision 55bd1414 htools/Ganeti/HTools/Node.hs

b/htools/Ganeti/HTools/Node.hs
273 273
buildPeers t il =
274 274
  let mdata = map
275 275
              (\i_idx -> let inst = Container.find i_idx il
276
                             mem = if Instance.autoBalance inst
276
                             mem = if Instance.usesSecMem inst
277 277
                                     then Instance.mem inst
278 278
                                     else 0
279 279
                         in (Instance.pNode inst, mem))
......
293 293
                  , utilLoad = utilLoad t `T.addUtil` Instance.util inst
294 294
                  , pTags = addTags (pTags t) (Instance.tags inst)
295 295
                  }
296
  where new_count = uCpu t + Instance.vcpus inst
296
  where new_count = Instance.applyIfOnline inst (+ Instance.vcpus inst)
297
                    (uCpu t )
297 298

  
298 299
-- | Assigns an instance to a node as secondary without other updates.
299 300
setSec :: Node -> Instance.Instance -> Node
......
343 344
                  else cur_dsk
344 345
      old_peers = peers t
345 346
      old_peem = P.find pnode old_peers
346
      new_peem =  if Instance.autoBalance inst
347
      new_peem =  if Instance.usesSecMem inst
347 348
                    then old_peem - Instance.mem inst
348 349
                    else old_peem
349 350
      new_peers = if new_peem > 0
......
423 424
      old_peers = peers t
424 425
      old_mem = fMem t
425 426
      new_dsk = fDsk t - Instance.dsk inst
426
      secondary_needed_mem = if Instance.autoBalance inst &&
427
                             not (Instance.instanceOffline inst)
427
      secondary_needed_mem = if Instance.usesSecMem inst
428 428
                               then Instance.mem inst
429 429
                               else 0
430 430
      new_peem = P.find pdx old_peers + secondary_needed_mem

Also available in: Unified diff