Revision e7d6946c
b/man/gnt-job.sgml | ||
---|---|---|
231 | 231 |
</para> |
232 | 232 |
|
233 | 233 |
</refsect2> |
234 |
|
|
235 |
<refsect2> |
|
236 |
<title>WATCH</title> |
|
237 |
<cmdsynopsis> |
|
238 |
<command>watch</command> |
|
239 |
<arg>id</arg> |
|
240 |
</cmdsynopsis> |
|
241 |
|
|
242 |
<para> |
|
243 |
This command follows the output of the job by the given |
|
244 |
<replaceable>id</replaceable> and prints it. |
|
245 |
</para> |
|
246 |
</refsect2> |
|
247 |
|
|
234 | 248 |
</refsect1> |
235 | 249 |
|
236 | 250 |
&footer; |
b/scripts/gnt-job | ||
---|---|---|
29 | 29 |
from ganeti import constants |
30 | 30 |
from ganeti import errors |
31 | 31 |
from ganeti import utils |
32 |
from ganeti import cli |
|
32 | 33 |
|
33 | 34 |
|
34 | 35 |
#: default list of fields for L{ListJobs} |
... | ... | |
312 | 313 |
return 0 |
313 | 314 |
|
314 | 315 |
|
316 |
def WatchJob(opts, args): |
|
317 |
"""Follow a job and print its output as it arrives. |
|
318 |
|
|
319 |
@param opts: the command line options selected by the user |
|
320 |
@type args: list |
|
321 |
@param args: Contains the job ID |
|
322 |
@rtype: int |
|
323 |
@return: the desired exit code |
|
324 |
|
|
325 |
""" |
|
326 |
job_id = args[0] |
|
327 |
|
|
328 |
msg = ("Output from job %s follows" % job_id) |
|
329 |
ToStdout(msg) |
|
330 |
ToStdout("-" * len(msg)) |
|
331 |
|
|
332 |
retcode = 0 |
|
333 |
try: |
|
334 |
cli.PollJob(job_id) |
|
335 |
except errors.GenericError, err: |
|
336 |
(retcode, job_result) = cli.FormatError(err) |
|
337 |
ToStderr("Job %s failed: %s", job_id, job_result) |
|
338 |
|
|
339 |
return retcode |
|
340 |
|
|
341 |
|
|
315 | 342 |
commands = { |
316 | 343 |
'list': (ListJobs, ARGS_ANY, |
317 | 344 |
[DEBUG_OPT, NOHDR_OPT, SEP_OPT, FIELDS_OPT], |
... | ... | |
336 | 363 |
'info': (ShowJobs, ARGS_ANY, [DEBUG_OPT], |
337 | 364 |
"<job-id> [<job-id> ...]", |
338 | 365 |
"Show detailed information about the specified jobs"), |
366 |
'watch': (WatchJob, ARGS_ONE, [DEBUG_OPT], |
|
367 |
"<job-id>", |
|
368 |
"Follows a job and prints its output as it arrives"), |
|
339 | 369 |
} |
340 | 370 |
|
341 | 371 |
|
Also available in: Unified diff