Revision 94428652

b/lib/cli.py
44 44
           "SubmitOpCode", "GetClient",
45 45
           "cli_option", "GenerateTable", "AskUser",
46 46
           "ARGS_NONE", "ARGS_FIXED", "ARGS_ATLEAST", "ARGS_ANY", "ARGS_ONE",
47
           "USEUNITS_OPT", "FIELDS_OPT", "FORCE_OPT",
47
           "USEUNITS_OPT", "FIELDS_OPT", "FORCE_OPT", "SUBMIT_OPT",
48 48
           "ListTags", "AddTags", "RemoveTags", "TAG_SRC_OPT",
49
           "FormatError", "SplitNodeOption"
49
           "FormatError", "SplitNodeOption", "SubmitOrSend",
50 50
           ]
51 51

  
52 52

  
......
180 180
TAG_SRC_OPT = make_option("--from", dest="tags_source",
181 181
                          default=None, help="File with tag names")
182 182

  
183
SUBMIT_OPT = make_option("--submit", dest="submit_only",
184
                         default=False, action="store_true",
185
                         help="Submit the job and return the job ID, but"
186
                         " don't wait for the job to finish")
187

  
183 188

  
184 189
def ARGS_FIXED(val):
185 190
  """Macro-like function denoting a fixed number of arguments"""
......
447 452
  return PollJob(job_id, cl)
448 453

  
449 454

  
455
def SubmitOrSend(op, opts, cl=None, feedback_fn=None):
456
  """Wrapper around SubmitOpCode or SendJob.
457

  
458
  This function will decide, based on the 'opts' parameter, whether to
459
  submit and wait for the result of the opcode (and return it), or
460
  whether to just send the job and print its identifier. It is used in
461
  order to simplify the implementation of the '--submit' option.
462

  
463
  """
464
  if opts and opts.submit_only:
465
    print SendJob([op], cl=cl)
466
    sys.exit(0)
467
  else:
468
    return SubmitOpCode(op, cl=cl, feedback_fn=feedback_fn)
469

  
470

  
450 471
def GetClient():
451 472
  # TODO: Cache object?
452 473
  try:
b/scripts/gnt-node
79 79
    selected_fields = opts.output.split(",")
80 80

  
81 81
  op = opcodes.OpQueryNodes(output_fields=selected_fields, names=[])
82
  output = SubmitOpCode(op)
82
  output = SubmitOrSend(op, opts)
83 83

  
84 84
  if not opts.no_headers:
85 85
    headers = {
......
335 335
  'info': (ShowNodeConfig, ARGS_ANY, [DEBUG_OPT],
336 336
           "[<node_name>...]", "Show information about the node(s)"),
337 337
  'list': (ListNodes, ARGS_NONE,
338
           [DEBUG_OPT, NOHDR_OPT, SEP_OPT, USEUNITS_OPT, FIELDS_OPT],
338
           [DEBUG_OPT, NOHDR_OPT, SEP_OPT, USEUNITS_OPT, FIELDS_OPT,
339
            SUBMIT_OPT],
339 340
           "", "Lists the nodes in the cluster. The available fields"
340 341
           " are (see the man page for details): name, pinst_cnt, pinst_list,"
341 342
           " sinst_cnt, sinst_list, pip, sip, dtotal, dfree, mtotal, mnode,"

Also available in: Unified diff