From: Iustin Pop Date: Tue, 10 Mar 2009 19:35:01 +0000 (+0100) Subject: Beautify solution list X-Git-Tag: htools-v0.0.6~28 X-Git-Url: https://code.grnet.gr/git/ganeti-local/commitdiff_plain/671b85b9f70022abef6753bdb00b854aa54b05fc Beautify solution list This patch makes the tabular solution list nicer, by changing from tabs to explicit widths. --- diff --git a/src/Cluster.hs b/src/Cluster.hs index 0cc7cc4..753b6e1 100644 --- a/src/Cluster.hs +++ b/src/Cluster.hs @@ -536,21 +536,29 @@ printSolution :: InstanceList -> [Placement] -> ([String], [[String]]) printSolution il ktn kti sol = - unzip $ map - (\ (i, p, s) -> - let inst = Container.find i il - inam = fromJust $ lookup (Instance.idx inst) kti - npri = fromJust $ lookup p ktn - nsec = fromJust $ lookup s ktn - opri = fromJust $ lookup (Instance.pnode inst) ktn - osec = fromJust $ lookup (Instance.snode inst) ktn - (moves, cmds) = computeMoves inam opri osec npri nsec - - in - (printf " I: %s\to: %s+>%s\tn: %s+>%s\ta: %s" - inam opri osec npri nsec moves, - cmds) - ) sol + let + mlen_fn = maximum . (map length) . snd . unzip + imlen = mlen_fn kti + nmlen = mlen_fn ktn + pmlen = (2*nmlen + 1) + in + unzip $ map + (\ (i, p, s) -> + let inst = Container.find i il + inam = fromJust $ lookup (Instance.idx inst) kti + npri = fromJust $ lookup p ktn + nsec = fromJust $ lookup s ktn + opri = fromJust $ lookup (Instance.pnode inst) ktn + osec = fromJust $ lookup (Instance.snode inst) ktn + (moves, cmds) = computeMoves inam opri osec npri nsec + ostr = (printf "%s:%s" opri osec)::String + nstr = (printf "%s:%s" npri nsec)::String + in + (printf " %-*s %-*s => %-*s a=%s" + imlen inam pmlen ostr + pmlen nstr moves, + cmds) + ) sol -- | Print the node list. printNodes :: [(Int, String)] -> NodeList -> String