LGTM
On Thu, Apr 10, 2014 at 11:57 AM, Klaus Aehlig <[email protected]> wrote: > Add a function that computes the list of job ids a job depends > on. This will allow to schedule only those jobs for execution, > where all jobs it depends on have been finalized. > > Signed-off-by: Klaus Aehlig <[email protected]> > --- > src/Ganeti/JQueue.hs | 14 ++++++++++++++ > 1 file changed, 14 insertions(+) > > diff --git a/src/Ganeti/JQueue.hs b/src/Ganeti/JQueue.hs > index 8cd1811..5cd07ca 100644 > --- a/src/Ganeti/JQueue.hs > +++ b/src/Ganeti/JQueue.hs > @@ -41,6 +41,7 @@ module Ganeti.JQueue > , advanceTimestamp > , setReceivedTimestamp > , extendJobReasonTrail > + , getJobDependencies > , opStatusFinalized > , extractOpSummary > , calcJobStatus > @@ -137,6 +138,11 @@ data InputOpCode = ValidOpCode MetaOpCode -- ^ OpCode > was parsed successfully > | InvalidOpCode JSValue -- ^ Invalid opcode > deriving (Show, Eq) > > +-- | From an InputOpCode obtain the MetaOpCode, if any. > +toMetaOpCode :: InputOpCode -> [MetaOpCode] > +toMetaOpCode (ValidOpCode mopc) = [mopc] > +toMetaOpCode _ = [] > + > -- | JSON instance for 'InputOpCode', trying to parse it and if > -- failing, keeping the original JSValue. > instance Text.JSON.JSON InputOpCode where > @@ -263,6 +269,14 @@ extendJobReasonTrail job = > qjOps job > } > > +-- | From a queued job obtain the list of jobs it depends on. > +getJobDependencies :: QueuedJob -> [JobId] > +getJobDependencies job = do > + op <- qjOps job > + mopc <- toMetaOpCode $ qoInput op > + dep <- fromMaybe [] . opDepends $ metaParams mopc > + getJobIdFromDependency dep > + > -- | Change the priority of a QueuedOpCode, if it is not already > -- finalized. > changeOpCodePriority :: Int -> QueuedOpCode -> QueuedOpCode > -- > 1.9.1.423.g4596e3a > >
