summaryrefslogtreecommitdiffstats
path: root/src/hooks/dhcp/mysql_cb
diff options
context:
space:
mode:
authorMarcin Siodelski <marcin@isc.org>2019-06-28 15:58:26 +0200
committerFrancis Dupont <fdupont@isc.org>2019-06-30 14:35:44 +0200
commit835aeee9b1b6f6ef0e721a19462cfe52ae5766c9 (patch)
tree0d7459f2a4708c85d4f7ec4fdf8b95c9a83081bb /src/hooks/dhcp/mysql_cb
parent[#651,!384] Updated ChangeLog entry (diff)
downloadkea-835aeee9b1b6f6ef0e721a19462cfe52ae5766c9.tar.xz
kea-835aeee9b1b6f6ef0e721a19462cfe52ae5766c9.zip
[#676] Modified internal representation of the tags in ServerSelector.
Diffstat (limited to 'src/hooks/dhcp/mysql_cb')
-rw-r--r--src/hooks/dhcp/mysql_cb/mysql_cb_dhcp4.cc42
-rw-r--r--src/hooks/dhcp/mysql_cb/mysql_cb_dhcp6.cc42
-rw-r--r--src/hooks/dhcp/mysql_cb/mysql_cb_impl.cc20
-rw-r--r--src/hooks/dhcp/mysql_cb/mysql_cb_impl.h27
-rw-r--r--src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp4_unittest.cc2
-rw-r--r--src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp6_unittest.cc2
6 files changed, 58 insertions, 77 deletions
diff --git a/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp4.cc b/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp4.cc
index 3f7c0b0b8c..69dfe47c59 100644
--- a/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp4.cc
+++ b/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp4.cc
@@ -143,10 +143,10 @@ public:
const std::string& name) {
StampedValueCollection parameters;
- auto tags = getServerTags(server_selector);
+ auto tags = server_selector.getTags();
for (auto tag : tags) {
MySqlBindingCollection in_bindings = {
- MySqlBinding::createString(tag),
+ MySqlBinding::createString(tag.get()),
MySqlBinding::createString(name)
};
@@ -529,10 +529,10 @@ public:
const SubnetID& subnet_id) {
Subnet4Collection subnets;
- auto tags = getServerTags(server_selector);
+ auto tags = server_selector.getTags();
for (auto tag : tags) {
MySqlBindingCollection in_bindings = {
- MySqlBinding::createString(tag),
+ MySqlBinding::createString(tag.get()),
MySqlBinding::createInteger<uint32_t>(subnet_id)
};
@@ -555,10 +555,10 @@ public:
const std::string& subnet_prefix) {
Subnet4Collection subnets;
- auto tags = getServerTags(server_selector);
+ auto tags = server_selector.getTags();
for (auto tag : tags) {
MySqlBindingCollection in_bindings = {
- MySqlBinding::createString(tag),
+ MySqlBinding::createString(tag.get()),
MySqlBinding::createString(subnet_prefix)
};
@@ -575,11 +575,11 @@ public:
/// subnets should be inserted.
void getAllSubnets4(const ServerSelector& server_selector,
Subnet4Collection& subnets) {
- auto tags = getServerTags(server_selector);
+ auto tags = server_selector.getTags();
for (auto tag : tags) {
MySqlBindingCollection in_bindings = {
- MySqlBinding::createString(tag)
+ MySqlBinding::createString(tag.get())
};
getSubnets4(GET_ALL_SUBNETS4, in_bindings, subnets);
@@ -595,11 +595,11 @@ public:
void getModifiedSubnets4(const ServerSelector& server_selector,
const boost::posix_time::ptime& modification_ts,
Subnet4Collection& subnets) {
- auto tags = getServerTags(server_selector);
+ auto tags = server_selector.getTags();
for (auto tag : tags) {
MySqlBindingCollection in_bindings = {
- MySqlBinding::createString(tag),
+ MySqlBinding::createString(tag.get()),
MySqlBinding::createTimestamp(modification_ts)
};
@@ -617,11 +617,11 @@ public:
void getSharedNetworkSubnets4(const ServerSelector& server_selector,
const std::string& shared_network_name,
Subnet4Collection& subnets) {
- auto tags = getServerTags(server_selector);
+ auto tags = server_selector.getTags();
for (auto tag : tags) {
MySqlBindingCollection in_bindings = {
- MySqlBinding::createString(tag),
+ MySqlBinding::createString(tag.get()),
MySqlBinding::createString(shared_network_name)
};
@@ -1252,11 +1252,11 @@ public:
/// structure where shared networks should be inserted.
void getAllSharedNetworks4(const ServerSelector& server_selector,
SharedNetwork4Collection& shared_networks) {
- auto tags = getServerTags(server_selector);
+ auto tags = server_selector.getTags();
for (auto tag : tags) {
MySqlBindingCollection in_bindings = {
- MySqlBinding::createString(tag)
+ MySqlBinding::createString(tag.get())
};
getSharedNetworks4(GET_ALL_SHARED_NETWORKS4, in_bindings, shared_networks);
@@ -1272,11 +1272,11 @@ public:
void getModifiedSharedNetworks4(const ServerSelector& server_selector,
const boost::posix_time::ptime& modification_ts,
SharedNetwork4Collection& shared_networks) {
- auto tags = getServerTags(server_selector);
+ auto tags = server_selector.getTags();
for (auto tag : tags) {
MySqlBindingCollection in_bindings = {
- MySqlBinding::createString(tag),
+ MySqlBinding::createString(tag.get()),
MySqlBinding::createTimestamp(modification_ts)
};
@@ -1407,7 +1407,7 @@ public:
// a server into the dhcp4_options_server table.
MySqlBindingCollection in_server_bindings = {
MySqlBinding::createInteger<uint64_t>(id), // option_id
- MySqlBinding::createString(*getServerTags(server_selector).begin()), // server_tag
+ MySqlBinding::createString(server_selector.getTags().begin()->get()), // server_tag
in_bindings[11] // copy modification timestamp from option
};
@@ -2609,9 +2609,9 @@ StampedValueCollection
MySqlConfigBackendDHCPv4::getAllGlobalParameters4(const ServerSelector& server_selector) const {
LOG_DEBUG(mysql_cb_logger, DBGLVL_TRACE_BASIC, MYSQL_CB_GET_ALL_GLOBAL_PARAMETERS4);
StampedValueCollection parameters;
- auto tags = impl_->getServerTags(server_selector);
+ auto tags = server_selector.getTags();
for (auto tag : tags) {
- MySqlBindingCollection in_bindings = { MySqlBinding::createString(tag) };
+ MySqlBindingCollection in_bindings = { MySqlBinding::createString(tag.get()) };
impl_->getGlobalParameters(MySqlConfigBackendDHCPv4Impl::GET_ALL_GLOBAL_PARAMETERS4,
in_bindings, parameters);
}
@@ -2626,10 +2626,10 @@ MySqlConfigBackendDHCPv4::getModifiedGlobalParameters4(const db::ServerSelector&
LOG_DEBUG(mysql_cb_logger, DBGLVL_TRACE_BASIC, MYSQL_CB_GET_MODIFIED_GLOBAL_PARAMETERS4)
.arg(util::ptimeToText(modification_time));
StampedValueCollection parameters;
- auto tags = impl_->getServerTags(server_selector);
+ auto tags = server_selector.getTags();
for (auto tag : tags) {
MySqlBindingCollection in_bindings = {
- MySqlBinding::createString(tag),
+ MySqlBinding::createString(tag.get()),
MySqlBinding::createTimestamp(modification_time)
};
impl_->getGlobalParameters(MySqlConfigBackendDHCPv4Impl::GET_MODIFIED_GLOBAL_PARAMETERS4,
diff --git a/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp6.cc b/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp6.cc
index 8f3e016660..aeb1fdbce8 100644
--- a/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp6.cc
+++ b/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp6.cc
@@ -150,10 +150,10 @@ public:
const std::string& name) {
StampedValueCollection parameters;
- auto tags = getServerTags(server_selector);
+ auto tags = server_selector.getTags();
for (auto tag : tags) {
MySqlBindingCollection in_bindings = {
- MySqlBinding::createString(tag),
+ MySqlBinding::createString(tag.get()),
MySqlBinding::createString(name)
};
@@ -585,10 +585,10 @@ public:
const SubnetID& subnet_id) {
Subnet6Collection subnets;
- auto tags = getServerTags(server_selector);
+ auto tags = server_selector.getTags();
for (auto tag : tags) {
MySqlBindingCollection in_bindings = {
- MySqlBinding::createString(tag),
+ MySqlBinding::createString(tag.get()),
MySqlBinding::createInteger<uint32_t>(subnet_id)
};
@@ -611,10 +611,10 @@ public:
const std::string& subnet_prefix) {
Subnet6Collection subnets;
- auto tags = getServerTags(server_selector);
+ auto tags = server_selector.getTags();
for (auto tag : tags) {
MySqlBindingCollection in_bindings = {
- MySqlBinding::createString(tag),
+ MySqlBinding::createString(tag.get()),
MySqlBinding::createString(subnet_prefix)
};
@@ -631,11 +631,11 @@ public:
/// subnets should be inserted.
void getAllSubnets6(const ServerSelector& server_selector,
Subnet6Collection& subnets) {
- auto tags = getServerTags(server_selector);
+ auto tags = server_selector.getTags();
for (auto tag : tags) {
MySqlBindingCollection in_bindings = {
- MySqlBinding::createString(tag)
+ MySqlBinding::createString(tag.get())
};
getSubnets6(GET_ALL_SUBNETS6, in_bindings, subnets);
@@ -651,11 +651,11 @@ public:
void getModifiedSubnets6(const ServerSelector& server_selector,
const boost::posix_time::ptime& modification_ts,
Subnet6Collection& subnets) {
- auto tags = getServerTags(server_selector);
+ auto tags = server_selector.getTags();
for (auto tag : tags) {
MySqlBindingCollection in_bindings = {
- MySqlBinding::createString(tag),
+ MySqlBinding::createString(tag.get()),
MySqlBinding::createTimestamp(modification_ts)
};
@@ -673,11 +673,11 @@ public:
void getSharedNetworkSubnets6(const ServerSelector& server_selector,
const std::string& shared_network_name,
Subnet6Collection& subnets) {
- auto tags = getServerTags(server_selector);
+ auto tags = server_selector.getTags();
for (auto tag : tags) {
MySqlBindingCollection in_bindings = {
- MySqlBinding::createString(tag),
+ MySqlBinding::createString(tag.get()),
MySqlBinding::createString(shared_network_name)
};
@@ -1452,11 +1452,11 @@ public:
/// structure where shared networks should be inserted.
void getAllSharedNetworks6(const ServerSelector& server_selector,
SharedNetwork6Collection& shared_networks) {
- auto tags = getServerTags(server_selector);
+ auto tags = server_selector.getTags();
for (auto tag : tags) {
MySqlBindingCollection in_bindings = {
- MySqlBinding::createString(tag)
+ MySqlBinding::createString(tag.get())
};
getSharedNetworks6(GET_ALL_SHARED_NETWORKS6, in_bindings, shared_networks);
@@ -1472,11 +1472,11 @@ public:
void getModifiedSharedNetworks6(const ServerSelector& server_selector,
const boost::posix_time::ptime& modification_ts,
SharedNetwork6Collection& shared_networks) {
- auto tags = getServerTags(server_selector);
+ auto tags = server_selector.getTags();
for (auto tag : tags) {
MySqlBindingCollection in_bindings = {
- MySqlBinding::createString(tag),
+ MySqlBinding::createString(tag.get()),
MySqlBinding::createTimestamp(modification_ts)
};
@@ -1618,7 +1618,7 @@ public:
// a server into the dhcp6_options_server table.
MySqlBindingCollection in_server_bindings = {
MySqlBinding::createInteger<uint64_t>(id), // option_id
- MySqlBinding::createString(*getServerTags(server_selector).begin()), // server_tag
+ MySqlBinding::createString(server_selector.getTags().begin()->get()), // server_tag
in_bindings[11] // copy modification timestamp from option
};
@@ -2971,9 +2971,9 @@ StampedValueCollection
MySqlConfigBackendDHCPv6::getAllGlobalParameters6(const ServerSelector& server_selector) const {
LOG_DEBUG(mysql_cb_logger, DBGLVL_TRACE_BASIC, MYSQL_CB_GET_ALL_GLOBAL_PARAMETERS6);
StampedValueCollection parameters;
- auto tags = impl_->getServerTags(server_selector);
+ auto tags = server_selector.getTags();
for (auto tag : tags) {
- MySqlBindingCollection in_bindings = { MySqlBinding::createString(tag) };
+ MySqlBindingCollection in_bindings = { MySqlBinding::createString(tag.get()) };
impl_->getGlobalParameters(MySqlConfigBackendDHCPv6Impl::GET_ALL_GLOBAL_PARAMETERS6,
in_bindings, parameters);
}
@@ -2988,10 +2988,10 @@ MySqlConfigBackendDHCPv6::getModifiedGlobalParameters6(const db::ServerSelector&
LOG_DEBUG(mysql_cb_logger, DBGLVL_TRACE_BASIC, MYSQL_CB_GET_MODIFIED_GLOBAL_PARAMETERS6)
.arg(util::ptimeToText(modification_time));
StampedValueCollection parameters;
- auto tags = impl_->getServerTags(server_selector);
+ auto tags = server_selector.getTags();
for (auto tag : tags) {
MySqlBindingCollection in_bindings = {
- MySqlBinding::createString(tag),
+ MySqlBinding::createString(tag.get()),
MySqlBinding::createTimestamp(modification_time)
};
impl_->getGlobalParameters(MySqlConfigBackendDHCPv6Impl::GET_MODIFIED_GLOBAL_PARAMETERS6,
diff --git a/src/hooks/dhcp/mysql_cb/mysql_cb_impl.cc b/src/hooks/dhcp/mysql_cb/mysql_cb_impl.cc
index 0a78d31eab..dd6a4421f1 100644
--- a/src/hooks/dhcp/mysql_cb/mysql_cb_impl.cc
+++ b/src/hooks/dhcp/mysql_cb/mysql_cb_impl.cc
@@ -193,13 +193,13 @@ MySqlConfigBackendImpl::getRecentAuditEntries(const int index,
MySqlBinding::createString(AUDIT_ENTRY_LOG_MESSAGE_BUF_LENGTH) // log_message
};
- auto tags = getServerTags(server_selector);
+ auto tags = server_selector.getTags();
for (auto tag : tags) {
// There is only one input binding, modification time.
MySqlBindingCollection in_bindings = {
- MySqlBinding::createString(tag),
+ MySqlBinding::createString(tag.get()),
MySqlBinding::createTimestamp(modification_time)
};
@@ -341,10 +341,10 @@ void
MySqlConfigBackendImpl::getAllOptionDefs(const int index,
const ServerSelector& server_selector,
OptionDefContainer& option_defs) {
- auto tags = getServerTags(server_selector);
+ auto tags = server_selector.getTags();
for (auto tag : tags) {
MySqlBindingCollection in_bindings = {
- MySqlBinding::createString(tag)
+ MySqlBinding::createString(tag.get())
};
getOptionDefs(index, in_bindings, option_defs);
}
@@ -355,10 +355,10 @@ MySqlConfigBackendImpl::getModifiedOptionDefs(const int index,
const ServerSelector& server_selector,
const boost::posix_time::ptime& modification_time,
OptionDefContainer& option_defs) {
- auto tags = getServerTags(server_selector);
+ auto tags = server_selector.getTags();
for (auto tag : tags) {
MySqlBindingCollection in_bindings = {
- MySqlBinding::createString(tag),
+ MySqlBinding::createString(tag.get()),
MySqlBinding::createTimestamp(modification_time)
};
getOptionDefs(index, in_bindings, option_defs);
@@ -587,10 +587,10 @@ MySqlConfigBackendImpl::getAllOptions(const int index,
const ServerSelector& server_selector) {
OptionContainer options;
- auto tags = getServerTags(server_selector);
+ auto tags = server_selector.getTags();
for (auto tag : tags) {
MySqlBindingCollection in_bindings = {
- MySqlBinding::createString(tag)
+ MySqlBinding::createString(tag.get())
};
getOptions(index, in_bindings, universe, options);
}
@@ -605,10 +605,10 @@ MySqlConfigBackendImpl::getModifiedOptions(const int index,
const boost::posix_time::ptime& modification_time) {
OptionContainer options;
- auto tags = getServerTags(server_selector);
+ auto tags = server_selector.getTags();
for (auto tag : tags) {
MySqlBindingCollection in_bindings = {
- MySqlBinding::createString(tag),
+ MySqlBinding::createString(tag.get()),
MySqlBinding::createTimestamp(modification_time)
};
getOptions(index, in_bindings, universe, options);
diff --git a/src/hooks/dhcp/mysql_cb/mysql_cb_impl.h b/src/hooks/dhcp/mysql_cb/mysql_cb_impl.h
index 456ee26d4d..f37d9de104 100644
--- a/src/hooks/dhcp/mysql_cb/mysql_cb_impl.h
+++ b/src/hooks/dhcp/mysql_cb/mysql_cb_impl.h
@@ -164,25 +164,6 @@ public:
const db::MySqlBindingPtr& min_binding,
const db::MySqlBindingPtr& max_binding);
- /// @brief Returns server tags associated with the particular selector.
- ///
- /// @param server_selector Server selector.
- /// @return Set of server tags.
- std::set<std::string> getServerTags(const db::ServerSelector& server_selector) const {
- std::set<std::string> tags;
- switch (server_selector.getType()) {
- case db::ServerSelector::Type::ALL:
- tags.insert("all");
- return (tags);
-
- default:
- return (server_selector.getTags());
- }
-
- // Unassigned server case.
- return (tags);
- }
-
/// @brief Returns server tag associated with the particular selector.
///
/// This method expects that there is exactly one server tag associated with
@@ -196,14 +177,14 @@ public:
/// is more than one server tag associated with the selector.
std::string getServerTag(const db::ServerSelector& server_selector,
const std::string& operation) const {
- auto tags = getServerTags(server_selector);
+ auto tags = server_selector.getTags();
if (tags.size() != 1) {
isc_throw(InvalidOperation, "expected exactly one server tag to be specified"
" while " << operation << ". Got: "
<< getServerTagsAsText(server_selector));
}
- return (*tags.begin());
+ return (tags.begin()->get());
}
/// @brief Returns server tags associated with the particular selector
@@ -212,12 +193,12 @@ public:
/// This method is useful for logging purposes.
std::string getServerTagsAsText(const db::ServerSelector& server_selector) const {
std::ostringstream s;
- auto server_tags = getServerTags(server_selector);
+ auto server_tags = server_selector.getTags();
for (auto tag : server_tags) {
if (s.tellp() != 0) {
s << ", ";
}
- s << tag;
+ s << tag.get();
}
return (s.str());
diff --git a/src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp4_unittest.cc b/src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp4_unittest.cc
index e0f0dc883e..8dca6fe890 100644
--- a/src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp4_unittest.cc
+++ b/src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp4_unittest.cc
@@ -392,7 +392,7 @@ public:
} else if (tags.size() == 1) {
// Get the server tag for which we run the current test.
- tag = *tags.begin();
+ tag = tags.begin()->get();
}
}
diff --git a/src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp6_unittest.cc b/src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp6_unittest.cc
index b07a5a6d06..b788ae8990 100644
--- a/src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp6_unittest.cc
+++ b/src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp6_unittest.cc
@@ -432,7 +432,7 @@ public:
} else if (tags.size() == 1) {
// Get the server tag for which we run the current test.
- tag = *tags.begin();
+ tag = tags.begin()->get();
}
}