By allowing also the primary ip field to be fetched directly, we avoid
one more confd lookup, or dns request, to find out which address the
master node lives at.

Signed-off-by: Guido Trotter <[email protected]>
---
 lib/confd/querylib.py |    7 ++++++-
 lib/constants.py      |    1 +
 2 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/lib/confd/querylib.py b/lib/confd/querylib.py
index f757760..eda060a 100644
--- a/lib/confd/querylib.py
+++ b/lib/confd/querylib.py
@@ -94,6 +94,9 @@ class ClusterMasterQuery(ConfdQuery):
   It accepts no arguments, and returns the current cluster master.
 
   """
+  def _GetMasterNode(self):
+    return self.reader.GetMasterNode()
+
   def Exec(self, query):
     """ClusterMasterQuery main execution
 
@@ -109,9 +112,11 @@ class ClusterMasterQuery(ConfdQuery):
         answer = []
         for field in req_fields:
           if field == constants.CONFD_REQFIELD_NAME:
-            answer.append(self.reader.GetMasterNode())
+            answer.append(self._GetMasterNode())
           elif field == constants.CONFD_REQFIELD_IP:
             answer.append(self.reader.GetMasterIP())
+          elif field == constants.CONFD_REQFIELD_MNODE_PIP:
+            answer.append(self.reader.GetNodePrimaryIp(self._GetMasterNode()))
       else:
         logging.debug("missing FIELDS in query dict")
         return QUERY_ARGUMENT_ERROR
diff --git a/lib/constants.py b/lib/constants.py
index 07493cd..54a8a01 100644
--- a/lib/constants.py
+++ b/lib/constants.py
@@ -691,6 +691,7 @@ CONFD_REQQ_FIELDS = "3"
 
 CONFD_REQFIELD_NAME = "0"
 CONFD_REQFIELD_IP = "1"
+CONFD_REQFIELD_MNODE_PIP = "2"
 
 CONFD_REQS = frozenset([
   CONFD_REQ_PING,
-- 
1.6.5

Reply via email to