diff --git a/src/Ganeti/HTools/Program/Hbal.hs b/src/Ganeti/HTools/Program/Hbal.hs index 09deca74112773bbd6617e8701f6b772ea8a4af5..be10c1a5a250ee0fa5a6cf646ab10c96ac31ebab 100644 --- a/src/Ganeti/HTools/Program/Hbal.hs +++ b/src/Ganeti/HTools/Program/Hbal.hs @@ -54,7 +54,8 @@ import Ganeti.HTools.CLI import Ganeti.HTools.ExtLoader import Ganeti.HTools.Types import Ganeti.HTools.Loader -import Ganeti.OpCodes (wrapOpCode, setOpComment, OpCode, MetaOpCode) +import Ganeti.OpCodes (wrapOpCode, setOpComment, setOpPriority, + OpCode, MetaOpCode) import Ganeti.Jobs as Jobs import Ganeti.Types import Ganeti.Utils @@ -93,6 +94,7 @@ options = do , oExTags , oExInst , oSaveCluster + , oPriority ] -- | The list of arguments supported by the program. @@ -224,7 +226,9 @@ maybeExecJobs opts ord_plc fin_nl il cmd_jobs = Nothing -> return $ Bad "Execution of commands possible only on LUXI" Just master -> - execWithCancel annotateOpCode master fin_nl il cmd_jobs) + let annotator = maybe id setOpPriority (optPriority opts) . + annotateOpCode + in execWithCancel annotator master fin_nl il cmd_jobs) else return $ Ok () -- | Signal handler for graceful termination. diff --git a/test/hs/shelltests/htools-balancing.test b/test/hs/shelltests/htools-balancing.test index bd3ef57e6a868cf9b267dd2857255f154d3bcff9..98b87b4762b0d0f29a6e1aed4ad5a9e89b176726 100644 --- a/test/hs/shelltests/htools-balancing.test +++ b/test/hs/shelltests/htools-balancing.test @@ -13,6 +13,12 @@ >>> /gnt-instance (failover|migrate|replace-disks)/ >>>= 0 +# test that correct priorities are accepted +./test/hs/hbal $BACKEND_BAL_STD -G group-01 -C -S $T/simu-rebal.standard --prio low +>>> /gnt-instance (failover|migrate|replace-disks)/ +>>>= 0 + + # test that hbal won't execute rebalances when using the text backend ./test/hs/hbal $BACKEND_BAL_STD -G group-01 -X >>>2 diff --git a/test/hs/shelltests/htools-invalid.test b/test/hs/shelltests/htools-invalid.test index 4c08a5859a57e87ccc8a50b9be7d173620258217..eabce21bed8ac8e7213b945b61a8cb3a768e69df 100644 --- a/test/hs/shelltests/htools-invalid.test +++ b/test/hs/shelltests/htools-invalid.test @@ -57,3 +57,8 @@ Error: This program doesn't take any arguments. >>>2 Error: Cannot create node graph >>>=1 + +# hbal doesn't accept invalid priority +./test/hs/hbal --priority=abc +>>>2/Unknown priority/ +>>>=1