Revision f154a7a3 lib/backend.py

b/lib/backend.py
255 255

  
256 256
  # and now start the master and rapi daemons
257 257
  if start_daemons:
258
    daemons_params = {
259
        'ganeti-masterd': [],
260
        'ganeti-rapi': [],
261
        }
262 258
    if no_voting:
263
      daemons_params['ganeti-masterd'].append('--no-voting')
264
      daemons_params['ganeti-masterd'].append('--yes-do-it')
265
    for daemon in daemons_params:
266
      cmd = [daemon]
267
      cmd.extend(daemons_params[daemon])
268
      result = utils.RunCmd(cmd)
269
      if result.failed:
270
        msg = "Can't start daemon %s: %s" % (daemon, result.output)
271
        logging.error(msg)
272
        err_msgs.append(msg)
259
      masterd_args = "--no-voting --yes-do-it"
260
    else:
261
      masterd_args = ""
262

  
263
    env = {
264
      "EXTRA_MASTERD_ARGS": masterd_args,
265
      }
266

  
267
    result = utils.RunCmd([constants.DAEMON_UTIL, "start-master"], env=env)
268
    if result.failed:
269
      msg = "Can't start Ganeti master: %s" % result.output
270
      logging.error(msg)
271
      err_msgs.append(msg)
273 272

  
274 273
  if err_msgs:
275 274
    _Fail("; ".join(err_msgs))
......
301 300
    # but otherwise ignore the failure
302 301

  
303 302
  if stop_daemons:
304
    # stop/kill the rapi and the master daemon
305
    for daemon in constants.RAPI, constants.MASTERD:
306
      utils.KillProcess(utils.ReadPidFile(utils.DaemonPidFileName(daemon)))
303
    result = utils.RunCmd([constants.DAEMON_UTIL, "stop-master"])
304
    if result.failed:
305
      logging.error("Could not stop Ganeti master, command %s had exitcode %s"
306
                    " and error %s",
307
                    result.cmd, result.exit_code, result.output)
307 308

  
308 309

  
309 310
def AddNode(dsa, dsapub, rsa, rsapub, sshkey, sshpub):
......
385 386
  except:
386 387
    logging.exception("Error while removing cluster secrets")
387 388

  
388
  confd_pid = utils.ReadPidFile(utils.DaemonPidFileName(constants.CONFD))
389

  
390
  if confd_pid:
391
    utils.KillProcess(confd_pid, timeout=2)
389
  result = utils.RunCmd([constants.DAEMON_UTIL, "stop", constants.CONFD])
390
  if result.failed:
391
    logging.error("Command %s failed with exitcode %s and error %s",
392
                  result.cmd, result.exit_code, result.output)
392 393

  
393 394
  # Raise a custom exception (handled in ganeti-noded)
394 395
  raise errors.QuitGanetiException(True, 'Shutdown scheduled')
......
2435 2436
  master, myself = ssconf.GetMasterAndMyself()
2436 2437
  if master == myself:
2437 2438
    _Fail("ssconf status shows I'm the master node, will not demote")
2438
  pid_file = utils.DaemonPidFileName(constants.MASTERD)
2439
  if utils.IsProcessAlive(utils.ReadPidFile(pid_file)):
2439

  
2440
  result = utils.RunCmd([constants.DAEMON_UTIL, "check", constants.MASTERD])
2441
  if not result.failed:
2440 2442
    _Fail("The master daemon is running, will not demote")
2443

  
2441 2444
  try:
2442 2445
    if os.path.isfile(constants.CLUSTER_CONF_FILE):
2443 2446
      utils.CreateBackup(constants.CLUSTER_CONF_FILE)
2444 2447
  except EnvironmentError, err:
2445 2448
    if err.errno != errno.ENOENT:
2446 2449
      _Fail("Error while backing up cluster file: %s", err, exc=True)
2450

  
2447 2451
  utils.RemoveFile(constants.CLUSTER_CONF_FILE)
2448 2452

  
2449 2453

  

Also available in: Unified diff