Revision 4bc33d60

b/Ganeti/HTools/Cluster.hs
7 7

  
8 8
{-
9 9

  
10
Copyright (C) 2009, 2010 Google Inc.
10
Copyright (C) 2009, 2010, 2011 Google Inc.
11 11

  
12 12
This program is free software; you can redistribute it and/or modify
13 13
it under the terms of the GNU General Public License as published by
......
58 58
    , tryAlloc
59 59
    , tryMGAlloc
60 60
    , tryReloc
61
    , tryMGReloc
61 62
    , tryEvac
62 63
    , collapseFailures
63 64
    -- * Allocation functions
......
718 719
                                \destinations required (" ++ show reqn ++
719 720
                                                  "), only one supported"
720 721

  
722
tryMGReloc :: (Monad m) =>
723
              Group.List      -- ^ The group list
724
           -> Node.List       -- ^ The node list
725
           -> Instance.List   -- ^ The instance list
726
           -> Idx             -- ^ The index of the instance to move
727
           -> Int             -- ^ The number of nodes required
728
           -> [Ndx]           -- ^ Nodes which should not be used
729
           -> m AllocSolution -- ^ Solution list
730
tryMGReloc _ mgnl mgil xid ncount ex_ndx = do
731
  let groups = splitCluster mgnl mgil
732
      -- TODO: we only relocate inside the group for now
733
      inst = Container.find xid mgil
734
  (nl, il) <- case lookup (instancePriGroup mgnl inst) groups of
735
                Nothing -> fail $ "Cannot find group for instance " ++
736
                           Instance.name inst
737
                Just v -> return v
738
  tryReloc nl il xid ncount ex_ndx
739

  
721 740
-- | Try to evacuate a list of nodes.
722 741
tryEvac :: (Monad m) =>
723 742
            Node.List       -- ^ The node list
......
984 1003
                show pgroup ++ ", secondary " ++ show sgroup)
985 1004
     else return pgroup
986 1005

  
1006
-- | Computes the group of an instance per the primary node
1007
instancePriGroup :: Node.List -> Instance.Instance -> Gdx
1008
instancePriGroup nl i =
1009
  let pnode = Container.find (Instance.pNode i) nl
1010
  in  Node.group pnode
1011

  
987 1012
-- | Compute the list of badly allocated instances (split across node
988 1013
-- groups)
989 1014
findSplitInstances :: Node.List -> Instance.List -> [Instance.Instance]
b/hail.hs
4 4

  
5 5
{-
6 6

  
7
Copyright (C) 2009, 2010 Google Inc.
7
Copyright (C) 2009, 2010, 2011 Google Inc.
8 8

  
9 9
This program is free software; you can redistribute it and/or modify
10 10
it under the terms of the GNU General Public License as published by
......
71 71
  let Request rqtype (ClusterData gl nl il _) = request
72 72
  in case rqtype of
73 73
       Allocate xi reqn -> Cluster.tryMGAlloc gl nl il xi reqn
74
       Relocate idx reqn exnodes -> Cluster.tryReloc nl il idx reqn exnodes
74
       Relocate idx reqn exnodes -> Cluster.tryMGReloc gl nl il
75
                                    idx reqn exnodes
75 76
       Evacuate exnodes -> Cluster.tryEvac nl il exnodes
76 77

  
77 78
-- | Reads the request from the data file(s)

Also available in: Unified diff