Revision d8bcfe21 lib/confd/client.py
b/lib/confd/client.py | ||
---|---|---|
72 | 72 |
implement a non-asyncore based client library. |
73 | 73 |
|
74 | 74 |
""" |
75 |
def __init__(self, client): |
|
75 |
def __init__(self, client, family):
|
|
76 | 76 |
"""Constructor for ConfdAsyncUDPClient |
77 | 77 |
|
78 | 78 |
@type client: L{ConfdClient} |
79 | 79 |
@param client: client library, to pass the datagrams to |
80 | 80 |
|
81 | 81 |
""" |
82 |
daemon.AsyncUDPSocket.__init__(self) |
|
82 |
daemon.AsyncUDPSocket.__init__(self, family)
|
|
83 | 83 |
self.client = client |
84 | 84 |
|
85 | 85 |
# this method is overriding a daemon.AsyncUDPSocket method |
... | ... | |
137 | 137 |
raise errors.ProgrammerError("callback must be callable") |
138 | 138 |
|
139 | 139 |
self.UpdatePeerList(peers) |
140 |
self._SetPeersAddressFamily() |
|
140 | 141 |
self._hmac_key = hmac_key |
141 |
self._socket = ConfdAsyncUDPClient(self) |
|
142 |
self._socket = ConfdAsyncUDPClient(self, self._family)
|
|
142 | 143 |
self._callback = callback |
143 | 144 |
self._confd_port = port |
144 | 145 |
self._logger = logger |
... | ... | |
385 | 386 |
else: |
386 | 387 |
return MISSING |
387 | 388 |
|
389 |
def _SetPeersAddressFamily(self): |
|
390 |
if not self._peers: |
|
391 |
raise errors.ConfdClientError("Peer list empty") |
|
392 |
try: |
|
393 |
peer = self._peers[0] |
|
394 |
self._family = netutils.GetAddressFamily(peer) |
|
395 |
for peer in self._peers[1:]: |
|
396 |
if netutils.GetAddressFamily(peer) != self._family: |
|
397 |
raise errors.ConfdClientError("Peers must be of same address family") |
|
398 |
except errors.GenericError: |
|
399 |
raise errors.ConfdClientError("Peer address %s invalid" % peer) |
|
400 |
|
|
388 | 401 |
|
389 | 402 |
# UPCALL_REPLY: server reply upcall |
390 | 403 |
# has all ConfdUpcallPayload fields populated |
Also available in: Unified diff