2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-31 14:05:33 +00:00

[#488,!259] Added support for authoritative flag in MySQL CB.

This commit is contained in:
Marcin Siodelski
2019-03-04 20:06:04 +01:00
parent f29512b100
commit 434b93940c
6 changed files with 39 additions and 14 deletions

View File

@@ -507,7 +507,7 @@ EOF
run_statement "dhcp4_option_def_server" "$qry"
# table: dhcp4_shared_network
qry="select id, name, client_class, interface, match_client_id, modification_ts, rebind_timer, relay, renew_timer, require_client_classes, reservation_mode, user_context, valid_lifetime, calculate_tee_times, t1_percent, t2_percent from dhcp4_shared_network"
qry="select id, name, client_class, interface, match_client_id, modification_ts, rebind_timer, relay, renew_timer, require_client_classes, reservation_mode, user_context, valid_lifetime, authoritative, calculate_tee_times, t1_percent, t2_percent from dhcp4_shared_network"
run_statement "dhcp4_shared_network" "$qry"
# table: dhcp4_shared_network_server
@@ -515,7 +515,7 @@ EOF
run_statement "dhcp4_shared_network_server" "$qry"
# table: dhcp4_subnet
qry="select subnet_prefix, 4o6_interface, 4o6_interface_id, 4o6_subnet, boot_file_name, client_class, interface, match_client_id, modification_ts, next_server, rebind_timer, relay, renew_timer, require_client_classes, reservation_mode, server_hostname, shared_network_name, subnet_id, user_context, valid_lifetime, calculate_tee_times, t1_percent, t2_percent from dhcp4_subnet"
qry="select subnet_prefix, 4o6_interface, 4o6_interface_id, 4o6_subnet, boot_file_name, client_class, interface, match_client_id, modification_ts, next_server, rebind_timer, relay, renew_timer, require_client_classes, reservation_mode, server_hostname, shared_network_name, subnet_id, user_context, valid_lifetime, authoritative, calculate_tee_times, t1_percent, t2_percent from dhcp4_subnet"
run_statement "dhcp4_subnet" "$qry"
# table: dhcp4_pool

View File

@@ -278,7 +278,8 @@ public:
MySqlBinding::createTimestamp(), //option: modification_ts
MySqlBinding::createInteger<uint8_t>(), // calculate_tee_times
MySqlBinding::createInteger<float>(), // t1_percent
MySqlBinding::createInteger<float>() // t2_percent
MySqlBinding::createInteger<float>(), // t2_percent
MySqlBinding::createInteger<uint8_t>() // authoritative
};
uint64_t last_pool_id = 0;
@@ -440,6 +441,11 @@ public:
last_subnet->setT2Percent(out_bindings[51]->getFloat());
}
// authoritative
if (!out_bindings[52]->amNull()) {
last_subnet->setAuthoritative(out_bindings[52]->getBool());
}
// Subnet ready. Add it to the list.
subnets.push_back(last_subnet);
}
@@ -798,7 +804,8 @@ public:
createBinding(subnet->getValid()),
MySqlBinding::condCreateBool(subnet->getCalculateTeeTimes()),
MySqlBinding::condCreateFloat(subnet->getT1Percent()),
MySqlBinding::condCreateFloat(subnet->getT2Percent())
MySqlBinding::condCreateFloat(subnet->getT2Percent()),
MySqlBinding::condCreateBool(subnet->getAuthoritative())
};
MySqlTransaction transaction(conn_);
@@ -1004,7 +1011,8 @@ public:
MySqlBinding::createTimestamp(), //option: modification_ts
MySqlBinding::createInteger<uint8_t>(), // calculate_tee_times
MySqlBinding::createInteger<float>(), // t1_percent
MySqlBinding::createInteger<float>() // t2_percent
MySqlBinding::createInteger<float>(), // t2_percent
MySqlBinding::createInteger<uint8_t>() // authoritative
};
uint64_t last_network_id = 0;
@@ -1118,6 +1126,11 @@ public:
last_network->setT2Percent(out_bindings[27]->getFloat());
}
// authoritative
if (!out_bindings[28]->amNull()) {
last_network->setAuthoritative(out_bindings[28]->getBool());
}
shared_networks.push_back(last_network);
}
@@ -1241,7 +1254,8 @@ public:
createBinding(shared_network->getValid()),
MySqlBinding::condCreateBool(shared_network->getCalculateTeeTimes()),
MySqlBinding::condCreateFloat(shared_network->getT1Percent()),
MySqlBinding::condCreateFloat(shared_network->getT2Percent())
MySqlBinding::condCreateFloat(shared_network->getT2Percent()),
MySqlBinding::condCreateBool(shared_network->getAuthoritative())
};
MySqlTransaction transaction(conn_);
@@ -2061,9 +2075,10 @@ TaggedStatementArray tagged_statements = { {
" valid_lifetime,"
" calculate_tee_times,"
" t1_percent,"
" t2_percent"
" t2_percent,"
" authoritative"
") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,"
"?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" },
"?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" },
// Insert association of the subnet with a server.
{ MySqlConfigBackendDHCPv4Impl::INSERT_SUBNET4_SERVER,
@@ -2092,8 +2107,9 @@ TaggedStatementArray tagged_statements = { {
" valid_lifetime,"
" calculate_tee_times,"
" t1_percent,"
" t2_percent"
") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" },
" t2_percent,"
" authoritative"
") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" },
// Insert association of the shared network with a server.
{ MySqlConfigBackendDHCPv4Impl::INSERT_SHARED_NETWORK4_SERVER,
@@ -2150,7 +2166,8 @@ TaggedStatementArray tagged_statements = { {
" valid_lifetime = ?,"
" calculate_tee_times = ?,"
" t1_percent = ?,"
" t2_percent = ? "
" t2_percent = ?,"
" authoritative = ? "
"WHERE subnet_id = ?" },
// Update existing shared network.
@@ -2170,7 +2187,8 @@ TaggedStatementArray tagged_statements = { {
" valid_lifetime = ?,"
" calculate_tee_times = ?,"
" t1_percent = ?,"
" t2_percent = ? "
" t2_percent = ?,"
" authoritative = ? "
"WHERE name = ?" },
// Update existing option definition.

View File

@@ -101,7 +101,8 @@ namespace {
" o.modification_ts," \
" s.calculate_tee_times," \
" s.t1_percent," \
" s.t2_percent " \
" s.t2_percent," \
" s.authoritative " \
"FROM dhcp4_subnet AS s " \
"INNER JOIN dhcp4_subnet_server AS a " \
" ON s.subnet_id = a.subnet_id " \
@@ -226,7 +227,8 @@ namespace {
" o.modification_ts," \
" n.calculate_tee_times," \
" n.t1_percent," \
" n.t2_percent " \
" n.t2_percent," \
" n.authoritative " \
"FROM dhcp4_shared_network AS n " \
"INNER JOIN dhcp4_shared_network_server AS a " \
" ON n.id = a.shared_network_id " \

View File

@@ -108,6 +108,7 @@ public:
subnet->setSname("server-hostname");
subnet->setContext(user_context);
subnet->setValid(555555);
subnet->setAuthoritative(true);
subnet->setCalculateTeeTimes(true);
subnet->setT1Percent(0.345);
subnet->setT2Percent(0.444);

View File

@@ -1344,6 +1344,7 @@ ALTER TABLE dhcp6_options
DEFAULT CURRENT_TIMESTAMP;
ALTER TABLE dhcp4_subnet
ADD COLUMN authoritative TINYINT(1) DEFAULT NULL,
ADD COLUMN calculate_tee_times TINYINT(1) DEFAULT NULL,
ADD COLUMN t1_percent FLOAT DEFAULT NULL,
ADD COLUMN t2_percent FLOAT DEFAULT NULL;
@@ -1355,6 +1356,7 @@ ALTER TABLE dhcp4_subnet
MODIFY COLUMN match_client_id TINYINT(1) DEFAULT NULL;
ALTER TABLE dhcp4_shared_network
ADD COLUMN authoritative TINYINT(1) DEFAULT NULL,
ADD COLUMN calculate_tee_times TINYINT(1) DEFAULT NULL,
ADD COLUMN t1_percent FLOAT DEFAULT NULL,
ADD COLUMN t2_percent FLOAT DEFAULT NULL;

View File

@@ -27,6 +27,7 @@ ALTER TABLE dhcp6_options
DEFAULT CURRENT_TIMESTAMP;
ALTER TABLE dhcp4_subnet
ADD COLUMN authoritative TINYINT(1) DEFAULT NULL,
ADD COLUMN calculate_tee_times TINYINT(1) DEFAULT NULL,
ADD COLUMN t1_percent FLOAT DEFAULT NULL,
ADD COLUMN t2_percent FLOAT DEFAULT NULL;
@@ -38,6 +39,7 @@ ALTER TABLE dhcp4_subnet
MODIFY COLUMN match_client_id TINYINT(1) DEFAULT NULL;
ALTER TABLE dhcp4_shared_network
ADD COLUMN authoritative TINYINT(1) DEFAULT NULL,
ADD COLUMN calculate_tee_times TINYINT(1) DEFAULT NULL,
ADD COLUMN t1_percent FLOAT DEFAULT NULL,
ADD COLUMN t2_percent FLOAT DEFAULT NULL;