}
void
-HostMgr::update(HostPtr const& host) {
- if (alternate_sources_.empty()) {
- isc_throw(NoHostDataSourceManager,
- "Unable to update existing host because there is no hosts-database configured.");
+HostMgr::update(HostPtr const& host, const HostMgrOperationTarget target) {
+ if (target & HostMgrOperationTarget::PRIMARY_SOURCE) {
+ getCfgHostsForEdit()->update(host);
}
- for (HostDataSourcePtr const& source : alternate_sources_) {
- source->update(host);
+
+ if (target & HostMgrOperationTarget::ALTERNATE_SOURCES) {
+ // Don't throw if all targets were selected.
+ if (alternate_sources_.empty() && !(target & HostMgrOperationTarget::PRIMARY_SOURCE)) {
+ isc_throw(NoHostDataSourceManager,
+ "Unable to update existing host because there is no hosts-database configured.");
+ }
+
+ for (HostDataSourcePtr const& source : alternate_sources_) {
+ source->update(host);
+ }
}
+
// If no backend throws the host should be cached.
if (cache_ptr_) {
cache(host);
}
}
+void
+HostMgr::update(HostPtr const& host) {
+ update(host, HostMgrOperationTarget::ALTERNATE_SOURCES);
+}
+
void
HostMgr::cache(ConstHostPtr host) const {
if (cache_ptr_) {
/// Attempts to update an existing host entry.
///
/// @param host the host up to date with the requested changes
+ /// @param target The host data source being a target of the operation.
+ void update(HostPtr const& host, const HostMgrOperationTarget target);
+
+ /// @brief The @c HostMgr::update with default operation target. Operates
+ /// on alternate host sources only.
void update(HostPtr const& host);
/// @brief Return backend type