Revision 7f119c27

b/htools/Ganeti/HTools/Program/Hcheck.hs
81 81
data Level = GroupLvl
82 82
           | ClusterLvl
83 83

  
84
-- | A type alias for a group index and node\/instance lists.
85
type GroupInfo = (Gdx, (Node.List, Instance.List))
86

  
87
-- | A type alias for group stats.
88
type GroupStats = ((Group.Group, Double), [Int])
89

  
84 90
-- | Prefix for machine readable names.
85 91
htcPrefix :: String
86 92
htcPrefix = "HCHECK"
......
200 206
  map show stats ++ map (printBool machineread) bstats
201 207

  
202 208
-- | Print all the statistics on a group level.
203
printGroupStats :: Int -> Bool -> Phase -> ((Group.Group, Double), [Int])
204
                -> IO ()
209
printGroupStats :: Int -> Bool -> Phase -> GroupStats -> IO ()
205 210
printGroupStats verbose machineread phase ((grp, score), stats) = do
206 211
  let values = prepareGroupValues stats score
207 212
      extradata = extractGroupData machineread grp
......
221 226
instances residing on offline nodes.
222 227

  
223 228
-}
224
perGroupChecks :: Group.List
225
               -> (Gdx, (Node.List, Instance.List))
226
               -> ((Group.Group, Double), [Int])
229
perGroupChecks :: Group.List -> GroupInfo -> GroupStats
227 230
perGroupChecks gl (gidx, (nl, il)) =
228 231
  let grp = Container.find gidx gl
229 232
      offnl = filter Node.offline (Container.elems nl)
......
243 246
-- | Use Hbal's iterateDepth to simulate group rebalance.
244 247
executeSimulation :: Options -> Cluster.Table -> Double
245 248
                  -> Gdx -> Node.List -> Instance.List
246
                  -> IO (Gdx, (Node.List, Instance.List))
249
                  -> IO GroupInfo
247 250
executeSimulation opts ini_tbl min_cv gidx nl il = do
248 251
  let imlen = maximum . map (length . Instance.alias) $ Container.elems il
249 252
      nmlen = maximum . map (length . Node.alias) $ Container.elems nl
......
260 263
  return (gidx, (fin_nl, fin_il))
261 264

  
262 265
-- | Simulate group rebalance if group's score is not good
263
maybeSimulateGroupRebalance :: Options -> (Gdx, (Node.List, Instance.List))
264
                            -> IO (Gdx, (Node.List, Instance.List))
266
maybeSimulateGroupRebalance :: Options -> GroupInfo -> IO GroupInfo
265 267
maybeSimulateGroupRebalance opts (gidx, (nl, il)) = do
266 268
  let ini_cv = Cluster.compCV nl
267 269
      ini_tbl = Cluster.Table nl il ini_cv []
......
273 275
-- | Decide whether to simulate rebalance.
274 276
maybeSimulateRebalance :: Bool             -- ^ Whether to simulate rebalance
275 277
                       -> Options          -- ^ Command line options
276
                       -> [(Gdx, (Node.List, Instance.List))] -- ^ Group data
277
                       -> IO [(Gdx, (Node.List, Instance.List))]
278
                       -> [GroupInfo]      -- ^ Group data
279
                       -> IO [GroupInfo]
278 280
maybeSimulateRebalance True opts cluster =
279 281
    mapM (maybeSimulateGroupRebalance opts) cluster
280 282
maybeSimulateRebalance False _ cluster = return cluster

Also available in: Unified diff