Revision fcad7225

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):
b/lib/cmdlib.py
1510 1510
      self.bad = self.bad or cond
1511 1511

  
1512 1512

  
1513
class LUClusterVerify(NoHooksLU):
1514
  """Submits all jobs necessary to verify the cluster.
1515

  
1516
  """
1517
  REQ_BGL = False
1518

  
1519
  def ExpandNames(self):
1520
    self.needed_locks = {}
1521

  
1522
  def Exec(self, feedback_fn):
1523
    jobs = []
1524

  
1525
    if self.op.group_name:
1526
      groups = [self.op.group_name]
1527
      depends_fn = lambda: None
1528
    else:
1529
      groups = self.cfg.GetNodeGroupList()
1530

  
1531
      # Verify global configuration
1532
      jobs.append([opcodes.OpClusterVerifyConfig()])
1533

  
1534
      # Always depend on global verification
1535
      depends_fn = lambda: [(-len(jobs), [])]
1536

  
1537
    jobs.extend([opcodes.OpClusterVerifyGroup(group_name=group,
1538
                                              depends=depends_fn())]
1539
                for group in groups)
1540

  
1541
    # Fix up all parameters
1542
    for op in itertools.chain(*jobs): # pylint: disable-msg=W0142
1543
      op.debug_simulate_errors = self.op.debug_simulate_errors
1544
      op.verbose = self.op.verbose
1545
      op.error_codes = self.op.error_codes
1546
      try:
1547
        op.skip_checks = self.op.skip_checks
1548
      except AttributeError:
1549
        assert not isinstance(op, opcodes.OpClusterVerifyGroup)
1550

  
1551
    return ResultWithJobs(jobs)
1552

  
1553

  
1513 1554
class LUClusterVerifyConfig(NoHooksLU, _VerifyErrors):
1514 1555
  """Verifies the cluster config.
1515 1556

  
b/lib/opcodes.py
573 573
  """Query cluster information."""
574 574

  
575 575

  
576
class OpClusterVerify(OpCode):
577
  """Submits all jobs necessary to verify the cluster.
578

  
579
  """
580
  OP_PARAMS = [
581
    _PDebugSimulateErrors,
582
    _PErrorCodes,
583
    _PSkipChecks,
584
    _PVerbose,
585
    ("group_name", None, ht.TMaybeString, "Group to verify")
586
    ]
587

  
588

  
576 589
class OpClusterVerifyConfig(OpCode):
577 590
  """Verify the cluster config.
578 591

  

Also available in: Unified diff