Skip to content

Commit 228e848

Browse files
author
Marcin Godzina
committed
[#3427] deprecate warning for lease wipe
1 parent 77195c4 commit 228e848

10 files changed

+57
-16
lines changed

ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2244. [func] mgodzina
2+
lease4-wipe and lease6-wipe now log a deprecation warning.
3+
(Gitlab #3427)
4+
15
2243. [func] razvan
26
Updated yang modules: removed qualifying-suffix,
37
override-no-update, override-client-update,

doc/sphinx/arm/hooks-lease-cmds.rst

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,12 @@ This library provides the following commands:
8787
- :isccmd:`lease6-update` - updates (replaces) an existing IPv6 lease.
8888

8989
- :isccmd:`lease4-wipe` - removes all leases from a specific IPv4 subnet or
90-
from all subnets.
90+
from all subnets. This command is deprecated and it will be removed
91+
in the future.
9192

9293
- :isccmd:`lease6-wipe` - removes all leases from a specific IPv6 subnet or
93-
from all subnets.
94+
from all subnets. This command is deprecated and it will be removed
95+
in the future.
9496

9597
- :isccmd:`lease4-resend-ddns` - resends a request to update DNS entries for
9698
an existing lease.
@@ -961,6 +963,11 @@ response, modifying it to the required outcome, and then issuing the
961963
The ``lease4-wipe``, ``lease6-wipe`` Commands
962964
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
963965

966+
.. warning::
967+
968+
The :isccmd:`lease4-wipe` and :isccmd:`lease6-wipe` commands are deprecated
969+
and they will be removed in the future.
970+
964971
:isccmd:`lease4-wipe` and :isccmd:`lease6-wipe` are designed to remove all leases
965972
associated with a given subnet. This administrative task is expected to
966973
be used when an existing subnet is being retired. The leases

src/hooks/dhcp/lease_cmds/lease_cmds.cc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2298,20 +2298,23 @@ LeaseCmdsImpl::lease4WipeHandler(CalloutHandle& handle) {
22982298
}
22992299

23002300
stringstream tmp;
2301-
tmp << "Deleted " << num << " IPv4 lease(s) from subnet(s)" << ids.str();
2301+
tmp << "Deleted " << num << " IPv4 lease(s) from subnet(s)" << ids.str()
2302+
<< " WARNING: lease4-wipe is deprecated!";
23022303
ConstElementPtr response = createAnswer(num ? CONTROL_RESULT_SUCCESS
23032304
: CONTROL_RESULT_EMPTY, tmp.str());
23042305
setResponse(handle, response);
23052306
} catch (const std::exception& ex) {
23062307
LOG_ERROR(lease_cmds_logger, LEASE_CMDS_WIPE4_FAILED)
23072308
.arg(cmd_args_ ? cmd_args_->str() : "<no args>")
23082309
.arg(ex.what());
2310+
LOG_WARN(lease_cmds_logger, LEASE_CMDS_WIPE4_DEPRECATED);
23092311
setErrorResponse(handle, ex.what());
23102312
return (1);
23112313
}
23122314

23132315
LOG_INFO(lease_cmds_logger, LEASE_CMDS_WIPE4)
23142316
.arg(cmd_args_ ? cmd_args_->str() : "<no args>");
2317+
LOG_WARN(lease_cmds_logger, LEASE_CMDS_WIPE4_DEPRECATED);
23152318
return (0);
23162319
}
23172320

@@ -2443,20 +2446,23 @@ LeaseCmdsImpl::lease6WipeHandler(CalloutHandle& handle) {
24432446
}
24442447

24452448
stringstream tmp;
2446-
tmp << "Deleted " << num << " IPv6 lease(s) from subnet(s)" << ids.str();
2449+
tmp << "Deleted " << num << " IPv6 lease(s) from subnet(s)" << ids.str()
2450+
<< " WARNING: lease6-wipe is deprecated!";
24472451
ConstElementPtr response = createAnswer(num ? CONTROL_RESULT_SUCCESS
24482452
: CONTROL_RESULT_EMPTY, tmp.str());
24492453
setResponse(handle, response);
24502454
} catch (const std::exception& ex) {
24512455
LOG_ERROR(lease_cmds_logger, LEASE_CMDS_WIPE6_FAILED)
24522456
.arg(cmd_args_ ? cmd_args_->str() : "<no args>")
24532457
.arg(ex.what());
2458+
LOG_WARN(lease_cmds_logger, LEASE_CMDS_WIPE6_DEPRECATED);
24542459
setErrorResponse(handle, ex.what());
24552460
return (1);
24562461
}
24572462

