X-Git-Url: https://code.grnet.gr/git/ganeti-local/blobdiff_plain/392ca296ad9c4b75c1dd4a9f96d5faac7327ccef..41ba40612c35f8c7510e7642fcbb0f3589e19234:/lib/confd/client.py diff --git a/lib/confd/client.py b/lib/confd/client.py index 803fbb5..e944431 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. @@ -151,7 +160,9 @@ class ConfdClient: client_reply = ConfdUpcallPayload(salt=rsalt, type=UPCALL_EXPIRE, orig_request=request, - extra_args=args) + extra_args=args, + client=self, + ) self._callback(client_reply) else: break @@ -227,7 +238,9 @@ class ConfdClient: orig_request=request, server_ip=ip, server_port=port, - extra_args=args) + extra_args=args, + client=self, + ) self._callback(client_reply) finally: @@ -263,6 +276,8 @@ class ConfdUpcallPayload(objects.ConfigObject): @ivar server_port: answering server port @type extra_args: any @ivar extra_args: 'args' argument of the SendRequest function + @type client: L{ConfdClient} + @ivar client: current confd client instance """ __slots__ = [ @@ -273,6 +288,7 @@ class ConfdUpcallPayload(objects.ConfigObject): "server_ip", "server_port", "extra_args", + "client", ] @@ -335,8 +351,8 @@ class ConfdFilterCallback: def _HandleExpire(self, up): # if we have no answer we have received none, before the expiration. - if salt in self._answers: - del self._answers[salt] + if up.salt in self._answers: + del self._answers[up.salt] def _HandleReply(self, up): """Handle a single confd reply, and decide whether to filter it.