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.
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):
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