gnt-cluster watcher: Show more information
authorMichael Hanselmann <hansmi@google.com>
Mon, 31 Aug 2009 15:59:25 +0000 (17:59 +0200)
committerMichael Hanselmann <hansmi@google.com>
Mon, 31 Aug 2009 16:23:53 +0000 (18:23 +0200)
Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>

daemons/ganeti-masterd
scripts/gnt-cluster

index 4c15a7d..46633af 100755 (executable)
@@ -413,6 +413,8 @@ def _SetWatcherPause(until):
     utils.WriteFile(constants.WATCHER_PAUSEFILE,
                     data="%d\n" % (until, ))
 
+  return until
+
 
 def CheckAgreement():
   """Check the agreement on who is the master.
index 342b613..9358cc4 100755 (executable)
@@ -542,6 +542,13 @@ def QueueOps(opts, args):
   return 0
 
 
+def _ShowWatcherPause(until):
+  if until is None or until < time.time():
+    ToStdout("The watcher is not paused.")
+  else:
+    ToStdout("The watcher is paused until %s.", time.ctime(until))
+
+
 def WatcherOps(opts, args):
   """Watcher operations.
 
@@ -557,20 +564,18 @@ def WatcherOps(opts, args):
 
   if command == "continue":
     client.SetWatcherPause(None)
+    ToStdout("The watcher is no longer paused.")
 
   elif command == "pause":
     if len(args) < 2:
       raise errors.OpPrereqError("Missing pause duration")
 
-    until = time.time() + ParseTimespec(args[1])
-    client.SetWatcherPause(until)
+    result = client.SetWatcherPause(time.time() + ParseTimespec(args[1]))
+    _ShowWatcherPause(result)
 
   elif command == "info":
     result = client.QueryConfigValues(["watcher_pause"])
-    if result is None or result < time.time():
-      ToStdout("The watcher is not paused.")
-    else:
-      ToStdout("The watcher is paused until %s.", time.ctime(result))
+    _ShowWatcherPause(result)
 
   else:
     raise errors.OpPrereqError("Command '%s' is not valid." % command)