Commit 0f4cd4d6 authored by Marcin Siodelski's avatar Marcin Siodelski

[#93,!35] Shared network name is now associated with subnet.

parent 3c33e8db
......@@ -232,6 +232,8 @@ public:
// server_hostname
// shared_network_name
// user_context
ElementPtr user_context = out_bindings[18]->getJSON();
if (user_context) {
......@@ -88,7 +88,6 @@ public:
// shared-network?
Pool4Ptr pool1(new Pool4(IOAddress(""), IOAddress("")));
......@@ -231,6 +230,35 @@ TEST_F(MySqlConfigBackendDHCPv4Test, getSubnet4) {
EXPECT_EQ(subnet2->toElement()->str(), returned_subnet->toElement()->str());
// Test that subnet can be associated with a shared network.
TEST_F(MySqlConfigBackendDHCPv4Test, getSubnet4SharedNetwork) {
Subnet4Ptr subnet = test_subnets_[0];
SharedNetwork4Ptr shared_network = test_networks_[0];
// Add subnet to a shared network.
// Store shared network in the database.
// Store subnet associated with the shared network in the database.
cbptr_->createUpdateSubnet4(ServerSelector::UNASSIGNED(), subnet);
// Fetch this subnet by subnet identifier.
Subnet4Ptr returned_subnet = cbptr_->getSubnet4(ServerSelector::UNASSIGNED(),
// The easiest way to verify whether the returned subnet matches the inserted
// subnet is to convert both to text.
EXPECT_EQ(subnet->toElement()->str(), returned_subnet->toElement()->str());
// However, the check above doesn't verify whether shared network name was
// correctly returned from the database.
EXPECT_EQ(shared_network->getName(), returned_subnet->getSharedNetworkName());
// Test that subnet can be fetched by prefix.
TEST_F(MySqlConfigBackendDHCPv4Test, getSubnet4ByPrefix) {
// Insert subnet to the database.
......@@ -267,6 +267,29 @@ private:
shared_network_ = shared_network;
/// @brief Returns shared network name.
std::string getSharedNetworkName() const {
return (shared_network_name_);
/// @brief Sets new shared network name.
/// In certain cases the subnet must be associated with the shared network
/// but the shared network object is not available. In particular, subnets
/// are returned from the configuration database with only names of the
/// shared networks. The actual shared networks must be fetched from the
/// database using a separate query. In order to not loose associations
/// of subnets with shared networks, the configuration backends will use
/// this method to store the shared network names. The servers will later
/// use those names to associate subnets with shared network instances.
/// @param shared_network_name New shared network name.
void setSharedNetworkName(const std::string& shared_network_name) {
shared_network_name_ = shared_network_name;
/// @brief Returns all pools (non-const variant)
......@@ -423,6 +446,9 @@ protected:
/// @brief Pointer to a shared network that subnet belongs to.
WeakNetworkPtr shared_network_;
/// @brief Shared network name.
std::string shared_network_name_;
/// @brief A generic pointer to either Subnet4 or Subnet6 object
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