Revision 2cdaf225 htools/Ganeti/HTools/Rapi.hs
b/htools/Ganeti/HTools/Rapi.hs | ||
---|---|---|
85 | 85 |
-- | Helper to convert I/O errors in 'Bad' values. |
86 | 86 |
ioErrToResult :: IO a -> IO (Result a) |
87 | 87 |
ioErrToResult ioaction = |
88 |
catch (ioaction >>= return . Ok)
|
|
88 |
catch (liftM Ok ioaction)
|
|
89 | 89 |
(\e -> return . Bad . show $ (e::IOException)) |
90 | 90 |
|
91 | 91 |
-- | Append the default port if not passed in. |
... | ... | |
203 | 203 |
readDataFile:: String -- ^ Path to the directory containing the files |
204 | 204 |
-> IO (Result String, Result String, Result String, Result String) |
205 | 205 |
readDataFile path = do |
206 |
group_body <- ioErrToResult $ readFile $ path </> "groups.json"
|
|
207 |
node_body <- ioErrToResult $ readFile $ path </> "nodes.json"
|
|
208 |
inst_body <- ioErrToResult $ readFile $ path </> "instances.json"
|
|
209 |
info_body <- ioErrToResult $ readFile $ path </> "info.json"
|
|
206 |
group_body <- ioErrToResult . readFile $ path </> "groups.json"
|
|
207 |
node_body <- ioErrToResult . readFile $ path </> "nodes.json"
|
|
208 |
inst_body <- ioErrToResult . readFile $ path </> "instances.json"
|
|
209 |
info_body <- ioErrToResult . readFile $ path </> "info.json"
|
|
210 | 210 |
return (group_body, node_body, inst_body, info_body) |
211 | 211 |
|
212 | 212 |
-- | Loads data via either 'readDataFile' or 'readDataHttp'. |
Also available in: Unified diff