diff --git a/htools/Ganeti/HTools/Cluster.hs b/htools/Ganeti/HTools/Cluster.hs index ca7cfb2e1c2fa0f9611f93b2f020c9826e9d2848..4588e7700ce5fb22ba3ce7ecadc605ee2986c142 100644 --- a/htools/Ganeti/HTools/Cluster.hs +++ b/htools/Ganeti/HTools/Cluster.hs @@ -515,10 +515,7 @@ checkMove nodes_idx disk_moves ini_tbl victims = tables = parMap rwhnf (checkInstanceMove nodes_idx disk_moves ini_tbl) victims -- iterate over all instances, computing the best move - best_tbl = - foldl' - (\ step_tbl new_tbl -> compareTables step_tbl new_tbl) - ini_tbl tables + best_tbl = foldl' compareTables ini_tbl tables Table _ _ _ best_plc = best_tbl in if length best_plc == length ini_plc then ini_tbl -- no advancement @@ -694,7 +691,7 @@ sortMGResults :: Group.List -> [(Gdx, AllocSolution)] -> [(Gdx, AllocSolution)] sortMGResults gl sols = - let extractScore = \(_, _, _, x) -> x + let extractScore (_, _, _, x) = x solScore (gdx, sol) = (Group.allocPolicy (Container.find gdx gl), (extractScore . head . asSolutions) sol) in sortBy (comparing solScore) sols @@ -837,8 +834,7 @@ tryMGEvac _ nl il ex_ndx = all_insts3 results <- mapM (\(_, gnl, gil, idxs) -> tryEvac gnl gil idxs ex_ndx) all_insts4 - let sol = foldl' (\orig_sol group_sol -> - sumAllocs orig_sol group_sol) emptySolution results + let sol = foldl' sumAllocs emptySolution results return $ annotateSolution sol -- | Recursively place instances on the cluster until we're out of space @@ -1084,8 +1080,8 @@ instancePriGroup nl i = -- | Compute the list of badly allocated instances (split across node -- groups) findSplitInstances :: Node.List -> Instance.List -> [Instance.Instance] -findSplitInstances nl il = - filter (not . isOk . instanceGroup nl) (Container.elems il) +findSplitInstances nl = + filter (not . isOk . instanceGroup nl) . Container.elems -- | Splits a cluster into the component node groups splitCluster :: Node.List -> Instance.List -> diff --git a/htools/Ganeti/HTools/Loader.hs b/htools/Ganeti/HTools/Loader.hs index c17aba1c79bce2ebfa64fb2e761311a0940a1f0d..186c1338395d4f48f421e31be5e183193a077482 100644 --- a/htools/Ganeti/HTools/Loader.hs +++ b/htools/Ganeti/HTools/Loader.hs @@ -7,7 +7,7 @@ has been loaded from external sources. {- -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 @@ -198,7 +198,7 @@ mergeData um extags exinsts cdata@(ClusterData _ nl il2 tags) = il4 = Container.map (filterExTags allextags . updateMovable exinsts) il3 nl2 = foldl' fixNodes nl (Container.elems il4) - nl3 = Container.map (\node -> Node.buildPeers node il4) nl2 + nl3 = Container.map (flip Node.buildPeers il4) nl2 node_names = map Node.name (Container.elems nl) inst_names = map Instance.name il common_suffix = longestDomain (node_names ++ inst_names) diff --git a/htools/Ganeti/HTools/Luxi.hs b/htools/Ganeti/HTools/Luxi.hs index 15dc6c3298ab1dd9d5620fd0922928d13b5dd0a5..a3855c5de5651d5854446a168173269abda73335 100644 --- a/htools/Ganeti/HTools/Luxi.hs +++ b/htools/Ganeti/HTools/Luxi.hs @@ -213,4 +213,4 @@ parseData (groups, nodes, instances, cinfo) = do -- | Top level function for data loading loadData :: String -- ^ Unix socket to use as source -> IO (Result ClusterData) -loadData master = readData master >>= return . parseData +loadData = fmap parseData . readData diff --git a/htools/Ganeti/HTools/Rapi.hs b/htools/Ganeti/HTools/Rapi.hs index f77e859ac41137a1a8c8a683802ba6bcac12e490..19aa817fb813ebbc559508dde0963cd3a1c1c6f0 100644 --- a/htools/Ganeti/HTools/Rapi.hs +++ b/htools/Ganeti/HTools/Rapi.hs @@ -182,4 +182,4 @@ parseData (group_body, node_body, inst_body, tags_body) = do -- | Top level function for data loading loadData :: String -- ^ Cluster or URL to use as source -> IO (Result ClusterData) -loadData master = readData master >>= return . parseData +loadData = fmap parseData . readData diff --git a/htools/Ganeti/HTools/Text.hs b/htools/Ganeti/HTools/Text.hs index 964fd8a38972f8bd255a7efa45cd65f8b5cf4147..052fd33f2f0b18316b3c28e9c7dc0d498c6e3978 100644 --- a/htools/Ganeti/HTools/Text.hs +++ b/htools/Ganeti/HTools/Text.hs @@ -188,4 +188,4 @@ parseData fdata = do -- | Top level function for data loading loadData :: String -- ^ Path to the text file -> IO (Result ClusterData) -loadData afile = readData afile >>= return . parseData +loadData = fmap parseData . readData