Revision 9b8fac3d Ganeti/HTools/Cluster.hs

b/Ganeti/HTools/Cluster.hs
32 32
      AllocSolution
33 33
    , Table(..)
34 34
    , CStats(..)
35
    , AllocStats
35 36
    -- * Generic functions
36 37
    , totalResources
38
    , computeAllocationDelta
37 39
    -- * First phase functions
38 40
    , computeBadItems
39 41
    -- * Second phase functions
......
103 105
                     , csNinst :: Int   -- ^ The total number of instances
104 106
                     }
105 107

  
108
-- | Currently used, possibly to allocate, unallocable
109
type AllocStats = (RSpec, RSpec, RSpec)
110

  
106 111
-- * Utility functions
107 112

  
108 113
-- | Verifies the N+1 status and return the affected nodes.
......
179 184
    let cs = foldl' updateCStats emptyCStats . Container.elems $ nl
180 185
    in cs { csScore = compCV nl }
181 186

  
187
-- | Compute the delta between two cluster state.
188
--
189
-- This is used when doing allocations, to understand better the
190
-- available cluster resources.
191
computeAllocationDelta :: CStats -> CStats -> AllocStats
192
computeAllocationDelta cini cfin =
193
    let CStats {csImem = i_imem, csIdsk = i_idsk, csIcpu = i_icpu} = cini
194
        CStats {csImem = f_imem, csIdsk = f_idsk, csIcpu = f_icpu,
195
                csTmem = t_mem, csTdsk = t_dsk, csVcpu = v_cpu } = cfin
196
        rini = RSpec i_icpu i_imem i_idsk
197
        rfin = RSpec f_icpu f_imem f_idsk
198
        un_cpu = if v_cpu == Node.noLimitInt
199
                 then Node.noLimitInt
200
                 else v_cpu - f_icpu
201
        runa = RSpec un_cpu (truncate t_mem - f_imem) (truncate t_dsk - f_idsk)
202
    in (rini, rfin, runa)
203

  
182 204
-- | The names of the individual elements in the CV list
183 205
detailedCVNames :: [String]
184 206
detailedCVNames = [ "free_mem_cv"

Also available in: Unified diff