mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-09-01 06:25:34 +00:00
minor changes
This commit is contained in:
@@ -1607,6 +1607,7 @@ CqlHostDataSourceImpl::getAll(const HWAddrPtr& hwaddr, const DuidPtr& duid) cons
|
|||||||
// Run statement.
|
// Run statement.
|
||||||
ConstHostCollection result = getHostCollection(CqlHostExchange::GET_HOST_BY_HOST_ID,
|
ConstHostCollection result = getHostCollection(CqlHostExchange::GET_HOST_BY_HOST_ID,
|
||||||
where_values);
|
where_values);
|
||||||
|
|
||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1642,6 +1643,7 @@ CqlHostDataSourceImpl::getAll4(const asiolink::IOAddress& address) const {
|
|||||||
// Run statement.
|
// Run statement.
|
||||||
ConstHostCollection result = getHostCollection(CqlHostExchange::GET_HOST_BY_IPV4_ADDRESS,
|
ConstHostCollection result = getHostCollection(CqlHostExchange::GET_HOST_BY_IPV4_ADDRESS,
|
||||||
where_values);
|
where_values);
|
||||||
|
|
||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -58,8 +58,7 @@ public:
|
|||||||
/// @param statement_tag prepared statement being executed; defaults to an
|
/// @param statement_tag prepared statement being executed; defaults to an
|
||||||
/// invalid index
|
/// invalid index
|
||||||
virtual void
|
virtual void
|
||||||
createBindForSelect(AnyArray &data,
|
createBindForSelect(AnyArray &data, StatementTag statement_tag = NULL) override = 0;
|
||||||
StatementTag statement_tag = NULL) override = 0;
|
|
||||||
|
|
||||||
/// @brief Copy received data into the derived class' object.
|
/// @brief Copy received data into the derived class' object.
|
||||||
///
|
///
|
||||||
@@ -115,8 +114,9 @@ class CqlLease4Exchange : public CqlLeaseExchange {
|
|||||||
public:
|
public:
|
||||||
/// @brief Constructor
|
/// @brief Constructor
|
||||||
///
|
///
|
||||||
/// The initialization of the variables here is only to satisfy cppcheck -
|
/// The initialization of the variables here is only to satisfy
|
||||||
/// all variables are initialized/set in the methods before they are used.
|
/// cppcheck - all variables are initialized/set in the methods before
|
||||||
|
/// they are used.
|
||||||
///
|
///
|
||||||
/// @param connection connection used for this query
|
/// @param connection connection used for this query
|
||||||
explicit CqlLease4Exchange(const CqlConnection &connection);
|
explicit CqlLease4Exchange(const CqlConnection &connection);
|
||||||
@@ -138,8 +138,7 @@ public:
|
|||||||
/// @param lease Updated lease information.
|
/// @param lease Updated lease information.
|
||||||
/// @param data lease info in CQL format will be stored here
|
/// @param data lease info in CQL format will be stored here
|
||||||
/// @param statement_tag tag identifying the query (optional)
|
/// @param statement_tag tag identifying the query (optional)
|
||||||
void createBindForUpdate(const Lease4Ptr &lease,
|
void createBindForUpdate(const Lease4Ptr &lease, AnyArray &data,
|
||||||
AnyArray &data,
|
|
||||||
StatementTag statement_tag = NULL);
|
StatementTag statement_tag = NULL);
|
||||||
|
|
||||||
/// @brief Create CQL_BIND objects for Lease4 Pointer
|
/// @brief Create CQL_BIND objects for Lease4 Pointer
|
||||||
@@ -329,7 +328,7 @@ StatementMap CqlLease4Exchange::tagged_statements_{
|
|||||||
|
|
||||||
// Gets an IPv4 lease with specified hardware addr and subnet-id
|
// Gets an IPv4 lease with specified hardware addr and subnet-id
|
||||||
{GET_LEASE4_HWADDR_SUBID,
|
{GET_LEASE4_HWADDR_SUBID,
|
||||||
{GET_LEASE4_HWADDR_SUBID,
|
{GET_LEASE4_HWADDR_SUBID,
|
||||||
"SELECT "
|
"SELECT "
|
||||||
"address, hwaddr, client_id, valid_lifetime, expire, subnet_id, "
|
"address, hwaddr, client_id, valid_lifetime, expire, subnet_id, "
|
||||||
"fqdn_fwd, fqdn_rev, hostname, state "
|
"fqdn_fwd, fqdn_rev, hostname, state "
|
||||||
@@ -431,10 +430,9 @@ CqlLease4Exchange::createBindForInsert(const Lease4Ptr &lease, AnyArray &data) {
|
|||||||
data.add(&state_);
|
data.add(&state_);
|
||||||
|
|
||||||
} catch (const Exception &ex) {
|
} catch (const Exception &ex) {
|
||||||
isc_throw(DbOperationError,
|
isc_throw(DbOperationError, "CqlLease4Exchange::createBindForInsert(): "
|
||||||
"CqlLease4Exchange::createBindForInsert(): "
|
"could not create bind array from Lease4: " << lease_->addr_.toText()
|
||||||
"could not create bind array from Lease4: "
|
<< ", reason: " << ex.what());
|
||||||
<< lease_->addr_.toText() << ", reason: " << ex.what());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -541,8 +539,6 @@ CqlLease4Exchange::createBindForDelete(const IOAddress &address, AnyArray &data,
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// address: int
|
// address: int
|
||||||
// The address in the Lease structure is an IOAddress object.
|
|
||||||
// Convert this to an integer for storage.
|
|
||||||
address_ = static_cast<cass_int32_t>(address.toUint32());
|
address_ = static_cast<cass_int32_t>(address.toUint32());
|
||||||
|
|
||||||
// Start with a fresh array.
|
// Start with a fresh array.
|
||||||
@@ -552,8 +548,8 @@ CqlLease4Exchange::createBindForDelete(const IOAddress &address, AnyArray &data,
|
|||||||
} catch (const Exception &ex) {
|
} catch (const Exception &ex) {
|
||||||
isc_throw(DbOperationError,
|
isc_throw(DbOperationError,
|
||||||
"CqlLease4Exchange::createBindForDelete(): "
|
"CqlLease4Exchange::createBindForDelete(): "
|
||||||
"could not create bind array from Lease4: "
|
"could not create bind array with address: "
|
||||||
<< lease_->addr_.toText() << ", reason: " << ex.what());
|
<< address_ << ", reason: " << ex.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -639,7 +635,7 @@ CqlLease4Exchange::retrieve() {
|
|||||||
return (result);
|
return (result);
|
||||||
} catch (const Exception &ex) {
|
} catch (const Exception &ex) {
|
||||||
isc_throw(DbOperationError,
|
isc_throw(DbOperationError,
|
||||||
"CqlLease4Exchange::retrieveLease(): "
|
"CqlLease4Exchange::retrieve(): "
|
||||||
"could not convert data to Lease4, reason: "
|
"could not convert data to Lease4, reason: "
|
||||||
<< ex.what());
|
<< ex.what());
|
||||||
}
|
}
|
||||||
@@ -732,7 +728,7 @@ class CqlLease6Exchange : public CqlLeaseExchange {
|
|||||||
public:
|
public:
|
||||||
/// @brief Constructor
|
/// @brief Constructor
|
||||||
///
|
///
|
||||||
/// The initialization of the variables here is nonly to satisfy
|
/// The initialization of the variables here is only to satisfy
|
||||||
/// cppcheck - all variables are initialized/set in the methods before
|
/// cppcheck - all variables are initialized/set in the methods before
|
||||||
/// they are used.
|
/// they are used.
|
||||||
///
|
///
|
||||||
@@ -741,7 +737,7 @@ public:
|
|||||||
|
|
||||||
/// @brief Create CQL_BIND objects for Lease6 Pointer
|
/// @brief Create CQL_BIND objects for Lease6 Pointer
|
||||||
///
|
///
|
||||||
/// Fills in the CQL_BIND array for sending data in the Lease4 object to
|
/// Fills in the CQL_BIND array for sending data in the Lease6 object to
|
||||||
/// the database. Used for INSERT statements.
|
/// the database. Used for INSERT statements.
|
||||||
///
|
///
|
||||||
/// @param lease The lease information to be inserted
|
/// @param lease The lease information to be inserted
|
||||||
@@ -750,7 +746,7 @@ public:
|
|||||||
|
|
||||||
/// @brief Create CQL_BIND objects for Lease6 Pointer
|
/// @brief Create CQL_BIND objects for Lease6 Pointer
|
||||||
///
|
///
|
||||||
/// Fills in the CQL_BIND array for sending data in the Lease4 object to
|
/// Fills in the CQL_BIND array for sending data in the Lease6 object to
|
||||||
/// the database. Used for UPDATE statements.
|
/// the database. Used for UPDATE statements.
|
||||||
///
|
///
|
||||||
/// @param lease Updated lease information.
|
/// @param lease Updated lease information.
|
||||||
@@ -761,13 +757,14 @@ public:
|
|||||||
|
|
||||||
/// @brief Create CQL_BIND objects for Lease4 Pointer
|
/// @brief Create CQL_BIND objects for Lease4 Pointer
|
||||||
///
|
///
|
||||||
/// Fills in the CQL_BIND array for sending data in the Lease4 object to
|
/// Fills in the CQL_BIND array for sending data in the Lease6 object to
|
||||||
/// the database. Used for DELETE statements.
|
/// the database. Used for DELETE statements.
|
||||||
///
|
///
|
||||||
/// @param address address of the lease to be deleted
|
/// @param address address of the lease to be deleted
|
||||||
/// @param data lease info in CQL format will be stored here
|
/// @param data lease info in CQL format will be stored here
|
||||||
/// @param statement_tag tag identifying the query (optional)
|
/// @param statement_tag tag identifying the query (optional)
|
||||||
void createBindForDelete(const IOAddress &address, AnyArray &data,
|
void createBindForDelete(const IOAddress &address,
|
||||||
|
AnyArray &data,
|
||||||
StatementTag statement_tag = NULL);
|
StatementTag statement_tag = NULL);
|
||||||
|
|
||||||
/// @brief Create BIND array to receive data
|
/// @brief Create BIND array to receive data
|
||||||
@@ -776,13 +773,13 @@ public:
|
|||||||
///
|
///
|
||||||
/// @param data info returned by CQL will be stored here
|
/// @param data info returned by CQL will be stored here
|
||||||
/// @param statement_tag tag identifying the query (optional)
|
/// @param statement_tag tag identifying the query (optional)
|
||||||
void createBindForSelect(AnyArray &data,
|
virtual void
|
||||||
StatementTag statement_tag = NULL) override;
|
createBindForSelect(AnyArray &data, StatementTag statement_tag = NULL) override;
|
||||||
|
|
||||||
/// @brief Retrieves the Lease6 object in Kea format
|
/// @brief Retrieves the Lease6 object in Kea format
|
||||||
///
|
///
|
||||||
/// @return C++ representation of the object being returned
|
/// @return C++ representation of the object being returned
|
||||||
boost::any retrieve() override;
|
virtual boost::any retrieve() override;
|
||||||
|
|
||||||
/// @brief Retrieves zero or more IPv6 leases
|
/// @brief Retrieves zero or more IPv6 leases
|
||||||
///
|
///
|
||||||
@@ -963,7 +960,8 @@ CqlLease6Exchange::CqlLease6Exchange(const CqlConnection &connection)
|
|||||||
void
|
void
|
||||||
CqlLease6Exchange::createBindForInsert(const Lease6Ptr &lease, AnyArray &data) {
|
CqlLease6Exchange::createBindForInsert(const Lease6Ptr &lease, AnyArray &data) {
|
||||||
if (!lease) {
|
if (!lease) {
|
||||||
isc_throw(BadValue, "Lease6 object is NULL");
|
isc_throw(BadValue, "CqlLease6Exchange::createBindForInsert(): "
|
||||||
|
"Lease6 object is NULL");
|
||||||
}
|
}
|
||||||
// Store lease object to ensure it remains valid.
|
// Store lease object to ensure it remains valid.
|
||||||
lease_ = lease;
|
lease_ = lease;
|
||||||
@@ -987,7 +985,8 @@ CqlLease6Exchange::createBindForInsert(const Lease6Ptr &lease, AnyArray &data) {
|
|||||||
// For convenience for external tools, this is converted to lease
|
// For convenience for external tools, this is converted to lease
|
||||||
// expiry time (expire). The relationship is given by:
|
// expiry time (expire). The relationship is given by:
|
||||||
// expire = cltt_ + valid_lft_
|
// expire = cltt_ + valid_lft_
|
||||||
CqlExchange::convertToDatabaseTime(lease_->cltt_, lease_->valid_lft_, expire_);
|
CqlExchange::convertToDatabaseTime(lease_->cltt_, lease_->valid_lft_,
|
||||||
|
expire_);
|
||||||
|
|
||||||
// subnet_id: int
|
// subnet_id: int
|
||||||
subnet_id_ = static_cast<cass_int32_t>(lease_->subnet_id_);
|
subnet_id_ = static_cast<cass_int32_t>(lease_->subnet_id_);
|
||||||
@@ -1087,7 +1086,8 @@ void
|
|||||||
CqlLease6Exchange::createBindForUpdate(const Lease6Ptr &lease, AnyArray &data,
|
CqlLease6Exchange::createBindForUpdate(const Lease6Ptr &lease, AnyArray &data,
|
||||||
StatementTag /* unused */) {
|
StatementTag /* unused */) {
|
||||||
if (!lease) {
|
if (!lease) {
|
||||||
isc_throw(BadValue, "Lease6 object is NULL");
|
isc_throw(BadValue, "CqlLease6Exchange::createBindForUpdate(): "
|
||||||
|
"Lease6 object is NULL");
|
||||||
}
|
}
|
||||||
// Store lease object to ensure it remains valid.
|
// Store lease object to ensure it remains valid.
|
||||||
lease_ = lease;
|
lease_ = lease;
|
||||||
@@ -1225,8 +1225,6 @@ CqlLease6Exchange::createBindForDelete(const IOAddress &address, AnyArray &data,
|
|||||||
// structure.
|
// structure.
|
||||||
try {
|
try {
|
||||||
// address: varchar
|
// address: varchar
|
||||||
// The address in the Lease structure is an IOAddress object.
|
|
||||||
// Convert this to an integer for storage.
|
|
||||||
address_ = address.toText();
|
address_ = address.toText();
|
||||||
|
|
||||||
// Start with a fresh array.
|
// Start with a fresh array.
|
||||||
@@ -1356,11 +1354,12 @@ CqlLease6Exchange::retrieve() {
|
|||||||
result->cltt_ = cltt;
|
result->cltt_ = cltt;
|
||||||
|
|
||||||
result->state_ = state_;
|
result->state_ = state_;
|
||||||
return result;
|
|
||||||
|
return (result);
|
||||||
} catch (const Exception &ex) {
|
} catch (const Exception &ex) {
|
||||||
isc_throw(DbOperationError,
|
isc_throw(DbOperationError,
|
||||||
"CqlLease6Exchange::retrieve(): "
|
"CqlLease6Exchange::retrieve(): "
|
||||||
"could not convert data to Lease4, reason: "
|
"could not convert data to Lease6, reason: "
|
||||||
<< ex.what());
|
<< ex.what());
|
||||||
}
|
}
|
||||||
return Lease6Ptr();
|
return Lease6Ptr();
|
||||||
@@ -1391,11 +1390,10 @@ CqlLease6Exchange::getLease(StatementTag &statement_tag, AnyArray &data,
|
|||||||
// Return single record if present, else clear the lease.
|
// Return single record if present, else clear the lease.
|
||||||
const size_t collection_size = collection.size();
|
const size_t collection_size = collection.size();
|
||||||
if (collection_size >= 2u) {
|
if (collection_size >= 2u) {
|
||||||
isc_throw(
|
isc_throw(MultipleRecords,
|
||||||
MultipleRecords,
|
"CqlLease6Exchange::getLease(): multiple records were found in "
|
||||||
"CqlLease6Exchange::getLease(): multiple records were found in "
|
"the database where only one was expected for statement "
|
||||||
"the database where only one was expected for statement "
|
<< statement_tag);
|
||||||
<< statement_tag);
|
|
||||||
} else if (collection_size == 0u) {
|
} else if (collection_size == 0u) {
|
||||||
result.reset();
|
result.reset();
|
||||||
} else {
|
} else {
|
||||||
@@ -1467,8 +1465,7 @@ CqlLeaseMgr::addLease(const Lease4Ptr &lease) {
|
|||||||
|
|
||||||
AnyArray data;
|
AnyArray data;
|
||||||
|
|
||||||
std::unique_ptr<CqlLease4Exchange> exchange4(
|
std::unique_ptr<CqlLease4Exchange> exchange4(new CqlLease4Exchange(dbconn_));
|
||||||
new CqlLease4Exchange(dbconn_));
|
|
||||||
exchange4->createBindForInsert(lease, data);
|
exchange4->createBindForInsert(lease, data);
|
||||||
try {
|
try {
|
||||||
exchange4->executeMutation(dbconn_, data, CqlLease4Exchange::INSERT_LEASE4);
|
exchange4->executeMutation(dbconn_, data, CqlLease4Exchange::INSERT_LEASE4);
|
||||||
@@ -1578,7 +1575,7 @@ CqlLeaseMgr::getLease4(const ClientId &clientid) const {
|
|||||||
std::unique_ptr<CqlLease4Exchange> exchange4(new CqlLease4Exchange(dbconn_));
|
std::unique_ptr<CqlLease4Exchange> exchange4(new CqlLease4Exchange(dbconn_));
|
||||||
exchange4->getLeaseCollection(CqlLease4Exchange::GET_LEASE4_CLIENTID, data, result);
|
exchange4->getLeaseCollection(CqlLease4Exchange::GET_LEASE4_CLIENTID, data, result);
|
||||||
|
|
||||||
return result;
|
return (result);
|
||||||
}
|
}
|
||||||
|
|
||||||
Lease4Ptr
|
Lease4Ptr
|
||||||
@@ -1684,7 +1681,7 @@ CqlLeaseMgr::getLeases6(Lease::Type lease_type, const DUID &duid, uint32_t iaid)
|
|||||||
std::unique_ptr<CqlLease6Exchange> exchange6(new CqlLease6Exchange(dbconn_));
|
std::unique_ptr<CqlLease6Exchange> exchange6(new CqlLease6Exchange(dbconn_));
|
||||||
exchange6->getLeaseCollection(CqlLease6Exchange::GET_LEASE6_DUID_IAID, data, result);
|
exchange6->getLeaseCollection(CqlLease6Exchange::GET_LEASE6_DUID_IAID, data, result);
|
||||||
|
|
||||||
return result;
|
return (result);
|
||||||
}
|
}
|
||||||
|
|
||||||
Lease6Collection
|
Lease6Collection
|
||||||
@@ -1715,6 +1712,7 @@ CqlLeaseMgr::getLeases6(Lease::Type lease_type, const DUID &duid, uint32_t iaid,
|
|||||||
Lease6Collection result;
|
Lease6Collection result;
|
||||||
std::unique_ptr<CqlLease6Exchange> exchange6(new CqlLease6Exchange(dbconn_));
|
std::unique_ptr<CqlLease6Exchange> exchange6(new CqlLease6Exchange(dbconn_));
|
||||||
exchange6->getLeaseCollection(CqlLease6Exchange::GET_LEASE6_DUID_IAID_SUBID, data, result);
|
exchange6->getLeaseCollection(CqlLease6Exchange::GET_LEASE6_DUID_IAID_SUBID, data, result);
|
||||||
|
|
||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1734,8 +1732,7 @@ CqlLeaseMgr::getExpiredLeases6(Lease6Collection &expired_leases,
|
|||||||
LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_CQL_GET_EXPIRED6)
|
LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_CQL_GET_EXPIRED6)
|
||||||
.arg(max_leases);
|
.arg(max_leases);
|
||||||
|
|
||||||
std::unique_ptr<CqlLease6Exchange> exchange6(
|
std::unique_ptr<CqlLease6Exchange> exchange6(new CqlLease6Exchange(dbconn_));
|
||||||
new CqlLease6Exchange(dbconn_));
|
|
||||||
exchange6->getExpiredLeases(max_leases, expired_leases);
|
exchange6->getExpiredLeases(max_leases, expired_leases);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user