with-defaults=trim does not work due to dodgy handling of state data marked as default

This commit is contained in:
Jan-Olof Carlson 2022-08-02 08:32:46 +00:00 committed by Olof hagsand
parent dcb78bbc26
commit 71fe10a057
2 changed files with 14 additions and 6 deletions

View file

@ -847,14 +847,19 @@ get_common(clicon_handle h,
if ((xfind = xml_find(xe, "with-defaults")) != NULL) { if ((xfind = xml_find(xe, "with-defaults")) != NULL) {
if ((with_defaults = xml_find_value(xfind, "body")) != NULL) { if ((with_defaults = xml_find_value(xfind, "body")) != NULL) {
if (strcmp(with_defaults, "explicit") == 0) { if (strcmp(with_defaults, "explicit") == 0) {
/* Clear marked nodes */
if (xml_apply(xret, CX_ELMNT, (xml_applyfn_t*)xml_flag_reset, (void*)XML_FLAG_MARK) < 0)
goto done;
/* Traverse XML and mark state nodes */ /* Traverse XML and mark state nodes */
if (xml_non_config_data(xret, NULL) < 0) if (xml_non_config_data(xret, NULL) < 0)
goto done; goto done;
/* Remove default configuration nodes from XML */ /* Remove default configuration nodes from XML */
if (xml_tree_prune_flags(xret, XML_FLAG_DEFAULT, XML_FLAG_MARK|XML_FLAG_DEFAULT) < 0) if (xml_tree_prune_flags(xret, XML_FLAG_DEFAULT, XML_FLAG_MARK|XML_FLAG_DEFAULT) < 0)
goto done; goto done;
/* Restore marked nodes */ }
if (xml_apply(xret, CX_ELMNT, (xml_applyfn_t*)xml_flag_reset, (void*)XML_FLAG_MARK) < 0) else if (strcmp(with_defaults, "trim") == 0) {
/* Remove default nodes from XML */
if (xml_tree_prune_flags(xret, XML_FLAG_DEFAULT, XML_FLAG_DEFAULT) < 0)
goto done; goto done;
} }
else if (strcmp(with_defaults, "report-all") == 0) { else if (strcmp(with_defaults, "report-all") == 0) {

View file

@ -191,9 +191,12 @@ expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" \
"<rpc $DEFAULTNS><get><filter type=\"subtree\"><interfaces $EXAMPLENS/></filter>\ "<rpc $DEFAULTNS><get><filter type=\"subtree\"><interfaces $EXAMPLENS/></filter>\
<with-defaults xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\">trim</with-defaults></get></rpc>" \ <with-defaults xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\">trim</with-defaults></get></rpc>" \
"" \ "" \
"<rpc-reply $DEFAULTNS><rpc-error><error-type>application</error-type><error-tag>operation-not-supported</error-tag>\ "<rpc-reply $DEFAULTNS><data><interfaces $EXAMPLENS>\
<error-severity>error</error-severity>\ <interface><name>eth0</name><mtu>8192</mtu></interface>\
<error-message>with-defaults retrieval mode \"trim\" is not supported</error-message></rpc-error></rpc-reply>" <interface><name>eth1</name></interface>\
<interface><name>eth2</name><mtu>9000</mtu><status>not feeling so good</status></interface>\
<interface><name>eth3</name><mtu>1500</mtu><status>waking up</status></interface>\
</interfaces></data></rpc-reply>"
new "rfc6243 3.3. 'explicit' Retrieval Mode" new "rfc6243 3.3. 'explicit' Retrieval Mode"
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" \ expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" \