diff --git a/Ganeti/HTools/Cluster.hs b/Ganeti/HTools/Cluster.hs index 1e111f05c5aacef67176b5e9f18b1092389a7db3..c3a1a26400b6f03ef6df886f2e2d06b74625dd4b 100644 --- a/Ganeti/HTools/Cluster.hs +++ b/Ganeti/HTools/Cluster.hs @@ -999,4 +999,4 @@ splitCluster nl il = let nidxs = map Node.idx nodes nodes' = zip nidxs nodes instances = Container.filter ((`elem` nidxs) . Instance.pNode) il - in (guuid, (Container.fromAssocList nodes', instances))) ngroups + in (guuid, (Container.fromList nodes', instances))) ngroups diff --git a/Ganeti/HTools/Container.hs b/Ganeti/HTools/Container.hs index d24bb793b89e0f7a2706953dc3115c22c10c21b3..12d19788fb24a7e5ca989e6d40c5a4df453b95e2 100644 --- a/Ganeti/HTools/Container.hs +++ b/Ganeti/HTools/Container.hs @@ -7,7 +7,7 @@ give the best performance for our workload. {- -Copyright (C) 2009 Google Inc. +Copyright (C) 2009, 2010 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 @@ -34,7 +34,7 @@ module Ganeti.HTools.Container -- * Creation , IntMap.empty , IntMap.singleton - , fromAssocList + , IntMap.fromList -- * Query , IntMap.size , IntMap.null @@ -69,10 +69,6 @@ find k = (IntMap.! k) add :: Key -> a -> Container a -> Container a add = IntMap.insert --- | Create a map from an association list. -fromAssocList :: [(Key, a)] -> Container a -fromAssocList = IntMap.fromList - -- | Add or update two elements of the map. addTwo :: Key -> a -> Key -> a -> Container a -> Container a addTwo k1 v1 k2 v2 = add k1 v1 . add k2 v2 diff --git a/Ganeti/HTools/Loader.hs b/Ganeti/HTools/Loader.hs index f011629dd9bf834ce15c0fd4d11d664fad8b1665..c17aba1c79bce2ebfa64fb2e761311a0940a1f0d 100644 --- a/Ganeti/HTools/Loader.hs +++ b/Ganeti/HTools/Loader.hs @@ -119,7 +119,7 @@ assignIndices nodes = let (na, idx_node) = unzip . map (\ (idx, (k, v)) -> ((k, idx), (idx, setIdx v idx))) . zip [0..] $ nodes - in (M.fromList na, Container.fromAssocList idx_node) + in (M.fromList na, Container.fromList idx_node) -- | For each instance, add its index to its primary and secondary nodes. fixNodes :: Node.List diff --git a/Ganeti/HTools/QC.hs b/Ganeti/HTools/QC.hs index 1f55a6ea69b5a72aa3f7e21074ff50581cd45f03..79600b83c21615f4a7afd16721a7b5cf8f4e67ff 100644 --- a/Ganeti/HTools/QC.hs +++ b/Ganeti/HTools/QC.hs @@ -85,7 +85,7 @@ defGroup = flip Group.setIdx 0 $ Types.AllocPreferred defGroupList :: Group.List -defGroupList = Container.fromAssocList [(Group.idx defGroup, defGroup)] +defGroupList = Container.fromList [(Group.idx defGroup, defGroup)] defGroupAssoc :: Data.Map.Map String Types.Gdx defGroupAssoc = Data.Map.singleton (Group.uuid defGroup) (Group.idx defGroup) @@ -325,7 +325,7 @@ prop_Container_findByName node othername = nn { Node.name = name, Node.alias = alias })) $ zip names nodes - nl' = Container.fromAssocList nodes' + nl' = Container.fromList nodes' target = snd (nodes' !! fidx) in Container.findByName nl' (Node.name target) == Just target && Container.findByName nl' (Node.alias target) == Just target && @@ -655,7 +655,7 @@ prop_Score_Zero node count = (Node.tDsk node > 0) && (Node.tMem node > 0)) ==> let fn = Node.buildPeers node Container.empty nlst = zip [1..] $ replicate count fn::[(Types.Ndx, Node.Node)] - nl = Container.fromAssocList nlst + nl = Container.fromList nlst score = Cluster.compCV nl -- we can't say == 0 here as the floating point errors accumulate; -- this should be much lower than the default score in CLI.hs @@ -667,7 +667,7 @@ prop_CStats_sane node count = (Node.availDisk node > 0) && (Node.availMem node > 0)) ==> let fn = Node.buildPeers node Container.empty nlst = zip [1..] $ replicate count fn::[(Types.Ndx, Node.Node)] - nl = Container.fromAssocList nlst + nl = Container.fromList nlst cstats = Cluster.totalResources nl in Cluster.csAdsk cstats >= 0 && Cluster.csAdsk cstats <= Cluster.csFdsk cstats @@ -770,7 +770,7 @@ prop_ClusterCheckConsistency node inst = inst1 = Instance.setBoth inst (Node.idx node1) (Node.idx node2) inst2 = Instance.setBoth inst (Node.idx node1) Node.noSecondary inst3 = Instance.setBoth inst (Node.idx node1) (Node.idx node3) - ccheck = Cluster.findSplitInstances nl' . Container.fromAssocList + ccheck = Cluster.findSplitInstances nl' . Container.fromList in null (ccheck [(0, inst1)]) && null (ccheck [(0, inst2)]) && (not . null $ ccheck [(0, inst3)]) @@ -849,7 +849,7 @@ prop_Loader_assignIndices nodes = -- | Checks that the number of primary instances recorded on the nodes -- is zero prop_Loader_mergeData ns = - let na = Container.fromAssocList $ map (\n -> (Node.idx n, n)) ns + let na = Container.fromList $ map (\n -> (Node.idx n, n)) ns in case Loader.mergeData [] [] [] (Loader.emptyCluster {Loader.cdNodes = na}) of Types.Bad _ -> False diff --git a/Ganeti/HTools/Simu.hs b/Ganeti/HTools/Simu.hs index f129a36709f7e0593e1342083a9964891182fae8..1515bd0db5659043e0e7047a0b166466cbefed6f 100644 --- a/Ganeti/HTools/Simu.hs +++ b/Ganeti/HTools/Simu.hs @@ -82,8 +82,8 @@ parseData ndata = do let ktn = map (\(idx, n) -> (idx, Node.setIdx n idx)) $ zip [1..] nodes' ktg = map (\g -> (Group.idx g, g)) groups - return (ClusterData (Container.fromAssocList ktg) - (Container.fromAssocList ktn) Container.empty []) + return (ClusterData (Container.fromList ktg) + (Container.fromList ktn) Container.empty []) -- | Builds the cluster data from node\/instance files. loadData :: [String] -- ^ Cluster description in text format