diff --git a/htools/Ganeti/HTools/Cluster.hs b/htools/Ganeti/HTools/Cluster.hs index 68ea006c91432b7c962af4a6baffe2e48f605383..ca7cfb2e1c2fa0f9611f93b2f020c9826e9d2848 100644 --- a/htools/Ganeti/HTools/Cluster.hs +++ b/htools/Ganeti/HTools/Cluster.hs @@ -830,8 +830,8 @@ tryMGEvac _ nl il ex_ndx = in do -- that done, we now add the per-group nl/il to the tuple all_insts4 <- - mapM (\(gdx, idxs) -> do - case lookup gdx gni of + mapM (\(gdx, idxs) -> + case lookup gdx gni of Nothing -> fail $ "Can't find group index " ++ show gdx Just (gnl, gil) -> return (gdx, gnl, gil, idxs)) all_insts3 diff --git a/htools/Ganeti/HTools/Luxi.hs b/htools/Ganeti/HTools/Luxi.hs index 0fbd798eb29945e7580ced5915b5789e42365b33..15dc6c3298ab1dd9d5620fd0922928d13b5dd0a5 100644 --- a/htools/Ganeti/HTools/Luxi.hs +++ b/htools/Ganeti/HTools/Luxi.hs @@ -177,7 +177,7 @@ parseGroup (JSArray [ uuid, name, apol ]) = do let convert a = genericConvert "Group" xname a xuuid <- convert "uuid" uuid xapol <- convert "alloc_policy" apol - return $ (xuuid, Group.create xname xuuid xapol) + return (xuuid, Group.create xname xuuid xapol) parseGroup v = fail ("Invalid group query result: " ++ show v) diff --git a/htools/Ganeti/HTools/Node.hs b/htools/Ganeti/HTools/Node.hs index 03849235d3c28f91c74d80bd6fa96848d5eaa78f..9c4fd917bc8f8b33e2d47b8c5cf4be2e9c96031d 100644 --- a/htools/Ganeti/HTools/Node.hs +++ b/htools/Ganeti/HTools/Node.hs @@ -494,7 +494,7 @@ showField t field = "mload" -> printf "%5.3f" uM "dload" -> printf "%5.3f" uD "nload" -> printf "%5.3f" uN - "ptags" -> intercalate "," . map (\(k, v) -> printf "%s=%d" k v) . + "ptags" -> intercalate "," . map (uncurry (printf "%s=%d")) . Map.toList $ pTags t "peermap" -> show $ peers t _ -> T.unknownField diff --git a/htools/Ganeti/HTools/Rapi.hs b/htools/Ganeti/HTools/Rapi.hs index eb300762dbd3be488832d5fec32e4538e740130f..f77e859ac41137a1a8c8a683802ba6bcac12e490 100644 --- a/htools/Ganeti/HTools/Rapi.hs +++ b/htools/Ganeti/HTools/Rapi.hs @@ -89,8 +89,8 @@ getGroups body = loadJSArray "Parsing group data" body >>= getFakeGroups :: Result [(String, Group.Group)] getFakeGroups = - return $ [(defaultGroupID, - Group.create "default" defaultGroupID AllocPreferred)] + return [(defaultGroupID, + Group.create "default" defaultGroupID AllocPreferred)] -- | Construct an instance from a JSON object. parseInstance :: NameAssoc diff --git a/htools/Ganeti/HTools/Text.hs b/htools/Ganeti/HTools/Text.hs index 1f446ac890f8819c64b25ea369743ef7155d9fc5..964fd8a38972f8bd255a7efa45cd65f8b5cf4147 100644 --- a/htools/Ganeti/HTools/Text.hs +++ b/htools/Ganeti/HTools/Text.hs @@ -7,7 +7,7 @@ files, as produced by gnt-node and gnt-instance list. {- -Copyright (C) 2009, 2010 Google Inc. +Copyright (C) 2009, 2010, 2011 Google Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -109,7 +109,7 @@ serializeCluster (ClusterData gl nl il ctags) = loadGroup :: (Monad m) => [String] -> m (String, Group.Group) loadGroup [name, gid, apol] = do xapol <- apolFromString apol - return $ (gid, Group.create name gid xapol) + return (gid, Group.create name gid xapol) loadGroup s = fail $ "Invalid/incomplete group data: '" ++ show s ++ "'" diff --git a/htools/hail.hs b/htools/hail.hs index 541e1a93f5d1ec0950582d8de793ffcf7f950af3..1831837c6eff0114bee91c93b4de49e87f6ff8e8 100644 --- a/htools/hail.hs +++ b/htools/hail.hs @@ -88,13 +88,12 @@ readRequest opts args = do hPutStrLn stderr $ "Error: " ++ err exitWith $ ExitFailure 1 Ok rq -> return rq - r2 <- if isJust (optDataFile opts) || (not . null . optNodeSim) opts - then do - cdata <- loadExternalData opts - let Request rqt _ = r1 - return $ Request rqt cdata - else return r1 - return r2 + (if isJust (optDataFile opts) || (not . null . optNodeSim) opts + then do + cdata <- loadExternalData opts + let Request rqt _ = r1 + return $ Request rqt cdata + else return r1) -- | Main function. main :: IO () diff --git a/htools/hbal.hs b/htools/hbal.hs index 46cccf8e19d369294261176d00614c38e2ad9a25..2b0f847c2e625c895fa56cbdc4afc4ab3cfd60e3 100644 --- a/htools/hbal.hs +++ b/htools/hbal.hs @@ -4,7 +4,7 @@ {- -Copyright (C) 2009, 2010 Google Inc. +Copyright (C) 2009, 2010, 2011 Google Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -280,7 +280,7 @@ main = do when (length ngroups > 1 && isNothing (optGroup opts)) $ do hPutStrLn stderr "Found multiple node groups:" mapM_ (hPutStrLn stderr . (" " ++) . Group.name . - (flip Container.find gl) . fst) ngroups + flip Container.find gl . fst) ngroups hPutStrLn stderr "Aborting." exitWith $ ExitFailure 1 @@ -307,7 +307,7 @@ main = do Nothing -> do -- TODO: while this is unlikely to happen, log here the -- actual group data to help debugging - hPutStrLn stderr $ "Internal failure, missing group idx" + hPutStrLn stderr "Internal failure, missing group idx" exitWith $ ExitFailure 1 Just cdata -> return (Group.name grp, cdata) @@ -417,4 +417,4 @@ main = do return False Just master -> runJobSet master fin_nl il cmd_jobs) else return True - when (not eval) (exitWith (ExitFailure 1)) + unless eval (exitWith (ExitFailure 1)) diff --git a/htools/hscan.hs b/htools/hscan.hs index c14846f21c05945aaace0533a4de71f385cc6c13..69601338ccb5ec7ed6275949ac7b87dbe7495d42 100644 --- a/htools/hscan.hs +++ b/htools/hscan.hs @@ -153,15 +153,12 @@ main = do let name = local input_data <- Luxi.loadData lsock result <- writeData nlen name opts input_data - when (not result) $ exitWith $ ExitFailure 2 + unless result $ exitWith $ ExitFailure 2 #ifndef NO_CURL - results <- mapM (\ name -> - do - input_data <- Rapi.loadData name - writeData nlen name opts input_data - ) clusters - when (not $ all id results) $ exitWith (ExitFailure 2) + results <- mapM (\name -> Rapi.loadData name >>= writeData nlen name opts) + clusters + unless (all id results) $ exitWith (ExitFailure 2) #else when (not $ null clusters) $ do putStrLn "RAPI/curl backend disabled at compile time, cannot scan clusters"