vty_init(master, true);
lib_cmd_init();
- yang_init();
+ yang_init(true);
nb_init(master, NULL, 0);
vty_stdio(vty_do_exit);
log_ref_vty_init();
lib_error_init();
- yang_init();
+ yang_init(true);
debug_init_cli();
}
}
-struct ly_ctx *yang_ctx_new_setup(void)
+struct ly_ctx *yang_ctx_new_setup(bool embedded_modules)
{
struct ly_ctx *ctx;
const char *yang_models_path = YANG_MODELS_PATH;
ctx = ly_ctx_new(yang_models_path, LY_CTX_DISABLE_SEARCHDIR_CWD);
if (!ctx)
return NULL;
- ly_ctx_set_module_imp_clb(ctx, yang_module_imp_clb, NULL);
+
+ if (embedded_modules)
+ ly_ctx_set_module_imp_clb(ctx, yang_module_imp_clb, NULL);
+
return ctx;
}
-void yang_init(void)
+void yang_init(bool embedded_modules)
{
/* Initialize libyang global parameters that affect all containers. */
ly_set_log_clb(ly_log_cb, 1);
ly_log_options(LY_LOLOG | LY_LOSTORE);
/* Initialize libyang container for native models. */
- ly_native_ctx = yang_ctx_new_setup();
+ ly_native_ctx = yang_ctx_new_setup(embedded_modules);
if (!ly_native_ctx) {
flog_err(EC_LIB_LIBYANG, "%s: ly_ctx_new() failed", __func__);
exit(1);
/*
* Create and set up a libyang context (for use by the translator)
+ *
+ * embedded_modules
+ * Specify whether libyang should attempt to look for embedded YANG modules.
*/
-extern struct ly_ctx *yang_ctx_new_setup(void);
+extern struct ly_ctx *yang_ctx_new_setup(bool embedded_modules);
/*
* Enable or disable libyang verbose debugging.
/*
* Initialize the YANG subsystem. Should be called only once during the
* daemon initialization process.
+ *
+ * embedded_modules
+ * Specify whether libyang should attempt to look for embedded YANG modules.
*/
-extern void yang_init(void);
+extern void yang_init(bool embedded_modules);
/*
* Finish the YANG subsystem gracefully. Should be called only when the daemon
RB_INSERT(yang_translators, &yang_translators, translator);
/* Initialize the translator libyang context. */
- translator->ly_ctx = yang_ctx_new_setup();
+ translator->ly_ctx = yang_ctx_new_setup(false);
if (!translator->ly_ctx) {
flog_warn(EC_LIB_LIBYANG, "%s: ly_ctx_new() failed", __func__);
goto error;
void yang_translator_init(void)
{
- ly_translator_ctx = yang_ctx_new_setup();
+ ly_translator_ctx = yang_ctx_new_setup(true);
if (!ly_translator_ctx) {
flog_err(EC_LIB_LIBYANG, "%s: ly_ctx_new() failed", __func__);
exit(1);
zprivs_init(&bgpd_privs);
master = thread_master_create(NULL);
- yang_init();
+ yang_init(true);
nb_init(master, NULL, 0);
bgp_master_init(master, BGP_SOCKET_SNDBUF_SIZE);
bgp_option_set(BGP_OPT_NO_LISTEN);
cmd_init(1);
vty_init(master, false);
lib_cmd_init();
- yang_init();
+ yang_init(true);
nb_init(master, NULL, 0);
/* OSPF vty inits. */
vty_init(master, false);
lib_cmd_init();
- yang_init();
+ yang_init(true);
nb_init(master, NULL, 0);
test_init(argc, argv);
struct cmd_element *cmd;
cmd_init(1);
- yang_init();
+ yang_init(true);
nb_init(master, NULL, 0);
install_node(&bgp_node, NULL);
cmd_hostname_set("test");
vty_init(master, false);
lib_cmd_init();
- yang_init();
+ yang_init(true);
nb_init(master, modules, array_size(modules));
/* Create artificial data. */
if (argc != 1)
usage(EXIT_FAILURE);
- yang_init();
+ yang_init(false);
if (search_path)
ly_ctx_set_searchdir(ly_native_ctx, search_path);
if (argc != 1)
usage(EXIT_FAILURE);
- yang_init();
+ yang_init(false);
/* Load YANG module. */
module = yang_module_load(argv[0]);