Commit be3423b7 authored by Francis Dupont's avatar Francis Dupont Committed by Tomek Mrugalski

[65-libyang-config-adaptor] Changed preProcess type

parent 8b8ba201
......@@ -402,9 +402,11 @@ AdaptorConfig::relaySuppliedOptions(ConstElementPtr dhcp) {
}
void
AdaptorConfig::preProcess(ConstElementPtr dhcp, const string& subsel,
AdaptorConfig::preProcess(ElementPtr dhcp, const string& subsel,
const string& space) {
ElementPtr mutable_dhcp = boost::const_pointer_cast<Element>(dhcp);
if (!dhcp) {
isc_throw(BadValue, "preProcess: null DHCP config");
}
bool have_ids = true;
SubnetIDSet set;
ConstElementPtr subnets = dhcp->get(subsel);
......@@ -414,7 +416,7 @@ AdaptorConfig::preProcess(ConstElementPtr dhcp, const string& subsel,
have_ids = false;
}
} else {
mutable_dhcp->remove(subsel);
dhcp->remove(subsel);
}
}
ConstElementPtr networks = dhcp->get("shared-networks");
......@@ -424,7 +426,7 @@ AdaptorConfig::preProcess(ConstElementPtr dhcp, const string& subsel,
have_ids = false;
}
} else {
mutable_dhcp->remove("shared-networks");
dhcp->remove("shared-networks");
}
}
......@@ -441,7 +443,7 @@ AdaptorConfig::preProcess(ConstElementPtr dhcp, const string& subsel,
if (defs->size() > 0) {
optionDefList(defs, space, codes);
} else {
mutable_dhcp->remove("option-def");
dhcp->remove("option-def");
}
}
ConstElementPtr options = dhcp->get("option-data");
......@@ -449,7 +451,7 @@ AdaptorConfig::preProcess(ConstElementPtr dhcp, const string& subsel,
if (options->size() > 0) {
optionDataList(options, space, codes);
} else {
mutable_dhcp->remove("option-data");
dhcp->remove("option-data");
}
}
ConstElementPtr classes = dhcp->get("client-classes");
......@@ -457,7 +459,7 @@ AdaptorConfig::preProcess(ConstElementPtr dhcp, const string& subsel,
if (classes->size() > 0) {
optionClasses(classes, space, codes);
} else {
mutable_dhcp->remove("client-classes");
dhcp->remove("client-classes");
}
}
ConstElementPtr hosts = dhcp->get("reservations");
......@@ -465,7 +467,7 @@ AdaptorConfig::preProcess(ConstElementPtr dhcp, const string& subsel,
if (hosts->size() > 0) {
optionHosts(hosts, space, codes);
} else {
mutable_dhcp->remove("reservations");
dhcp->remove("reservations");
}
}
optionSubnets(subnets, space, codes);
......@@ -502,7 +504,8 @@ AdaptorConfig::preProcess4(ConstElementPtr config) {
if (!dhcp) {
return;
}
preProcess(dhcp, "subnet4", "dhcp4");
ElementPtr mutable_dhcp = boost::const_pointer_cast<Element>(dhcp);
preProcess(mutable_dhcp, "subnet4", "dhcp4");
}
void
......@@ -517,8 +520,10 @@ AdaptorConfig::preProcess6(ConstElementPtr config) {
if (!dhcp) {
return;
}
preProcess(dhcp, "subnet6", "dhcp6");
ElementPtr mutable_dhcp = boost::const_pointer_cast<Element>(dhcp);
preProcess(mutable_dhcp, "subnet6", "dhcp6");
}
}; // end of namespace isc::yang
}; // end of namespace isc
......@@ -34,7 +34,9 @@ public:
/// @brief Pre process a DHCPv4 configuration.
///
/// Assign subnet IDs, check and set default in options.
/// Assign subnet IDs, check and set default in options, etc.
/// Note even the parameter is a ConstElementPtr and is not modified
/// sub-structures can be so if you need a copy do a deep one.
///
/// @param config The configuration.
/// @throw MissingKey when a required key is missing.
......@@ -44,7 +46,9 @@ public:
/// @brief Pre process a DHCPv6 configuration.
///
/// Assign subnet IDs, check and set default in options.
/// Assign subnet IDs, check and set default in options, etc.
/// Note even the parameter is a ConstElementPtr and is not modified
/// sub-structures can be so if you need a copy do a deep one.
///
/// @param config The configuration.
/// @throw MissingKey when a required key is missing.
......@@ -257,7 +261,7 @@ protected:
/// @param subsel The subnet list name.
/// @param space The default option space name.
/// @throw MissingKey when a required key is missing.
static void preProcess(isc::data::ConstElementPtr dhcp,
static void preProcess(isc::data::ElementPtr dhcp,
const std::string& subsel,
const std::string& space);
};
......
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