Revision 1c69ad80

b/lib/constants.py
331 331
EXIT_NOTMASTER = 11
332 332
EXIT_NODESETUP_ERROR = 12
333 333
EXIT_CONFIRMATION = 13 # need user confirmation
334
EXIT_NOTCANDIDATE = 14
335 334

  
336 335
# tags
337 336
TAG_CLUSTER = "cluster"
b/lib/ssconf.py
497 497
    if debug:
498 498
      sys.stderr.write("Not master, exiting.\n")
499 499
    sys.exit(constants.EXIT_NOTMASTER)
500

  
501

  
502
def CheckMasterCandidate(debug, ss=None):
503
  """Checks the node setup.
504

  
505
  If this is a master candidate, the function will return. Otherwise it will
506
  exit with an exit code based on the node status.
507

  
508
  """
509
  try:
510
    if ss is None:
511
      ss = SimpleStore()
512
    myself = utils.HostInfo().name
513
    candidates = ss.GetMasterCandidates()
514
  except errors.ConfigurationError, err:
515
    print "Cluster configuration incomplete: '%s'" % str(err)
516
    sys.exit(constants.EXIT_NODESETUP_ERROR)
517
  except errors.ResolverError, err:
518
    sys.stderr.write("Cannot resolve my own name (%s)\n" % err.args[0])
519
    sys.exit(constants.EXIT_NODESETUP_ERROR)
520

  
521
  if myself not in candidates:
522
    if debug:
523
      sys.stderr.write("Not master candidate, exiting.\n")
524
    sys.exit(constants.EXIT_NOTCANDIDATE)

Also available in: Unified diff