static constexpr StatementTag DELETE_LEASE4 = "DELETE_LEASE4";
// Delete expired lease4s in certain state
static constexpr StatementTag GET_LEASE4_EXPIRE = "GET_LEASE4_EXPIRE";
+ // Get lease4
+ static constexpr StatementTag GET_LEASE4 = "GET_LEASE4";
// Get lease4 by address
static constexpr StatementTag GET_LEASE4_ADDR = "GET_LEASE4_ADDR";
// Get lease4 by client ID
static constexpr StatementTag GET_LEASE4_CLIENTID = "GET_LEASE4_CLIENTID";
// Get lease4 by client ID & subnet ID
- static constexpr StatementTag GET_LEASE4_CLIENTID_SUBID =
- "GET_LEASE4_CLIENTID_SUBID";
+ static constexpr StatementTag GET_LEASE4_CLIENTID_SUBID = "GET_LEASE4_CLIENTID_SUBID";
// Get lease4 by HW address
static constexpr StatementTag GET_LEASE4_HWADDR = "GET_LEASE4_HWADDR";
// Get lease4 by HW address & subnet ID
- static constexpr StatementTag GET_LEASE4_HWADDR_SUBID =
- "GET_LEASE4_HWADDR_SUBID";
+ static constexpr StatementTag GET_LEASE4_HWADDR_SUBID = "GET_LEASE4_HWADDR_SUBID";
+ // Get lease4 by subnet ID
+ static constexpr StatementTag GET_LEASE4_SUBID = "GET_LEASE4_SUBID";
/// @}
private:
constexpr StatementTag CqlLease4Exchange::UPDATE_LEASE4;
constexpr StatementTag CqlLease4Exchange::DELETE_LEASE4;
constexpr StatementTag CqlLease4Exchange::GET_LEASE4_EXPIRE;
+constexpr StatementTag CqlLease4Exchange::GET_LEASE4;
constexpr StatementTag CqlLease4Exchange::GET_LEASE4_ADDR;
constexpr StatementTag CqlLease4Exchange::GET_LEASE4_CLIENTID;
constexpr StatementTag CqlLease4Exchange::GET_LEASE4_CLIENTID_SUBID;
constexpr StatementTag CqlLease4Exchange::GET_LEASE4_HWADDR;
constexpr StatementTag CqlLease4Exchange::GET_LEASE4_HWADDR_SUBID;
+constexpr StatementTag CqlLease4Exchange::GET_LEASE4_SUBID;
StatementMap CqlLease4Exchange::tagged_statements_{
"LIMIT ? "
"ALLOW FILTERING "}},
+ // Gets an IPv4 lease(s)
+ {GET_LEASE4,
+ {GET_LEASE4,
+ "SELECT "
+ "address, hwaddr, client_id, valid_lifetime, expire, subnet_id, "
+ "fqdn_fwd, fqdn_rev, hostname, state "
+ "FROM lease4 "}},
+
// Gets an IPv4 lease with specified IPv4 address
{GET_LEASE4_ADDR,
{GET_LEASE4_ADDR,
"AND subnet_id = ? "
"ALLOW FILTERING "}},
+ // Gets an IPv4 lease(s) with specified subnet-id
+ {GET_LEASE4_SUBID,
+ {GET_LEASE4_SUBID,
+ "SELECT "
+ "address, hwaddr, client_id, valid_lifetime, expire, subnet_id, "
+ "fqdn_fwd, fqdn_rev, hostname, state "
+ "FROM lease4 "
+ "WHERE subnet_id = ? "
+ "ALLOW FILTERING "}}
};
CqlLease4Exchange::CqlLease4Exchange(const CqlConnection &connection)
address_ = static_cast<cass_int32_t>(lease->addr_.toUint32());
// hwaddr: blob
- if (lease_->hwaddr_ && lease->hwaddr_->hwaddr_.size() > 0) {
+ if (lease_->hwaddr_ && lease_->hwaddr_->hwaddr_.size() > 0) {
if (lease_->hwaddr_->hwaddr_.size() > HWAddr::MAX_HWADDR_LEN) {
isc_throw(DbOperationError,
"hardware address "
}
// client_id: blob
- if (lease_->client_id_ && lease->client_id_->getClientId().size() > 0) {
+ if (lease_->client_id_ && lease_->client_id_->getClientId().size() > 0) {
client_id_ = lease_->client_id_->getClientId();
} else {
client_id_.clear();
address_ = static_cast<cass_int32_t>(lease->addr_.toUint32());
// hwaddr: blob
- if (lease_->hwaddr_ && lease->hwaddr_->hwaddr_.size() > 0) {
+ if (lease_->hwaddr_ && lease_->hwaddr_->hwaddr_.size() > 0) {
if (lease_->hwaddr_->hwaddr_.size() > HWAddr::MAX_HWADDR_LEN) {
isc_throw(DbOperationError,
"hardware address "
}
// client_id: blob
- if (lease_->client_id_ && lease->client_id_->getClientId().size() > 0) {
+ if (lease_->client_id_ && lease_->client_id_->getClientId().size() > 0) {
client_id_ = lease_->client_id_->getClientId();
} else {
client_id_.clear();
hostname_ = lease_->hostname_;
// hwaddr: blob
- if (lease_->hwaddr_ && lease->hwaddr_->hwaddr_.size() > 0) {
+ if (lease_->hwaddr_ && lease_->hwaddr_->hwaddr_.size() > 0) {
if (lease_->hwaddr_->hwaddr_.size() > HWAddr::MAX_HWADDR_LEN) {
isc_throw(DbOperationError, "hardware address " << lease_->hwaddr_->toText()
<< " of length " << lease_->hwaddr_->hwaddr_.size()
hostname_ = lease_->hostname_;
// hwaddr: blob
- if (lease_->hwaddr_ && lease->hwaddr_->hwaddr_.size() > 0) {
+ if (lease_->hwaddr_ && lease_->hwaddr_->hwaddr_.size() > 0) {
if (lease_->hwaddr_->hwaddr_.size() > HWAddr::MAX_HWADDR_LEN) {
isc_throw(DbOperationError,
"hardware address "
}
Lease4Collection
-CqlLeaseMgr::getLeases4(SubnetID) const {
- isc_throw(NotImplemented, "getLeases4(subnet_id) is not implemented");
+CqlLeaseMgr::getLeases4(SubnetID subnet_id) const {
+ LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_CQL_GET_SUBID4)
+ .arg(subnet_id);
+
+ // Set up the WHERE clause value
+ AnyArray data;
+
+ cass_int32_t subnet_id_data = static_cast<cass_int32_t>(subnet_id);
+ data.add(&subnet_id_data);
+
+ // Get the data.
+ Lease4Collection result;
+ std::unique_ptr<CqlLease4Exchange> exchange4(new CqlLease4Exchange(dbconn_));
+ exchange4->getLeaseCollection(CqlLease4Exchange::GET_LEASE4, data, result);
+
+ return (result);
}
Lease4Collection
CqlLeaseMgr::getLeases4() const {
- isc_throw(NotImplemented, "getLeases4() is not implemented");
+ LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_CQL_GET4);
+
+ // Set up the WHERE clause value
+ AnyArray data;
+
+ // Get the data.
+ Lease4Collection result;
+ std::unique_ptr<CqlLease4Exchange> exchange4(new CqlLease4Exchange(dbconn_));
+ exchange4->getLeaseCollection(CqlLease4Exchange::GET_LEASE4_SUBID, data, result);
+
+ return (result);
}
Lease6Ptr