diff options
author | Marcin Siodelski <marcin@isc.org> | 2018-06-28 14:19:08 +0200 |
---|---|---|
committer | Marcin Siodelski <marcin@isc.org> | 2018-06-28 14:19:08 +0200 |
commit | e8778d41be64dd36ed8203daa153ca40635abbf0 (patch) | |
tree | 3f4c02f3d130d126c7d0b6cea91971bd494410ab /src/hooks | |
parent | [5651] Removed total-count from leaseX-get-page command in User's Guide. (diff) | |
download | kea-e8778d41be64dd36ed8203daa153ca40635abbf0.tar.xz kea-e8778d41be64dd36ed8203daa153ca40635abbf0.zip |
[5651] Renamed count to limit for leaseX-get-page command.
Diffstat (limited to 'src/hooks')
-rw-r--r-- | src/hooks/dhcp/lease_cmds/lease_cmds.cc | 37 | ||||
-rw-r--r-- | src/hooks/dhcp/lease_cmds/tests/lease_cmds_unittest.cc | 34 |
2 files changed, 27 insertions, 44 deletions
diff --git a/src/hooks/dhcp/lease_cmds/lease_cmds.cc b/src/hooks/dhcp/lease_cmds/lease_cmds.cc index e1a1e9056a..4d24546df9 100644 --- a/src/hooks/dhcp/lease_cmds/lease_cmds.cc +++ b/src/hooks/dhcp/lease_cmds/lease_cmds.cc @@ -624,34 +624,27 @@ LeaseCmdsImpl::leaseGetPageHandler(CalloutHandle& handle) { << " is not an IPv6 address"); } - // The 'count' is a desired page size. It must always be present. - ConstElementPtr page_count = cmd_args_->get("count"); - if (!page_count) { - isc_throw(BadValue, "'count' parameter not specified"); + // The 'limit' is a desired page size. It must always be present. + ConstElementPtr page_limit = cmd_args_->get("limit"); + if (!page_limit) { + isc_throw(BadValue, "'limit' parameter not specified"); } - // The 'count' must be a number. - if (page_count->getType() != Element::integer) { - isc_throw(BadValue, "'count' parameter must be a number"); + // The 'limit' must be a number. + if (page_limit->getType() != Element::integer) { + isc_throw(BadValue, "'limit' parameter must be a number"); } // Retrieve the desired page size. - size_t page_count_value = static_cast<size_t>(page_count->intValue()); + size_t page_limit_value = static_cast<size_t>(page_limit->intValue()); ElementPtr leases_json = Element::createList(); - // Use lease stats function to retrieve the total number of leases. - // Total number of leases is returned apart from the leases list - // so as the controlling client can track the progress of leases - // viewed vs all leases count. - LeaseStatsQueryPtr query; if (v4) { // Get page of IPv4 leases. Lease4Collection leases = LeaseMgrFactory::instance().getLeases4(*from_address, - LeasePageSize(page_count_value)); - // Get the total lease count. - query = LeaseMgrFactory::instance().startLeaseStatsQuery4(); + LeasePageSize(page_limit_value)); // Convert leases into JSON list. for (auto lease : leases) { @@ -663,10 +656,7 @@ LeaseCmdsImpl::leaseGetPageHandler(CalloutHandle& handle) { // Get page of IPv6 leases. Lease6Collection leases = LeaseMgrFactory::instance().getLeases6(*from_address, - LeasePageSize(page_count_value)); - // Get the total lease count. - query = LeaseMgrFactory::instance().startLeaseStatsQuery6(); - + LeasePageSize(page_limit_value)); // Convert leases into JSON list. for (auto lease : leases) { ElementPtr lease_json = lease->toElement(); @@ -674,13 +664,6 @@ LeaseCmdsImpl::leaseGetPageHandler(CalloutHandle& handle) { } } - // Sum up lease counters for various lease states. - LeaseStatsRow row; - int64_t total_leases = 0; - while (query->getNextRow(row)) { - total_leases += row.state_count_; - } - // Prepare textual status. std::ostringstream s; s << leases_json->size() diff --git a/src/hooks/dhcp/lease_cmds/tests/lease_cmds_unittest.cc b/src/hooks/dhcp/lease_cmds/tests/lease_cmds_unittest.cc index bf9eb6c103..630a6d3ae9 100644 --- a/src/hooks/dhcp/lease_cmds/tests/lease_cmds_unittest.cc +++ b/src/hooks/dhcp/lease_cmds/tests/lease_cmds_unittest.cc @@ -1613,7 +1613,7 @@ TEST_F(LeaseCmdsTest, Lease4GetPaged) { " \"command\": \"lease4-get-page\",\n" " \"arguments\": {" " \"from\": \"" + last_address + "\"," - " \"count\": 2" + " \"limit\": 2" " }" "}"; @@ -1697,7 +1697,7 @@ TEST_F(LeaseCmdsTest, Lease4GetPagedZeroAddress) { " \"command\": \"lease4-get-page\",\n" " \"arguments\": {" " \"from\": \"0.0.0.0\"," - " \"count\": 2" + " \"limit\": 2" " }" "}"; @@ -1717,7 +1717,7 @@ TEST_F(LeaseCmdsTest, Lease4GetPagedIPv4Address) { " \"command\": \"lease4-get-page\",\n" " \"arguments\": {" " \"from\": \"2001:db8::1\"," - " \"count\": 2" + " \"limit\": 2" " }" "}"; @@ -1948,7 +1948,7 @@ TEST_F(LeaseCmdsTest, Lease6GetPaged) { " \"command\": \"lease6-get-page\",\n" " \"arguments\": {" " \"from\": \"" + last_address + "\"," - " \"count\": 2" + " \"limit\": 2" " }" "}"; @@ -2033,7 +2033,7 @@ TEST_F(LeaseCmdsTest, Lease6GetPagedZeroAddress) { " \"command\": \"lease6-get-page\",\n" " \"arguments\": {" " \"from\": \"::\"," - " \"count\": 2" + " \"limit\": 2" " }" "}"; @@ -2053,7 +2053,7 @@ TEST_F(LeaseCmdsTest, Lease6GetPagedIPv4Address) { " \"command\": \"lease6-get-page\",\n" " \"arguments\": {" " \"from\": \"192.0.2.3\"," - " \"count\": 2" + " \"limit\": 2" " }" "}"; @@ -2074,7 +2074,7 @@ TEST_F(LeaseCmdsTest, Lease6GetPagedInvalidFrom) { " \"command\": \"lease6-get-page\",\n" " \"arguments\": {" " \"from\": \"foo\"," - " \"count\": 2" + " \"limit\": 2" " }" "}"; @@ -2083,8 +2083,8 @@ TEST_F(LeaseCmdsTest, Lease6GetPagedInvalidFrom) { testCommand(cmd, CONTROL_RESULT_ERROR, exp_rsp); } -// Verifies that count is mandatory. -TEST_F(LeaseCmdsTest, Lease6GetPagedNoCount) { +// Verifies that limit is mandatory. +TEST_F(LeaseCmdsTest, Lease6GetPagedNoLimit) { // Initialize lease manager (true = v6, true = add a lease) initLeaseMgr(true, true); @@ -2098,12 +2098,12 @@ TEST_F(LeaseCmdsTest, Lease6GetPagedNoCount) { " }" "}"; - string exp_rsp = "'count' parameter not specified"; + string exp_rsp = "'limit' parameter not specified"; testCommand(cmd, CONTROL_RESULT_ERROR, exp_rsp); } -// Verifies that the count must be a number. -TEST_F(LeaseCmdsTest, Lease6GetPagedCountNotNumber) { +// Verifies that the limit must be a number. +TEST_F(LeaseCmdsTest, Lease6GetPagedLimitNotNumber) { // Initialize lease manager (true = v6, true = add a lease) initLeaseMgr(true, true); @@ -2114,16 +2114,16 @@ TEST_F(LeaseCmdsTest, Lease6GetPagedCountNotNumber) { " \"command\": \"lease6-get-page\",\n" " \"arguments\": {" " \"from\": \"start\"," - " \"count\": false" + " \"limit\": false" " }" "}"; - string exp_rsp = "'count' parameter must be a number"; + string exp_rsp = "'limit' parameter must be a number"; testCommand(cmd, CONTROL_RESULT_ERROR, exp_rsp); } -// Verifies that the count of 0 is rejected. -TEST_F(LeaseCmdsTest, Lease6GetPagedCountIsZero) { +// Verifies that the limit of 0 is rejected. +TEST_F(LeaseCmdsTest, Lease6GetPagedLimitIsZero) { // Initialize lease manager (true = v6, true = add a lease) initLeaseMgr(true, true); @@ -2134,7 +2134,7 @@ TEST_F(LeaseCmdsTest, Lease6GetPagedCountIsZero) { " \"command\": \"lease6-get-page\",\n" " \"arguments\": {" " \"from\": \"start\"," - " \"count\": 0" + " \"limit\": 0" " }" "}"; |