Revision c3024b7e
b/htools/Ganeti/HTools/Cluster.hs | ||
---|---|---|
1302 | 1302 |
_ -> fs |
1303 | 1303 |
snl = sortBy (comparing Node.idx) (Container.elems nl) |
1304 | 1304 |
(header, isnum) = unzip $ map Node.showHeader fields |
1305 |
in unlines . map ((:) ' ' . unwords) $ |
|
1306 |
formatTable (header:map (Node.list fields) snl) isnum |
|
1305 |
in printTable "" header (map (Node.list fields) snl) isnum |
|
1307 | 1306 |
|
1308 | 1307 |
-- | Print the instance list. |
1309 | 1308 |
printInsts :: Node.List -> Instance.List -> String |
... | ... | |
1329 | 1328 |
header = [ "F", "Name", "Pri_node", "Sec_node", "Auto_bal" |
1330 | 1329 |
, "vcpu", "mem" , "dsk", "lCpu", "lMem", "lDsk", "lNet" ] |
1331 | 1330 |
isnum = False:False:False:False:False:repeat True |
1332 |
in unlines . map ((:) ' ' . unwords) $ |
|
1333 |
formatTable (header:map helper sil) isnum |
|
1331 |
in printTable "" header (map helper sil) isnum |
|
1334 | 1332 |
|
1335 | 1333 |
-- | Shows statistics for a given node list. |
1336 | 1334 |
printStats :: String -> Node.List -> String |
... | ... | |
1344 | 1342 |
, printf "%.8f" val |
1345 | 1343 |
, printf "x%.2f" w |
1346 | 1344 |
]) hd |
1347 |
in unlines . map ((++) lp) . map ((:) ' ' . unwords) $ |
|
1348 |
formatTable (header:formatted) $ False:repeat True |
|
1345 |
in printTable lp header formatted $ False:repeat True |
|
1349 | 1346 |
|
1350 | 1347 |
-- | Convert a placement into a list of OpCodes (basically a job). |
1351 | 1348 |
iMoveToJob :: Node.List -- ^ The node list; only used for node |
b/htools/Ganeti/HTools/Utils.hs | ||
---|---|---|
33 | 33 |
, commaJoin |
34 | 34 |
, tryRead |
35 | 35 |
, formatTable |
36 |
, printTable |
|
36 | 37 |
, parseUnit |
37 | 38 |
, plural |
38 | 39 |
) where |
... | ... | |
156 | 157 |
) (zip3 vtrans numpos mlens) |
157 | 158 |
in transpose expnd |
158 | 159 |
|
160 |
-- | Constructs a printable table from given header and rows |
|
161 |
printTable :: String -> [String] -> [[String]] -> [Bool] -> String |
|
162 |
printTable lp header rows isnum = |
|
163 |
unlines . map ((++) lp) . map ((:) ' ' . unwords) $ |
|
164 |
formatTable (header:rows) isnum |
|
165 |
|
|
159 | 166 |
-- | Tries to extract number and scale from the given string. |
160 | 167 |
-- |
161 | 168 |
-- Input must be in the format NUMBER+ SPACE* [UNIT]. If no unit is |
Also available in: Unified diff