Revision 7eda951b

b/htools/Ganeti/HTools/Cluster.hs
34 34
    , Table(..)
35 35
    , CStats(..)
36 36
    , AllocStats
37
    , AllocMethod
37 38
    -- * Generic functions
38 39
    , totalResources
39 40
    , computeAllocationDelta
......
165 166
-- | Currently used, possibly to allocate, unallocable.
166 167
type AllocStats = (RSpec, RSpec, RSpec)
167 168

  
169
-- | A simple type for allocation functions.
170
type AllocMethod =  Node.List           -- ^ Node list
171
                 -> Instance.List       -- ^ Instance list
172
                 -> Maybe Int           -- ^ Optional allocation limit
173
                 -> Instance.Instance   -- ^ Instance spec for allocation
174
                 -> AllocNodes          -- ^ Which nodes we should allocate on
175
                 -> [Instance.Instance] -- ^ Allocated instances
176
                 -> [CStats]            -- ^ Running cluster stats
177
                 -> Result AllocResult  -- ^ Allocation result
178

  
168 179
-- * Utility functions
169 180

  
170 181
-- | Verifies the N+1 status and return the affected nodes.
......
1145 1156
            (map (`Container.find` ini_il) idxs)
1146 1157
    in return (fin_nl, fin_il, reverseEvacSolution esol)
1147 1158

  
1148
-- | Recursively place instances on the cluster until we're out of space.
1149
iterateAlloc :: Node.List
1150
             -> Instance.List
1151
             -> Maybe Int
1152
             -> Instance.Instance
1153
             -> AllocNodes
1154
             -> [Instance.Instance]
1155
             -> [CStats]
1156
             -> Result AllocResult
1159
-- | Standard-sized allocation method.
1160
--
1161
-- This places instances of the same size on the cluster until we're
1162
-- out of space. The result will be a list of identically-sized
1163
-- instances.
1164
iterateAlloc :: AllocMethod
1157 1165
iterateAlloc nl il limit newinst allocnodes ixes cstats =
1158 1166
      let depth = length ixes
1159 1167
          newname = printf "new-%d" depth::String
......
1173 1181
                          newlimit newinst allocnodes (xi:ixes)
1174 1182
                          (totalResources xnl:cstats)
1175 1183

  
1176
-- | The core of the tiered allocation mode.
1177
tieredAlloc :: Node.List
1178
            -> Instance.List
1179
            -> Maybe Int
1180
            -> Instance.Instance
1181
            -> AllocNodes
1182
            -> [Instance.Instance]
1183
            -> [CStats]
1184
            -> Result AllocResult
1184
-- | Tiered allocation method.
1185
--
1186
-- This places instances on the cluster, and decreases the spec until
1187
-- we can allocate again. The result will be a list of decreasing
1188
-- instance specs.
1189
tieredAlloc :: AllocMethod
1185 1190
tieredAlloc nl il limit newinst allocnodes ixes cstats =
1186 1191
    case iterateAlloc nl il limit newinst allocnodes ixes cstats of
1187 1192
      Bad s -> Bad s

Also available in: Unified diff