Commit f6d60a63 authored by Marcin Siodelski's avatar Marcin Siodelski

[#93,!51] Rebased !51 against !35.

parent 87162653
......@@ -550,7 +550,7 @@ public:
} catch (const DuplicateEntry&) {
deletePools4(subnet);
deleteOptions4(existing_subnet);
deleteOptions4(subnet);
// Need to add one more binding for WHERE clause.
in_bindings.push_back(MySqlBinding::createInteger<uint32_t>(subnet->getID()));
......@@ -560,7 +560,8 @@ public:
// (Re)create pools.
for (auto pool : subnet->getPools(Lease::TYPE_V4)) {
createPool4(selector, boost::dynamic_pointer_cast<Pool4>(pool), subnet);
createPool4(server_selector, boost::dynamic_pointer_cast<Pool4>(pool),
subnet);
}
// (Re)create options.
......@@ -570,7 +571,7 @@ public:
for (auto desc = options->begin(); desc != options->end(); ++desc) {
OptionDescriptorPtr desc_copy(new OptionDescriptor(*desc));
desc_copy->space_name_ = option_space;
createUpdateOption4(selector, subnet->getID(), desc_copy);
createUpdateOption4(server_selector, subnet->getID(), desc_copy);
}
}
......@@ -852,7 +853,8 @@ public:
for (auto desc = options->begin(); desc != options->end(); ++desc) {
OptionDescriptorPtr desc_copy(new OptionDescriptor(*desc));
desc_copy->space_name_ = option_space;
createUpdateOption4(selector, shared_network->getName(), desc_copy);
createUpdateOption4(server_selector, shared_network->getName(),
desc_copy);
}
}
......@@ -1277,8 +1279,8 @@ public:
/// @param name Option name.
/// @return Number of deleted option definitions.
uint64_t deleteOptionDef4(const ServerSelector& /* server_selector */,
const uint16_t code,
const std::string& space) {
const uint16_t code,
const std::string& space) {
MySqlBindingCollection in_bindings = {
MySqlBinding::createInteger<uint8_t>(static_cast<uint8_t>(code)),
MySqlBinding::createString(space)
......@@ -1293,16 +1295,17 @@ public:
/// @param selector Server selector.
/// @param code Code of the deleted option.
/// @param space Option space of the deleted option.
void deleteOption4(const db::ServerSelector& /* selector */,
const uint16_t code,
const std::string& space) {
/// @return Number of deleted options.
uint64_t deleteOption4(const ServerSelector& /* selector */,
const uint16_t code,
const std::string& space) {
MySqlBindingCollection in_bindings = {
MySqlBinding::createInteger<uint8_t>(code),
MySqlBinding::createString(space)
};
// Run DELETE.
conn_.updateDeleteQuery(DELETE_OPTION4, in_bindings);
return (conn_.updateDeleteQuery(DELETE_OPTION4, in_bindings));
}
/// @brief Deletes subnet level option.
......@@ -1312,10 +1315,11 @@ public:
/// belongs.
/// @param code Code of the deleted option.
/// @param space Option space of the deleted option.
void deleteOption4(const db::ServerSelector& /* selector */,
const SubnetID& subnet_id,
const uint16_t code,
const std::string& space) {
/// @return Number of deleted options.
uint64_t deleteOption4(const ServerSelector& /* selector */,
const SubnetID& subnet_id,
const uint16_t code,
const std::string& space) {
MySqlBindingCollection in_bindings = {
MySqlBinding::createInteger<uint32_t>(static_cast<uint32_t>(subnet_id)),
MySqlBinding::createInteger<uint8_t>(code),
......@@ -1323,7 +1327,7 @@ public:
};
// Run DELETE.
conn_.updateDeleteQuery(DELETE_OPTION4_SUBNET_ID, in_bindings);
return (conn_.updateDeleteQuery(DELETE_OPTION4_SUBNET_ID, in_bindings));
}
/// @brief Deletes pool level option.
......@@ -1333,11 +1337,12 @@ public:
/// @param pool_end_address Upper bound pool address.
/// @param code Code of the deleted option.
/// @param space Option space of the deleted option.
void deleteOption4(const db::ServerSelector& /* selector */,
const IOAddress& pool_start_address,
const IOAddress& pool_end_address,
const uint16_t code,
const std::string& space) {
/// @return Number of deleted options.
uint64_t deleteOption4(const db::ServerSelector& /* selector */,
const IOAddress& pool_start_address,
const IOAddress& pool_end_address,
const uint16_t code,
const std::string& space) {
MySqlBindingCollection in_bindings = {
MySqlBinding::createInteger<uint32_t>(pool_start_address.toUint32()),
MySqlBinding::createInteger<uint32_t>(pool_end_address.toUint32()),
......@@ -1346,7 +1351,8 @@ public:
};
// Run DELETE.
conn_.updateDeleteQuery(DELETE_OPTION4_POOL_RANGE, in_bindings);
return (conn_.updateDeleteQuery(DELETE_OPTION4_POOL_RANGE,
in_bindings));
}
/// @brief Deletes shared network level option.
......@@ -1356,7 +1362,8 @@ public:
/// option belongs to
/// @param code Code of the deleted option.
/// @param space Option space of the deleted option.
void deleteOption4(const db::ServerSelector& /* selector */,
/// @return Number of deleted options.
uint64_t deleteOption4(const db::ServerSelector& /* selector */,
const std::string& shared_network_name,
const uint16_t code,
const std::string& space) {
......@@ -1367,33 +1374,38 @@ public:
};
// Run DELETE.
conn_.updateDeleteQuery(DELETE_OPTION4_SHARED_NETWORK, in_bindings);
return (conn_.updateDeleteQuery(DELETE_OPTION4_SHARED_NETWORK,
in_bindings));
}
/// @brief Deletes options belonging to a subnet from the database.
///
/// @param subnet Pointer to the subnet for which options should be
/// deleted.
void deleteOptions4(const Subnet4Ptr& subnet) {
/// @return Number of deleted options.
uint64_t deleteOptions4(const Subnet4Ptr& subnet) {
MySqlBindingCollection in_bindings = {
MySqlBinding::createInteger<uint32_t>(subnet->getID())
};
// Run DELETE.
conn_.updateDeleteQuery(DELETE_OPTIONS4_SUBNET_ID, in_bindings);
return (conn_.updateDeleteQuery(DELETE_OPTIONS4_SUBNET_ID,
in_bindings));
}
/// @brief Deletes options belonging to a shared network from the database.
///
/// @param subnet Pointer to the subnet for which options should be
/// deleted.
void deleteOptions4(const SharedNetwork4Ptr& shared_network) {
/// @return Number of deleted options.
uint64_t deleteOptions4(const SharedNetwork4Ptr& shared_network) {
MySqlBindingCollection in_bindings = {
MySqlBinding::createString(shared_network->getName())
};
// Run DELETE.
conn_.updateDeleteQuery(DELETE_OPTIONS4_SHARED_NETWORK, in_bindings);
return (conn_.updateDeleteQuery(DELETE_OPTIONS4_SHARED_NETWORK,
in_bindings));
}
};
......@@ -2377,7 +2389,7 @@ void
MySqlConfigBackendDHCPv4::createUpdateOption4(const db::ServerSelector& server_selector,
const std::string& shared_network_name,
const OptionDescriptorPtr& option) {
impl_->createUpdateOption4(selector, shared_network_name, option);
impl_->createUpdateOption4(server_selector, shared_network_name, option);
}
void
......@@ -2451,10 +2463,10 @@ MySqlConfigBackendDHCPv4::deleteAllOptionDefs4(const ServerSelector& /* server_s
}
uint64_t
MySqlConfigBackendDHCPv4::deleteOption4(const ServerSelector& selector,
MySqlConfigBackendDHCPv4::deleteOption4(const ServerSelector& server_selector,
const uint16_t code,
const std::string& space) {
impl_->deleteOption4(selector, code, space);
return (impl_->deleteOption4(server_selector, code, space));
}
uint64_t
......@@ -2462,15 +2474,16 @@ MySqlConfigBackendDHCPv4::deleteOption4(const ServerSelector& server_selector,
const std::string& shared_network_name,
const uint16_t code,
const std::string& space) {
impl_->deleteOption4(selector, shared_network_name, code, space);
return (impl_->deleteOption4(server_selector, shared_network_name,
code, space));
}
void
uint64_t
MySqlConfigBackendDHCPv4::deleteOption4(const ServerSelector& selector,
const SubnetID& subnet_id,
const uint16_t code,
const std::string& space) {
impl_->deleteOption4(selector, subnet_id, code, space);
return (impl_->deleteOption4(selector, subnet_id, code, space));
}
uint64_t
......@@ -2479,8 +2492,8 @@ MySqlConfigBackendDHCPv4::deleteOption4(const ServerSelector& selector,
const asiolink::IOAddress& pool_end_address,
const uint16_t code,
const std::string& space) {
impl_->deleteOption4(selector, pool_start_address, pool_end_address,
code, space);
return (impl_->deleteOption4(selector, pool_start_address, pool_end_address,
code, space));
}
uint64_t
......
......@@ -327,7 +327,7 @@ public:
/// option belongs to
/// @param code Code of the deleted option.
/// @param space Option space of the deleted option.
virtual void
virtual uint64_t
deleteOption4(const db::ServerSelector& selector,
const std::string& shared_network_name,
const uint16_t code,
......
......@@ -329,7 +329,7 @@ public:
/// belongs to.
/// @param code Code of the option to be deleted.
/// @param space Option space of the option to be deleted.
virtual void
virtual uint64_t
deleteOption4(const db::ServerSelector& selector,
const std::string& shared_network_name,
const uint16_t code,
......
......@@ -219,7 +219,7 @@ void
ConfigBackendPoolDHCPv4::createUpdateOption4(const BackendSelector& backend_selector,
const ServerSelector& server_selector,
const OptionDescriptorPtr& option) {
createUpdateDeleteProperty<void, const OptionPtr&>
createUpdateDeleteProperty<void, const OptionDescriptorPtr&>
(&ConfigBackendDHCPv4::createUpdateOption4, backend_selector,
server_selector, option);
}
......@@ -229,7 +229,7 @@ ConfigBackendPoolDHCPv4::createUpdateOption4(const BackendSelector& backend_sele
const ServerSelector& server_selector,
const std::string& shared_network_name,
const OptionDescriptorPtr& option) {
createUpdateDeleteProperty<const std::string&, const OptionDescriptorPtr&>
createUpdateDeleteProperty<void, const std::string&, const OptionDescriptorPtr&>
(&ConfigBackendDHCPv4::createUpdateOption4, backend_selector,
server_selector, shared_network_name, option);
}
......@@ -240,7 +240,7 @@ ConfigBackendPoolDHCPv4::createUpdateOption4(const BackendSelector& backend_sele
const ServerSelector& server_selector,
const SubnetID& subnet_id,
const OptionDescriptorPtr& option) {
createUpdateDeleteProperty<void, const SubnetID&, const OptionPtr&>
createUpdateDeleteProperty<void, const SubnetID&, const OptionDescriptorPtr&>
(&ConfigBackendDHCPv4::createUpdateOption4, backend_selector,
server_selector, subnet_id, option);
}
......@@ -251,7 +251,7 @@ ConfigBackendPoolDHCPv4::createUpdateOption4(const BackendSelector& backend_sele
const IOAddress& pool_start_address,
const IOAddress& pool_end_address,
const OptionDescriptorPtr& option) {
createUpdateDeleteProperty<void, const IOAddress&, const IOAddress&, const OptionPtr&>
createUpdateDeleteProperty<void, const IOAddress&, const IOAddress&,
const OptionDescriptorPtr&>
(&ConfigBackendDHCPv4::createUpdateOption4, backend_selector,
server_selector, pool_start_address, pool_end_address, option);
......@@ -345,15 +345,16 @@ ConfigBackendPoolDHCPv4::deleteOption4(const BackendSelector& backend_selector,
code, space));
}
void
uint64_t
ConfigBackendPoolDHCPv4::deleteOption4(const BackendSelector& backend_selector,
const ServerSelector& server_selector,
const std::string& shared_network_name,
const uint16_t code,
const std::string& space) {
createUpdateDeleteProperty<const std::string&, uint16_t, const std::string&>
(&ConfigBackendDHCPv4::deleteOption4, backend_selector, server_selector,
shared_network_name, code, space);
return (createUpdateDeleteProperty<uint64_t, const std::string&, const uint16_t,
const std::string&>
(&ConfigBackendDHCPv4::deleteOption4, backend_selector, server_selector,
shared_network_name, code, space));
}
uint64_t
......
......@@ -400,7 +400,7 @@ public:
/// belongs to.
/// @param code Code of the option to be deleted.
/// @param space Option space of the option to be deleted.
virtual void
virtual uint64_t
deleteOption4(const db::BackendSelector& backend_selector,
const db::ServerSelector& selector,
const std::string& shared_network_name,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment