Revision ed0efaa5 daemons/ganeti-masterd

b/daemons/ganeti-masterd
442 442
  return result
443 443

  
444 444

  
445
def CheckMasterd(options, args):
446
  """Initial checks whether to run or exit with a failure.
447

  
448
  """
445
def CheckAgreementWithRpc():
449 446
  rpc.Init()
450 447
  try:
451
    ssconf.CheckMaster(options.debug)
452

  
453
    # we believe we are the master, let's ask the other nodes...
454
    if options.no_voting and not options.yes_do_it:
455
      sys.stdout.write("The 'no voting' option has been selected.\n")
456
      sys.stdout.write("This is dangerous, please confirm by"
457
                       " typing uppercase 'yes': ")
458
      sys.stdout.flush()
459
      confirmation = sys.stdin.readline().strip()
460
      if confirmation != "YES":
461
        print "Aborting."
462
        return
463
    elif not options.no_voting:
464
      if not CheckAgreement():
465
        return
448
    return CheckAgreement()
466 449
  finally:
467 450
    rpc.Shutdown()
468 451

  
......
511 494
  return bool(exitcode)
512 495

  
513 496

  
497
def CheckMasterd(options, args):
498
  """Initial checks whether to run or exit with a failure.
499

  
500
  """
501
  ssconf.CheckMaster(options.debug)
502

  
503
  # If CheckMaster didn't fail we believe we are the master, but we have to
504
  # confirm with the other nodes.
505
  if options.no_voting:
506
    if options.yes_do_it:
507
      return
508

  
509
    sys.stdout.write("The 'no voting' option has been selected.\n")
510
    sys.stdout.write("This is dangerous, please confirm by"
511
                     " typing uppercase 'yes': ")
512
    sys.stdout.flush()
513

  
514
    confirmation = sys.stdin.readline().strip()
515
    if confirmation != "YES":
516
      print >>sys.stderr, "Aborting."
517
      sys.exit(constants.EXIT_FAILURE)
518

  
519
    return
520

  
521
  # CheckAgreement uses RPC and threads, hence it needs to be run in a separate
522
  # process before we call utils.Daemonize in the current process.
523
  if not _RunInSeparateProcess(CheckAgreementWithRpc):
524
    sys.exit(constants.EXIT_FAILURE)
525

  
526

  
514 527
def ExecMasterd (options, args):
515 528
  """Main master daemon function, executed with the PID file held.
516 529

  

Also available in: Unified diff