Commit 5e718042 authored by Iustin Pop's avatar Iustin Pop
Browse files

Simu loader: move the loading to non-IO code

While we don't actually have IO code in the Simu loader, we do have the
same interface. So we move the code again to a separate parseData
function which is exported.
parent b3f0710c
......@@ -28,6 +28,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
module Ganeti.HTools.Simu
(
loadData
, parseData
) where
import Text.Printf (printf)
......@@ -49,17 +50,22 @@ parseDesc desc =
return (ncount, disk, mem, cpu)
_ -> fail "Invalid cluster specification"
-- | Builds the cluster data from node\/instance files.
parseData :: String -- ^ Cluster description in text format
-> Result (Node.AssocList, Instance.AssocList, [String])
parseData ndata = do
(cnt, disk, mem, cpu) <- parseDesc ndata
let nodes = map (\idx ->
let n = Node.create (printf "node%03d" idx)
(fromIntegral mem) 0 mem
(fromIntegral disk) disk
(fromIntegral cpu) False
in (idx, Node.setIdx n idx)
) [1..cnt]
return (nodes, [], [])
-- | Builds the cluster data from node\/instance files.
loadData :: String -- ^ Cluster description in text format
-> IO (Result (Node.AssocList, Instance.AssocList, [String]))
loadData ndata = -- IO monad, just for consistency with the other loaders
return $ do
(cnt, disk, mem, cpu) <- parseDesc ndata
let nodes = map (\idx ->
let n = Node.create (printf "node%03d" idx)
(fromIntegral mem) 0 mem
(fromIntegral disk) disk
(fromIntegral cpu) False
in (idx, Node.setIdx n idx)
) [1..cnt]
return (nodes, [], [])
loadData = -- IO monad, just for consistency with the other loaders
return . parseData
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment