Commit 0600f7c4 authored by Francis Dupont's avatar Francis Dupont Committed by Tomek Mrugalski

[65-libyang-config-adaptor] Added empty require client class list removal

parent 48c5eb9b
......@@ -279,6 +279,49 @@ AdaptorConfig::optionSharedNetworks(ConstElementPtr networks,
}
}
void
AdaptorConfig::requireClassesPools(ConstElementPtr pools) {
if (pools && (pools->size() > 0)) {
for (size_t i = 0; i < pools->size(); ++i) {
ElementPtr pool = pools->getNonConst(i);
ConstElementPtr requires = pool->get("require-client-classes");
if (requires && (requires->size() == 0)) {
pool->remove("require-client-classes");
}
}
}
}
void
AdaptorConfig::requireClassesSubnets(ConstElementPtr subnets) {
if (subnets && (subnets->size() > 0)) {
for (size_t i = 0; i < subnets->size(); ++i) {
ElementPtr subnet = subnets->getNonConst(i);
requireClassesPools(subnet->get("pools"));
requireClassesPools(subnet->get("pd-pools"));
ConstElementPtr requires = subnet->get("require-client-classes");
if (requires && (requires->size() == 0)) {
subnet->remove("require-client-classes");
}
}
}
}
void
AdaptorConfig::requireClassesSharedNetworks(ConstElementPtr networks,
const string& subsel) {
if (networks && (networks->size() > 0)) {
for (size_t i = 0; i < networks->size(); ++i) {
ElementPtr network = networks->getNonConst(i);
requireClassesSubnets(network->get(subsel));
ConstElementPtr requires = network->get("require-client-classes");
if (requires && (requires->size() == 0)) {
network->remove("require-client-classes");
}
}
}
}
void
AdaptorConfig::hostList(ConstElementPtr hosts) {
if (hosts && (hosts->size() > 0)) {
......@@ -426,6 +469,9 @@ AdaptorConfig::preProcess(ConstElementPtr dhcp, const string& subsel,
relaySubnets(subnets);
relaySharedNetworks(networks, subsel);
requireClassesSubnets(subnets);
requireClassesSharedNetworks(networks, subsel);
updateDatabase(dhcp);
}
......
......@@ -163,6 +163,23 @@ protected:
const std::string& space,
const OptionCodes& codes);
/// @brief Process require client classes in a pool list.
///
/// @param pools The pool list.
static void requireClassesPools(isc::data::ConstElementPtr pools);
/// @brief Process require client classes in a subnet list.
///
/// @param subnets The subnet list.
static void requireClassesSubnets(isc::data::ConstElementPtr subnets);
/// @brief Process require client classes in a shared network list.
///
/// @param networks The shared network list.
/// @param subsel The subnet list name.
static void requireClassesSharedNetworks(isc::data::ConstElementPtr networks,
const std::string& subsel);
/// @brief Process host reservation list.
///
/// @param hosts The host reservation list.
......
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