Revision 8a3b30ca Ganeti/HTools/Cluster.hs

b/Ganeti/HTools/Cluster.hs
202 202
        runa = RSpec un_cpu (truncate t_mem - f_imem) (truncate t_dsk - f_idsk)
203 203
    in (rini, rfin, runa)
204 204

  
205
-- | The names of the individual elements in the CV list
206
detailedCVNames :: [String]
207
detailedCVNames = [ "free_mem_cv"
208
                  , "free_disk_cv"
209
                  , "n1_cnt"
210
                  , "reserved_mem_cv"
211
                  , "offline_all_cnt"
212
                  , "offline_pri_cnt"
213
                  , "vcpu_ratio_cv"
214
                  , "cpu_load_cv"
215
                  , "mem_load_cv"
216
                  , "disk_load_cv"
217
                  , "net_load_cv"
218
                  , "pri_tags_score"
219
                  ]
205
-- | The names and weights of the individual elements in the CV list
206
detailedCVInfo :: [(Double, String)]
207
detailedCVInfo = [ (1,  "free_mem_cv")
208
                 , (1,  "free_disk_cv")
209
                 , (1,  "n1_cnt")
210
                 , (1,  "reserved_mem_cv")
211
                 , (4,  "offline_all_cnt")
212
                 , (16, "offline_pri_cnt")
213
                 , (1,  "vcpu_ratio_cv")
214
                 , (1,  "cpu_load_cv")
215
                 , (1,  "mem_load_cv")
216
                 , (1,  "disk_load_cv")
217
                 , (1,  "net_load_cv")
218
                 , (1,  "pri_tags_score")
219
                 ]
220

  
221
detailedCVWeights :: [Double]
222
detailedCVWeights = map fst detailedCVInfo
220 223

  
221 224
-- | Compute the mem and disk covariance.
222 225
compDetailedCV :: Node.List -> [Double]
......
265 268

  
266 269
-- | Compute the /total/ variance.
267 270
compCV :: Node.List -> Double
268
compCV = sum . compDetailedCV
271
compCV = sum . zipWith (*) detailedCVWeights . compDetailedCV
269 272

  
270 273
-- | Compute online nodes from a Node.List
271 274
getOnline :: Node.List -> [Node.Node]
......
797 800
printStats :: Node.List -> String
798 801
printStats nl =
799 802
    let dcvs = compDetailedCV nl
800
        hd = zip (detailedCVNames ++ repeat "unknown") dcvs
801
        formatted = map (\(header, val) ->
802
                             printf "%s=%.8f" header val::String) hd
803
        (weights, names) = unzip detailedCVInfo
804
        hd = zip3 (weights ++ repeat 1) (names ++ repeat "unknown") dcvs
805
        formatted = map (\(w, header, val) ->
806
                             printf "%s=%.8f(x%.2f)" header val w::String) hd
803 807
    in intercalate ", " formatted
804 808

  
805 809
-- | Convert a placement into a list of OpCodes (basically a job).

Also available in: Unified diff