Revision 00152519

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
b/htools/hail.hs
26 26
module Main (main) where
27 27

  
28 28
import Control.Monad
29
import Data.List
30 29
import Data.Maybe (isJust, fromJust)
31 30
import System.IO
32 31
import qualified System
......
35 34

  
36 35
import Ganeti.HTools.CLI
37 36
import Ganeti.HTools.IAlloc
38
import Ganeti.HTools.Types
39 37
import Ganeti.HTools.Loader (Request(..), ClusterData(..))
40 38

  
41 39
-- | Options list and functions
......
73 71
         hPutStrLn stderr $ Cluster.printNodes (cdNodes cdata)
74 72
                       (fromJust shownodes)
75 73

  
76
  let sols = processRequest request >>= processResults rq
77
  let (ok, info, rn) =
78
          case sols of
79
            Ok as -> (True, "Request successful: " ++
80
                            intercalate ", " (Cluster.asLog as),
81
                      Cluster.asSolutions as)
82
            Bad s -> (False, "Request failed: " ++ s, [])
83
      resp = formatResponse ok info rq rn
74
  let resp = runIAllocator request
84 75
  putStrLn resp

Also available in: Unified diff