diff --git a/daemons/ganeti-watcher b/daemons/ganeti-watcher index 3d4357f266a8d9fcd1e26e3022a9b7f39fe4c0fc..7fc2dc537e090c417ba0f326aeaa5602a71c81bb 100755 --- a/daemons/ganeti-watcher +++ b/daemons/ganeti-watcher @@ -71,27 +71,14 @@ def ShouldPause(): return bool(utils.ReadWatcherPauseFile(constants.WATCHER_PAUSEFILE)) -def EnsureDaemon(name): - """Check for and start daemon if not alive. - - """ - result = utils.RunCmd([constants.DAEMON_UTIL, "check-and-start", name]) - if result.failed: - logging.error("Can't start daemon '%s', failure %s, output: %s", - name, result.fail_reason, result.output) - return False - - return True - - def StartNodeDaemons(): """Start all the daemons that should be running on all nodes. """ # on master or not, try to start the node dameon - EnsureDaemon(constants.NODED) + utils.EnsureDaemon(constants.NODED) # start confd as well. On non candidates it will be in disabled mode. - EnsureDaemon(constants.CONFD) + utils.EnsureDaemon(constants.CONFD) def RunWatcherHooks(): @@ -527,14 +514,14 @@ def main(): except luxi.NoMasterError, err: logging.warning("Master seems to be down (%s), trying to restart", str(err)) - if not EnsureDaemon(constants.MASTERD): + if not utils.EnsureDaemon(constants.MASTERD): logging.critical("Can't start the master, exiting") sys.exit(constants.EXIT_FAILURE) # else retry the connection client = cli.GetClient() # we are on master now - EnsureDaemon(constants.RAPI) + utils.EnsureDaemon(constants.RAPI) try: watcher = Watcher(options, notepad) diff --git a/lib/utils.py b/lib/utils.py index ec08b1eb6b78c4b4ca1589ceff1b0f91df9e139b..6877dc704d6a44f389b2e166df47839bc6a846cb 100644 --- a/lib/utils.py +++ b/lib/utils.py @@ -1610,6 +1610,19 @@ def DaemonPidFileName(name): return os.path.join(constants.RUN_GANETI_DIR, "%s.pid" % name) +def EnsureDaemon(name): + """Check for and start daemon if not alive. + + """ + result = RunCmd([constants.DAEMON_UTIL, "check-and-start", name]) + if result.failed: + logging.error("Can't start daemon '%s', failure %s, output: %s", + name, result.fail_reason, result.output) + return False + + return True + + def WritePidFile(name): """Write the current process pidfile.