forked from Mirror/frr
lib: introduce function that loads all FRR native YANG modules
In some cases it will be necessary to load all FRR native modules. Examples: * vtysh needs to load all YANG modules so that it can manipulate data from all daemons. * The gen_northbound_callbacks tool will need to load all YANG modules since augmentations from one module can have an effect in the required northbound callbacks of other modules. The new yang_module_load_all() function provides this functionality. As a side note, the "frr_native_modules" will need to be updated every time we add a new YANG module to FRR. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
This commit is contained in:
parent
e5dc8a44ee
commit
a1b5f469e7
11
lib/yang.c
11
lib/yang.c
|
@ -71,6 +71,11 @@ static const char *yang_module_imp_clb(const char *mod_name,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char * const frr_native_modules[] = {
|
||||||
|
"frr-interface",
|
||||||
|
"frr-ripd",
|
||||||
|
};
|
||||||
|
|
||||||
/* Generate the yang_modules tree. */
|
/* Generate the yang_modules tree. */
|
||||||
static inline int yang_module_compare(const struct yang_module *a,
|
static inline int yang_module_compare(const struct yang_module *a,
|
||||||
const struct yang_module *b)
|
const struct yang_module *b)
|
||||||
|
@ -108,6 +113,12 @@ struct yang_module *yang_module_load(const char *module_name)
|
||||||
return module;
|
return module;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void yang_module_load_all(void)
|
||||||
|
{
|
||||||
|
for (size_t i = 0; i < array_size(frr_native_modules); i++)
|
||||||
|
yang_module_load(frr_native_modules[i]);
|
||||||
|
}
|
||||||
|
|
||||||
struct yang_module *yang_module_find(const char *module_name)
|
struct yang_module *yang_module_find(const char *module_name)
|
||||||
{
|
{
|
||||||
struct yang_module s;
|
struct yang_module s;
|
||||||
|
|
|
@ -114,6 +114,11 @@ extern struct yang_modules yang_modules;
|
||||||
*/
|
*/
|
||||||
extern struct yang_module *yang_module_load(const char *module_name);
|
extern struct yang_module *yang_module_load(const char *module_name);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Load all FRR native YANG models.
|
||||||
|
*/
|
||||||
|
extern void yang_module_load_all(void);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Find a YANG module by its name.
|
* Find a YANG module by its name.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue