Revision 6d0bc5ca

b/Ganeti/HTools/Cluster.hs
623 623
annotateSolution as = as { asLog = describeSolution as : asLog as }
624 624

  
625 625
-- | Generate the valid node allocation singles or pairs for a new instance.
626
genAllocNodes :: Node.List         -- ^ The node map
626
genAllocNodes :: Group.List        -- ^ Group list
627
              -> Node.List         -- ^ The node map
627 628
              -> Int               -- ^ The number of nodes required
629
              -> Bool              -- ^ Whether to drop or not
630
                                   -- unallocable nodes
628 631
              -> Result AllocNodes -- ^ The (monadic) result
629
genAllocNodes nl count =
630
    let all_nodes = getOnline nl
632
genAllocNodes gl nl count drop_unalloc =
633
    let filter_fn = if drop_unalloc
634
                    then filter ((/=) AllocUnallocable . Group.allocPolicy .
635
                                     flip Container.find gl . Node.group)
636
                    else id
637
        all_nodes = filter_fn $ getOnline nl
631 638
        all_pairs = liftM2 (,) all_nodes all_nodes
632 639
        ok_pairs = filter (\(x, y) -> Node.idx x /= Node.idx y &&
633 640
                                      Node.group x == Node.group y) all_pairs
......
703 710
  let groups = splitCluster mgnl mgil
704 711
      -- TODO: currently we consider all groups preferred
705 712
      sols = map (\(gid, (nl, il)) ->
706
                   (gid, genAllocNodes nl cnt >>= tryAlloc nl il inst))
713
                   (gid, genAllocNodes mggl nl cnt False >>=
714
                       tryAlloc nl il inst))
707 715
             groups::[(Gdx, Result AllocSolution)]
708 716
      all_msgs = concatMap (solutionDescription mggl) sols
709 717
      goodSols = filterMGResults mggl sols
b/Ganeti/HTools/QC.hs
684 684
    let nl = makeSmallCluster node count
685 685
        il = Container.empty
686 686
        inst' = setInstanceSmallerThanNode node inst
687
    in case Cluster.genAllocNodes nl 2 >>= Cluster.tryAlloc nl il inst' of
687
    in case Cluster.genAllocNodes defGroupList nl 2 True >>=
688
       Cluster.tryAlloc nl il inst' of
688 689
         Types.Bad _ -> False
689 690
         Types.Ok as ->
690 691
             case Cluster.asSolutions as of
......
707 708
            ==>
708 709
    let nl = makeSmallCluster node count
709 710
        il = Container.empty
710
        allocnodes = Cluster.genAllocNodes nl rqnodes
711
        allocnodes = Cluster.genAllocNodes defGroupList nl rqnodes True
711 712
    in case allocnodes >>= \allocnodes' ->
712 713
        Cluster.tieredAlloc nl il inst allocnodes' [] [] of
713 714
         Types.Bad _ -> False
......
726 727
    let nl = makeSmallCluster node count
727 728
        il = Container.empty
728 729
        inst' = setInstanceSmallerThanNode node inst
729
    in case Cluster.genAllocNodes nl 2 >>= Cluster.tryAlloc nl il inst' of
730
    in case Cluster.genAllocNodes defGroupList nl 2 True >>=
731
       Cluster.tryAlloc nl il inst' of
730 732
         Types.Bad _ -> False
731 733
         Types.Ok as ->
732 734
             case Cluster.asSolutions as of
......
751 753
    let nl = makeSmallCluster node count
752 754
        (hnode, nl') = IntMap.deleteFindMax nl
753 755
        il = Container.empty
754
        allocnodes = Cluster.genAllocNodes nl' 2
756
        allocnodes = Cluster.genAllocNodes defGroupList nl' 2 True
755 757
        i_templ = createInstance Types.unitMem Types.unitDsk Types.unitCpu
756 758
    in case allocnodes >>= \allocnodes' ->
757 759
        Cluster.iterateAlloc nl' il i_templ allocnodes' [] [] of
b/hspace.hs
290 290

  
291 291
  let reqinst = iofspec ispec
292 292

  
293
  allocnodes <- exitifbad $ Cluster.genAllocNodes nl req_nodes
293
  allocnodes <- exitifbad $ Cluster.genAllocNodes gl nl req_nodes True
294 294

  
295 295
  -- Run the tiered allocation, if enabled
296 296

  

Also available in: Unified diff