This new 'execJobs' function doesn't wait for job completion, it just
returns the job IDs immediately.

Signed-off-by: Dato Simó <[email protected]>
---
 src/Ganeti/Jobs.hs | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/src/Ganeti/Jobs.hs b/src/Ganeti/Jobs.hs
index 7990a77..b690a4d 100644
--- a/src/Ganeti/Jobs.hs
+++ b/src/Ganeti/Jobs.hs
@@ -24,7 +24,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 -}
 
 module Ganeti.Jobs
-  ( execJobsWait
+  ( execJobs
+  , execJobsWait
   , waitForJobs
   ) where
 
@@ -36,6 +37,15 @@ import qualified Ganeti.Luxi as L
 import Ganeti.OpCodes
 import Ganeti.Types
 
+-- | Executes a set of jobs and returns their job IDs without waiting for
+-- completion.
+execJobs :: [[MetaOpCode]] -> L.Client -> IO (Result [L.JobId])
+execJobs opcodes client = do
+  jids <- L.submitManyJobs client opcodes
+  return (case jids of
+            Bad e    -> Bad $ "Job submission error: " ++ formatError e
+            Ok jids' -> Ok jids')
+
 -- | Executes a set of jobs and waits for their completion, returning their
 -- status.
 execJobsWait :: [[MetaOpCode]]        -- ^ The list of jobs
@@ -43,9 +53,9 @@ execJobsWait :: [[MetaOpCode]]        -- ^ The list of jobs
              -> L.Client              -- ^ The Luxi client
              -> IO (Result [(L.JobId, JobStatus)])
 execJobsWait opcodes callback client = do
-  jids <- L.submitManyJobs client opcodes
+  jids <- execJobs opcodes client
   case jids of
-    Bad e -> return . Bad $ "Job submission error: " ++ formatError e
+    Bad e -> return $ Bad e
     Ok jids' -> do
       callback jids'
       waitForJobs jids' client
-- 
1.8.0.2-x20-1

Reply via email to