diff --git a/apps/backend/backend_get.c b/apps/backend/backend_get.c
index 88483f6c..e50a8f9f 100644
--- a/apps/backend/backend_get.c
+++ b/apps/backend/backend_get.c
@@ -498,10 +498,12 @@ with_defaults(cxobj *xe,
/* Mark state nodes */
if (xml_non_config_data(xret, NULL) < 0)
goto done;
- /* Remove default configuration nodes*/
+ /* Remove default configuration nodes */
if (xml_tree_prune_flags(xret, XML_FLAG_DEFAULT, XML_FLAG_MARK | XML_FLAG_DEFAULT) < 0)
goto done;
- /* TODO. Remove empty containers */
+ /* Remove empty containers */
+ if (xml_defaults_nopresence(xret, 1) < 0)
+ goto done;
goto ok;
}
if (strcmp(mode, "trim") == 0) {
@@ -514,7 +516,9 @@ with_defaults(cxobj *xe,
if (xml_tree_prune_flags(xret, XML_FLAG_MARK, XML_FLAG_MARK)
< 0)
goto done;
- /* TODO. Remove empty containers */
+ /* Remove empty containers */
+ if (xml_defaults_nopresence(xret, 1) < 0)
+ goto done;
goto ok;
}
if (strcmp(mode, "report-all-tagged") == 0) {
diff --git a/test/test_yang_with_defaults.sh b/test/test_yang_with_defaults.sh
index 988c7326..47992970 100755
--- a/test/test_yang_with_defaults.sh
+++ b/test/test_yang_with_defaults.sh
@@ -95,7 +95,23 @@ module example {
type status-type;
config false;
}
- }
+ }
+ container cedv {
+ description
+ "Container for test with explicit default value - EDV";
+ leaf edv {
+ type string;
+ default "edv";
+ }
+ }
+ container cdv {
+ description
+ "Container for test with default value - DV";
+ leaf dv {
+ type string;
+ default "dv";
+ }
+ }
}
}
EOF
@@ -109,6 +125,7 @@ XML="\
eth1\
eth29000\
eth31500\
+edv\
"
cat < $fstate
@@ -184,6 +201,7 @@ expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" \
eth11500ok\
eth29000not feeling so good\
eth31500waking up\
+edvdv\
"
new "rfc6243 3.2. 'trim' Retrieval Mode"
@@ -208,6 +226,7 @@ expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" \
eth1ok\
eth29000not feeling so good\
eth31500waking up\
+edv\
"
new "rfc6243 3.4. 'report-all-tagged' Retrieval Mode"
@@ -220,6 +239,7 @@ expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" \
eth11500ok\
eth29000not feeling so good\
eth31500waking up\
+edvdv\
"
new "rfc6243 2.3.1. 'explicit' Basic Mode Retrieval"
@@ -230,6 +250,7 @@ expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" \
eth11500ok\
eth29000not feeling so good\
eth31500waking up\
+edvdv\
" ""
new "rfc6243 2.3.3. 'explicit' and Behavior (part 1): create explicit node"
@@ -262,6 +283,7 @@ expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" \
eth11500ok\
eth29000not feeling so good\
eth31500waking up\
+edvdv\
" ""
new "rfc6243 2.3.3. 'explicit' and Behavior (part 2): create default node"
@@ -290,6 +312,7 @@ expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" \
eth13000ok\
eth29000not feeling so good\
eth31500waking up\
+edvdv\
" ""
new "rfc6243 2.3.3. 'explicit' and Behavior (part 3): delete explicit node"
@@ -318,6 +341,7 @@ expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" \
eth11500ok\
eth29000not feeling so good\
eth31500waking up\
+edvdv\
" ""
new "rfc6243 2.3.3. 'explicit' and Behavior (part 4): delete default node"
@@ -351,6 +375,7 @@ expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" \
eth11500ok\
eth29000not feeling so good\
eth31500waking up\
+edvdv\
" ""
new "Pagination"
@@ -424,6 +449,7 @@ expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" \
eth11500\
eth29000\
eth31500\
+edvdv\
"
@@ -433,7 +459,7 @@ expectpart "$(curl $CURLOPTS -X GET -H 'Accept: application/yang-data+json' $RCP
"HTTP/$HVER 200" \
"Content-Type: application/yang-data+json" \
"Cache-Control: no-cache" \
-'{"example:interfaces":{"interface":\[{"name":"eth0","mtu":8192,"status":"ok"},{"name":"eth1","mtu":1500,"status":"ok"},{"name":"eth2","mtu":9000,"status":"not feeling so good"},{"name":"eth3","mtu":1500,"status":"waking up"}\]}}'
+'{"example:interfaces":{"interface":\[{"name":"eth0","mtu":8192,"status":"ok"},{"name":"eth1","mtu":1500,"status":"ok"},{"name":"eth2","mtu":9000,"status":"not feeling so good"},{"name":"eth3","mtu":1500,"status":"waking up"}\],"cedv":{"edv":"edv"},"cdv":{"dv":"dv"}}}'
new "rfc8040 4.3. RESTCONF GET xml"
expectpart "$(curl $CURLOPTS -X GET -H 'Accept: application/yang-data+xml' $RCPROTO://localhost/restconf/data/example:interfaces)" \
@@ -441,7 +467,7 @@ expectpart "$(curl $CURLOPTS -X GET -H 'Accept: application/yang-data+xml' $RCPR
"HTTP/$HVER 200" \
"Content-Type: application/yang-data+xml" \
"Cache-Control: no-cache" \
-'eth08192oketh11500oketh29000not feeling so goodeth31500waking up'
+'eth08192oketh11500oketh29000not feeling so goodeth31500waking upedvdv'
new "rfc8040 B.3.9. RESTCONF with-defaults parameter = report-all json"
expectpart "$(curl $CURLOPTS -X GET -H 'Accept: application/yang-data+json' $RCPROTO://localhost/restconf/data/example:interfaces/interface=eth1?with-defaults=report-all)" \