24582463
LOG_INFO(lease_cmds_logger, LEASE_CMDS_WIPE6)
24592464
.arg(cmd_args_ ? cmd_args_->str() : "<no args>");
2465+
LOG_WARN(lease_cmds_logger, LEASE_CMDS_WIPE6_DEPRECATED);
24602466
return (0);
24612467
}
24622468

src/hooks/dhcp/lease_cmds/lease_cmds_messages.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ extern const isc::log::MessageID LEASE_CMDS_UPDATE6 = "LEASE_CMDS_UPDATE6";
3333
extern const isc::log::MessageID LEASE_CMDS_UPDATE6_CONFLICT = "LEASE_CMDS_UPDATE6_CONFLICT";
3434
extern const isc::log::MessageID LEASE_CMDS_UPDATE6_FAILED = "LEASE_CMDS_UPDATE6_FAILED";
3535
extern const isc::log::MessageID LEASE_CMDS_WIPE4 = "LEASE_CMDS_WIPE4";
36+
extern const isc::log::MessageID LEASE_CMDS_WIPE4_DEPRECATED = "LEASE_CMDS_WIPE4_DEPRECATED";
3637
extern const isc::log::MessageID LEASE_CMDS_WIPE4_FAILED = "LEASE_CMDS_WIPE4_FAILED";
3738
extern const isc::log::MessageID LEASE_CMDS_WIPE6 = "LEASE_CMDS_WIPE6";
39+
extern const isc::log::MessageID LEASE_CMDS_WIPE6_DEPRECATED = "LEASE_CMDS_WIPE6_DEPRECATED";
3840
extern const isc::log::MessageID LEASE_CMDS_WIPE6_FAILED = "LEASE_CMDS_WIPE6_FAILED";
3941

