From 7d20c64777c7af04dbbc7b80f278717fef65eadc Mon Sep 17 00:00:00 2001
From: Guido Trotter <ultrotter@google.com>
Date: Wed, 16 Sep 2009 16:58:53 +0100
Subject: [PATCH] Confd client: make confd port configurable

The port can be now chosen at library init time, with a default of
calling GetDaemonPort.

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>
---
 lib/confd/client.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/lib/confd/client.py b/lib/confd/client.py
index f5276866a..a11d25cde 100644
--- a/lib/confd/client.py
+++ b/lib/confd/client.py
@@ -65,7 +65,7 @@ class ConfdClient:
   through asyncore or with your own handling.
 
   """
-  def __init__(self, hmac_key, peers, callback):
+  def __init__(self, hmac_key, peers, callback, port=None):
     """Constructor for ConfdClient
 
     @type hmac_key: string
@@ -74,6 +74,8 @@ class ConfdClient:
     @param peers: list of peer nodes
     @type callback: f(L{ConfdUpcallPayload})
     @param callback: function to call when getting answers
+    @type port: integer
+    @keyword port: confd port (default: use GetDaemonPort)
 
     """
     if not isinstance(peers, list):
@@ -85,9 +87,12 @@ class ConfdClient:
     self._hmac_key = hmac_key
     self._socket = ConfdAsyncUDPClient(self)
     self._callback = callback
+    self._confd_port = port
     self._requests = {}
     self._expire_requests = []
-    self._confd_port = utils.GetDaemonPort(constants.CONFD)
+
+    if self._confd_port is None:
+      self._confd_port = utils.GetDaemonPort(constants.CONFD)
 
   def _PackRequest(self, request, now=None):
     """Prepare a request to be sent on the wire.
-- 
GitLab