Commit 2f25ffc0 authored by Marcin Siodelski's avatar Marcin Siodelski

[#93,!35] Enclose subnet/network creation in transaction.

parent ca00cbc8
...@@ -361,6 +361,8 @@ public: ...@@ -361,6 +361,8 @@ public:
MySqlBinding::createInteger<uint32_t>(subnet->getValid()) MySqlBinding::createInteger<uint32_t>(subnet->getValid())
}; };
MySqlTransaction transaction(conn_);
// Check if the subnet already exists. // Check if the subnet already exists.
Subnet4Ptr existing_subnet = getSubnet4(server_selector, subnet->getID()); Subnet4Ptr existing_subnet = getSubnet4(server_selector, subnet->getID());
...@@ -385,6 +387,8 @@ public: ...@@ -385,6 +387,8 @@ public:
for (auto pool : subnet->getPools(Lease::TYPE_V4)) { for (auto pool : subnet->getPools(Lease::TYPE_V4)) {
createPool4(boost::dynamic_pointer_cast<Pool4>(pool), subnet); createPool4(boost::dynamic_pointer_cast<Pool4>(pool), subnet);
} }
transaction.commit();
} }
/// @brief Inserts new IPv4 pool to the database. /// @brief Inserts new IPv4 pool to the database.
...@@ -598,6 +602,8 @@ public: ...@@ -598,6 +602,8 @@ public:
MySqlBinding::condCreateInteger<uint32_t>(shared_network->getValid()) MySqlBinding::condCreateInteger<uint32_t>(shared_network->getValid())
}; };
MySqlTransaction transaction(conn_);
// Check if the shared network already exists. // Check if the shared network already exists.
SharedNetwork4Ptr existing_network = getSharedNetwork4(server_selector, SharedNetwork4Ptr existing_network = getSharedNetwork4(server_selector,
shared_network->getName()); shared_network->getName());
...@@ -614,6 +620,8 @@ public: ...@@ -614,6 +620,8 @@ public:
conn_.insertQuery(MySqlConfigBackendDHCPv4Impl::INSERT_SHARED_NETWORK4, conn_.insertQuery(MySqlConfigBackendDHCPv4Impl::INSERT_SHARED_NETWORK4,
in_bindings); in_bindings);
} }
transaction.commit();
} }
/// @brief Sends query to the database to retrieve multiple option /// @brief Sends query to the database to retrieve multiple option
......
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