Revision 8fd09137 htools/Ganeti/HTools/Cluster.hs

b/htools/Ganeti/HTools/Cluster.hs
748 748
                               (extractScore . head . asSolutions) sol)
749 749
    in sortBy (comparing solScore) sols
750 750

  
751
-- | Try to allocate an instance on a multi-group cluster.
752
tryMGAlloc :: Group.List           -- ^ The group list
753
           -> Node.List            -- ^ The node list
754
           -> Instance.List        -- ^ The instance list
755
           -> Instance.Instance    -- ^ The instance to allocate
756
           -> Int                  -- ^ Required number of nodes
757
           -> Result AllocSolution -- ^ Possible solution list
758
tryMGAlloc mggl mgnl mgil inst cnt =
751
-- | Finds the best group for an instance on a multi-group cluster.
752
findBestAllocGroup :: Group.List           -- ^ The group list
753
                   -> Node.List            -- ^ The node list
754
                   -> Instance.List        -- ^ The instance list
755
                   -> Instance.Instance    -- ^ The instance to allocate
756
                   -> Int                  -- ^ Required number of nodes
757
                   -> Result (Gdx, AllocSolution, [String])
758
findBestAllocGroup mggl mgnl mgil inst cnt =
759 759
  let groups = splitCluster mgnl mgil
760 760
      sols = map (\(gid, (nl, il)) ->
761 761
                   (gid, genAllocNodes mggl nl cnt False >>=
......
767 767
  in if null sortedSols
768 768
     then Bad $ intercalate ", " all_msgs
769 769
     else let (final_group, final_sol) = head sortedSols
770
              final_name = Group.name $ Container.find final_group mggl
771
              selmsg = "Selected group: " ++  final_name
772
          in Ok $ final_sol { asLog = selmsg:all_msgs }
770
          in return (final_group, final_sol, all_msgs)
771

  
772
-- | Try to allocate an instance on a multi-group cluster.
773
tryMGAlloc :: Group.List           -- ^ The group list
774
           -> Node.List            -- ^ The node list
775
           -> Instance.List        -- ^ The instance list
776
           -> Instance.Instance    -- ^ The instance to allocate
777
           -> Int                  -- ^ Required number of nodes
778
           -> Result AllocSolution -- ^ Possible solution list
779
tryMGAlloc mggl mgnl mgil inst cnt = do
780
  (best_group, solution, all_msgs) <-
781
      findBestAllocGroup mggl mgnl mgil inst cnt
782
  let group_name = Group.name $ Container.find best_group mggl
783
      selmsg = "Selected group: " ++ group_name
784
  return $ solution { asLog = selmsg:all_msgs }
773 785

  
774 786
-- | Try to relocate an instance on the cluster.
775 787
tryReloc :: (Monad m) =>

Also available in: Unified diff