Commit a7ab381a authored by Klaus Aehlig's avatar Klaus Aehlig

Add a function changing the priority of an opcode

This pure function follows the semantic that an opcode, including
its priority, may only be changed if the opcode is not finalized.
Signed-off-by: default avatarKlaus Aehlig <aehlig@google.com>
Reviewed-by: default avatarPetr Pudlak <pudlak@google.com>
parent 27a5367a
......@@ -31,6 +31,7 @@ module Ganeti.JQueue
, InputOpCode(..)
, queuedOpCodeFromMetaOpCode
, queuedJobFromOpCodes
, changeOpCodePriority
, cancelQueuedJob
, Timestamp
, fromClockTime
......@@ -213,6 +214,14 @@ queuedJobFromOpCodes jobid ops = do
setReceivedTimestamp :: Timestamp -> QueuedJob -> QueuedJob
setReceivedTimestamp ts job = job { qjReceivedTimestamp = Just ts }
-- | Change the priority of a QueuedOpCode, if it is not already
-- finalized.
changeOpCodePriority :: Int -> QueuedOpCode -> QueuedOpCode
changeOpCodePriority prio op =
if qoStatus op > OP_STATUS_RUNNING
then op
else op { qoPriority = prio }
-- | Set the state of a QueuedOpCode to canceled.
cancelOpCode :: Timestamp -> QueuedOpCode -> QueuedOpCode
cancelOpCode now op =
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment