Commit 4404ffad authored by Iustin Pop's avatar Iustin Pop
Browse files

Implement gnt-cluster master-ping



This can be used from shell-scripts to quickly check the status of the
master node, before launching a series of jobs (and handling the failure
of the jobs due to masterd other issues).
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent b8ebd37b
......@@ -590,6 +590,27 @@
</refsect2>
<refsect2>
<title>MASTER-PING</title>
<cmdsynopsis>
<command>master-ping</command>
</cmdsynopsis>
<para>
Checks if the master daemon is alive.
</para>
<para>
If the master daemon is alive and can respond to a basic query
(the equivalent of <command>gnt-cluster info</command>), then
the exit code of the command will be 0. If the master daemon
is not alive (either due to a crash or because this is not the
master node), the exit code will be 1.
</para>
</refsect2>
<refsect2>
<title>MODIFY</title>
......
......@@ -517,6 +517,24 @@ def MasterFailover(opts, args):
return bootstrap.MasterFailover(no_voting=opts.no_voting)
def MasterPing(opts, args):
"""Checks if the master is alive.
@param opts: the command line options selected by the user
@type args: list
@param args: should be an empty list
@rtype: int
@return: the desired exit code
"""
try:
cl = GetClient()
cl.QueryClusterInfo()
return 0
except Exception: # pylint: disable-msg=W0703
return 1
def SearchTags(opts, args):
"""Searches the tags on all the cluster.
......@@ -857,6 +875,9 @@ commands = {
'master-failover': (
MasterFailover, ARGS_NONE, [NOVOTING_OPT],
"", "Makes the current node the master"),
'master-ping': (
MasterPing, ARGS_NONE, [],
"", "Checks if the master is alive"),
'version': (
ShowClusterVersion, ARGS_NONE, [],
"", "Shows the cluster version"),
......
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