Revision 255f55a9 htools/Ganeti/HTools/Cluster.hs

b/htools/Ganeti/HTools/Cluster.hs
200 200
  in
201 201
    (bad_nodes, bad_instances)
202 202

  
203
-- | Extracts the node pairs for an instance. This can fail if the
204
-- instance is single-homed. FIXME: this needs to be improved,
205
-- together with the general enhancement for handling non-DRBD moves.
206
instanceNodes :: Node.List -> Instance.Instance ->
207
                 (Ndx, Ndx, Node.Node, Node.Node)
208
instanceNodes nl inst =
209
  let old_pdx = Instance.pNode inst
210
      old_sdx = Instance.sNode inst
211
      old_p = Container.find old_pdx nl
212
      old_s = Container.find old_sdx nl
213
  in (old_pdx, old_sdx, old_p, old_s)
214

  
203 215
-- | Zero-initializer for the CStats type.
204 216
emptyCStats :: CStats
205 217
emptyCStats = CStats 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
......
358 370
          -> IMove -> OpResult (Node.List, Instance.Instance, Ndx, Ndx)
359 371
-- Failover (f)
360 372
applyMove nl inst Failover =
361
  let old_pdx = Instance.pNode inst
362
      old_sdx = Instance.sNode inst
363
      old_p = Container.find old_pdx nl
364
      old_s = Container.find old_sdx nl
373
  let (old_pdx, old_sdx, old_p, old_s) = instanceNodes nl inst
365 374
      int_p = Node.removePri old_p inst
366 375
      int_s = Node.removeSec old_s inst
367 376
      force_p = Node.offline old_p
......
375 384

  
376 385
-- Replace the primary (f:, r:np, f)
377 386
applyMove nl inst (ReplacePrimary new_pdx) =
378
  let old_pdx = Instance.pNode inst
379
      old_sdx = Instance.sNode inst
380
      old_p = Container.find old_pdx nl
381
      old_s = Container.find old_sdx nl
387
  let (old_pdx, old_sdx, old_p, old_s) = instanceNodes nl inst
382 388
      tgt_n = Container.find new_pdx nl
383 389
      int_p = Node.removePri old_p inst
384 390
      int_s = Node.removeSec old_s inst
......
413 419

  
414 420
-- Replace the secondary and failover (r:np, f)
415 421
applyMove nl inst (ReplaceAndFailover new_pdx) =
416
  let old_pdx = Instance.pNode inst
417
      old_sdx = Instance.sNode inst
418
      old_p = Container.find old_pdx nl
419
      old_s = Container.find old_sdx nl
422
  let (old_pdx, old_sdx, old_p, old_s) = instanceNodes nl inst
420 423
      tgt_n = Container.find new_pdx nl
421 424
      int_p = Node.removePri old_p inst
422 425
      int_s = Node.removeSec old_s inst
......
432 435

  
433 436
-- Failver and replace the secondary (f, r:ns)
434 437
applyMove nl inst (FailoverAndReplace new_sdx) =
435
  let old_pdx = Instance.pNode inst
436
      old_sdx = Instance.sNode inst
437
      old_p = Container.find old_pdx nl
438
      old_s = Container.find old_sdx nl
438
  let (old_pdx, old_sdx, old_p, old_s) = instanceNodes nl inst
439 439
      tgt_n = Container.find new_sdx nl
440 440
      int_p = Node.removePri old_p inst
441 441
      int_s = Node.removeSec old_s inst

Also available in: Unified diff