/// @brief Attempts to update an existing host entry.
///
/// @param host the host up to date with the requested changes
- virtual void update(HostPtr const& host) = 0;
+ virtual void update(HostPtr const& host) {
+ bool deleted(false);
+ if (host->getIPv4SubnetID() != SUBNET_ID_UNUSED) {
+ std::vector<uint8_t> const& identifier(host->getIdentifier());
+ deleted = del4(host->getIPv4SubnetID(), host->getIdentifierType(), identifier.data(),
+ identifier.size());
+ } else if (host->getIPv6SubnetID() != SUBNET_ID_UNUSED) {
+ std::vector<uint8_t> const& identifier(host->getIdentifier());
+ deleted = del6(host->getIPv6SubnetID(), host->getIdentifierType(), identifier.data(),
+ identifier.size());
+ } else {
+ isc_throw(HostNotFound, "Mandatory 'subnet-id' parameter missing.");
+ }
+ if (!deleted) {
+ isc_throw(HostNotFound, "Host not updated (not found).");
+ }
+ add(host);
+ }
/// @brief Return backend type
///
return (false);
}
-void
-CfgHosts::update(HostPtr const& host) {
- bool deleted(false);
- if (CfgMgr::instance().getFamily() == AF_INET) {
- vector<uint8_t> const& identifier(host->getIdentifier());
- deleted = del4(host->getIPv4SubnetID(), host->getIdentifierType(), identifier.data(),
- identifier.size());
- } else {
- vector<uint8_t> const& identifier(host->getIdentifier());
- deleted = del6(host->getIPv6SubnetID(), host->getIdentifierType(), identifier.data(),
- identifier.size());
- }
- if (!deleted) {
- isc_throw(HostNotFound, "Host not updated (not found).");
- }
- add(host);
-}
-
bool
CfgHosts::setIPReservationsUnique(const bool unique) {
ip_reservations_unique_ = unique;
const Host::IdentifierType& identifier_type,
const uint8_t* identifier_begin, const size_t identifier_len);
- /// @brief Implements @ref BaseHostDataSource::update() for config hosts.
- ///
- /// Attempts to update an existing host entry.
- ///
- /// @param host the host up to date with the requested changes
- void update(HostPtr const& host);
-
/// @brief Return backend type
///
/// Returns the type of the backend (e.g. "mysql", "memfile" etc.)
// updating the host to exactly as is described in the command, which may involve inserts and
// deletes alongside updates. So let's delete and add. The delete cascades into all tables. The
// add explicitly adds into all tables.
- bool deleted(false);
- if (CfgMgr::instance().getFamily() == AF_INET) {
- vector<uint8_t> const& identifier(host->getIdentifier());
- deleted = del4(host->getIPv4SubnetID(), host->getIdentifierType(), identifier.data(),
- identifier.size());
- } else {
- vector<uint8_t> const& identifier(host->getIdentifier());
- deleted = del6(host->getIPv6SubnetID(), host->getIdentifierType(), identifier.data(),
- identifier.size());
- }
- if (!deleted) {
- isc_throw(NoRowsAffected, "Host not updated (not found).");
- }
- add(host);
+ BaseHostDataSource::update(host);
// Everything went fine, so explicitly commit the transaction.
transaction.commit();
// updating the host to exactly as is described in the command, which may involve inserts and
// deletes alongside updates. So let's delete and add. The delete cascades into all tables. The
// add explicitly adds into all tables.
- bool deleted(false);
- if (CfgMgr::instance().getFamily() == AF_INET) {
- vector<uint8_t> const& identifier(host->getIdentifier());
- deleted = del4(host->getIPv4SubnetID(), host->getIdentifierType(), identifier.data(),
- identifier.size());
- } else {
- vector<uint8_t> const& identifier(host->getIdentifier());
- deleted = del6(host->getIPv6SubnetID(), host->getIdentifierType(), identifier.data(),
- identifier.size());
- }
- if (!deleted) {
- isc_throw(NoRowsAffected, "Host not updated (not found).");
- }
- add(host);
+ BaseHostDataSource::update(host);
// Everything went fine, so explicitly commit the transaction.
transaction.commit();
return (false);
}
-void
-MemHostDataSource::update(HostPtr const& host) {
- bool deleted(false);
- if (host->getIPv4SubnetID() != SUBNET_ID_UNUSED) {
- vector<uint8_t> const& identifier(host->getIdentifier());
- deleted = del4(host->getIPv4SubnetID(), host->getIdentifierType(), identifier.data(),
- identifier.size());
- } else if (host->getIPv6SubnetID() != SUBNET_ID_UNUSED) {
- vector<uint8_t> const& identifier(host->getIdentifier());
- deleted = del6(host->getIPv6SubnetID(), host->getIdentifierType(), identifier.data(),
- identifier.size());
- } else {
- isc_throw(HostNotFound, "Mandatory 'subnet-id' parameter missing.");
- }
- if (!deleted) {
- isc_throw(HostNotFound, "Host not updated (not found).");
- }
- store_.push_back(host);
-}
-
size_t
MemHostDataSource::size() const {
return (store_.size());
const Host::IdentifierType& identifier_type,
const uint8_t* identifier_begin, const size_t identifier_len);
- /// @brief Implements @ref BaseHostDataSource::update() for memory hosts.
- ///
- /// Attempts to update an existing host entry.
- ///
- /// @param host the host up to date with the requested changes
- void update(HostPtr const& host);
-
/// @brief Return backend type
///
/// Returns the type of the backend (e.g. "mysql", "memfile" etc.)