Skip to content
Snippets Groups Projects
Commit 142538ff authored by Iustin Pop's avatar Iustin Pop
Browse files

Enhance the command list for the solution

This patch moves the formatting of the command list to Cluster.hs and
enhances it with separator messages between the steps.
parent 79ac6b6f
No related branches found
No related tags found
No related merge requests found
...@@ -23,6 +23,7 @@ module Cluster ...@@ -23,6 +23,7 @@ module Cluster
, applySolution , applySolution
, printSolution , printSolution
, printSolutionLine , printSolutionLine
, formatCmds
, printNodes , printNodes
-- * Balacing functions -- * Balacing functions
, checkMove , checkMove
...@@ -569,6 +570,13 @@ printSolutionLine il ktn kti nmlen imlen plc = ...@@ -569,6 +570,13 @@ printSolutionLine il ktn kti nmlen imlen plc =
pmlen nstr c moves, pmlen nstr c moves,
cmds) 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 -} {-| Converts a solution to string format -}
printSolution :: InstanceList printSolution :: InstanceList
-> [(Int, String)] -> [(Int, String)]
......
...@@ -185,8 +185,7 @@ main = do ...@@ -185,8 +185,7 @@ main = do
do do
putStrLn "" putStrLn ""
putStrLn "Commands to run to reach the above solution:" putStrLn "Commands to run to reach the above solution:"
putStr $ unlines $ map (" echo gnt-instance " ++) putStr . Cluster.formatCmds . reverse $ cmd_strs
$ concat $ reverse cmd_strs
when (optShowNodes opts) $ when (optShowNodes opts) $
do do
let (orig_mem, orig_disk) = Cluster.totalResources nl let (orig_mem, orig_disk) = Cluster.totalResources nl
......
...@@ -187,7 +187,8 @@ main = do ...@@ -187,7 +187,8 @@ main = do
do do
putStrLn "" putStrLn ""
putStrLn "Commands to run to reach the above solution:" 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) $ when (optShowNodes opts) $
do do
let (orig_mem, orig_disk) = Cluster.totalResources nl let (orig_mem, orig_disk) = Cluster.totalResources nl
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment