Enhance the command list for the solution
authorIustin Pop <iustin@google.com>
Fri, 13 Mar 2009 19:11:12 +0000 (20:11 +0100)
committerIustin Pop <iustin@google.com>
Fri, 13 Mar 2009 19:11:12 +0000 (20:11 +0100)
This patch moves the formatting of the command list to Cluster.hs and
enhances it with separator messages between the steps.

src/Cluster.hs
src/hbal.hs
src/hn1.hs

index 0247e6a..8494491 100644 (file)
@@ -23,6 +23,7 @@ module Cluster
     , applySolution
     , printSolution
     , printSolutionLine
+    , formatCmds
     , printNodes
     -- * Balacing functions
     , checkMove
@@ -569,6 +570,13 @@ printSolutionLine il ktn kti nmlen imlen plc =
        pmlen nstr c moves,
        cmds)
 
+formatCmds :: [[String]] -> String
+formatCmds cmd_strs =
+    unlines $ map ("  echo " ++) $
+    concat $ map (\(a, b) ->
+        (printf "step %d" (a::Int)):(map ("gnt-instance" ++) b)) $
+        zip [1..] cmd_strs
+
 {-| Converts a solution to string format -}
 printSolution :: InstanceList
               -> [(Int, String)]
index 352fbb4..06d85c5 100644 (file)
@@ -185,8 +185,7 @@ main = do
        do
          putStrLn ""
          putStrLn "Commands to run to reach the above solution:"
-         putStr $ unlines $ map ("  echo gnt-instance " ++)
-                    $ concat $ reverse cmd_strs
+         putStr . Cluster.formatCmds . reverse $ cmd_strs
   when (optShowNodes opts) $
        do
          let (orig_mem, orig_disk) = Cluster.totalResources nl
index cb84392..5506e8a 100644 (file)
@@ -187,7 +187,8 @@ main = do
        do
          putStrLn ""
          putStrLn "Commands to run to reach the above solution:"
-         putStr $ unlines $ map ("  echo gnt-instance " ++) $ concat cmd_strs
+         putStr . Cluster.formatCmds . reverse $ cmd_strs
+
   when (optShowNodes opts) $
        do
          let (orig_mem, orig_disk) = Cluster.totalResources nl