Revision 56aa9fd5 lib/backend.py

b/lib/backend.py
2051 2051
    return (False, str(err))
2052 2052

  
2053 2053

  
2054
def DemoteFromMC():
2055
  """Demotes the current node from master candidate role.
2056

  
2057
  """
2058
  # try to ensure we're not the master by mistake
2059
  master, myself = ssconf.GetMasterAndMyself()
2060
  if master == myself:
2061
    return (False, "ssconf status shows I'm the master node, will not demote")
2062
  pid_file = utils.DaemonPidFileName(constants.MASTERD_PID)
2063
  if utils.IsProcessAlive(utils.ReadPidFile(pid_file)):
2064
    return (False, "The master daemon is running, will not demote")
2065
  try:
2066
    utils.CreateBackup(constants.CLUSTER_CONF_FILE)
2067
  except EnvironmentError, err:
2068
    if err.errno != errno.ENOENT:
2069
      return (False, "Error while backing up cluster file: %s" % str(err))
2070
  utils.RemoveFile(constants.CLUSTER_CONF_FILE)
2071
  return (True, "Done")
2072

  
2073

  
2054 2074
class HooksRunner(object):
2055 2075
  """Hook runner.
2056 2076

  

Also available in: Unified diff