void createUpdateGlobalParameter4(const db::ServerSelector& server_selector,
const StampedValuePtr& value) {
- MySqlTransaction transaction(conn_);
+ if (server_selector.amUnassigned()) {
+ isc_throw(NotImplemented, "managing configuration for no particular server"
+ " (unassigned) is unsupported at the moment");
+ }
auto tag = getServerTag(server_selector, "creating or updating global parameter");
MySqlBinding::createString(value->getName())
};
+ MySqlTransaction transaction(conn_);
+
// Try to update the existing row.
if (conn_.updateDeleteQuery(MySqlConfigBackendDHCPv4Impl::UPDATE_GLOBAL_PARAMETER4,
in_bindings) == 0) {
void createUpdateSubnet4(const ServerSelector& server_selector,
const Subnet4Ptr& subnet) {
+ if (server_selector.amUnassigned()) {
+ isc_throw(NotImplemented, "managing configuration for no particular server"
+ " (unassigned) is unsupported at the moment");
+ }
+
auto tag = getServerTag(server_selector, "creating or updating subnet");
// Convert DHCPv4o6 interface id to text.
/// network doesn't exist.
SharedNetwork4Ptr getSharedNetwork4(const ServerSelector& server_selector,
const std::string& name) {
+
+ if (server_selector.amUnassigned()) {
+ isc_throw(NotImplemented, "managing configuration for no particular server"
+ " (unassigned) is unsupported at the moment");
+ }
+
auto tag = getServerTag(server_selector, "fetching shared network");
MySqlBindingCollection in_bindings = {
/// @param subnet Pointer to the shared network to be inserted or updated.
void createUpdateSharedNetwork4(const ServerSelector& server_selector,
const SharedNetwork4Ptr& shared_network) {
+
+ if (server_selector.amUnassigned()) {
+ isc_throw(NotImplemented, "managing configuration for no particular server"
+ " (unassigned) is unsupported at the moment");
+ }
+
auto tag = getServerTag(server_selector, "creating or updating shared network");
MySqlBindingCollection in_bindings = {
void createUpdateOption4(const ServerSelector& server_selector,
const OptionDescriptorPtr& option) {
+ if (server_selector.amUnassigned()) {
+ isc_throw(NotImplemented, "managing configuration for no particular server"
+ " (unassigned) is unsupported at the moment");
+ }
+
auto tag = getServerTag(server_selector, "creating or updating global option");
MySqlBindingCollection in_bindings = {
const SubnetID& subnet_id,
const OptionDescriptorPtr& option) {
+ if (server_selector.amUnassigned()) {
+ isc_throw(NotImplemented, "managing configuration for no particular server"
+ " (unassigned) is unsupported at the moment");
+ }
+
auto tag = getServerTag(server_selector,
"creating or updating subnet level option");
const uint64_t pool_id,
const OptionDescriptorPtr& option) {
+ if (server_selector.amUnassigned()) {
+ isc_throw(NotImplemented, "managing configuration for no particular server"
+ " (unassigned) is unsupported at the moment");
+ }
+
auto tag = getServerTag(server_selector,
"creating or updating pool level option");
void createUpdateOption4(const ServerSelector& server_selector,
const std::string& shared_network_name,
const OptionDescriptorPtr& option) {
+
+ if (server_selector.amUnassigned()) {
+ isc_throw(NotImplemented, "managing configuration for no particular server"
+ " (unassigned) is unsupported at the moment");
+ }
+
auto tag = getServerTag(server_selector, "creating or updating shared"
" network level option");
OptionDefinitionPtr getOptionDef4(const ServerSelector& server_selector,
const uint16_t code,
const std::string& space) {
+
+ if (server_selector.amUnassigned()) {
+ isc_throw(NotImplemented, "managing configuration for no particular server"
+ " (unassigned) is unsupported at the moment");
+ }
+
auto tag = getServerTag(server_selector, "fetching option definition");
OptionDefContainer option_defs;
OptionDescriptorPtr
getOption4(const ServerSelector& server_selector, const uint16_t code,
const std::string& space) {
+
+ if (server_selector.amUnassigned()) {
+ isc_throw(NotImplemented, "managing configuration for no particular server"
+ " (unassigned) is unsupported at the moment");
+ }
+
auto tag = getServerTag(server_selector, "fetching global option");
OptionContainer options;
const SubnetID& subnet_id,
const uint16_t code,
const std::string& space) {
+
+ if (server_selector.amUnassigned()) {
+ isc_throw(NotImplemented, "managing configuration for no particular server"
+ " (unassigned) is unsupported at the moment");
+ }
+
auto tag = getServerTag(server_selector, "fetching subnet level option");
OptionContainer options;
const uint64_t pool_id,
const uint16_t code,
const std::string& space) {
+
+ if (server_selector.amUnassigned()) {
+ isc_throw(NotImplemented, "managing configuration for no particular server"
+ " (unassigned) is unsupported at the moment");
+ }
+
auto tag = getServerTag(server_selector, "fetching pool level option");
OptionContainer options;
const std::string& shared_network_name,
const uint16_t code,
const std::string& space) {
+
+ if (server_selector.amUnassigned()) {
+ isc_throw(NotImplemented, "managing configuration for no particular server"
+ " (unassigned) is unsupported at the moment");
+ }
+
auto tag = getServerTag(server_selector, "fetching shared network"
" level option");
/// @param option_def Pointer to the option definition to be inserted or updated.
void createUpdateOptionDef4(const ServerSelector& server_selector,
const OptionDefinitionPtr& option_def) {
+
+ if (server_selector.amUnassigned()) {
+ isc_throw(NotImplemented, "managing configuration for no particular server"
+ " (unassigned) is unsupported at the moment");
+ }
+
auto tag = getServerTag(server_selector, "creating or updating option definition");
ElementPtr record_types = Element::createList();
uint64_t deleteOptionDef4(const ServerSelector& server_selector,
const uint16_t code,
const std::string& space) {
+
+ if (server_selector.amUnassigned()) {
+ isc_throw(NotImplemented, "managing configuration for no particular server"
+ " (unassigned) is unsupported at the moment");
+ }
+
auto tag = getServerTag(server_selector, "deleting option definition");
MySqlBindingCollection in_bindings = {
uint64_t deleteOption4(const ServerSelector& server_selector,
const uint16_t code,
const std::string& space) {
+
+ if (server_selector.amUnassigned()) {
+ isc_throw(NotImplemented, "managing configuration for no particular server"
+ " (unassigned) is unsupported at the moment");
+ }
+
auto tag = getServerTag(server_selector, "deleting global option");
MySqlBindingCollection in_bindings = {
const SubnetID& subnet_id,
const uint16_t code,
const std::string& space) {
+
+ if (server_selector.amUnassigned()) {
+ isc_throw(NotImplemented, "managing configuration for no particular server"
+ " (unassigned) is unsupported at the moment");
+ }
+
auto tag = getServerTag(server_selector, "deleting option for a subnet");
MySqlBindingCollection in_bindings = {
const IOAddress& pool_end_address,
const uint16_t code,
const std::string& space) {
+
+ if (server_selector.amUnassigned()) {
+ isc_throw(NotImplemented, "managing configuration for no particular server"
+ " (unassigned) is unsupported at the moment");
+ }
+
auto tag = getServerTag(server_selector, "deleting option for a pool");
MySqlBindingCollection in_bindings = {
const std::string& shared_network_name,
const uint16_t code,
const std::string& space) {
+
+ if (server_selector.amUnassigned()) {
+ isc_throw(NotImplemented, "managing configuration for no particular server"
+ " (unassigned) is unsupported at the moment");
+ }
+
auto tag = getServerTag(server_selector, "deleting option for a shared network");
MySqlBindingCollection in_bindings = {
/// @return Number of deleted options.
uint64_t deleteOptions4(const ServerSelector& server_selector,
const Subnet4Ptr& subnet) {
+
+ if (server_selector.amUnassigned()) {
+ isc_throw(NotImplemented, "managing configuration for no particular server"
+ " (unassigned) is unsupported at the moment");
+ }
+
auto tag = getServerTag(server_selector, "deleting options for a subnet");
MySqlBindingCollection in_bindings = {
/// @return Number of deleted options.
uint64_t deleteOptions4(const ServerSelector& server_selector,
const SharedNetwork4Ptr& shared_network) {
+
+ if (server_selector.amUnassigned()) {
+ isc_throw(NotImplemented, "managing configuration for no particular server"
+ " (unassigned) is unsupported at the moment");
+ }
+
auto tag = getServerTag(server_selector, "deleting options for a shared network");
MySqlBindingCollection in_bindings = {
/// @param server_selector Server selector.
/// @param subnet_prefix Prefix of the subnet to be retrieved.
/// @return Pointer to the retrieved subnet or NULL if not found.
+ /// @throw NotImplemented if server selector is "unassigned".
virtual Subnet4Ptr
getSubnet4(const db::ServerSelector& server_selector,
const std::string& subnet_prefix) const;
/// @param server_selector Server selector.
/// @param subnet_id Identifier of a subnet to be retrieved.
/// @return Pointer to the retrieved subnet or NULL if not found.
+ /// @throw NotImplemented if server selector is "unassigned".
virtual Subnet4Ptr
getSubnet4(const db::ServerSelector& server_selector, const SubnetID& subnet_id) const;
/// @param server_selector Server selector.
/// @param name Name of the shared network to be retrieved.
/// @return Pointer to the shared network or NULL if not found.
+ /// @throw NotImplemented if server selector is "unassigned".
virtual SharedNetwork4Ptr
getSharedNetwork4(const db::ServerSelector& server_selector,
const std::string& name) const;
/// @param code Code of the option to be retrieved.
/// @param space Option space of the option to be retrieved.
/// @return Pointer to the option definition or NULL if not found.
+ /// @throw NotImplemented if server selector is "unassigned".
virtual OptionDefinitionPtr
getOptionDef4(const db::ServerSelector& server_selector, const uint16_t code,
const std::string& space) const;
/// @param server_selector Server selector.
/// @return Pointer to the retrieved option descriptor or null if
/// no option was found.
+ /// @throw NotImplemented if server selector is "unassigned".
virtual OptionDescriptorPtr
getOption4(const db::ServerSelector& server_selector, const uint16_t code,
const std::string& space) const;
/// @param server_selector Server selector.
/// @param name Name of the global parameter to be retrieved.
/// @return Value of the global parameter.
+ /// @throw NotImplemented if server selector is "unassigned".
virtual data::StampedValuePtr
getGlobalParameter4(const db::ServerSelector& server_selector,
const std::string& name) const;
///
/// @param server_selector Server selector.
/// @param subnet Subnet to be added or updated.
+ /// @throw NotImplemented if server selector is "unassigned".
virtual void
createUpdateSubnet4(const db::ServerSelector& server_selector,
const Subnet4Ptr& subnet);
///
/// @param server_selector Server selector.
/// @param shared_network Shared network to be added or updated.
+ /// @throw NotImplemented if server selector is "unassigned".
virtual void
createUpdateSharedNetwork4(const db::ServerSelector& server_selector,
const SharedNetwork4Ptr& shared_network);
///
/// @param server_selector Server selector.
/// @param option_def Option definition to be added or updated.
+ /// @throw NotImplemented if server selector is "unassigned".
virtual void
createUpdateOptionDef4(const db::ServerSelector& server_selector,
const OptionDefinitionPtr& option_def);
///
/// @param server_selector Server selector.
/// @param option Option to be added or updated.
+ /// @throw NotImplemented if server selector is "unassigned".
virtual void
createUpdateOption4(const db::ServerSelector& server_selector,
const OptionDescriptorPtr& option);
/// @param shared_network_name Name of a shared network to which option
/// belongs.
/// @param option Option to be added or updated.
+ /// @throw NotImplemented if server selector is "unassigned".
virtual void
createUpdateOption4(const db::ServerSelector& server_selector,
const std::string& shared_network_name,
/// @param server_selector Server selector.
/// @param subnet_id Identifier of a subnet to which option belongs.
/// @param option Option to be added or updated.
+ /// @throw NotImplemented if server selector is "unassigned".
virtual void
createUpdateOption4(const db::ServerSelector& server_selector,
const SubnetID& subnet_id,
/// @param pool_end_address Upper bound address of the pool to which the
/// option belongs.
/// @param option Option to be added or updated.
+ /// @throw NotImplemented if server selector is "unassigned".
virtual void
createUpdateOption4(const db::ServerSelector& server_selector,
const asiolink::IOAddress& pool_start_address,
/// @param server_selector Server selector.
/// @param name Name of the global parameter.
/// @param value Value of the global parameter.
+ /// @throw NotImplemented if server selector is "unassigned".
virtual void
createUpdateGlobalParameter4(const db::ServerSelector& server_selector,
const data::StampedValuePtr& value);
/// @param server_selector Server selector.
/// @param subnet_prefix Prefix of the subnet to be deleted.
/// @return Number of deleted subnets.
+ /// @throw NotImplemented if server selector is "unassigned".
virtual uint64_t
deleteSubnet4(const db::ServerSelector& server_selector,
const std::string& subnet_prefix);
/// @param server_selector Server selector.
/// @param subnet_id Identifier of the subnet to be deleted.
/// @return Number of deleted subnets.
+ /// @throw NotImplemented if server selector is "unassigned".
virtual uint64_t
deleteSubnet4(const db::ServerSelector& server_selector, const SubnetID& subnet_id);
///
/// @param server_selector Server selector.
/// @return Number of deleted subnets.
+ /// @throw NotImplemented if server selector is "unassigned".
virtual uint64_t
deleteAllSubnets4(const db::ServerSelector& server_selector);
/// @param server_selector Server selector.
/// @param name Name of the shared network to be deleted.
/// @return Number of deleted shared networks.
+ /// @throw NotImplemented if server selector is "unassigned".
virtual uint64_t
deleteSharedNetwork4(const db::ServerSelector& server_selector,
const std::string& name);
/// @param code Code of the option to be deleted.
/// @param space Option space of the option to be deleted.
/// @return Number of deleted option definitions.
+ /// @throw NotImplemented if server selector is "unassigned".
virtual uint64_t
deleteOptionDef4(const db::ServerSelector& server_selector, const uint16_t code,
const std::string& space);
///
/// @param server_selector Server selector.
/// @return Number of deleted option definitions.
+ /// @throw NotImplemented if server selector is "unassigned".
virtual uint64_t
deleteAllOptionDefs4(const db::ServerSelector& server_selector);
/// @param code Code of the option to be deleted.
/// @param space Option space of the option to be deleted.
/// @return Number of deleted options.
+ /// @throw NotImplemented if server selector is "unassigned".
virtual uint64_t
deleteOption4(const db::ServerSelector& server_selector, const uint16_t code,
const std::string& space);
/// option belongs to
/// @param code Code of the deleted option.
/// @param space Option space of the deleted option.
+ /// @throw NotImplemented if server selector is "unassigned".
virtual uint64_t
deleteOption4(const db::ServerSelector& server_selector,
const std::string& shared_network_name,
/// @param code Code of the deleted option.
/// @param space Option space of the deleted option.
/// @return Number of deleted options.
+ /// @throw NotImplemented if server selector is "unassigned".
virtual uint64_t
deleteOption4(const db::ServerSelector& server_selector, const SubnetID& subnet_id,
const uint16_t code, const std::string& space);
/// @param code Code of the deleted option.
/// @param space Option space of the deleted option.
/// @return Number of deleted options.
+ /// @throw NotImplemented if server selector is "unassigned".
virtual uint64_t
deleteOption4(const db::ServerSelector& server_selector,
const asiolink::IOAddress& pool_start_address,
/// @param server_selector Server selector.
/// @param name Name of the global parameter to be deleted.
/// @return Number of deleted global parameters.
+ /// @throw NotImplemented if server selector is "unassigned".
virtual uint64_t
deleteGlobalParameter4(const db::ServerSelector& server_selector,
const std::string& name);
///
/// @param server_selector Server selector.
/// @return Number of deleted global parameters.
+ /// @throw NotImplemented if server selector is "unassigned".
virtual uint64_t
deleteAllGlobalParameters4(const db::ServerSelector& server_selector);
MySqlConfigBackendImpl::deleteFromTable(const int index,
const ServerSelector& server_selector,
const std::string& operation) {
+
+ if (server_selector.amUnassigned()) {
+ isc_throw(NotImplemented, "managing configuration for no particular server"
+ " (unassigned) is unsupported at the moment");
+ }
+
auto tag = getServerTag(server_selector, operation);
MySqlBindingCollection in_bindings = {
return (tags_);
}
+ /// @brief Convenience method checking if the server selector is "unassigned".
+ ///
+ /// @return true if the selector is "unassigned", false otherwise.
+ bool amUnassigned() const {
+ return (getType() == Type::UNASSIGNED);
+ }
+
private:
/// @brief Constructor used for "unassigned" and "all" slection types.
TEST(ServerSelectorTest, unassigned) {
ServerSelector selector = ServerSelector::UNASSIGNED();
EXPECT_EQ(ServerSelector::Type::UNASSIGNED, selector.getType());
+ EXPECT_TRUE(selector.amUnassigned());
EXPECT_TRUE(selector.getTags().empty());
}
TEST(ServerSelectorTest, all) {
ServerSelector selector = ServerSelector::ALL();
EXPECT_EQ(ServerSelector::Type::ALL, selector.getType());
+ EXPECT_FALSE(selector.amUnassigned());
EXPECT_TRUE(selector.getTags().empty());
}
TEST(ServerSelectorTest, one) {
ServerSelector selector = ServerSelector::ONE("some-tag");
EXPECT_EQ(ServerSelector::Type::SUBSET, selector.getType());
+ EXPECT_FALSE(selector.amUnassigned());
std::set<std::string> tags = selector.getTags();
ASSERT_EQ(1, tags.size());
TEST(ServerSelectorTest, multiple) {
ServerSelector selector = ServerSelector::MULTIPLE({ "tag1", "tag2", "tag3" });
EXPECT_EQ(ServerSelector::Type::SUBSET, selector.getType());
+ EXPECT_FALSE(selector.amUnassigned());
std::set<std::string> tags = selector.getTags();
ASSERT_EQ(3, tags.size());