Revision 756df409 htools/Ganeti/HTools/Cluster.hs

b/htools/Ganeti/HTools/Cluster.hs
68 68
    -- * Allocation functions
69 69
    , iterateAlloc
70 70
    , tieredAlloc
71
    , tieredSpecMap
72 71
     -- * Node group functions
73 72
    , instanceGroup
74 73
    , findSplitInstances
75 74
    , splitCluster
76 75
    ) where
77 76

  
78
import Data.Function (on)
79 77
import qualified Data.IntSet as IntSet
80 78
import Data.List
81 79
import Data.Maybe (fromJust)
......
1171 1169
            Ok newinst' -> tieredAlloc nl' il' newlimit
1172 1170
                           newinst' allocnodes ixes' cstats'
1173 1171

  
1174
-- | Compute the tiered spec string description from a list of
1175
-- allocated instances.
1176
tieredSpecMap :: [Instance.Instance]
1177
              -> [String]
1178
tieredSpecMap trl_ixes =
1179
    let fin_trl_ixes = reverse trl_ixes
1180
        ix_byspec = groupBy ((==) `on` Instance.specOf) fin_trl_ixes
1181
        spec_map = map (\ixs -> (Instance.specOf $ head ixs, length ixs))
1182
                   ix_byspec
1183
    in  map (\(spec, cnt) -> printf "%d,%d,%d=%d" (rspecMem spec)
1184
                             (rspecDsk spec) (rspecCpu spec) cnt) spec_map
1185

  
1186 1172
-- * Formatting functions
1187 1173

  
1188 1174
-- | Given the original and final nodes, computes the relocation description.

Also available in: Unified diff