Commit 1c1132f4 authored by Klaus Aehlig's avatar Klaus Aehlig

Provide convenience function to create Job from op-codes

This function handles the pure part of generating a job,
i.e., assuming the job id already assigned and not setting
time stamps.
Signed-off-by: default avatarKlaus Aehlig <aehlig@google.com>
Reviewed-by: default avatarMichele Tartara <mtartara@google.com>
parent 62933497
......@@ -30,6 +30,7 @@ module Ganeti.JQueue
, QueuedJob(..)
, InputOpCode(..)
, queuedOpCodeFromMetaOpCode
, queuedJobFromOpCodes
, Timestamp
, noTimestamp
, opStatusFinalized
......@@ -147,6 +148,19 @@ queuedOpCodeFromMetaOpCode op =
, qoExecTimestamp = Nothing
}
-- | From a job-id and a list of op-codes create a job. This is
-- the pure part of job creation, as allocating a new job id
-- lives in IO.
queuedJobFromOpCodes :: (Monad m) => JobId -> [MetaOpCode] -> m QueuedJob
queuedJobFromOpCodes jobid ops = do
ops' <- mapM (`resolveDependencies` jobid) ops
return QueuedJob { qjId = jobid
, qjOps = map queuedOpCodeFromMetaOpCode ops'
, qjReceivedTimestamp = Nothing
, qjStartTimestamp = Nothing
, qjEndTimestamp = 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