Revision 293ba2d8

b/lib/cli.py
1188 1188
    raise errors.OpExecError(result)
1189 1189

  
1190 1190

  
1191
def SubmitOpCode(op, cl=None, feedback_fn=None):
1191
def SubmitOpCode(op, cl=None, feedback_fn=None, opts=None):
1192 1192
  """Legacy function to submit an opcode.
1193 1193

  
1194 1194
  This is just a simple wrapper over the construction of the processor
......
1199 1199
  if cl is None:
1200 1200
    cl = GetClient()
1201 1201

  
1202
  SetGenericOpcodeOpts([op], opts)
1203

  
1202 1204
  job_id = SendJob([op], cl)
1203 1205

  
1204 1206
  op_results = PollJob(job_id, cl=cl, feedback_fn=feedback_fn)
......
1214 1216
  whether to just send the job and print its identifier. It is used in
1215 1217
  order to simplify the implementation of the '--submit' option.
1216 1218

  
1217
  It will also add the dry-run parameter from the options passed, if true.
1219
  It will also process the opcodes if we're sending the via SendJob
1220
  (otherwise SubmitOpCode does it).
1218 1221

  
1219 1222
  """
1220
  if opts and opts.dry_run:
1221
    op.dry_run = opts.dry_run
1222 1223
  if opts and opts.submit_only:
1223
    job_id = SendJob([op], cl=cl)
1224
    job = [op]
1225
    SetGenericOpcodeOpts(job, opts)
1226
    job_id = SendJob(job, cl=cl)
1224 1227
    raise JobSubmittedException(job_id)
1225 1228
  else:
1226
    return SubmitOpCode(op, cl=cl, feedback_fn=feedback_fn)
1229
    return SubmitOpCode(op, cl=cl, feedback_fn=feedback_fn, opts=opts)
1230

  
1231

  
1232
def SetGenericOpcodeOpts(opcode_list, options):
1233
  """Processor for generic options.
1234

  
1235
  This function updates the given opcodes based on generic command
1236
  line options (like debug, dry-run, etc.).
1237

  
1238
  @param opcode_list: list of opcodes
1239
  @param options: command line options or None
1240
  @return: None (in-place modification)
1241

  
1242
  """
1243
  if not options:
1244
    return
1245
  for op in opcode_list:
1246
    op.dry_run = options.dry_run
1247
    op.debug_level = options.debug
1227 1248

  
1228 1249

  
1229 1250
def GetClient():

Also available in: Unified diff