options :: [OptType]
options =
[ oPrintNodes
+ , oPrintInsts
, oPrintCommands
, oOneline
- , oNodeFile
- , oInstFile
+ , oDataFile
+ , oEvacMode
, oRapiMaster
, oLuxiSocket
, oExecJobs
, oMaxCpu
, oMinDisk
, oDiskMoves
+ , oDynuFile
+ , oExTags
+ , oExInst
, oShowVer
, oShowHelp
]
-> [MoveJob] -- ^ Current command list
-> Bool -- ^ Whether to be silent
-> Score -- ^ Score at which to stop
+ -> Bool -- ^ Enable evacuation mode
-> IO (Cluster.Table, [MoveJob]) -- ^ The resulting table
-- and commands
iterateDepth ini_tbl max_rounds disk_moves nmlen imlen
- cmd_strs oneline min_score =
+ cmd_strs oneline min_score evac_mode =
let Cluster.Table ini_nl ini_il _ _ = ini_tbl
- m_fin_tbl = Cluster.tryBalance ini_tbl max_rounds disk_moves min_score
+ allowed_next = Cluster.doNextBalance ini_tbl max_rounds min_score
+ m_fin_tbl = if allowed_next
+ then Cluster.tryBalance ini_tbl disk_moves evac_mode
+ else Nothing
in
case m_fin_tbl of
Just fin_tbl ->
hFlush stdout
iterateDepth fin_tbl max_rounds disk_moves
nmlen imlen upd_cmd_strs oneline min_score
+ evac_mode
Nothing -> return (ini_tbl, cmd_strs)
-- | Formats the solution for the oneline display
let oneline = optOneline opts
verbose = optVerbose opts
+ shownodes = optShowNodes opts
- (fixed_nl, il, csf) <- loadExternalData opts
+ (fixed_nl, il, ctags, csf) <- loadExternalData opts
let offline_names = optOffline opts
all_nodes = Container.elems fixed_nl
nl = Container.map (flip Node.setMdsk m_dsk . flip Node.setMcpu m_cpu)
nm
+ when (not oneline && verbose > 1) $
+ putStrLn $ "Loaded cluster tags: " ++ intercalate "," ctags
+
when (Container.size il == 0) $ do
(if oneline then putStrLn $ formatOneline 0 0 0
else printf "Cluster is empty, exiting.\n")
putStrLn "Cluster is not N+1 happy, continuing but no guarantee \
\that the cluster will end N+1 happy."
- when (optShowNodes opts) $
+ when (optShowInsts opts) $ do
+ putStrLn ""
+ putStrLn "Initial instance map:"
+ putStrLn $ Cluster.printInsts nl il
+
+ when (isJust shownodes) $
do
putStrLn "Initial cluster status:"
- putStrLn $ Cluster.printNodes nl
+ putStrLn $ Cluster.printNodes nl (fromJust shownodes)
let ini_cv = Cluster.compCV nl
ini_tbl = Cluster.Table nl il ini_cv []
(fin_tbl, cmd_strs) <- iterateDepth ini_tbl (optMaxLength opts)
(optDiskMoves opts)
- nmlen imlen [] oneline min_cv
- let (Cluster.Table fin_nl _ fin_cv fin_plc) = fin_tbl
+ nmlen imlen [] oneline min_cv (optEvacMode opts)
+ let (Cluster.Table fin_nl fin_il fin_cv fin_plc) = fin_tbl
ord_plc = reverse fin_plc
sol_msg = if null fin_plc
then printf "No solution found\n"
exitWith $ ExitFailure 1
Just master -> execJobSet master csf fin_nl il cmd_jobs)
- when (optShowNodes opts) $
+ when (optShowInsts opts) $ do
+ putStrLn ""
+ putStrLn "Final instance map:"
+ putStr $ Cluster.printInsts fin_nl fin_il
+
+ when (isJust shownodes) $
do
let ini_cs = Cluster.totalResources nl
fin_cs = Cluster.totalResources fin_nl
putStrLn ""
putStrLn "Final cluster status:"
- putStrLn $ Cluster.printNodes fin_nl
+ putStrLn $ Cluster.printNodes fin_nl (fromJust shownodes)
when (verbose > 3) $
do
printf "Original: mem=%d disk=%d\n"
- (Cluster.cs_fmem ini_cs) (Cluster.cs_fdsk ini_cs)
+ (Cluster.csFmem ini_cs) (Cluster.csFdsk ini_cs)
printf "Final: mem=%d disk=%d\n"
- (Cluster.cs_fmem fin_cs) (Cluster.cs_fdsk fin_cs)
+ (Cluster.csFmem fin_cs) (Cluster.csFdsk fin_cs)
when oneline $
putStrLn $ formatOneline ini_cv (length ord_plc) fin_cv