htools: simplify select tests
[ganeti-local] / htools / Ganeti / HTools / ExtLoader.hs
index b7ca04a..435d368 100644 (file)
@@ -1,4 +1,4 @@
-{-| External data loader
+{-| External data loader.
 
 This module holds the external data loading, and thus is the only one
 depending (via the specialized Text\/Rapi\/Luxi modules) on the actual
@@ -51,23 +51,23 @@ import Ganeti.HTools.Types
 import Ganeti.HTools.CLI
 import Ganeti.HTools.Utils (sepSplit, tryRead)
 
--- | Error beautifier
+-- | Error beautifier.
 wrapIO :: IO (Result a) -> IO (Result a)
 wrapIO = flip catch (return . Bad . show)
 
 parseUtilisation :: String -> Result (String, DynUtil)
 parseUtilisation line =
-    let columns = sepSplit ' ' line
-    in case columns of
-         [name, cpu, mem, dsk, net] -> do
-                      rcpu <- tryRead name cpu
-                      rmem <- tryRead name mem
-                      rdsk <- tryRead name dsk
-                      rnet <- tryRead name net
-                      let du = DynUtil { cpuWeight = rcpu, memWeight = rmem
-                                       , dskWeight = rdsk, netWeight = rnet }
-                      return (name, du)
-         _ -> Bad $ "Cannot parse line " ++ line
+    case sepSplit ' ' line of
+      [name, cpu, mem, dsk, net] ->
+          do
+            rcpu <- tryRead name cpu
+            rmem <- tryRead name mem
+            rdsk <- tryRead name dsk
+            rnet <- tryRead name net
+            let du = DynUtil { cpuWeight = rcpu, memWeight = rmem
+                             , dskWeight = rdsk, netWeight = rnet }
+            return (name, du)
+      _ -> Bad $ "Cannot parse line " ++ line
 
 -- | External tool data loader from a variety of sources.
 loadExternalData :: Options