diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/frrscript.c | 6 | ||||
| -rw-r--r-- | lib/northbound.c | 21 | ||||
| -rw-r--r-- | lib/northbound_cli.c | 21 |
3 files changed, 35 insertions, 13 deletions
diff --git a/lib/frrscript.c b/lib/frrscript.c index 4fee79991a..8add44c19e 100644 --- a/lib/frrscript.c +++ b/lib/frrscript.c @@ -373,7 +373,7 @@ int frrscript_load(struct frrscript *fs, const char *function_name, } if (luaL_dofile(L, script_name) != 0) { - zlog_err("frrscript: failed loading script '%s.lua': error: %s", + zlog_err("frrscript: failed loading script '%s': error: %s", script_name, lua_tostring(L, -1)); goto fail; } @@ -381,7 +381,7 @@ int frrscript_load(struct frrscript *fs, const char *function_name, /* To check the Lua function, we get it from the global table */ lua_getglobal(L, function_name); if (lua_isfunction(L, lua_gettop(L)) == 0) { - zlog_err("frrscript: loaded script '%s.lua' but %s not found", + zlog_err("frrscript: loaded script '%s' but %s not found", script_name, function_name); goto fail; } @@ -391,7 +391,7 @@ int frrscript_load(struct frrscript *fs, const char *function_name, if (load_cb && (*load_cb)(fs) != 0) { zlog_err( - "frrscript: '%s.lua': %s: loaded but callback returned non-zero exit code", + "frrscript: '%s': %s: loaded but callback returned non-zero exit code", script_name, function_name); goto fail; } diff --git a/lib/northbound.c b/lib/northbound.c index 49adea6d53..2cc7ac6ea1 100644 --- a/lib/northbound.c +++ b/lib/northbound.c @@ -1649,10 +1649,12 @@ static int nb_oper_data_iter_container(const struct nb_node *nb_node, uint32_t flags, nb_oper_data_cb cb, void *arg) { + const struct lysc_node *snode = nb_node->snode; + if (CHECK_FLAG(nb_node->flags, F_NB_NODE_CONFIG_ONLY)) return NB_OK; - /* Presence containers. */ + /* Read-only presence containers. */ if (nb_node->cbs.get_elem) { struct yang_data *data; int ret; @@ -1662,15 +1664,24 @@ static int nb_oper_data_iter_container(const struct nb_node *nb_node, /* Presence container is not present. */ return NB_OK; - ret = (*cb)(nb_node->snode, translator, data, arg); + ret = (*cb)(snode, translator, data, arg); if (ret != NB_OK) return ret; } + /* Read-write presence containers. */ + if (CHECK_FLAG(snode->flags, LYS_CONFIG_W)) { + struct lysc_node_container *scontainer; + + scontainer = (struct lysc_node_container *)snode; + if (CHECK_FLAG(scontainer->flags, LYS_PRESENCE) + && !yang_dnode_get(running_config->dnode, xpath)) + return NB_OK; + } + /* Iterate over the child nodes. */ - return nb_oper_data_iter_children(nb_node->snode, xpath, list_entry, - list_keys, translator, false, flags, - cb, arg); + return nb_oper_data_iter_children(snode, xpath, list_entry, list_keys, + translator, false, flags, cb, arg); } static int diff --git a/lib/northbound_cli.c b/lib/northbound_cli.c index 1e25f6a1e2..56eac9dc32 100644 --- a/lib/northbound_cli.c +++ b/lib/northbound_cli.c @@ -1464,6 +1464,7 @@ DEFPY (show_yang_operational_data, [{\ format <json$json|xml$xml>\ |translate WORD$translator_family\ + |with-config$with_config\ }]", SHOW_STR "YANG information\n" @@ -1473,13 +1474,15 @@ DEFPY (show_yang_operational_data, "JavaScript Object Notation\n" "Extensible Markup Language\n" "Translate operational data\n" - "YANG module translator\n") + "YANG module translator\n" + "Merge configuration data\n") { LYD_FORMAT format; struct yang_translator *translator = NULL; struct ly_ctx *ly_ctx; struct lyd_node *dnode; char *strp; + uint32_t print_options = LYD_PRINT_WITHSIBLINGS; if (xml) format = LYD_XML; @@ -1507,13 +1510,21 @@ DEFPY (show_yang_operational_data, yang_dnode_free(dnode); return CMD_WARNING; } + + if (with_config && yang_dnode_exists(running_config->dnode, xpath)) { + struct lyd_node *config_dnode = + yang_dnode_get(running_config->dnode, xpath); + if (config_dnode != NULL) { + lyd_merge_tree(&dnode, yang_dnode_dup(config_dnode), + LYD_MERGE_DESTRUCT); + print_options |= LYD_PRINT_WD_ALL; + } + } + (void)lyd_validate_all(&dnode, ly_ctx, 0, NULL); /* Display the data. */ - if (lyd_print_mem(&strp, dnode, format, - LYD_PRINT_WITHSIBLINGS | LYD_PRINT_WD_ALL) - != 0 - || !strp) { + if (lyd_print_mem(&strp, dnode, format, print_options) != 0 || !strp) { vty_out(vty, "%% Failed to display operational data.\n"); yang_dnode_free(dnode); return CMD_WARNING; |
