diff options
| author | Russ White <russ@riw.us> | 2022-03-29 10:51:02 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-03-29 10:51:02 -0400 |
| commit | dcaba5ae1a94484b5f1a1351dfad5dbb41d97652 (patch) | |
| tree | 2492b10e9652032a0e74d74646d6a655223f93d1 /lib/northbound_cli.c | |
| parent | f06b9fee95b3b42651f6a601f1a9eda63d1d2e72 (diff) | |
| parent | 1c9bd416f4fb91abfed12a654fef802712e2db2e (diff) | |
Merge pull request #10719 from opensourcerouting/nb-show-fixes
lib: fix and improve yang operational data display
Diffstat (limited to 'lib/northbound_cli.c')
| -rw-r--r-- | lib/northbound_cli.c | 21 |
1 files changed, 16 insertions, 5 deletions
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; |
