Revision 3f71b464 lib/ssconf.py

b/lib/ssconf.py
290 290
    if debug:
291 291
      sys.stderr.write("Not master, exiting.\n")
292 292
    sys.exit(constants.EXIT_NOTMASTER)
293

  
294

  
295
def CheckMasterCandidate(debug, ss=None):
296
  """Checks the node setup.
297

  
298
  If this is a master candidate, the function will return. Otherwise it will
299
  exit with an exit code based on the node status.
300

  
301
  """
302
  try:
303
    if ss is None:
304
      ss = SimpleStore()
305
    myself = utils.HostInfo().name
306
    candidates = ss.GetMasterCandidates()
307
  except errors.ConfigurationError, err:
308
    print "Cluster configuration incomplete: '%s'" % str(err)
309
    sys.exit(constants.EXIT_NODESETUP_ERROR)
310
  except errors.ResolverError, err:
311
    sys.stderr.write("Cannot resolve my own name (%s)\n" % err.args[0])
312
    sys.exit(constants.EXIT_NODESETUP_ERROR)
313

  
314
  if myself not in candidates:
315
    if debug:
316
      sys.stderr.write("Not master candidate, exiting.\n")
317
    sys.exit(constants.EXIT_NOTCANDIDATE)
318

  

Also available in: Unified diff