automatic YANG translators
Universal/softcoded/automatic translators.
Turn this:
ConstElementPtr networks = getSharedNetworks(xpath);
if (networks && !networks->empty()) {
result->set("shared-networks", networks);
}
ConstElementPtr classes = getClasses(xpath);
if (classes && !classes->empty()) {
result->set("client-classes", classes);
}
ConstElementPtr database = getDatabase(xpath + "/lease-database");
if (database) {
result->set("lease-database", database);
}
[...]
into something like this pseudocode:
ElementPtr result = Element::createMap();
for (S_Data_Node i : module->dataNodes()) {
result->set(i->xpath(), Element::from(i->valueStr()));
}
It would work with any module out-of-the-box and no node would be left out. When a new node gets added in the configuration, on top of the usual bison parser diligences, we would only need to update the YANG module.
The nodes of the Kea YANG modules would be 1:1 with the JSON configuration. For the IETF model, indeed the data would require changing, but at least this automatic translator would get you the YANG data in ElementPtr form and you would start from there.
Benefits:
- makes configuration maintenance easier
- is less error-prone
- improves performance because non-existing nodes are no longer checked