diff --git a/lib/confd/client.py b/lib/confd/client.py index e08141b0c9f3743837122affef11c918db9a7a23..9bd9ef7fc692194b0e782bbf676a43519ba50b07 100644 --- a/lib/confd/client.py +++ b/lib/confd/client.py @@ -194,7 +194,7 @@ class ConfdClient: ) self._callback(client_reply) - def SendRequest(self, request, args=None, coverage=None, async=True): + def SendRequest(self, request, args=None, coverage=0, async=True): """Send a confd request to some MCs @type request: L{objects.ConfdRequest} @@ -202,13 +202,19 @@ class ConfdClient: @type args: tuple @param args: additional callback arguments @type coverage: integer - @param coverage: number of remote nodes to contact + @param coverage: number of remote nodes to contact; if default + (0), it will use a reasonable default + (L{ganeti.constants.CONFD_DEFAULT_REQ_COVERAGE}), if -1 is + passed, it will use the maximum number of peers, otherwise the + number passed in will be used @type async: boolean @param async: handle the write asynchronously """ - if coverage is None: + if coverage == 0: coverage = min(len(self._peers), constants.CONFD_DEFAULT_REQ_COVERAGE) + elif coverage == -1: + coverage = len(self._peers) if coverage > len(self._peers): raise errors.ConfdClientError("Not enough MCs known to provide the" diff --git a/test/ganeti.confd_client_unittest.py b/test/ganeti.confd_client_unittest.py index d116483fef7dbfa92bb2c27fc0d0c2ec0f3730dd..e501c1d2ecc5122d498f9431f99175adf95578c3 100755 --- a/test/ganeti.confd_client_unittest.py +++ b/test/ganeti.confd_client_unittest.py @@ -139,6 +139,10 @@ class TestClient(unittest.TestCase): req2, coverage=15) self.assertEquals(self.client._socket.send_count, constants.CONFD_DEFAULT_REQ_COVERAGE) + # Send with max coverage + self.client.SendRequest(req2, coverage=-1) + self.assertEquals(self.client._socket.send_count, + constants.CONFD_DEFAULT_REQ_COVERAGE + len(self.mc_list)) self.assert_(self.client._socket.last_address in self.mc_list)