Commit 95b2e626 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

gnt-cluster: Add CLI for watcher pause

Signed-off-by: default avatarMichael Hanselmann <>
Reviewed-by: default avatarIustin Pop <>
parent 05e50653
......@@ -560,6 +560,37 @@
<group choice="req">
<arg>pause <replaceable>duration</replaceable></arg>
Make the watcher pause or let it continue.
The <option>pause</option> option causes the watcher to pause for
<replaceable>duration</replaceable> seconds.
The <option>continue</option> option will let the watcher continue.
The <option>info</option> option shows whether the watcher is currently
......@@ -25,6 +25,7 @@
import sys
import os.path
import time
from ganeti.cli import *
from ganeti import opcodes
......@@ -533,6 +534,43 @@ def QueueOps(opts, args):
return 0
def WatcherOps(opts, args):
"""Watcher operations.
@param opts: the command line options selected by the user
@type args: list
@param args: should contain only one element, the subcommand
@rtype: int
@return: the desired exit code
command = args[0]
client = GetClient()
if command == "continue":
elif command == "pause":
if len(args) < 2:
raise errors.OpPrereqError("Missing pause duration")
until = time.time() + ParseTimespec(args[1])
elif command == "info":
result = client.QueryConfigValues(["watcher_pause"])
if result is None or result < time.time():
ToStdout("The watcher is not paused.")
ToStdout("The watcher is paused until %s.", time.ctime(result))
raise errors.OpPrereqError("Command '%s' is not valid." % command)
return 0
# this is an option common to more than one command, so we declare
# it here and reuse it
node_option = cli_option("-n", "--node", action="append", dest="nodes",
......@@ -660,6 +698,12 @@ commands = {
[ArgChoice(min=1, max=1, choices=["drain", "undrain", "info"])],
"drain|undrain|info", "Change queue properties"),
'watcher': (WatcherOps,
[ArgChoice(min=1, max=1,
choices=["pause", "continue", "info"]),
ArgSuggest(min=0, max=1, choices=["30m", "1h", "4h"])],
"{pause <timespec>|continue|info}", "Change watcher properties"),
'modify': (SetClusterParams, ARGS_NONE,
cli_option("-g", "--vg-name", dest="vg_name",
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