From 4a605ff25e3ecc20b8b61c698a575365f30b9c0a Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Sat, 12 Aug 2023 16:28:08 +0200 Subject: [PATCH] Fixed: ["show configuration devices" and "show configuration devices | display cli" differs](https://github.com/clicon/clixon-controller/issues/24) --- CHANGELOG.md | 3 ++- apps/cli/cli_pipe.c | 24 +++++++++++++++--------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c04345b8..7660358f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,7 +50,8 @@ Expected: October 2023 ### Corrected Bugs -* Fixed: [Openconfig configuration on Juniper MX does not work](https://github.com/clicon/clixon-controller/issues/20) +* Fixed: ["show configuration devices" and "show configuration devices | display cli" differs](https://github.com/clicon/clixon-controller/issues/24) +* Fixed: [Configuring Juniper PTX produces CLI errors](https://github.com/clicon/clixon-controller/issues/19) * Fixed: CLI output pipes: Add CLICON_PIPETREE to any cli files, not just the first ## 6.3.0 diff --git a/apps/cli/cli_pipe.c b/apps/cli/cli_pipe.c index 2298b4c2..334d12c4 100644 --- a/apps/cli/cli_pipe.c +++ b/apps/cli/cli_pipe.c @@ -214,17 +214,18 @@ pipe_tail_fn(clicon_handle h, */ int pipe_showas_fn(clicon_handle h, - cvec *cvv, - cvec *argv) + cvec *cvv, + cvec *argv) { int retval = -1; cxobj *xt = NULL; int argc = 0; enum format_enum format = FORMAT_XML; - int ybind = 1; yang_stmt *yspec; int pretty = 1; char *prepend = NULL; + int ret; + cxobj *xerr = NULL; if (cvec_len(argv) < 1 || cvec_len(argv) > 3){ clicon_err(OE_PLUGIN, EINVAL, "Received %d arguments. Expected:: [ []]", cvec_len(argv)); @@ -241,13 +242,16 @@ pipe_showas_fn(clicon_handle h, if (cvec_len(argv) > argc){ prepend = cv_string_get(cvec_i(argv, argc++)); } - if (ybind){ - yspec = clicon_dbspec_yang(h); - if (clixon_xml_parse_file(stdin, YB_MODULE, yspec, &xt, NULL) < 0) - goto done; - } - else if (clixon_xml_parse_file(stdin, YB_NONE, NULL, &xt, NULL) < 0) + yspec = clicon_dbspec_yang(h); + /* Bind module with mtpoints requires h, but parse functions font have h */ + if (clixon_xml_parse_file(stdin, YB_NONE, yspec, &xt, NULL) < 0) goto done; + if ((ret = xml_bind_yang(h, xt, YB_MODULE, yspec, &xerr)) < 0) + goto done; + if (ret == 0){ + clixon_netconf_error(xerr, "Parse top file", NULL); + goto done; + } switch (format){ case FORMAT_XML: if (clixon_xml2file(stdout, xt, 0, pretty, NULL, cligen_output, 1, 0) < 0) @@ -270,6 +274,8 @@ pipe_showas_fn(clicon_handle h, } retval = 0; done: + if (xerr) + xml_free(xerr); if (xt) xml_free(xt); return retval;