From ce0392e6ac6224393f1a362bbda32aa8ce9eaeee Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Wed, 21 Oct 2009 20:06:40 +0900 Subject: [PATCH] Some cleanup of Loader.mergeData This doesn't need to be a monadic function, let's make it a simpler one. --- Ganeti/HTools/Loader.hs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Ganeti/HTools/Loader.hs b/Ganeti/HTools/Loader.hs index b737a46e8..8a351502b 100644 --- a/Ganeti/HTools/Loader.hs +++ b/Ganeti/HTools/Loader.hs @@ -135,7 +135,7 @@ mergeData :: [(String, DynUtil)] -- ^ Instance utilisation data Instance.AssocList) -- ^ Data from either Text.loadData -- or Rapi.loadData -> Result (Node.List, Instance.List, String) -mergeData um (nl, il) = do +mergeData um (nl, il) = let il2 = Container.fromAssocList il il3 = foldl' (\im (name, n_util) -> case Container.findByName im name of @@ -144,16 +144,16 @@ mergeData um (nl, il) = do let new_i = inst { Instance.util = n_util } in Container.add (Instance.idx inst) new_i im ) il2 um - let nl2 = foldl' fixNodes nl (Container.elems il3) - let nl3 = Container.fromAssocList + nl2 = foldl' fixNodes nl (Container.elems il3) + nl3 = Container.fromAssocList (map (\ (k, v) -> (k, Node.buildPeers v il3)) nl2) - node_names = map Node.name $ Container.elems nl3 - inst_names = map Instance.name $ Container.elems il3 + node_names = map (Node.name . snd) nl + inst_names = map (Instance.name . snd) il common_suffix = longestDomain (node_names ++ inst_names) csl = length common_suffix snl = Container.map (\n -> setName n (stripSuffix csl $ nameOf n)) nl3 sil = Container.map (\i -> setName i (stripSuffix csl $ nameOf i)) il3 - return (snl, sil, common_suffix) + in Ok (snl, sil, common_suffix) -- | Checks the cluster data for consistency. checkData :: Node.List -> Instance.List -- GitLab