projects
/
ganeti-local
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
TryOSFromDisk: s/os_scripts/os_files/
[ganeti-local]
/
lib
/
confd
/
client.py
diff --git
a/lib/confd/client.py
b/lib/confd/client.py
index
803fbb5
..
e944431
100644
(file)
--- a/
lib/confd/client.py
+++ b/
lib/confd/client.py
@@
-101,12
+101,10
@@
class ConfdClient:
@keyword logger: optional logger for internal conditions
"""
@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")
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
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)
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.
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,
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
self._callback(client_reply)
else:
break
@@
-227,7
+238,9
@@
class ConfdClient:
orig_request=request,
server_ip=ip,
server_port=port,
orig_request=request,
server_ip=ip,
server_port=port,
- extra_args=args)
+ extra_args=args,
+ client=self,
+ )
self._callback(client_reply)
finally:
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
@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__ = [
"""
__slots__ = [
@@
-273,6
+288,7
@@
class ConfdUpcallPayload(objects.ConfigObject):
"server_ip",
"server_port",
"extra_args",
"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.
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.
def _HandleReply(self, up):
"""Handle a single confd reply, and decide whether to filter it.