Revision cc6484c4
b/lib/confd/client.py | ||
---|---|---|
194 | 194 |
) |
195 | 195 |
self._callback(client_reply) |
196 | 196 |
|
197 |
def SendRequest(self, request, args=None, coverage=None, async=True):
|
|
197 |
def SendRequest(self, request, args=None, coverage=0, async=True):
|
|
198 | 198 |
"""Send a confd request to some MCs |
199 | 199 |
|
200 | 200 |
@type request: L{objects.ConfdRequest} |
... | ... | |
202 | 202 |
@type args: tuple |
203 | 203 |
@param args: additional callback arguments |
204 | 204 |
@type coverage: integer |
205 |
@param coverage: number of remote nodes to contact |
|
205 |
@param coverage: number of remote nodes to contact; if default |
|
206 |
(0), it will use a reasonable default |
|
207 |
(L{ganeti.constants.CONFD_DEFAULT_REQ_COVERAGE}), if -1 is |
|
208 |
passed, it will use the maximum number of peers, otherwise the |
|
209 |
number passed in will be used |
|
206 | 210 |
@type async: boolean |
207 | 211 |
@param async: handle the write asynchronously |
208 | 212 |
|
209 | 213 |
""" |
210 |
if coverage is None:
|
|
214 |
if coverage == 0:
|
|
211 | 215 |
coverage = min(len(self._peers), constants.CONFD_DEFAULT_REQ_COVERAGE) |
216 |
elif coverage == -1: |
|
217 |
coverage = len(self._peers) |
|
212 | 218 |
|
213 | 219 |
if coverage > len(self._peers): |
214 | 220 |
raise errors.ConfdClientError("Not enough MCs known to provide the" |
b/test/ganeti.confd_client_unittest.py | ||
---|---|---|
139 | 139 |
req2, coverage=15) |
140 | 140 |
self.assertEquals(self.client._socket.send_count, |
141 | 141 |
constants.CONFD_DEFAULT_REQ_COVERAGE) |
142 |
# Send with max coverage |
|
143 |
self.client.SendRequest(req2, coverage=-1) |
|
144 |
self.assertEquals(self.client._socket.send_count, |
|
145 |
constants.CONFD_DEFAULT_REQ_COVERAGE + len(self.mc_list)) |
|
142 | 146 |
self.assert_(self.client._socket.last_address in self.mc_list) |
143 | 147 |
|
144 | 148 |
|
Also available in: Unified diff