Revision f25e5aac Ganeti/HTools/Cluster.hs

b/Ganeti/HTools/Cluster.hs
46 46
    , printNodes
47 47
    -- * Balacing functions
48 48
    , checkMove
49
    , tryBalance
49 50
    , compCV
50 51
    , printStats
51 52
    -- * IAllocator functions
......
442 443
      else
443 444
          best_tbl
444 445

  
446
-- | Run a balance move
447

  
448
tryBalance :: Table       -- ^ The starting table
449
           -> Int         -- ^ Remaining length
450
           -> Bool        -- ^ Allow disk moves
451
           -> Score       -- ^ Score at which to stop
452
           -> Maybe Table -- ^ The resulting table and commands
453
tryBalance ini_tbl max_rounds disk_moves min_score =
454
    let Table ini_nl ini_il ini_cv ini_plc = ini_tbl
455
        ini_plc_len = length ini_plc
456
        allowed_next = (max_rounds < 0 || ini_plc_len < max_rounds) &&
457
                       ini_cv > min_score
458
    in
459
      if allowed_next
460
      then let all_inst = Container.elems ini_il
461
               node_idx = map Node.idx . filter (not . Node.offline) $
462
                          Container.elems ini_nl
463
               fin_tbl = checkMove node_idx disk_moves ini_tbl all_inst
464
               (Table _ _ fin_cv _) = fin_tbl
465
           in
466
             if fin_cv < ini_cv
467
             then Just fin_tbl -- this round made success, try deeper
468
             else Nothing
469
      else Nothing
470

  
445 471
-- * Allocation functions
446 472

  
447 473
-- | Build failure stats out of a list of failures

Also available in: Unified diff