Commit 4b49a72b authored by Klaus Aehlig's avatar Klaus Aehlig

Provide a convenience method to optain a QueuedOpCode

When generating jobs from sequences of op-codes, it is necessary
to wrap op-codes into queued form.
Signed-off-by: default avatarKlaus Aehlig <aehlig@google.com>
Reviewed-by: default avatarMichele Tartara <mtartara@google.com>
parent 5badb3e7
......@@ -29,6 +29,7 @@ module Ganeti.JQueue
( QueuedOpCode(..)
, QueuedJob(..)
, InputOpCode(..)
, queuedOpCodeFromMetaOpCode
, Timestamp
, noTimestamp
, opStatusFinalized
......@@ -48,6 +49,7 @@ module Ganeti.JQueue
import Control.Exception
import Control.Monad
import Data.List
import Data.Maybe
import Data.Ord (comparing)
-- workaround what seems to be a bug in ghc 7.4's TH shadowing code
import Prelude hiding (log, id)
......@@ -131,6 +133,20 @@ $(buildObject "QueuedJob" "qj"
simpleField "end_timestamp" [t| Timestamp |]
])
-- | Convenience function to obtain a QueuedOpCode from a MetaOpCode
queuedOpCodeFromMetaOpCode :: MetaOpCode -> QueuedOpCode
queuedOpCodeFromMetaOpCode op =
QueuedOpCode { qoInput = ValidOpCode op
, qoStatus = OP_STATUS_QUEUED
, qoPriority = opSubmitPriorityToRaw . opPriority . metaParams
$ op
, qoLog = []
, qoResult = JSNull
, qoStartTimestamp = Nothing
, qoEndTimestamp = Nothing
, qoExecTimestamp = Nothing
}
-- | Job file prefix.
jobFilePrefix :: String
jobFilePrefix = "job-"
......
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