Revision d0a14556 htools/Ganeti/HTools/Program/Hinfo.hs
b/htools/Ganeti/HTools/Program/Hinfo.hs | ||
---|---|---|
58 | 58 |
, oShowHelp |
59 | 59 |
] |
60 | 60 |
|
61 |
-- | Gather and print split instances |
|
61 |
-- | Node group statistics. |
|
62 |
calcGroupInfo :: Group.Group |
|
63 |
-> Node.List |
|
64 |
-> Instance.List |
|
65 |
-> (String, (Int, Int), (Int, Int), Bool) |
|
66 |
calcGroupInfo g nl il = |
|
67 |
let nl_size = Container.size nl |
|
68 |
il_size = Container.size il |
|
69 |
(bad_nodes, bad_instances) = Cluster.computeBadItems nl il |
|
70 |
bn_size = length bad_nodes |
|
71 |
bi_size = length bad_instances |
|
72 |
n1h = bn_size == 0 |
|
73 |
in (Group.name g, (nl_size, il_size), (bn_size, bi_size), n1h) |
|
74 |
|
|
75 |
-- | Helper to format one group row result. |
|
76 |
groupRowFormatHelper :: (String, (Int, Int), (Int, Int), Bool) -> [String] |
|
77 |
groupRowFormatHelper (gname, (nl_size, il_size), (bn_size, bi_size), n1h) = |
|
78 |
[ gname |
|
79 |
, printf "%d" nl_size |
|
80 |
, printf "%d" il_size |
|
81 |
, printf "%d" bn_size |
|
82 |
, printf "%d" bi_size |
|
83 |
, show n1h ] |
|
84 |
|
|
85 |
-- | Print node group information. |
|
86 |
showGroupInfo :: Int -> Group.List -> Node.List -> Instance.List -> IO () |
|
87 |
showGroupInfo verbose gl nl il = do |
|
88 |
let cgrs = map (\(gdx, (gnl, gil)) -> |
|
89 |
calcGroupInfo (Container.find gdx gl) gnl gil) $ |
|
90 |
Cluster.splitCluster nl il |
|
91 |
cn1h = all (\(_, _, _, n1h) -> n1h) cgrs |
|
92 |
grs = map groupRowFormatHelper cgrs |
|
93 |
header = ["Group", "Nodes", "Instances", "Bad_Nodes", "Bad_Instances", |
|
94 |
"N+1"] |
|
95 |
|
|
96 |
when (verbose > 1) $ |
|
97 |
printf "Node group information:\n%s" |
|
98 |
(printTable " " header grs [False, True, True, True, True, False]) |
|
99 |
|
|
100 |
printf "Cluster is N+1 %s\n" $ if cn1h then "happy" else "unhappy" |
|
101 |
|
|
102 |
-- | Gather and print split instances. |
|
62 | 103 |
splitInstancesInfo :: Int -> Node.List -> Instance.List -> IO () |
63 | 104 |
splitInstancesInfo verbose nl il = do |
64 | 105 |
let split_insts = Cluster.findSplitInstances nl il |
... | ... | |
70 | 111 |
putStrLn "Found instances belonging to multiple node groups:" |
71 | 112 |
mapM_ (\i -> hPutStrLn stderr $ " " ++ Instance.name i) split_insts |
72 | 113 |
|
73 |
-- | Print common (interesting) information |
|
114 |
-- | Print common (interesting) information.
|
|
74 | 115 |
commonInfo :: Int -> Group.List -> Node.List -> Instance.List -> IO () |
75 | 116 |
commonInfo verbose gl nl il = do |
76 | 117 |
when (Container.null il && verbose > 1) $ do |
... | ... | |
112 | 153 |
|
113 | 154 |
splitInstancesInfo verbose nlf ilf |
114 | 155 |
|
156 |
showGroupInfo verbose gl nlf ilf |
|
157 |
|
|
115 | 158 |
maybePrintInsts showinsts "Instances" (Cluster.printInsts nlf ilf) |
116 | 159 |
|
117 | 160 |
maybePrintNodes shownodes "Cluster" (Cluster.printNodes nlf) |
Also available in: Unified diff