Revision f037e9d7 lib/client/gnt_job.py

b/lib/client/gnt_job.py
79 79
  fmtoverride.update(dict.fromkeys(["opstart", "opexec", "opend"],
80 80
    (lambda value: map(FormatTimestamp, value), None)))
81 81

  
82
  qfilter = qlang.MakeSimpleFilter("status", opts.status_filter)
83

  
82 84
  return GenericList(constants.QR_JOB, selected_fields, args, None,
83 85
                     opts.separator, not opts.no_headers,
84 86
                     format_override=fmtoverride, verbose=opts.verbose,
85
                     force_filter=opts.force_filter, namefield="id")
87
                     force_filter=opts.force_filter, namefield="id",
88
                     qfilter=qfilter)
86 89

  
87 90

  
88 91
def ListJobFields(opts, args):
......
337 340
  return retcode
338 341

  
339 342

  
343
_PENDING_OPT = \
344
  cli_option("--pending", default=None,
345
             action="store_const", dest="status_filter",
346
             const=frozenset([
347
               constants.JOB_STATUS_QUEUED,
348
               constants.JOB_STATUS_WAITING,
349
               ]),
350
             help="Show only jobs pending execution")
351

  
352
_RUNNING_OPT = \
353
  cli_option("--running", default=None,
354
             action="store_const", dest="status_filter",
355
             const=frozenset([
356
               constants.JOB_STATUS_RUNNING,
357
               ]),
358
             help="Show jobs currently running only")
359

  
360
_ERROR_OPT = \
361
  cli_option("--error", default=None,
362
             action="store_const", dest="status_filter",
363
             const=frozenset([
364
               constants.JOB_STATUS_ERROR,
365
               ]),
366
             help="Show failed jobs only")
367

  
368
_FINISHED_OPT = \
369
  cli_option("--finished", default=None,
370
             action="store_const", dest="status_filter",
371
             const=constants.JOBS_FINALIZED,
372
             help="Show finished jobs only")
373

  
374

  
340 375
commands = {
341 376
  "list": (
342 377
    ListJobs, [ArgJobId()],
343
    [NOHDR_OPT, SEP_OPT, FIELDS_OPT, VERBOSE_OPT, FORCE_FILTER_OPT],
378
    [NOHDR_OPT, SEP_OPT, FIELDS_OPT, VERBOSE_OPT, FORCE_FILTER_OPT,
379
     _PENDING_OPT, _RUNNING_OPT, _ERROR_OPT, _FINISHED_OPT],
344 380
    "[job_id ...]",
345 381
    "Lists the jobs and their status. The available fields can be shown"
346 382
    " using the \"list-fields\" command (see the man page for details)."

Also available in: Unified diff