Commit f5d13a77 authored by Klaus Aehlig's avatar Klaus Aehlig

Add new command gnt_job wait

This command tacitly waits for a job to finish. In that
way, job dependency can also be handled in shell scripts.
Signed-off-by: default avatarKlaus Aehlig <>
Reviewed-by: default avatarHelga Velroyen <>
parent e7aa0b03
......@@ -440,6 +440,28 @@ def WatchJob(opts, args):
return retcode
def WaitJob(opts, args):
"""Wait for a job to finish, not producing any output.
@param opts: the command line options selected by the user
@type args: list
@param args: Contains the job ID
@rtype: int
@return: the desired exit code
job_id = args[0]
retcode = 0
cli.PollJob(job_id, feedback_fn=lambda _: None)
except errors.GenericError, err:
(retcode, job_result) = cli.FormatError(err)
ToStderr("Job %s failed: %s", job_id, job_result)
return retcode
cli_option("--pending", default=None,
action="store_const", dest="status_filter",
......@@ -523,6 +545,9 @@ commands = {
ShowJobs, [ArgJobId(min=1)], [],
"<job-id> [<job-id> ...]",
"Show detailed information about the specified jobs"),
"wait": (
WaitJob, [ArgJobId(min=1, max=1)], [],
"<job-id>", "Wait for a job to finish"),
"watch": (
WatchJob, [ArgJobId(min=1, max=1)], [],
"<job-id>", "Follows a job and prints its output as it arrives"),
......@@ -124,6 +124,14 @@ LIST-FIELDS
Lists available fields for jobs.
**wait** {id}
Wait for the job by the given *id* to finish; do not produce
any output.
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