Enable hbal to use the new command line option
[ganeti-local] / hbal.hs
diff --git a/hbal.hs b/hbal.hs
index 1ad686e..529a643 100644 (file)
--- a/hbal.hs
+++ b/hbal.hs
@@ -59,8 +59,8 @@ options =
     , oPrintInsts
     , oPrintCommands
     , oOneline
-    , oNodeFile
-    , oInstFile
+    , oDataFile
+    , oEvacMode
     , oRapiMaster
     , oLuxiSocket
     , oExecJobs
@@ -73,6 +73,8 @@ options =
     , oMinDisk
     , oDiskMoves
     , oDynuFile
+    , oExTags
+    , oExInst
     , oShowVer
     , oShowHelp
     ]
@@ -89,12 +91,16 @@ iterateDepth :: Cluster.Table    -- ^ The starting table
              -> [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 ->
@@ -112,6 +118,7 @@ iterateDepth ini_tbl max_rounds disk_moves nmlen imlen
                        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
@@ -186,7 +193,7 @@ main = do
       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
@@ -209,6 +216,9 @@ main = do
       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")
@@ -264,7 +274,7 @@ main = do
 
   (fin_tbl, cmd_strs) <- iterateDepth ini_tbl (optMaxLength opts)
                          (optDiskMoves opts)
-                         nmlen imlen [] oneline min_cv
+                         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