ganeti-watcher: Don't run if paused
authorMichael Hanselmann <hansmi@google.com>
Wed, 26 Aug 2009 14:47:01 +0000 (16:47 +0200)
committerMichael Hanselmann <hansmi@google.com>
Wed, 26 Aug 2009 16:09:14 +0000 (18:09 +0200)
Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

daemons/ganeti-watcher

index 1a3ed1c..1e29f64 100755 (executable)
@@ -31,6 +31,7 @@ import os
 import sys
 import time
 import logging
+import errno
 from optparse import OptionParser
 
 from ganeti import utils
@@ -70,6 +71,13 @@ def Indent(s, prefix='| '):
   return "%s%s\n" % (prefix, ('\n' + prefix).join(s.splitlines()))
 
 
+def ShouldPause():
+  """Check whether we should pause.
+
+  """
+  return bool(utils.ReadWatcherPauseFile(constants.WATCHER_PAUSEFILE))
+
+
 def StartMaster():
   """Try to start the master daemon.
 
@@ -476,6 +484,10 @@ def main():
   utils.SetupLogging(constants.LOG_WATCHER, debug=options.debug,
                      stderr_logging=options.debug)
 
+  if ShouldPause():
+    logging.debug("Pause has been set, exiting")
+    sys.exit(constants.EXIT_SUCCESS)
+
   update_file = False
   try:
     # on master or not, try to start the node dameon