mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-31 14:05:33 +00:00
[#1540] Removed useless getLease4 variant
This commit is contained in:
@@ -2263,22 +2263,6 @@ CqlLeaseMgr::getLease4(const ClientId &clientid) const {
|
||||
return (result);
|
||||
}
|
||||
|
||||
Lease4Ptr
|
||||
CqlLeaseMgr::getLease4(const ClientId &clientid, const HWAddr &hwaddr,
|
||||
SubnetID subnet_id) const {
|
||||
/// @todo: Remove this method in this and all other implementations.
|
||||
/// This method is currently not implemented because allocation engine
|
||||
/// searches for the lease using HW address or client identifier.
|
||||
/// It never uses both parameters in the same time. We need to
|
||||
/// consider if this method is needed at all.
|
||||
LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_CQL_GET_CLIENTID_HWADDR_SUBID)
|
||||
.arg(clientid.toText())
|
||||
.arg(hwaddr.toText())
|
||||
.arg(subnet_id);
|
||||
|
||||
isc_throw(NotImplemented, "CqlLeaseMgr::getLease4() is obsolete");
|
||||
}
|
||||
|
||||
Lease4Ptr
|
||||
CqlLeaseMgr::getLease4(const ClientId &clientid, SubnetID subnet_id) const {
|
||||
LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_CQL_GET_SUBID_CLIENTID)
|
||||
|
@@ -169,21 +169,6 @@ public:
|
||||
/// failed.
|
||||
virtual Lease4Collection getLease4(const ClientId& clientid) const override;
|
||||
|
||||
/// @brief Returns IPv4 lease for the specified client identifier, HW
|
||||
/// address and subnet identifier.
|
||||
///
|
||||
/// @param client_id A client identifier.
|
||||
/// @param hwaddr hardware address.
|
||||
/// @param subnet_id A subnet identifier.
|
||||
///
|
||||
/// @return A pointer to the lease or NULL if the lease is not found.
|
||||
///
|
||||
/// @throw isc::NotImplemented On every call as this method is currently
|
||||
/// not implemented for the CQL backend.
|
||||
virtual Lease4Ptr getLease4(const ClientId& client_id,
|
||||
const HWAddr& hwaddr,
|
||||
SubnetID subnet_id) const override;
|
||||
|
||||
/// @brief Returns existing IPv4 lease for specified client-id
|
||||
///
|
||||
/// There can be at most one lease for a given HW address in a single
|
||||
|
@@ -121,7 +121,6 @@ extern const isc::log::MessageID DHCPSRV_MEMFILE_GET6_DUID = "DHCPSRV_MEMFILE_GE
|
||||
extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_ADDR4 = "DHCPSRV_MEMFILE_GET_ADDR4";
|
||||
extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_ADDR6 = "DHCPSRV_MEMFILE_GET_ADDR6";
|
||||
extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_CLIENTID = "DHCPSRV_MEMFILE_GET_CLIENTID";
|
||||
extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_CLIENTID_HWADDR_SUBID = "DHCPSRV_MEMFILE_GET_CLIENTID_HWADDR_SUBID";
|
||||
extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_EXPIRED4 = "DHCPSRV_MEMFILE_GET_EXPIRED4";
|
||||
extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_EXPIRED6 = "DHCPSRV_MEMFILE_GET_EXPIRED6";
|
||||
extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_HOSTNAME4 = "DHCPSRV_MEMFILE_GET_HOSTNAME4";
|
||||
@@ -382,7 +381,6 @@ const char* values[] = {
|
||||
"DHCPSRV_MEMFILE_GET_ADDR4", "obtaining IPv4 lease for address %1",
|
||||
"DHCPSRV_MEMFILE_GET_ADDR6", "obtaining IPv6 lease for address %1 and lease type %2",
|
||||
"DHCPSRV_MEMFILE_GET_CLIENTID", "obtaining IPv4 leases for client ID %1",
|
||||
"DHCPSRV_MEMFILE_GET_CLIENTID_HWADDR_SUBID", "obtaining IPv4 lease for client ID %1, hardware address %2 and subnet ID %3",
|
||||
"DHCPSRV_MEMFILE_GET_EXPIRED4", "obtaining maximum %1 of expired IPv4 leases",
|
||||
"DHCPSRV_MEMFILE_GET_EXPIRED6", "obtaining maximum %1 of expired IPv6 leases",
|
||||
"DHCPSRV_MEMFILE_GET_HOSTNAME4", "obtaining IPv4 leases for hostname %1",
|
||||
|
@@ -122,7 +122,6 @@ extern const isc::log::MessageID DHCPSRV_MEMFILE_GET6_DUID;
|
||||
extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_ADDR4;
|
||||
extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_ADDR6;
|
||||
extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_CLIENTID;
|
||||
extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_CLIENTID_HWADDR_SUBID;
|
||||
extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_EXPIRED4;
|
||||
extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_EXPIRED6;
|
||||
extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_HOSTNAME4;
|
||||
|
@@ -600,11 +600,6 @@ A debug message issued when the server is attempting to obtain a set of
|
||||
IPv4 leases from the memory file database for a client with the specified
|
||||
client identification.
|
||||
|
||||
% DHCPSRV_MEMFILE_GET_CLIENTID_HWADDR_SUBID obtaining IPv4 lease for client ID %1, hardware address %2 and subnet ID %3
|
||||
A debug message issued when the server is attempting to obtain an IPv4
|
||||
lease from the memory file database for a client with the specified
|
||||
client ID, hardware address and subnet ID.
|
||||
|
||||
% DHCPSRV_MEMFILE_GET_EXPIRED4 obtaining maximum %1 of expired IPv4 leases
|
||||
A debug message issued when the server is attempting to obtain expired
|
||||
IPv4 leases to reclaim them. The maximum number of leases to be retrieved
|
||||
|
@@ -311,20 +311,6 @@ public:
|
||||
/// @return lease collection
|
||||
virtual Lease4Collection getLease4(const ClientId& clientid) const = 0;
|
||||
|
||||
/// @brief Returns existing IPv4 lease for a given client identifier,
|
||||
/// HW address and subnet identifier.
|
||||
///
|
||||
/// @todo Consider whether this function is needed or not. In the basic
|
||||
/// DHCPv4 server implementation it is not used by the allocation engine.
|
||||
///
|
||||
/// @param client_id A client identifier.
|
||||
/// @param hwaddr Hardware address.
|
||||
/// @param subnet_id A subnet identifier.
|
||||
///
|
||||
/// @return A pointer to the lease or NULL if the lease is not found.
|
||||
virtual Lease4Ptr getLease4(const ClientId& client_id, const HWAddr& hwaddr,
|
||||
SubnetID subnet_id) const = 0;
|
||||
|
||||
/// @brief Returns existing IPv4 lease for specified client-id
|
||||
///
|
||||
/// There can be at most one lease for a given client-id in a single
|
||||
|
@@ -882,44 +882,6 @@ Memfile_LeaseMgr::getLease4(const ClientId& client_id) const {
|
||||
return (collection);
|
||||
}
|
||||
|
||||
Lease4Ptr
|
||||
Memfile_LeaseMgr::getLease4Internal(const ClientId& client_id,
|
||||
const HWAddr& hwaddr,
|
||||
SubnetID subnet_id) const {
|
||||
// Get the index by client id, HW address and subnet id.
|
||||
const Lease4StorageClientIdHWAddressSubnetIdIndex& idx =
|
||||
storage4_.get<ClientIdHWAddressSubnetIdIndexTag>();
|
||||
// Try to get the lease using client id, hardware address and subnet id.
|
||||
Lease4StorageClientIdHWAddressSubnetIdIndex::const_iterator lease =
|
||||
idx.find(boost::make_tuple(client_id.getClientId(), hwaddr.hwaddr_,
|
||||
subnet_id));
|
||||
|
||||
if (lease == idx.end()) {
|
||||
// Lease was not found. Return empty pointer to the caller.
|
||||
return (Lease4Ptr());
|
||||
}
|
||||
|
||||
// Lease was found. Return it to the caller.
|
||||
return (*lease);
|
||||
}
|
||||
|
||||
Lease4Ptr
|
||||
Memfile_LeaseMgr::getLease4(const ClientId& client_id,
|
||||
const HWAddr& hwaddr,
|
||||
SubnetID subnet_id) const {
|
||||
LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL,
|
||||
DHCPSRV_MEMFILE_GET_CLIENTID_HWADDR_SUBID).arg(client_id.toText())
|
||||
.arg(hwaddr.toText())
|
||||
.arg(subnet_id);
|
||||
|
||||
if (MultiThreadingMgr::instance().getMode()) {
|
||||
std::lock_guard<std::mutex> lock(*mutex_);
|
||||
return (getLease4Internal(client_id, hwaddr, subnet_id));
|
||||
} else {
|
||||
return (getLease4Internal(client_id, hwaddr, subnet_id));
|
||||
}
|
||||
}
|
||||
|
||||
Lease4Ptr
|
||||
Memfile_LeaseMgr::getLease4Internal(const ClientId& client_id,
|
||||
SubnetID subnet_id) const {
|
||||
|
@@ -200,21 +200,6 @@ public:
|
||||
/// @return lease collection
|
||||
virtual Lease4Collection getLease4(const ClientId& client_id) const;
|
||||
|
||||
/// @brief Returns IPv4 lease for specified client-id/hwaddr/subnet-id tuple
|
||||
///
|
||||
/// There can be at most one lease for a given client-id/hwaddr tuple
|
||||
/// in a single pool, so this method with either return a single lease
|
||||
/// or NULL.
|
||||
///
|
||||
/// @param clientid client identifier
|
||||
/// @param hwaddr hardware address of the client
|
||||
/// @param subnet_id identifier of the subnet that lease must belong to
|
||||
///
|
||||
/// @return a pointer to the lease (or NULL if a lease is not found)
|
||||
virtual Lease4Ptr getLease4(const ClientId& clientid,
|
||||
const HWAddr& hwaddr,
|
||||
SubnetID subnet_id) const;
|
||||
|
||||
/// @brief Returns existing IPv4 lease for specified client-id
|
||||
///
|
||||
/// This function returns a copy of the lease. The modification in the
|
||||
|
@@ -2268,16 +2268,6 @@ MySqlLeaseMgr::getLease4(const ClientId& clientid) const {
|
||||
return (result);
|
||||
}
|
||||
|
||||
Lease4Ptr
|
||||
MySqlLeaseMgr::getLease4(const ClientId&, const HWAddr&, SubnetID) const {
|
||||
/// This function is currently not implemented because allocation engine
|
||||
/// searches for the lease using HW address or client identifier.
|
||||
/// It never uses both parameters in the same time. We need to
|
||||
/// consider if this function is needed at all.
|
||||
isc_throw(NotImplemented, "The MySqlLeaseMgr::getLease4 function was"
|
||||
" called, but it is not implemented");
|
||||
}
|
||||
|
||||
Lease4Ptr
|
||||
MySqlLeaseMgr::getLease4(const ClientId& clientid, SubnetID subnet_id) const {
|
||||
LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_MYSQL_GET_SUBID_CLIENTID)
|
||||
|
@@ -250,19 +250,6 @@ public:
|
||||
/// failed.
|
||||
virtual Lease4Collection getLease4(const ClientId& clientid) const;
|
||||
|
||||
/// @brief Returns IPv4 lease for the specified client identifier, HW
|
||||
/// address and subnet identifier.
|
||||
///
|
||||
/// @param client_id A client identifier.
|
||||
/// @param hwaddr Hardware address.
|
||||
/// @param subnet_id A subnet identifier.
|
||||
///
|
||||
/// @return A pointer to the lease or NULL if the lease is not found.
|
||||
/// @throw isc::NotImplemented On every call as this function is currently
|
||||
/// not implemented for the MySQL backend.
|
||||
virtual Lease4Ptr getLease4(const ClientId& client_id, const HWAddr& hwaddr,
|
||||
SubnetID subnet_id) const;
|
||||
|
||||
/// @brief Returns existing IPv4 lease for specified client-id
|
||||
///
|
||||
/// There can be at most one lease for a given HW address in a single
|
||||
|
@@ -1597,16 +1597,6 @@ PgSqlLeaseMgr::getLease4(const ClientId& clientid) const {
|
||||
return (result);
|
||||
}
|
||||
|
||||
Lease4Ptr
|
||||
PgSqlLeaseMgr::getLease4(const ClientId&, const HWAddr&, SubnetID) const {
|
||||
/// This function is currently not implemented because allocation engine
|
||||
/// searches for the lease using HW address or client identifier.
|
||||
/// It never uses both parameters in the same time. We need to
|
||||
/// consider if this function is needed at all.
|
||||
isc_throw(NotImplemented, "The PgSqlLeaseMgr::getLease4 function was"
|
||||
" called, but it is not implemented");
|
||||
}
|
||||
|
||||
Lease4Ptr
|
||||
PgSqlLeaseMgr::getLease4(const ClientId& clientid, SubnetID subnet_id) const {
|
||||
LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_PGSQL_GET_SUBID_CLIENTID)
|
||||
|
@@ -237,19 +237,6 @@ public:
|
||||
/// failed.
|
||||
virtual Lease4Collection getLease4(const ClientId& clientid) const;
|
||||
|
||||
/// @brief Returns IPv4 lease for the specified client identifier, HW
|
||||
/// address and subnet identifier.
|
||||
///
|
||||
/// @param client_id A client identifier.
|
||||
/// @param hwaddr Hardware address.
|
||||
/// @param subnet_id A subnet identifier.
|
||||
///
|
||||
/// @return A pointer to the lease or NULL if the lease is not found.
|
||||
/// @throw isc::NotImplemented On every call as this function is currently
|
||||
/// not implemented for the PostgreSQL backend.
|
||||
virtual Lease4Ptr getLease4(const ClientId& client_id, const HWAddr& hwaddr,
|
||||
SubnetID subnet_id) const;
|
||||
|
||||
/// @brief Returns existing IPv4 lease for specified client-id
|
||||
///
|
||||
/// There can be at most one lease for a given HW address in a single
|
||||
|
@@ -595,40 +595,6 @@ GenericLeaseMgrTest::testGetLease4HWAddr2() {
|
||||
EXPECT_EQ(0, returned.size());
|
||||
}
|
||||
|
||||
void
|
||||
GenericLeaseMgrTest::testGetLease4ClientIdHWAddrSubnetId() {
|
||||
Lease4Ptr leaseA = initializeLease4(straddress4_[4]);
|
||||
Lease4Ptr leaseB = initializeLease4(straddress4_[5]);
|
||||
Lease4Ptr leaseC = initializeLease4(straddress4_[6]);
|
||||
// Set NULL client id for one of the leases. This is to make sure that such
|
||||
// a lease may coexist with other leases with non NULL client id.
|
||||
leaseC->client_id_.reset();
|
||||
|
||||
HWAddr hwaddrA(*leaseA->hwaddr_);
|
||||
HWAddr hwaddrB(*leaseB->hwaddr_);
|
||||
HWAddr hwaddrC(*leaseC->hwaddr_);
|
||||
EXPECT_TRUE(lmptr_->addLease(leaseA));
|
||||
EXPECT_TRUE(lmptr_->addLease(leaseB));
|
||||
EXPECT_TRUE(lmptr_->addLease(leaseC));
|
||||
// First case we should retrieve our lease
|
||||
Lease4Ptr lease = lmptr_->getLease4(*leaseA->client_id_, hwaddrA, leaseA->subnet_id_);
|
||||
detailCompareLease(lease, leaseA);
|
||||
// Retrieve the other lease.
|
||||
lease = lmptr_->getLease4(*leaseB->client_id_, hwaddrB, leaseB->subnet_id_);
|
||||
detailCompareLease(lease, leaseB);
|
||||
// The last lease has NULL client id so we will use a different getLease4 function
|
||||
// which doesn't require client id (just a hwaddr and subnet id).
|
||||
lease = lmptr_->getLease4(hwaddrC, leaseC->subnet_id_);
|
||||
detailCompareLease(lease, leaseC);
|
||||
|
||||
// An attempt to retrieve the lease with non matching lease parameters should
|
||||
// result in NULL pointer being returned.
|
||||
lease = lmptr_->getLease4(*leaseA->client_id_, hwaddrB, leaseA->subnet_id_);
|
||||
EXPECT_FALSE(lease);
|
||||
lease = lmptr_->getLease4(*leaseA->client_id_, hwaddrA, leaseB->subnet_id_);
|
||||
EXPECT_FALSE(lease);
|
||||
}
|
||||
|
||||
void
|
||||
GenericLeaseMgrTest::testAddGetDelete6() {
|
||||
const std::string addr234("2001:db8:1::234");
|
||||
|
@@ -174,9 +174,6 @@ public:
|
||||
/// HWAddr information.
|
||||
void testGetLease4HWAddr2();
|
||||
|
||||
/// @brief Test lease retrieval using client id, HW address and subnet id.
|
||||
void testGetLease4ClientIdHWAddrSubnetId();
|
||||
|
||||
/// @brief Get lease4 by hardware address (2)
|
||||
///
|
||||
/// Check that the system can cope with getting a hardware address of
|
||||
|
@@ -910,19 +910,6 @@ TEST_F(MemfileLeaseMgrTest, getLease4HWAddr2MultiThread) {
|
||||
testGetLease4HWAddr2();
|
||||
}
|
||||
|
||||
/// @brief Checks lease4 retrieval with clientId, HWAddr and subnet_id
|
||||
TEST_F(MemfileLeaseMgrTest, getLease4ClientIdHWAddrSubnetId) {
|
||||
startBackend(V4);
|
||||
testGetLease4ClientIdHWAddrSubnetId();
|
||||
}
|
||||
|
||||
/// @brief Checks lease4 retrieval with clientId, HWAddr and subnet_id
|
||||
TEST_F(MemfileLeaseMgrTest, getLease4ClientIdHWAddrSubnetIdMultiThread) {
|
||||
startBackend(V4);
|
||||
MultiThreadingMgr::instance().setMode(true);
|
||||
testGetLease4ClientIdHWAddrSubnetId();
|
||||
}
|
||||
|
||||
/// @brief Basic Lease4 Checks
|
||||
///
|
||||
/// Checks that the addLease, getLease4(by address), getLease4(hwaddr,subnet_id),
|
||||
@@ -2072,16 +2059,6 @@ TEST_F(MemfileLeaseMgrTest, lease4ContainerIndexUpdate) {
|
||||
<< error_desc;
|
||||
detailCompareLease(tested, lease_by_clientid_subnet);
|
||||
|
||||
// Retrieve lease by client id, HW address and subnet.
|
||||
Lease4Ptr lease_by_clientid_hwaddr_subnet = lmptr_->getLease4(*tested->client_id_,
|
||||
*tested->hwaddr_,
|
||||
tested->subnet_id_);
|
||||
ASSERT_TRUE(lease_by_clientid_hwaddr_subnet)
|
||||
<< "Lease " << tested->addr_.toText()
|
||||
<< " not found by getLease4(clientid, hwaddr, subnet_id)"
|
||||
<< error_desc;
|
||||
detailCompareLease(tested, lease_by_clientid_hwaddr_subnet);
|
||||
|
||||
// Retrieve lease by HW address.
|
||||
Lease4Collection leases_by_hwaddr = lmptr_->getLease4(*tested->hwaddr_);
|
||||
ASSERT_EQ(1, leases_by_hwaddr.size());
|
||||
|
Reference in New Issue
Block a user