Commit 59782988 authored by Marcin Siodelski's avatar Marcin Siodelski
Browse files

[#689] Do not include subnet-id in failed leases in response to bulk apply.

parent ebd975ba
......@@ -269,15 +269,13 @@ public:
/// The DUID is only included if it is non-null. The address is only
/// included if it is non-zero.
///
/// @param subnet_id identifier of the subnet where the lease belongs.
/// @param lease_type lease type.
/// @param lease_address lease address.
/// @param duid DUID of the client.
/// @param control_result Control result: "empty" of the lease was
/// not found, "error" otherwise.
/// @param error_message Error message.
ElementPtr createFailedLeaseMap(const SubnetID& subnet_id,
const Lease::Type& lease_type,
ElementPtr createFailedLeaseMap(const Lease::Type& lease_type,
const IOAddress& lease_address,
const DuidPtr& duid,
const int control_result,
......@@ -921,7 +919,7 @@ LeaseCmdsImpl::lease6BulkApplyHandler(CalloutHandle& handle) {
// on the list of leases which failed to delete. That
// corresponds to the lease6-del command which returns
// an error when the lease doesn't exist.
failed_deleted_list->add(createFailedLeaseMap(p.subnet_id, p.lease_type,
failed_deleted_list->add(createFailedLeaseMap(p.lease_type,
p.addr, p.duid,
CONTROL_RESULT_EMPTY,
"lease not found"));
......@@ -933,7 +931,7 @@ LeaseCmdsImpl::lease6BulkApplyHandler(CalloutHandle& handle) {
if (!failed_deleted_list) {
failed_deleted_list = Element::createList();
}
failed_deleted_list->add(createFailedLeaseMap(p.subnet_id, p.lease_type,
failed_deleted_list->add(createFailedLeaseMap(p.lease_type,
p.addr, p.duid,
CONTROL_RESULT_ERROR,
ex.what()));
......@@ -968,8 +966,7 @@ LeaseCmdsImpl::lease6BulkApplyHandler(CalloutHandle& handle) {
if (!failed_leases_list) {
failed_leases_list = Element::createList();
}
failed_leases_list->add(createFailedLeaseMap(lease->subnet_id_,
lease->type_,
failed_leases_list->add(createFailedLeaseMap(lease->type_,
lease->addr_,
lease->duid_,
CONTROL_RESULT_ERROR,
......@@ -1279,15 +1276,12 @@ LeaseCmdsImpl::getIPv6AddressForDelete(const Parameters& parameters) const {
}
ElementPtr
LeaseCmdsImpl::createFailedLeaseMap(const SubnetID& subnet_id,
const Lease::Type& lease_type,
LeaseCmdsImpl::createFailedLeaseMap(const Lease::Type& lease_type,
const IOAddress& lease_address,
const DuidPtr& duid,
const int control_result,
const std::string& error_message) const {
auto failed_lease_map = Element::createMap();
failed_lease_map->set("subnet-id",
Element::create(static_cast<long int>(subnet_id)));
failed_lease_map->set("type", Element::create(Lease::typeToText(lease_type)));
if (!lease_address.isV6Zero()) {
......
......@@ -504,14 +504,11 @@ public:
/// @oaram expected_control_result Expected control result for the lease.
/// @param expected_error_msg Expected error message. Default is an empty
/// string which indicates that the error message should not be checked.
/// @param expected_subnet_id Expected subnet id. Default is -1 which means
/// that the subnet_id is not required and should not be checked.
void checkFailedLease(const ConstElementPtr& failed_leases_list,
const std::string& expected_type,
const std::string& expected_ip_address,
const int expected_control_result,
const std::string& expected_error_msg = "",
const SubnetID& expected_subnet_id = -1) {
const std::string& expected_error_msg = "") {
ASSERT_TRUE(failed_leases_list);
for (auto i = 0; i < failed_leases_list->size(); ++i) {
......@@ -540,12 +537,6 @@ public:
ASSERT_EQ(Element::string, error_msg->getType());
}
if (expected_subnet_id > 0) {
auto subnet_id = failed_lease->get("subnet-id");
ASSERT_TRUE(subnet_id);
ASSERT_EQ(Element::integer, subnet_id->getType());
}
return;
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment