On Thu, Nov 7, 2013 at 1:20 PM, Klaus Aehlig <[email protected]> wrote:
> When generating jobs from sequences of op-codes, it is necessary
> to wrap op-codes into queued form.
>
> Signed-off-by: Klaus Aehlig <[email protected]>
> ---
>  src/Ganeti/JQueue.hs | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
>
> diff --git a/src/Ganeti/JQueue.hs b/src/Ganeti/JQueue.hs
> index 828e662..937dd27 100644
> --- a/src/Ganeti/JQueue.hs
> +++ b/src/Ganeti/JQueue.hs
> @@ -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-"
> --
> 1.8.4.1
>

LGTM, thanks.
Michele

-- 
Google Germany GmbH
Dienerstr. 12
80331 München

Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg
Geschäftsführer: Graham Law, Christine Elizabeth Flores

Reply via email to