On Thu, Nov 7, 2013 at 1:20 PM, Klaus Aehlig <[email protected]> wrote:
> SubmitManyJobs also accepts jobs with dependencies given as
> relative ids. Together with the absolute id of the job, once
> assigned, the dependency can be resolved. Add a function doing
> this computation.
>
> Signed-off-by: Klaus Aehlig <[email protected]>
> ---
>  src/Ganeti/Types.hs | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
>
> diff --git a/src/Ganeti/Types.hs b/src/Ganeti/Types.hs
> index 63124fd..8e2f4ec 100644
> --- a/src/Ganeti/Types.hs
> +++ b/src/Ganeti/Types.hs
> @@ -110,6 +110,7 @@ module Ganeti.Types
>    , RelativeJobId
>    , JobIdDep(..)
>    , JobDependency(..)
> +  , absoluteJobDependency
>    , OpSubmitPriority(..)
>    , opSubmitPriorityToRaw
>    , parseSubmitPriority
> @@ -675,6 +676,12 @@ instance JSON.JSON JobIdDep where
>        JSON.Ok r -> return $ JobDepRelative r
>        JSON.Error _ -> liftM JobDepAbsolute (parseJobId v)
>
> +-- | From job ID dependency and job ID, compute the absolute dependency.
> +absoluteJobIdDep :: (Monad m) => JobIdDep -> JobId -> m JobIdDep
> +absoluteJobIdDep (JobDepAbsolute jid) _ = return $ JobDepAbsolute jid
> +absoluteJobIdDep (JobDepRelative rjid) jid =
> +  liftM JobDepAbsolute . makeJobId $ fromJobId jid + fromNegative rjid
> +
>  -- | Job Dependency type.
>  data JobDependency = JobDependency JobIdDep [FinalizedJobStatus]
>                       deriving (Show, Eq)
> @@ -683,6 +690,11 @@ instance JSON JobDependency where
>    showJSON (JobDependency dep status) = showJSON (dep, status)
>    readJSON = liftM (uncurry JobDependency) . readJSON
>
> +-- | From job dependency and job id compute an absolute job dependency.
> +absoluteJobDependency :: (Monad m) => JobDependency -> JobId -> m 
> JobDependency
> +absoluteJobDependency (JobDependency jdep fstats) jid =
> +  liftM (flip JobDependency fstats) $ absoluteJobIdDep jdep jid
> +
>  -- | Valid opcode priorities for submit.
>  $(THH.declareIADT "OpSubmitPriority"
>    [ ("OpPrioLow",    'ConstantUtils.priorityLow)
> --
> 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