From fe8724723de49db9db579e87a95765cbacc970fd Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Thu, 6 Aug 2020 09:02:11 +0200 Subject: [PATCH] -q: print and quit after upgrade: even if sort/bind errors, print the XML --- apps/backend/backend_commit.c | 8 +++----- lib/src/clixon_datastore_write.c | 3 +++ test/test_upgrade_quit.sh | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/apps/backend/backend_commit.c b/apps/backend/backend_commit.c index 9262d8a0..cbcc5314 100644 --- a/apps/backend/backend_commit.c +++ b/apps/backend/backend_commit.c @@ -227,12 +227,10 @@ startup_common(clicon_handle h, xml_print(stderr, xret); clicon_err(OE_XML, 0, "%s: YANG binding error", __func__); } - exit(0); - } - /* sort yang */ - if (xml_sort_recurse(xt) < 0) { + + } /* sort yang */ + else if (xml_sort_recurse(xt) < 0) { clicon_err(OE_XML, EFAULT, "Yang sort error"); - exit(0); } if (xmldb_dump(h, stdout, xt) < 0) goto done; diff --git a/lib/src/clixon_datastore_write.c b/lib/src/clixon_datastore_write.c index 1044096b..5e74fdec 100644 --- a/lib/src/clixon_datastore_write.c +++ b/lib/src/clixon_datastore_write.c @@ -1057,6 +1057,9 @@ xmldb_dump(clicon_handle h, char *format; int pretty; + /* clear XML tree of defaults */ + if (xml_tree_prune_flagged(xt, XML_FLAG_DEFAULT, 1) < 0) + goto done; /* Add modstate first */ if ((x = clicon_modst_cache_get(h, 1)) != NULL){ if ((xmodst = xml_dup(x)) == NULL) diff --git a/test/test_upgrade_quit.sh b/test/test_upgrade_quit.sh index dce92d99..0c95d3c3 100755 --- a/test/test_upgrade_quit.sh +++ b/test/test_upgrade_quit.sh @@ -285,7 +285,7 @@ EOF MODSTATE='0clixon-lib2020-04-23http://clicon.org/libietf-inet-types2013-07-15urn:ietf:params:xml:ns:yang:ietf-inet-typesietf-netconf2011-06-01urn:ietf:params:xml:ns:netconf:base:1.0ietf-restconf2017-01-26urn:ietf:params:xml:ns:yang:ietf-restconfietf-yang-library2016-06-21urn:ietf:params:xml:ns:yang:ietf-yang-libraryietf-yang-types2013-07-15urn:ietf:params:xml:ns:yang:ietf-yang-typesinterfaces2018-02-20urn:example:interfaces' -XML='e0ethup54326.4328458765First interfacee1ethdown' +XML='e0First interfaceethup54326.4328458765e1ethdown' ALL="$MODSTATE$XML"