Revision 5440c877 htools/Ganeti/HTools/IAlloc.hs

b/htools/Ganeti/HTools/IAlloc.hs
241 241
    _ -> fail "Internal error: multiple allocation solutions"
242 242

  
243 243
-- | Convert a node-evacuation/change group result.
244
formatNodeEvac :: Cluster.EvacSolution -> Result IAllocResult
245
formatNodeEvac es =
246
    let fes = Cluster.esFailed es
247
        mes = Cluster.esMoved es
244
formatNodeEvac :: Group.List
245
               -> Node.List
246
               -> Instance.List
247
               -> Cluster.EvacSolution
248
               -> Result IAllocResult
249
formatNodeEvac gl nl il es =
250
    let iname = Instance.name . flip Container.find il
251
        nname = Node.name . flip Container.find nl
252
        gname = Group.name . flip Container.find gl
253
        fes = map (\(idx, msg) -> (iname idx, msg)) $ Cluster.esFailed es
254
        mes = map (\(idx, gdx, ndxs) -> (iname idx, gname gdx, map nname ndxs))
255
              $ Cluster.esMoved es
248 256
        failed = length fes
249 257
        moved  = length mes
250 258
        info = show failed ++ " instances failed to move and " ++ show moved ++
......
263 271
       Evacuate exnodes ->
264 272
           Cluster.tryMGEvac gl nl il exnodes >>= formatEvacuate
265 273
       ChangeGroup gdxs idxs ->
266
           Cluster.tryChangeGroup gl nl il idxs gdxs >>= formatNodeEvac
274
           Cluster.tryChangeGroup gl nl il idxs gdxs >>=
275
                  formatNodeEvac gl nl il
267 276
       NodeEvacuate xi mode ->
268
           Cluster.tryNodeEvac gl nl il mode xi >>= formatNodeEvac
277
           Cluster.tryNodeEvac gl nl il mode xi >>=
278
                  formatNodeEvac gl nl il
269 279

  
270 280
-- | Reads the request from the data file(s)
271 281
readRequest :: Options -> [String] -> IO Request

Also available in: Unified diff