4042
namespace {
@@ -69,8 +71,10 @@ const char* values[] = {
6971
"LEASE_CMDS_UPDATE6_CONFLICT", "lease6-update command failed due to conflict (parameters: %1, reason: %2)",
7072
"LEASE_CMDS_UPDATE6_FAILED", "lease6-add command failed (parameters: %1, reason: %2)",
7173
"LEASE_CMDS_WIPE4", "lease4-wipe command successful (parameters: %1)",
74+
"LEASE_CMDS_WIPE4_DEPRECATED", "lease4-wipe command is deprecated and it will be removed in the future.",
7275
"LEASE_CMDS_WIPE4_FAILED", "lease4-wipe command failed (parameters: %1, reason: %2)",
7376
"LEASE_CMDS_WIPE6", "lease6-wipe command successful (parameters: %1)",
77+
"LEASE_CMDS_WIPE6_DEPRECATED", "lease6-wipe command is deprecated and it will be removed in the future.",
7478
"LEASE_CMDS_WIPE6_FAILED", "lease6-wipe command failed (parameters: %1, reason: %2)",
7579
NULL
7680
};

src/hooks/dhcp/lease_cmds/lease_cmds_messages.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ extern const isc::log::MessageID LEASE_CMDS_UPDATE6;
3434
extern const isc::log::MessageID LEASE_CMDS_UPDATE6_CONFLICT;
3535
extern const isc::log::MessageID LEASE_CMDS_UPDATE6_FAILED;
3636
extern const isc::log::MessageID LEASE_CMDS_WIPE4;
37+
extern const isc::log::MessageID LEASE_CMDS_WIPE4_DEPRECATED;
3738
extern const isc::log::MessageID LEASE_CMDS_WIPE4_FAILED;
3839
extern const isc::log::MessageID LEASE_CMDS_WIPE6;
40+
extern const isc::log::MessageID LEASE_CMDS_WIPE6_DEPRECATED;
3941
extern const isc::log::MessageID LEASE_CMDS_WIPE6_FAILED;
4042

4143
#endif // LEASE_CMDS_MESSAGES_H

src/hooks/dhcp/lease_cmds/lease_cmds_messages.mes

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,16 @@ are logged.
128128
The lease4-wipe command has failed. Both the reason as well as the
129129
parameters passed are logged.
130130

131+
% LEASE_CMDS_WIPE4_DEPRECATED lease4-wipe command is deprecated and it will be removed in the future.
132+
The lease4-wipe command is deprecated and it will be removed in the future.
133+
131134
% LEASE_CMDS_WIPE6 lease6-wipe command successful (parameters: %1)
132135
The lease6-wipe command has been successful. Parameters of the command
133136
are logged.
134137

135138
% LEASE_CMDS_WIPE6_FAILED lease6-wipe command failed (parameters: %1, reason: %2)
136139
The lease6-wipe command has failed. Both the reason as well as the
137140
parameters passed are logged.
141+
142+
% LEASE_CMDS_WIPE6_DEPRECATED lease6-wipe command is deprecated and it will be removed in the future.
143+
The lease6-wipe command is deprecated and it will be removed in the future.

src/hooks/dhcp/lease_cmds/tests/lease_cmds4_unittest.cc

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2806,7 +2806,8 @@ void Lease4CmdsTest::testLease4Wipe() {
28062806
" \"subnet-id\": 44"
28072807
" }\n"
28082808
"}";
2809-
string exp_rsp = "Deleted 2 IPv4 lease(s) from subnet(s) 44";
2809+
string exp_rsp = "Deleted 2 IPv4 lease(s) from subnet(s) 44"
2810+
" WARNING: lease4-wipe is deprecated!";
28102811

28112812
// The status expected is success. The lease should be deleted.
28122813
testCommand(cmd, CONTROL_RESULT_SUCCESS, exp_rsp);
@@ -2840,7 +2841,8 @@ void Lease4CmdsTest::testLease4WipeAll() {
28402841
" \"subnet-id\": 0"
28412842
" }\n"
28422843
"}";
2843-
string exp_rsp = "Deleted 4 IPv4 lease(s) from subnet(s) 44 88";
2844+
string exp_rsp = "Deleted 4 IPv4 lease(s) from subnet(s) 44 88"
2845+
" WARNING: lease4-wipe is deprecated!";
28442846

28452847
// The status expected is success. The lease should be deleted.
28462848
testCommand(cmd, CONTROL_RESULT_SUCCESS, exp_rsp);
@@ -2871,7 +2873,8 @@ void Lease4CmdsTest::testLease4WipeAllNoArgs() {
28712873
"{\n"
28722874
" \"command\": \"lease4-wipe\"\n"
28732875
"}";
2874-
string exp_rsp = "Deleted 4 IPv4 lease(s) from subnet(s) 44 88";
2876+
string exp_rsp = "Deleted 4 IPv4 lease(s) from subnet(s) 44 88"
2877+
" WARNING: lease4-wipe is deprecated!";
28752878

28762879
// The status expected is success. The lease should be deleted.
28772880
testCommand(cmd, CONTROL_RESULT_SUCCESS, exp_rsp);
@@ -2905,7 +2908,8 @@ void Lease4CmdsTest::testLease4WipeNoLeases() {
29052908
" \"subnet-id\": 44"
29062909
" }\n"
29072910
"}";
2908-
string exp_rsp = "Deleted 0 IPv4 lease(s) from subnet(s) 44";
2911+
string exp_rsp = "Deleted 0 IPv4 lease(s) from subnet(s) 44"
2912+
" WARNING: lease4-wipe is deprecated!";
29092913
testCommand(cmd, CONTROL_RESULT_EMPTY, exp_rsp);
29102914

29112915
checkLease4Stats(44, 0, 0);
@@ -2929,7 +2933,8 @@ void Lease4CmdsTest::testLease4WipeNoLeasesAll() {
29292933
" \"subnet-id\": 0"
29302934
" }\n"
29312935
"}";
2932-
string exp_rsp = "Deleted 0 IPv4 lease(s) from subnet(s) 44 88";
2936+
string exp_rsp = "Deleted 0 IPv4 lease(s) from subnet(s) 44 88"
2937+
" WARNING: lease4-wipe is deprecated!";
29332938
testCommand(cmd, CONTROL_RESULT_EMPTY, exp_rsp);
29342939

29352940
checkLease4Stats(44, 0, 0);

src/hooks/dhcp/lease_cmds/tests/lease_cmds6_unittest.cc

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2969,7 +2969,8 @@ void Lease6CmdsTest::testLease6Wipe() {
29692969
" \"subnet-id\": 66\n"
29702970
" }\n"
29712971
"}";
2972-
string exp_rsp = "Deleted 2 IPv6 lease(s) from subnet(s) 66";
2972+
string exp_rsp = "Deleted 2 IPv6 lease(s) from subnet(s) 66"
2973+
" WARNING: lease6-wipe is deprecated!";
29732974

29742975
// The status expected is success. The lease should be deleted.
29752976
testCommand(cmd, CONTROL_RESULT_SUCCESS, exp_rsp);
@@ -3003,7 +3004,8 @@ void Lease6CmdsTest::testLease6WipeAll() {
30033004
" \"subnet-id\": 0\n"
30043005
" }\n"
30053006
"}";
3006-
string exp_rsp = "Deleted 4 IPv6 lease(s) from subnet(s) 66 99";
3007+
string exp_rsp = "Deleted 4 IPv6 lease(s) from subnet(s) 66 99"
3008+
" WARNING: lease6-wipe is deprecated!";
30073009

30083010
// The status expected is success. The lease should be deleted.
30093011
testCommand(cmd, CONTROL_RESULT_SUCCESS, exp_rsp);
@@ -3034,7 +3036,8 @@ void Lease6CmdsTest::testLease6WipeAllNoArgs() {
30343036
"{\n"
30353037
" \"command\": \"lease6-wipe\"\n"
30363038
"}";
3037-
string exp_rsp = "Deleted 4 IPv6 lease(s) from subnet(s) 66 99";
3039+
string exp_rsp = "Deleted 4 IPv6 lease(s) from subnet(s) 66 99"
3040+
" WARNING: lease6-wipe is deprecated!";
30383041

30393042
// The status expected is success. The lease should be deleted.
30403043
testCommand(cmd, CONTROL_RESULT_SUCCESS, exp_rsp);
@@ -3068,7 +3071,8 @@ void Lease6CmdsTest::testLease6WipeNoLeases() {
30683071
" \"subnet-id\": 66"
30693072
" }\n"
30703073
"}";
3071-
string exp_rsp = "Deleted 0 IPv6 lease(s) from subnet(s) 66";
3074+
string exp_rsp = "Deleted 0 IPv6 lease(s) from subnet(s) 66"
3075+
" WARNING: lease6-wipe is deprecated!";
30723076
testCommand(cmd, CONTROL_RESULT_EMPTY, exp_rsp);
30733077

30743078
checkLease6Stats(66, 0, 0, 0);
@@ -3092,7 +3096,8 @@ void Lease6CmdsTest::testLease6WipeNoLeasesAll() {
30923096
" \"subnet-id\": 0"
30933097
" }\n"
30943098
"}";
3095-
string exp_rsp = "Deleted 0 IPv6 lease(s) from subnet(s) 66 99";
3099+
string exp_rsp = "Deleted 0 IPv6 lease(s) from subnet(s) 66 99"
3100+
" WARNING: lease6-wipe is deprecated!";
30963101
testCommand(cmd, CONTROL_RESULT_EMPTY, exp_rsp);
30973102

30983103
checkLease6Stats(66, 0, 0, 0);

src/share/api/lease4-wipe.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"access": "write",
33
"avail": "1.3.0",
44
"brief": [
5-
"This command removes all leases associated with a given subnet."
5+
"This command removes all leases associated with a given subnet.",
6+
"This command is deprecated and it will be removed in the future."
67
],
78
"cmd-syntax": [
89
"{",

src/share/api/lease6-wipe.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"access": "write",
33
"avail": "1.3.0",
44
"brief": [
5-
"This command removes all leases associated with a given subnet."
5+
"This command removes all leases associated with a given subnet.",
6+
"This command is deprecated and it will be removed in the future."
67
],
78
"cmd-comment": [
89
"Note: not all backends support this command."

0 commit comments

Comments
 (0)