Revision 3c3690aa htools/Ganeti/HTools/Program/Hspace.hs

b/htools/Ganeti/HTools/Program/Hspace.hs
50 50
-- | Options list and functions.
51 51
options :: [OptType]
52 52
options =
53
    [ oPrintNodes
54
    , oDataFile
55
    , oDiskTemplate
56
    , oNodeSim
57
    , oRapiMaster
58
    , oLuxiSocket
59
    , oVerbose
60
    , oQuiet
61
    , oOfflineNode
62
    , oIMem
63
    , oIDisk
64
    , oIVcpus
65
    , oMachineReadable
66
    , oMaxCpu
67
    , oMaxSolLength
68
    , oMinDisk
69
    , oTieredSpec
70
    , oSaveCluster
71
    , oShowVer
72
    , oShowHelp
73
    ]
53
  [ oPrintNodes
54
  , oDataFile
55
  , oDiskTemplate
56
  , oNodeSim
57
  , oRapiMaster
58
  , oLuxiSocket
59
  , oVerbose
60
  , oQuiet
61
  , oOfflineNode
62
  , oIMem
63
  , oIDisk
64
  , oIVcpus
65
  , oMachineReadable
66
  , oMaxCpu
67
  , oMaxSolLength
68
  , oMinDisk
69
  , oTieredSpec
70
  , oSaveCluster
71
  , oShowVer
72
  , oShowHelp
73
  ]
74 74

  
75 75
-- | The allocation phase we're in (initial, after tiered allocs, or
76 76
-- after regular allocation).
......
203 203
tieredSpecMap :: [Instance.Instance]
204 204
              -> [(RSpec, Int)]
205 205
tieredSpecMap trl_ixes =
206
    let fin_trl_ixes = reverse trl_ixes
207
        ix_byspec = groupBy ((==) `on` Instance.specOf) fin_trl_ixes
208
        spec_map = map (\ixs -> (Instance.specOf $ head ixs, length ixs))
209
                   ix_byspec
210
    in spec_map
206
  let fin_trl_ixes = reverse trl_ixes
207
      ix_byspec = groupBy ((==) `on` Instance.specOf) fin_trl_ixes
208
      spec_map = map (\ixs -> (Instance.specOf $ head ixs, length ixs))
209
                 ix_byspec
210
  in spec_map
211 211

  
212 212
-- | Formats a spec map to strings.
213 213
formatSpecMap :: [(RSpec, Int)] -> [String]
214 214
formatSpecMap =
215
    map (\(spec, cnt) -> printf "%d,%d,%d=%d" (rspecMem spec)
216
                         (rspecDsk spec) (rspecCpu spec) cnt)
215
  map (\(spec, cnt) -> printf "%d,%d,%d=%d" (rspecMem spec)
216
                       (rspecDsk spec) (rspecCpu spec) cnt)
217 217

  
218 218
-- | Formats \"key-metrics\" values.
219 219
formatRSpec :: Double -> String -> RSpec -> [(String, String)]
220 220
formatRSpec m_cpu s r =
221
    [ ("KM_" ++ s ++ "_CPU", show $ rspecCpu r)
222
    , ("KM_" ++ s ++ "_NPU", show $ fromIntegral (rspecCpu r) / m_cpu)
223
    , ("KM_" ++ s ++ "_MEM", show $ rspecMem r)
224
    , ("KM_" ++ s ++ "_DSK", show $ rspecDsk r)
225
    ]
221
  [ ("KM_" ++ s ++ "_CPU", show $ rspecCpu r)
222
  , ("KM_" ++ s ++ "_NPU", show $ fromIntegral (rspecCpu r) / m_cpu)
223
  , ("KM_" ++ s ++ "_MEM", show $ rspecMem r)
224
  , ("KM_" ++ s ++ "_DSK", show $ rspecDsk r)
225
  ]
226 226

  
227 227
-- | Shows allocations stats.
228 228
printAllocationStats :: Double -> Node.List -> Node.List -> IO ()
......
331 331
-- | Displays the cluster efficiency.
332 332
printClusterEff :: Cluster.CStats -> IO ()
333 333
printClusterEff cs =
334
    mapM_ (\(s, fn) ->
335
               printf "  - %s usage efficiency: %5.2f%%\n" s (fn cs * 100))
334
  mapM_ (\(s, fn) ->
335
           printf "  - %s usage efficiency: %5.2f%%\n" s (fn cs * 100))
336 336
          [("memory", memEff),
337 337
           ("  disk", dskEff),
338 338
           ("  vcpu", cpuEff)]

Also available in: Unified diff