Commit 7454d2d0 authored by Francis Dupont's avatar Francis Dupont
Browse files

[259-libyang-adapt-authoritative] Wrote methods to remove not hyet supported authoritative flags

parent 633e05b6
......@@ -522,6 +522,52 @@ AdaptorConfig::sanitizeRelaySuppliedOptions(ConstElementPtr dhcp) {
mutable_dhcp->remove("relay-supplied-options");
}
void
AdaptorConfig::removeAuthoritativeSubnets(ConstElementPtr subnets) {
if (!subnets || subnets->empty()) {
// nothing to do here.
return;
}
for (size_t i = 0; i < subnets->size(); ++i) {
ElementPtr subnet = subnets->getNonConst(i);
ConstElementPtr auth = subnet->get("authoritative");
if (auth) {
subnet->remove("authoritative");
}
}
}
void
AdaptorConfig::removeAuthoritativeSharedNetworks(ConstElementPtr networks) {
if (!networks || networks->empty()) {
// nothing to do here.
return;
}
for (size_t i = 0; i < networks->size(); ++i) {
ElementPtr network = networks->getNonConst(i);
ConstElementPtr auth = network->get("authoritative");
if (auth) {
network->remove("authoritative");
}
removeAuthoritativeSubnets(network->get("subnet4"));
}
}
void
AdaptorConfig::removeAuthoritative(ConstElementPtr dhcp) {
removeAuthoritativeSubnets(dhcp->get("subnet4"));
removeAuthoritativeSharedNetworks(dhcp->get("shared-networks"));
ConstElementPtr auth = dhcp->get("authoritative");
if (!auth) {
// Done.
return;
}
ElementPtr mutable_dhcp = boost::const_pointer_cast<Element>(dhcp);
mutable_dhcp->remove("authoritative");
}
void
AdaptorConfig::preProcess(ElementPtr dhcp, const string& subsel,
const string& space) {
......@@ -608,7 +654,9 @@ AdaptorConfig::preProcess(ElementPtr dhcp, const string& subsel,
sanitizeDatabase(dhcp);
if (space == DHCP6_SPACE) {
if (space == DHCP4_SPACE) {
removeAuthoritative(dhcp);
} else if (space == DHCP6_SPACE) {
sanitizeRelaySuppliedOptions(dhcp);
}
}
......
......@@ -275,6 +275,26 @@ protected:
/// @param dhcp The DHCPv6 server.
static void sanitizeRelaySuppliedOptions(isc::data::ConstElementPtr dhcp);
/// @brief Remove authoritative flag from a subnet list.
///
/// @param subnets The subnet list.
static void removeAuthoritativeSubnets(isc::data::ConstElementPtr subnets);
/// @brief Remove authoritative flag from a shared network list.
///
/// Remove authoritative flag in each shared network and its
/// subnet4 children.
///
/// @param networks The shared network list.
static void removeAuthoritativeSharedNetworks(isc::data::ConstElementPtr networks);
/// @brief Remove authoritative flags.
///
/// Remove global, shared network and subnet4 authoritative flags.
///
/// @param dhcp The DHCPv4 server.
static void removeAuthoritative(isc::data::ConstElementPtr dhcp);
/// @brief Pre process a configuration.
///
/// Assign subnet IDs, check and set default in options, etc.
......
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