Commit 28b498cd authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

gnt-cluster watcher: Show more information


Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent 48166551
...@@ -413,6 +413,8 @@ def _SetWatcherPause(until): ...@@ -413,6 +413,8 @@ def _SetWatcherPause(until):
utils.WriteFile(constants.WATCHER_PAUSEFILE, utils.WriteFile(constants.WATCHER_PAUSEFILE,
data="%d\n" % (until, )) data="%d\n" % (until, ))
return until
def CheckAgreement(): def CheckAgreement():
"""Check the agreement on who is the master. """Check the agreement on who is the master.
......
...@@ -542,6 +542,13 @@ def QueueOps(opts, args): ...@@ -542,6 +542,13 @@ def QueueOps(opts, args):
return 0 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): def WatcherOps(opts, args):
"""Watcher operations. """Watcher operations.
...@@ -557,20 +564,18 @@ def WatcherOps(opts, args): ...@@ -557,20 +564,18 @@ def WatcherOps(opts, args):
if command == "continue": if command == "continue":
client.SetWatcherPause(None) client.SetWatcherPause(None)
ToStdout("The watcher is no longer paused.")
elif command == "pause": elif command == "pause":
if len(args) < 2: if len(args) < 2:
raise errors.OpPrereqError("Missing pause duration") raise errors.OpPrereqError("Missing pause duration")
until = time.time() + ParseTimespec(args[1]) result = client.SetWatcherPause(time.time() + ParseTimespec(args[1]))
client.SetWatcherPause(until) _ShowWatcherPause(result)
elif command == "info": elif command == "info":
result = client.QueryConfigValues(["watcher_pause"]) result = client.QueryConfigValues(["watcher_pause"])
if result is None or result < time.time(): _ShowWatcherPause(result)
ToStdout("The watcher is not paused.")
else:
ToStdout("The watcher is paused until %s.", time.ctime(result))
else: else:
raise errors.OpPrereqError("Command '%s' is not valid." % command) raise errors.OpPrereqError("Command '%s' is not valid." % command)
......
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