Revision 00152519 htools/Ganeti/HTools/IAlloc.hs

b/htools/Ganeti/HTools/IAlloc.hs
24 24
-}
25 25

  
26 26
module Ganeti.HTools.IAlloc
27
    ( parseData
28
    , formatResponse
29
    , readRequest
30
    , processRequest
31
    , processResults
27
    ( readRequest
28
    , runIAllocator
32 29
    ) where
33 30

  
34 31
import Data.Either ()
35
import Data.Maybe (fromMaybe, isJust, fromJust)
32
import Data.Maybe (fromMaybe, isJust)
36 33
import Data.List
37 34
import Control.Monad
38 35
import Text.JSON (JSObject, JSValue(JSBool, JSString, JSArray),
......
293 290
     let Request rqt _ = r1
294 291
     return $ Request rqt cdata
295 292
   else return r1)
293

  
294
-- | Main iallocator pipeline.
295
runIAllocator :: Request -> String
296
runIAllocator request =
297
  let Request rq _ = request
298
      sols = processRequest request >>= processResults rq
299
      (ok, info, rn) =
300
          case sols of
301
            Ok as -> (True, "Request successful: " ++
302
                            intercalate ", " (Cluster.asLog as),
303
                      Cluster.asSolutions as)
304
            Bad s -> (False, "Request failed: " ++ s, [])
305
      resp = formatResponse ok info rq rn
306
  in resp

Also available in: Unified diff