Skip to content
Snippets Groups Projects
Commit 83ad1f3c authored by Iustin Pop's avatar Iustin Pop
Browse files

hspace: show tiered-alloc stats in the output

This is a first attempt to get a readable output of tiered allocation
stats in hspace's output. Not very nice, but it should be somewhat
parseable.
parent 189bc08f
No related branches found
No related tags found
No related merge requests found
......@@ -36,6 +36,7 @@ module Ganeti.HTools.Instance
, setPri
, setSec
, setBoth
, specOf
, shrinkByType
) where
......@@ -152,3 +153,8 @@ shrinkByType inst T.FailCPU = let v = vcpus inst - unitCpu
then T.Bad "out of vcpus"
else T.Ok inst { vcpus = v }
shrinkByType _ f = T.Bad $ "Unhandled failure mode " ++ show f
-- | Return the spec of an instance.
specOf :: Instance -> T.RSpec
specOf Instance { mem = m, dsk = d, vcpus = c } =
T.RSpec { T.rspecCpu = c, T.rspecMem = m, T.rspecDsk = d }
......@@ -68,7 +68,7 @@ data RSpec = RSpec
{ rspecCpu :: Int -- ^ Requested VCPUs
, rspecMem :: Int -- ^ Requested memory
, rspecDsk :: Int -- ^ Requested disk
} deriving (Show)
} deriving (Show, Eq)
-- | The dynamic resource specs of a machine (i.e. load or load
-- capacity, as opposed to size).
......
......@@ -293,18 +293,27 @@ main = do
let tresu = tieredAlloc nl il (iofspec tspec) req_nodes []
(_, trl_nl, trl_ixes) <- exitifbad tresu
let fin_trl_ixes = reverse trl_ixes
ix_byspec = groupBy ((==) `on` Instance.specOf) fin_trl_ixes
spec_map = map (\ixs -> (Instance.specOf $ head ixs, length ixs))
ix_byspec::[(RSpec, Int)]
spec_map' = map (\(idx, (spec, cnt)) ->
printf "%dx%dx%dx%d=%d" idx (rspecCpu spec)
(rspecMem spec) (rspecDsk spec) cnt)
$ zip ([1..]::[Int]) spec_map::[String]
when (verbose > 1) $ do
hPutStrLn stderr "Tiered allocation map"
hPutStr stderr . unlines . map ((:) ' ' . intercalate " ") $
formatTable (map (printInstance trl_nl) fin_trl_ixes)
[False, False, False, True, True, True]
when (optShowNodes opts) $ do
hPutStrLn stderr ""
hPutStrLn stderr "Tiered allocation status:"
hPutStrLn stderr $ Cluster.printNodes trl_nl
printKeys $ printStats PTiered (Cluster.totalResources trl_nl))
printKeys $ printStats PTiered (Cluster.totalResources trl_nl)
printKeys [("TSPEC", intercalate " " spec_map')])
-- Run the standard (avg-mode) allocation
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment