in common/defaultvalueprovider.cpp [440:483]
void DefaultValueProvider::LoadModule(const string &name, const string &path, struct ly_ctx *context)
{
const struct lys_module *module = ly_ctx_load_module(
context,
name.c_str(),
EMPTY_STR); // Use EMPTY_STR to revision to load the latest revision
if (module == nullptr)
{
const char* err = ly_errmsg(context);
SWSS_LOG_ERROR("Load Yang file %s failed: %s.\n", path.c_str(), err);
return;
}
if (module->data == nullptr)
{
// Not every yang file should contains yang model
SWSS_LOG_WARN("Yang file %s does not contains model %s.\n", path.c_str(), name.c_str());
return;
}
struct lys_node *topLevelNode = module->data;
while (topLevelNode)
{
if (topLevelNode->nodetype != LYS_CONTAINER)
{
SWSS_LOG_DEBUG("ignore top level element %s, tyoe %d\n",topLevelNode->name, topLevelNode->nodetype);
// Config DB table schema is defined by top level container
topLevelNode = topLevelNode->next;
continue;
}
SWSS_LOG_DEBUG("top level container: %s\n",topLevelNode->name);
auto container = topLevelNode->child;
while (container)
{
SWSS_LOG_DEBUG("container name: %s\n",container->name);
AppendTableInfoToMapping(container);
container = container->next;
}
topLevelNode = topLevelNode->next;
}
}