Revision 5675cd1f lib/ssconf.py

b/lib/ssconf.py
27 27
"""
28 28

  
29 29
import socket
30
import sys
30 31

  
31 32
from ganeti import errors
32 33
from ganeti import constants
......
199 200
    utils.WriteFile(file_name, data="%s\n" % str(value),
200 201
                    uid=0, gid=0, mode=0400)
201 202

  
203

  
204
def CheckMaster(debug):
205
  """Checks the node setup.
206

  
207
  If this is the master, the function will return. Otherwise it will
208
  exit with an exit code based on the node status.
209

  
210
  """
211
  try:
212
    ss = SimpleStore()
213
    master_name = ss.GetMasterNode()
214
  except errors.ConfigurationError, err:
215
    print "Cluster configuration incomplete: '%s'" % str(err)
216
    sys.exit(constants.EXIT_NODESETUP_ERROR)
217

  
218
  try:
219
    myself = utils.HostInfo()
220
  except errors.ResolverError, err:
221
    sys.stderr.write("Cannot resolve my own name (%s)\n" % err.args[0])
222
    sys.exit(constants.EXIT_NODESETUP_ERROR)
223

  
224
  if myself.name != master_name:
225
    if debug:
226
      sys.stderr.write("Not master, exiting.\n")
227
    sys.exit(constants.EXIT_NOTMASTER)

Also available in: Unified diff