Revision fcad7225 lib/client/gnt_cluster.py

b/lib/client/gnt_cluster.py
455 455
  @return: the desired exit code
456 456

  
457 457
  """
458
  simulate = opts.simulate_errors
459 458
  skip_checks = []
460 459

  
461
  if opts.nodegroup is None:
462
    # Verify cluster config.
463
    op = opcodes.OpClusterVerifyConfig(verbose=opts.verbose,
464
                                       error_codes=opts.error_codes,
465
                                       debug_simulate_errors=simulate)
466

  
467
    success, all_groups = SubmitOpCode(op, opts=opts)
468
  else:
469
    success = True
470
    all_groups = [opts.nodegroup]
471

  
472 460
  if opts.skip_nplusone_mem:
473 461
    skip_checks.append(constants.VERIFY_NPLUSONE_MEM)
474 462

  
475
  jex = JobExecutor(opts=opts, verbose=False)
463
  cl = GetClient()
476 464

  
477
  for group in all_groups:
478
    op = opcodes.OpClusterVerifyGroup(group_name=group,
479
                                      skip_checks=skip_checks,
480
                                      verbose=opts.verbose,
481
                                      error_codes=opts.error_codes,
482
                                      debug_simulate_errors=simulate)
483
    jex.QueueJob("group " + group, op)
465
  op = opcodes.OpClusterVerify(verbose=opts.verbose,
466
                               error_codes=opts.error_codes,
467
                               debug_simulate_errors=opts.simulate_errors,
468
                               skip_checks=skip_checks,
469
                               group_name=opts.nodegroup)
470
  result = SubmitOpCode(op, cl=cl, opts=opts)
484 471

  
485
  results = jex.GetResults()
486
  success &= compat.all(r[1][0] for r in results)
472
  # Keep track of submitted jobs
473
  jex = JobExecutor(cl=cl, opts=opts)
487 474

  
488
  if success:
489
    return constants.EXIT_SUCCESS
475
  for (status, job_id) in result[constants.JOB_IDS_KEY]:
476
    jex.AddJobId(None, status, job_id)
477

  
478
  results = jex.GetResults()
479
  bad_cnt = len([row for row in results if not row[0]])
480
  if bad_cnt == 0:
481
    rcode = constants.EXIT_SUCCESS
490 482
  else:
491
    return constants.EXIT_FAILURE
483
    ToStdout("%s job(s) failed while verifying the cluster.", bad_cnt)
484
    rcode = constants.EXIT_FAILURE
485

  
486
  return rcode
492 487

  
493 488

  
494 489
def VerifyDisks(opts, args):

Also available in: Unified diff