Commit 084a1668 authored by Stephen Morris's avatar Stephen Morris
Browse files

[2546] Remove LeaseMgr::getLease4(address, subnetid)

As the address is th eprimary key of the table, there can only ever
be at most one lease in the database with a given address.  Additional
selection by subnet ID is not needed.
parent 93eddf78
......@@ -443,19 +443,6 @@ public:
/// with the same address was already there).
virtual bool addLease(const Lease6Ptr& lease) = 0;
/// @brief Returns IPv4 lease for specified IPv4 address and subnet_id
///
/// This method is used to get a lease for specific subnet_id. There can be
/// at most one lease for any given subnet, so this method returns a single
/// pointer.
///
/// @param addr address of the searched lease
/// @param subnet_id ID of the subnet the lease must belong to
///
/// @return smart pointer to the lease (or NULL if a lease is not found)
virtual Lease4Ptr getLease4(const isc::asiolink::IOAddress& addr,
SubnetID subnet_id) const = 0;
/// @brief Returns an IPv4 lease for specified IPv4 address
///
/// This method return a lease that is associated with a given address.
......
......@@ -49,11 +49,6 @@ Lease4Collection Memfile_LeaseMgr::getLease4(const HWAddr& ) const {
return (Lease4Collection());
}
Lease4Ptr Memfile_LeaseMgr::getLease4(const isc::asiolink::IOAddress&,
SubnetID) const {
return (Lease4Ptr());
}
Lease4Ptr Memfile_LeaseMgr::getLease4(const HWAddr&,
SubnetID) const {
return (Lease4Ptr());
......
......@@ -68,16 +68,6 @@ public:
/// @return a collection of leases
virtual Lease4Ptr getLease4(const isc::asiolink::IOAddress& addr) const;
/// @brief Returns existing IPv4 lease for specific address and subnet
///
/// @todo Not implemented yet
/// @param addr address of the searched lease
/// @param subnet_id ID of the subnet the lease must belong to
///
/// @return smart pointer to the lease (or NULL if a lease is not found)
virtual Lease4Ptr getLease4(const isc::asiolink::IOAddress& addr,
SubnetID subnet_id) const;
/// @brief Returns existing IPv4 leases for specified hardware address.
///
/// @todo Not implemented yet
......
......@@ -1274,24 +1274,6 @@ MySqlLeaseMgr::getLease4(const isc::asiolink::IOAddress& addr) const {
}
Lease4Ptr
MySqlLeaseMgr::getLease4(const isc::asiolink::IOAddress& addr,
SubnetID subnet_id) const {
// As the address is the unique primary key of the lease4 table, there can
// only be one lease with a given address. Therefore we will get that
// lease and do the filtering on subnet ID here.
Lease4Ptr result = getLease4(addr);
if (result && (result->subnet_id_ != subnet_id)) {
// Lease found but IDs do not match. Return null pointer
result.reset();
}
return (result);
}
Lease4Collection
MySqlLeaseMgr::getLease4(const HWAddr& hwaddr) const {
// Set up the WHERE clause value
......
......@@ -94,19 +94,6 @@ public:
/// failed.
virtual bool addLease(const Lease6Ptr& lease);
/// @brief Return IPv4 lease for specified IPv4 address and subnet_id
///
/// This method is used to get a lease for specific subnet_id. There can be
/// at most one lease for any given subnet, so this method returns a single
/// pointer.
///
/// @param addr address of the sought lease
/// @param subnet_id ID of the subnet the lease must belong to
///
/// @return smart pointer to the lease (or NULL if a lease is not found)
virtual Lease4Ptr getLease4(const isc::asiolink::IOAddress& addr,
SubnetID subnet_id) const;
/// @brief Returns an IPv4 lease for specified IPv4 address
///
/// This method return a lease that is associated with a given address.
......
......@@ -73,16 +73,6 @@ public:
return (Lease4Ptr());
}
/// @brief Returns existing IPv4 lease for specific address and subnet
/// @param addr address of the searched lease
/// @param subnet_id ID of the subnet the lease must belong to
///
/// @return smart pointer to the lease (or NULL if a lease is not found)
virtual Lease4Ptr getLease4(const isc::asiolink::IOAddress&,
SubnetID) const {
return (Lease4Ptr());
}
/// @brief Returns existing IPv4 leases for specified hardware address.
///
/// Although in the usual case there will be only one lease, for mobile
......
......@@ -796,45 +796,6 @@ TEST_F(MySqlLeaseMgrTest, basicLease6) {
detailCompareLease(leases[2], l_returned);
}
/// @brief Check GetLease4 methods - access by Address and SubnetID
///
/// Adds leases to the database and checks that they can be accessed via
/// a the hardware address
TEST_F(MySqlLeaseMgrTest, getLease4AddressSubnetId) {
// Get the leases to be used for the test.
vector<Lease4Ptr> leases = createLeases4();
const SubnetID lease1_subnetid = leases[1]->subnet_id_;
// Generate a Subnet ID known to be invalid - one more than the maximum
// Subnet ID in all the leases.
SubnetID invalid_subnetid = 0;
for (int i = 0; i < leases.size(); ++i) {
invalid_subnetid = max(invalid_subnetid, leases[i]->subnet_id_);
}
++invalid_subnetid;
// Add just one to the database.
EXPECT_TRUE(lmptr_->addLease(leases[1]));
// Look for a known lease with a valid Subnet ID
Lease4Ptr l_returned = lmptr_->getLease4(ioaddress4_[1], lease1_subnetid);
ASSERT_TRUE(l_returned);
detailCompareLease(leases[1], l_returned);
// Look for a lease known to be in the database with an invalid Subnet ID
l_returned = lmptr_->getLease4(ioaddress4_[1], invalid_subnetid);
EXPECT_FALSE(l_returned);
// Look for a lease known not to be in the database with a valid Subnet ID
l_returned = lmptr_->getLease4(ioaddress4_[2], lease1_subnetid);
EXPECT_FALSE(l_returned);
// Look for a lease known not to be in the database with and invalid
l_returned = lmptr_->getLease4(ioaddress4_[2], invalid_subnetid);
EXPECT_FALSE(l_returned);
}
/// @brief Check GetLease4 methods - access by Hardware Address
///
/// Adds leases to the database and checks that they can be accessed via
......
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