Revision 2826b361

b/daemons/ganeti-watcher
71 71
  return bool(utils.ReadWatcherPauseFile(constants.WATCHER_PAUSEFILE))
72 72

  
73 73

  
74
def EnsureDaemon(name):
75
  """Check for and start daemon if not alive.
76

  
77
  """
78
  result = utils.RunCmd([constants.DAEMON_UTIL, "check-and-start", name])
79
  if result.failed:
80
    logging.error("Can't start daemon '%s', failure %s, output: %s",
81
                  name, result.fail_reason, result.output)
82
    return False
83

  
84
  return True
85

  
86

  
87 74
def StartNodeDaemons():
88 75
  """Start all the daemons that should be running on all nodes.
89 76

  
90 77
  """
91 78
  # on master or not, try to start the node dameon
92
  EnsureDaemon(constants.NODED)
79
  utils.EnsureDaemon(constants.NODED)
93 80
  # start confd as well. On non candidates it will be in disabled mode.
94
  EnsureDaemon(constants.CONFD)
81
  utils.EnsureDaemon(constants.CONFD)
95 82

  
96 83

  
97 84
def RunWatcherHooks():
......
527 514
      except luxi.NoMasterError, err:
528 515
        logging.warning("Master seems to be down (%s), trying to restart",
529 516
                        str(err))
530
        if not EnsureDaemon(constants.MASTERD):
517
        if not utils.EnsureDaemon(constants.MASTERD):
531 518
          logging.critical("Can't start the master, exiting")
532 519
          sys.exit(constants.EXIT_FAILURE)
533 520
        # else retry the connection
534 521
        client = cli.GetClient()
535 522

  
536 523
      # we are on master now
537
      EnsureDaemon(constants.RAPI)
524
      utils.EnsureDaemon(constants.RAPI)
538 525

  
539 526
      try:
540 527
        watcher = Watcher(options, notepad)
b/lib/utils.py
1610 1610
  return os.path.join(constants.RUN_GANETI_DIR, "%s.pid" % name)
1611 1611

  
1612 1612

  
1613
def EnsureDaemon(name):
1614
  """Check for and start daemon if not alive.
1615

  
1616
  """
1617
  result = RunCmd([constants.DAEMON_UTIL, "check-and-start", name])
1618
  if result.failed:
1619
    logging.error("Can't start daemon '%s', failure %s, output: %s",
1620
                  name, result.fail_reason, result.output)
1621
    return False
1622

  
1623
  return True
1624

  
1625

  
1613 1626
def WritePidFile(name):
1614 1627
  """Write the current process pidfile.
1615 1628

  

Also available in: Unified diff