diff --git a/Ganeti/HTools/Instance.hs b/Ganeti/HTools/Instance.hs index 72b27dadcdc94d271308f49349f27db22b3c8622..752ab7e1fd5d057ca45d218686ecdb2e3248237c 100644 --- a/Ganeti/HTools/Instance.hs +++ b/Ganeti/HTools/Instance.hs @@ -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 } diff --git a/Ganeti/HTools/Types.hs b/Ganeti/HTools/Types.hs index ba0cf7dbaefbd0954ddc09f5f2ebc3c59d1dc94b..1151cec8864d42b8f155b96618d36ee99a42ac04 100644 --- a/Ganeti/HTools/Types.hs +++ b/Ganeti/HTools/Types.hs @@ -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). diff --git a/hspace.hs b/hspace.hs index 7b01fbefdddb409d57c77b48e8c25a5c7d9fc7ae..ad9b788f133ee0d56acaf7ec6a3008ce9286a143 100644 --- a/hspace.hs +++ b/hspace.hs @@ -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