## Revision 97936d51 htools/Ganeti/HTools/Cluster.hs

b/htools/Ganeti/HTools/Cluster.hs
113 113
```type AllocNodes = Either [Ndx] [(Ndx, Ndx)]
```
114 114

115 115
```-- | The empty solution we start with when computing allocations.
```
116
```emptySolution :: AllocSolution
```
117
```emptySolution = AllocSolution { asFailures = [], asAllocs = 0
```
118
```                              , asSolutions = [], asLog = [] }
```
116
```emptyAllocSolution :: AllocSolution
```
117
```emptyAllocSolution = AllocSolution { asFailures = [], asAllocs = 0
```
118
```                                   , asSolutions = [], asLog = [] }
```
119 119

120 120
```-- | The complete state for the balancing solution.
```
121 121
```data Table = Table Node.List Instance.List Score [Placement]
```
......
665 665
```tryAlloc nl _ inst (Right ok_pairs) =
```
666 666
```    let sols = foldl' (\cstate (p, s) ->
```
667 667
```                           concatAllocs cstate \$ allocateOnPair nl inst p s
```
668
```                      ) emptySolution ok_pairs
```
668
```                      ) emptyAllocSolution ok_pairs
```
669 669

670 670
```    in if null ok_pairs -- means we have just one node
```
671 671
```       then fail "Not enough online nodes"
```
......
674 674
```tryAlloc nl _ inst (Left all_nodes) =
```
675 675
```    let sols = foldl' (\cstate ->
```
676 676
```                           concatAllocs cstate . allocateOnSingle nl inst
```
677
```                      ) emptySolution all_nodes
```
677
```                      ) emptyAllocSolution all_nodes
```
678 678
```    in if null all_nodes
```
679 679
```       then fail "No online nodes"
```
680 680
```       else return \$ annotateSolution sols
```
......
758 758
```                                  return (mnl, i, [Container.find x mnl],
```
759 759
```                                          compCV mnl)
```
760 760
```                            in concatAllocs cstate em
```
761
```                       ) emptySolution valid_idxes
```
761
```                       ) emptyAllocSolution valid_idxes
```
762 762
```    in return sols1
```
763 763

764 764
```tryReloc _ _ _ reqn _  = fail \$ "Unsupported number of relocation \
```
......
819 819
```         -> [Ndx]           -- ^ Restricted nodes (the ones being evacuated)
```
820 820
```         -> m AllocSolution -- ^ Solution list
```
821 821
```tryEvac nl il idxs ex_ndx = do
```
822
```  (_, sol) <- foldM (evacInstance ex_ndx il) (nl, emptySolution) idxs
```
822
```  (_, sol) <- foldM (evacInstance ex_ndx il) (nl, emptyAllocSolution) idxs
```
823 823
```  return sol
```
824 824

825 825
```-- | Multi-group evacuation of a list of nodes.
```
......
836 836
```    in do
```
837 837
```      results <- mapM (\(_, (gnl, gil, idxs)) -> tryEvac gnl gil idxs ex_ndx)
```
838 838
```                 all_insts'
```
839
```      let sol = foldl' sumAllocs emptySolution results
```
839
```      let sol = foldl' sumAllocs emptyAllocSolution results
```
840 840
```      return \$ annotateSolution sol
```
841 841

842 842
```-- | Recursively place instances on the cluster until we're out of space.
```

Also available in: Unified diff