Revision 63a78055

b/htools/Ganeti/HTools/Cluster.hs
74 74
    ) where
75 75

  
76 76
import Data.Function (on)
77
import qualified Data.IntSet as IntSet
77 78
import Data.List
78 79
import Data.Ord (comparing)
79 80
import Text.Printf (printf)
......
1103 1104
associateIdxs idxs =
1104 1105
    map (\(gdx, (nl, il)) ->
1105 1106
             (gdx, (nl, il, filter (`Container.member` il) idxs)))
1107

  
1108
-- | Compute the list of nodes that are to be evacuated, given a list
1109
-- of instances and an evacuation mode.
1110
nodesToEvacuate :: Instance.List -- ^ The cluster-wide instance list
1111
                -> EvacMode      -- ^ The evacuation mode we're using
1112
                -> [Idx]         -- ^ List of instance indices being evacuated
1113
                -> IntSet.IntSet -- ^ Set of node indices
1114
nodesToEvacuate il mode =
1115
    IntSet.delete Node.noSecondary .
1116
    foldl' (\ns idx ->
1117
                let i = Container.find idx il
1118
                    pdx = Instance.pNode i
1119
                    sdx = Instance.sNode i
1120
                    dt = Instance.diskTemplate i
1121
                    withSecondary = case dt of
1122
                                      DTDrbd8 -> IntSet.insert sdx ns
1123
                                      _ -> ns
1124
                in case mode of
1125
                     ChangePrimary   -> IntSet.insert pdx ns
1126
                     ChangeSecondary -> withSecondary
1127
                     ChangeAll       -> IntSet.insert pdx withSecondary
1128
           ) IntSet.empty

Also available in: Unified diff