From a5229439a0908a071d13dc8c1e9099e171e896bd Mon Sep 17 00:00:00 2001 From: Guido Trotter <ultrotter@google.com> Date: Tue, 29 Sep 2009 09:25:33 +0100 Subject: [PATCH] confd/client: make it possible to update peer list Until now the peers have to be the same all the time. Adding a new function to update the list, and call it from the constructor to avoid duplicating code. Signed-off-by: Guido Trotter <ultrotter@google.com> Reviewed-by: Michael Hanselmann <hansmi@google.com> --- lib/confd/client.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/confd/client.py b/lib/confd/client.py index b12a730f8..e9444318e 100644 --- a/lib/confd/client.py +++ b/lib/confd/client.py @@ -101,12 +101,10 @@ class ConfdClient: @keyword logger: optional logger for internal conditions """ - if not isinstance(peers, list): - raise errors.ProgrammerError("peers must be a list") if not callable(callback): raise errors.ProgrammerError("callback must be callable") - self._peers = peers + self.UpdatePeerList(peers) self._hmac_key = hmac_key self._socket = ConfdAsyncUDPClient(self) self._callback = callback @@ -118,6 +116,17 @@ class ConfdClient: if self._confd_port is None: self._confd_port = utils.GetDaemonPort(constants.CONFD) + def UpdatePeerList(self, peers): + """Update the list of peers + + @type peers: list + @param peers: list of peer nodes + + """ + if not isinstance(peers, list): + raise errors.ProgrammerError("peers must be a list") + self._peers = peers + def _PackRequest(self, request, now=None): """Prepare a request to be sent on the wire. -- GitLab