Commit f2921752 authored by Iustin Pop's avatar Iustin Pop
Browse files

Modify cli.JobExecutor to use SubmitManyJobs

This patch changes the generic "multiple job executor" to use the many
jobs submit model, which automatically makes all its users use the new

This makes, for example, startup/shutdown of a full cluster much more
logical (all the submitted job IDs are visible fast, and then waiting
for them proceeds normally).
Signed-off-by: default avatarIustin Pop <>
Reviewed-by: default avatarGuido Trotter <>
(cherry picked from commit 23b4b983)
parent 56d8ff91
......@@ -994,15 +994,24 @@ class JobExecutor(object):
cl = GetClient() = cl
self.verbose = verbose = []
def QueueJob(self, name, *ops):
"""Submit a job for execution.
"""Record a job for later submit.
@type name: string
@param name: a description of the job, will be used in WaitJobSet
job_id = SendJob(ops,
self.queue.append((job_id, name))
self.queue.append((name, ops))
def SubmitPending(self):
"""Submit all pending jobs.
results =[row[1] for row in self.queue])
for ((status, data), (name, _)) in zip(results, self.queue):, data, name))
def GetResults(self):
"""Wait for and return the results of all jobs.
......@@ -1013,10 +1022,18 @@ class JobExecutor(object):
there will be the error message
if not
results = []
if self.verbose:
ToStdout("Submitted jobs %s", ", ".join(row[0] for row in self.queue))
for jid, name in self.queue:
ok_jobs = [row[1] for row in if row[0]]
if ok_jobs:
ToStdout("Submitted jobs %s", ", ".join(ok_jobs))
for submit_status, jid, name in
if not submit_status:
ToStderr("Failed to submit job for %s: %s", name, jid)
results.append((False, jid))
if self.verbose:
ToStdout("Waiting for job %s for %s...", jid, name)
......@@ -1041,5 +1058,10 @@ class JobExecutor(object):
if wait:
return self.GetResults()
for jid, name in self.queue:
ToStdout("%s: %s", jid, name)
if not
for status, result, name in
if status:
ToStdout("%s: %s", result, name)
ToStderr("Failure for %s: %s", name, result)
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