Revision d72ff6c3

b/htools/Ganeti/HTools/Cluster.hs
749 749
    in sortBy (comparing solScore) sols
750 750

  
751 751
-- | Finds the best group for an instance on a multi-group cluster.
752
--
753
-- Only solutions in @preferred@ and @last_resort@ groups will be
754
-- accepted as valid, and additionally if the allowed groups parameter
755
-- is not null then allocation will only be run for those group
756
-- indices.
752 757
findBestAllocGroup :: Group.List           -- ^ The group list
753 758
                   -> Node.List            -- ^ The node list
754 759
                   -> Instance.List        -- ^ The instance list
760
                   -> Maybe [Gdx]          -- ^ The allowed groups
755 761
                   -> Instance.Instance    -- ^ The instance to allocate
756 762
                   -> Int                  -- ^ Required number of nodes
757 763
                   -> Result (Gdx, AllocSolution, [String])
758
findBestAllocGroup mggl mgnl mgil inst cnt =
764
findBestAllocGroup mggl mgnl mgil allowed_gdxs inst cnt =
759 765
  let groups = splitCluster mgnl mgil
766
      groups' = maybe groups (\gs -> filter ((`elem` gs) . fst) groups)
767
                allowed_gdxs
760 768
      sols = map (\(gid, (nl, il)) ->
761 769
                   (gid, genAllocNodes mggl nl cnt False >>=
762 770
                       tryAlloc nl il inst))
763
             groups::[(Gdx, Result AllocSolution)]
771
             groups'::[(Gdx, Result AllocSolution)]
764 772
      all_msgs = concatMap (solutionDescription mggl) sols
765 773
      goodSols = filterMGResults mggl sols
766 774
      sortedSols = sortMGResults mggl goodSols
......
778 786
           -> Result AllocSolution -- ^ Possible solution list
779 787
tryMGAlloc mggl mgnl mgil inst cnt = do
780 788
  (best_group, solution, all_msgs) <-
781
      findBestAllocGroup mggl mgnl mgil inst cnt
789
      findBestAllocGroup mggl mgnl mgil Nothing inst cnt
782 790
  let group_name = Group.name $ Container.find best_group mggl
783 791
      selmsg = "Selected group: " ++ group_name
784 792
  return $ solution { asLog = selmsg:all_msgs }

Also available in: Unified diff