The current implementation of “gnt-cluster getmaster” doesn't work on
non-master nodes, which is a regression from 1.2. This patch implements
it (again) via ssconf.
---
lib/bootstrap.py | 16 ++++++++++++++++
scripts/gnt-cluster | 3 ++-
2 files changed, 18 insertions(+), 1 deletions(-)
diff --git a/lib/bootstrap.py b/lib/bootstrap.py
index 4db905e..edee90d 100644
--- a/lib/bootstrap.py
+++ b/lib/bootstrap.py
@@ -446,6 +446,22 @@ def MasterFailover():
return rcode
+def GetMaster():
+ """Returns the current master node.
+
+ This is a separate function in bootstrap since it's needed by
+ gnt-cluster, and instead of importing directly ssconf, it's better
+ to abstract it in bootstrap, where we do use ssconf in other
+ functions too.
+
+ """
+ sstore = ssconf.SimpleStore()
+
+ old_master, _ = ssconf.GetMasterAndMyself(sstore)
+
+ return old_master
+
+
def GatherMasterVotes(node_list):
"""Check the agreement on who is the master.
diff --git a/scripts/gnt-cluster b/scripts/gnt-cluster
index b0309c0..c8473fa 100755
--- a/scripts/gnt-cluster
+++ b/scripts/gnt-cluster
@@ -207,7 +207,8 @@ def ShowClusterMaster(opts, args):
@return: the desired exit code
"""
- ToStdout("%s", GetClient().QueryConfigValues(["master_node"])[0])
+ master = bootstrap.GetMaster()
+ ToStdout(master)
return 0
--
1.6.2.4