Commit 9f4bb951 authored by Michael Hanselmann's avatar Michael Hanselmann

Move ganeti-watcher to ganeti.watcher

Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarRené Nussbaumer <rn@google.com>
parent 67313146
......@@ -36,6 +36,7 @@
/daemons/daemon-util
/daemons/ensure-dirs
/daemons/ganeti-cleaner
/daemons/ganeti-watcher
# devel
/devel/clean-cluster
......
......@@ -23,6 +23,7 @@ httpdir = $(pkgpythondir)/http
masterddir = $(pkgpythondir)/masterd
confddir = $(pkgpythondir)/confd
rapidir = $(pkgpythondir)/rapi
watcherdir = $(pkgpythondir)/watcher
impexpddir = $(pkgpythondir)/impexpd
toolsdir = $(pkglibdir)/tools
docdir = $(datadir)/doc/$(PACKAGE)
......@@ -47,6 +48,7 @@ DIRS = \
lib/impexpd \
lib/masterd \
lib/rapi \
lib/watcher \
man \
qa \
test \
......@@ -188,6 +190,9 @@ masterd_PYTHON = \
impexpd_PYTHON = \
lib/impexpd/__init__.py
watcher_PYTHON = \
lib/watcher/__init__.py
docrst = \
doc/admin.rst \
doc/design-2.0.rst \
......@@ -270,6 +275,7 @@ gnt_scripts = \
scripts/gnt-os
PYTHON_BOOTSTRAP = \
daemons/ganeti-watcher \
scripts/gnt-backup \
scripts/gnt-cluster \
scripts/gnt-debug \
......@@ -280,7 +286,6 @@ PYTHON_BOOTSTRAP = \
dist_sbin_SCRIPTS = \
daemons/ganeti-noded \
daemons/ganeti-watcher \
daemons/ganeti-masterd \
daemons/ganeti-confd \
daemons/ganeti-rapi
......@@ -468,6 +473,7 @@ all_python_code = \
$(confd_PYTHON) \
$(masterd_PYTHON) \
$(impexpd_PYTHON) \
$(watcher_PYTHON) \
$(noinst_PYTHON)
srclink_files = \
......@@ -634,6 +640,7 @@ $(REPLACE_VARS_SED): Makefile
} > $@
# Using deferred evaluation
daemons/ganeti-watcher: MODULE = ganeti.watcher
scripts/%: MODULE = ganeti.client.$(subst -,_,$(notdir $@))
$(PYTHON_BOOTSTRAP): Makefile | $(all_dirfiles)
......
#!/usr/bin/python
#
#
# Copyright (C) 2006, 2007, 2008, 2009, 2010 Google Inc.
......@@ -679,7 +679,7 @@ def ParseOptions():
@rapi.client.UsesRapiClient
def main():
def Main():
"""Main function.
"""
......@@ -689,18 +689,18 @@ def main():
if args: # watcher doesn't take any arguments
print >> sys.stderr, ("Usage: %s [-f] " % sys.argv[0])
sys.exit(constants.EXIT_FAILURE)
return constants.EXIT_FAILURE
utils.SetupLogging(constants.LOG_WATCHER, debug=options.debug,
stderr_logging=options.debug)
if ShouldPause() and not options.ignore_pause:
logging.debug("Pause has been set, exiting")
sys.exit(constants.EXIT_SUCCESS)
return constants.EXIT_SUCCESS
statefile = OpenStateFile(constants.WATCHER_STATEFILE)
if not statefile:
sys.exit(constants.EXIT_FAILURE)
return constants.EXIT_FAILURE
update_file = False
try:
......@@ -719,13 +719,13 @@ def main():
# this is, from cli.GetClient, a not-master case
logging.debug("Not on master, exiting")
update_file = True
sys.exit(constants.EXIT_SUCCESS)
return constants.EXIT_SUCCESS
except luxi.NoMasterError, err:
logging.warning("Master seems to be down (%s), trying to restart",
str(err))
if not utils.EnsureDaemon(constants.MASTERD):
logging.critical("Can't start the master, exiting")
sys.exit(constants.EXIT_FAILURE)
return constants.EXIT_FAILURE
# else retry the connection
client = cli.GetClient()
......@@ -749,7 +749,7 @@ def main():
except errors.ConfigurationError:
# Just exit if there's no configuration
update_file = True
sys.exit(constants.EXIT_SUCCESS)
return constants.EXIT_SUCCESS
watcher.Run()
update_file = True
......@@ -763,18 +763,16 @@ def main():
raise
except NotMasterError:
logging.debug("Not master, exiting")
sys.exit(constants.EXIT_NOTMASTER)
return constants.EXIT_NOTMASTER
except errors.ResolverError, err:
logging.error("Cannot resolve hostname '%s', exiting.", err.args[0])
sys.exit(constants.EXIT_NODESETUP_ERROR)
return constants.EXIT_NODESETUP_ERROR
except errors.JobQueueFull:
logging.error("Job queue is full, can't query cluster state")
except errors.JobQueueDrainError:
logging.error("Job queue is drained, can't maintain cluster state")
except Exception, err:
logging.exception(str(err))
sys.exit(constants.EXIT_FAILURE)
return constants.EXIT_FAILURE
if __name__ == '__main__':
main()
return constants.EXIT_SUCCESS
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment