Revision 4331f6cd daemons/ganeti-masterd

b/daemons/ganeti-masterd
428 428
  utils.debug = options.debug
429 429
  utils.no_fork = True
430 430

  
431
  ssconf.CheckMaster(options.debug)
431
  rpc.Init()
432
  try:
433
    ssconf.CheckMaster(options.debug)
432 434

  
433
  # we believe we are the master, let's ask the other nodes...
434
  if not CheckAgreement():
435
    return
435
    # we believe we are the master, let's ask the other nodes...
436
    if not CheckAgreement():
437
      return
436 438

  
437
  master = IOServer(constants.MASTER_SOCKET, ClientRqHandler)
439
    master = IOServer(constants.MASTER_SOCKET, ClientRqHandler)
440
  finally:
441
    rpc.Shutdown()
438 442

  
439 443
  # become a daemon
440 444
  if options.fork:
......
446 450
  utils.SetupLogging(constants.LOG_MASTERDAEMON, debug=options.debug,
447 451
                     stderr_logging=not options.fork)
448 452

  
449
  logging.info("ganeti master daemon startup")
453
  rpc.Init()
454
  try:
455
    logging.info("ganeti master daemon startup")
450 456

  
451
  # activate ip
452
  master_node = ssconf.SimpleConfigReader().GetMasterNode()
453
  if not rpc.RpcRunner.call_node_start_master(master_node, False):
454
    logging.error("Can't activate master IP address")
457
    # activate ip
458
    master_node = ssconf.SimpleConfigReader().GetMasterNode()
459
    if not rpc.RpcRunner.call_node_start_master(master_node, False):
460
      logging.error("Can't activate master IP address")
455 461

  
456
  master.setup_queue()
457
  try:
458
    master.serve_forever()
462
    master.setup_queue()
463
    try:
464
      master.serve_forever()
465
    finally:
466
      master.server_cleanup()
467
      utils.RemovePidFile(constants.MASTERD_PID)
459 468
  finally:
460
    master.server_cleanup()
461
    utils.RemovePidFile(constants.MASTERD_PID)
469
    rpc.Shutdown()
462 470

  
463 471

  
464 472
if __name__ == "__main__":

Also available in: Unified diff