Revision b989b9d9 lib/backend.py

b/lib/backend.py
351 351
  utils.RunCmd([constants.SSH_INITD_SCRIPT, "restart"])
352 352

  
353 353

  
354
def LeaveCluster():
354
def LeaveCluster(modify_ssh_setup):
355 355
  """Cleans up and remove the current node.
356 356

  
357 357
  This function cleans up and prepares the current node to be removed
......
361 361
  L{errors.QuitGanetiException} which is used as a special case to
362 362
  shutdown the node daemon.
363 363

  
364
  @param modify_ssh_setup: boolean
365

  
364 366
  """
365 367
  _CleanDirectory(constants.DATA_DIR)
366 368
  JobQueuePurge()
367 369

  
368
  try:
369
    priv_key, pub_key, auth_keys = ssh.GetUserFiles(constants.GANETI_RUNAS)
370
  if modify_ssh_setup:
371
    try:
372
      priv_key, pub_key, auth_keys = ssh.GetUserFiles(constants.GANETI_RUNAS)
370 373

  
371
    utils.RemoveAuthorizedKey(auth_keys, utils.ReadFile(pub_key))
374
      utils.RemoveAuthorizedKey(auth_keys, utils.ReadFile(pub_key))
372 375

  
373
    utils.RemoveFile(priv_key)
374
    utils.RemoveFile(pub_key)
375
  except errors.OpExecError:
376
    logging.exception("Error while processing ssh files")
376
      utils.RemoveFile(priv_key)
377
      utils.RemoveFile(pub_key)
378
    except errors.OpExecError:
379
      logging.exception("Error while processing ssh files")
377 380

  
378 381
  try:
379 382
    utils.RemoveFile(constants.HMAC_CLUSTER_KEY)

Also available in: Unified diff