Commit 48166551 authored by Guido Trotter's avatar Guido Trotter
Browse files

confd: add cluster master query


Signed-off-by: default avatarGuido Trotter <ultrotter@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent 0bc8432b
......@@ -82,6 +82,25 @@ class PingQuery(ConfdQuery):
return status, answer
class ClusterMasterQuery(ConfdQuery):
"""Cluster master query.
It accepts no arguments, and returns the current cluster master.
"""
def Exec(self, query):
"""ClusterMasterQuery main execution
"""
if query is None:
status = constants.CONFD_REPL_STATUS_OK
answer = self.reader.GetMasterNode()
else:
status = constants.CONFD_REPL_STATUS_ERROR
answer = 'master query accepts no query argument'
return status, answer
class NodeRoleQuery(ConfdQuery):
"""A query for the role of a node.
......
......@@ -51,6 +51,7 @@ class ConfdProcessor(object):
constants.CONFD_REQ_NODE_ROLE_BYNAME: querylib.NodeRoleQuery,
constants.CONFD_REQ_NODE_PIP_BY_INSTANCE_IP:
querylib.InstanceIpToNodePrimaryIpQuery,
constants.CONFD_REQ_CLUSTER_MASTER: querylib.ClusterMasterQuery,
}
def __init__(self):
......
......@@ -638,11 +638,13 @@ CONFD_PROTOCOL_VERSION = 1
CONFD_REQ_PING = 0
CONFD_REQ_NODE_ROLE_BYNAME = 1
CONFD_REQ_NODE_PIP_BY_INSTANCE_IP = 2
CONFD_REQ_CLUSTER_MASTER = 3
CONFD_REQS = frozenset([
CONFD_REQ_PING,
CONFD_REQ_NODE_ROLE_BYNAME,
CONFD_REQ_NODE_PIP_BY_INSTANCE_IP,
CONFD_REQ_CLUSTER_MASTER,
])
CONFD_REPL_STATUS_OK = 0
......
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