remove containers holding only default values
This commit is contained in:
parent
38f501be19
commit
42d5b6fba2
2 changed files with 36 additions and 6 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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="<interfaces $EXAMPLENS>\
|
|||
<interface><name>eth1</name></interface>\
|
||||
<interface><name>eth2</name><mtu>9000</mtu></interface>\
|
||||
<interface><name>eth3</name><mtu>1500</mtu></interface>\
|
||||
<cedv><edv>edv</edv></cedv>\
|
||||
</interfaces>"
|
||||
|
||||
cat <<EOF > $fstate
|
||||
|
|
@ -184,6 +201,7 @@ expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" \
|
|||
<interface><name>eth1</name><mtu>1500</mtu><status>ok</status></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>\
|
||||
<cedv><edv>edv</edv></cedv><cdv><dv>dv</dv></cdv>\
|
||||
</interfaces></data></rpc-reply>"
|
||||
|
||||
new "rfc6243 3.2. 'trim' Retrieval Mode"
|
||||
|
|
@ -208,6 +226,7 @@ expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" \
|
|||
<interface><name>eth1</name><status>ok</status></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>\
|
||||
<cedv><edv>edv</edv></cedv>\
|
||||
</interfaces></data></rpc-reply>"
|
||||
|
||||
new "rfc6243 3.4. 'report-all-tagged' Retrieval Mode"
|
||||
|
|
@ -220,6 +239,7 @@ expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" \
|
|||
<interface><name>eth1</name><mtu wd:default=\"true\">1500</mtu><status wd:default=\"true\">ok</status></interface>\
|
||||
<interface><name>eth2</name><mtu>9000</mtu><status>not feeling so good</status></interface>\
|
||||
<interface><name>eth3</name><mtu wd:default=\"true\">1500</mtu><status>waking up</status></interface>\
|
||||
<cedv><edv wd:default=\"true\">edv</edv></cedv><cdv><dv wd:default=\"true\">dv</dv></cdv>\
|
||||
</interfaces></data></rpc-reply>"
|
||||
|
||||
new "rfc6243 2.3.1. 'explicit' Basic Mode Retrieval"
|
||||
|
|
@ -230,6 +250,7 @@ expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" \
|
|||
<interface><name>eth1</name><mtu>1500</mtu><status>ok</status></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>\
|
||||
<cedv><edv>edv</edv></cedv><cdv><dv>dv</dv></cdv>\
|
||||
</interfaces></data></rpc-reply>" ""
|
||||
|
||||
new "rfc6243 2.3.3. 'explicit' <edit-config> and <copy-config> Behavior (part 1): create explicit node"
|
||||
|
|
@ -262,6 +283,7 @@ expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" \
|
|||
<interface><name>eth1</name><mtu>1500</mtu><status>ok</status></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>\
|
||||
<cedv><edv>edv</edv></cedv><cdv><dv>dv</dv></cdv>\
|
||||
</interfaces></data></rpc-reply>" ""
|
||||
|
||||
new "rfc6243 2.3.3. 'explicit' <edit-config> and <copy-config> Behavior (part 2): create default node"
|
||||
|
|
@ -290,6 +312,7 @@ expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" \
|
|||
<interface><name>eth1</name><mtu>3000</mtu><status>ok</status></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>\
|
||||
<cedv><edv>edv</edv></cedv><cdv><dv>dv</dv></cdv>\
|
||||
</interfaces></data></rpc-reply>" ""
|
||||
|
||||
new "rfc6243 2.3.3. 'explicit' <edit-config> and <copy-config> Behavior (part 3): delete explicit node"
|
||||
|
|
@ -318,6 +341,7 @@ expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" \
|
|||
<interface><name>eth1</name><mtu>1500</mtu><status>ok</status></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>\
|
||||
<cedv><edv>edv</edv></cedv><cdv><dv>dv</dv></cdv>\
|
||||
</interfaces></data></rpc-reply>" ""
|
||||
|
||||
new "rfc6243 2.3.3. 'explicit' <edit-config> and <copy-config> Behavior (part 4): delete default node"
|
||||
|
|
@ -351,6 +375,7 @@ expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" \
|
|||
<interface><name>eth1</name><mtu>1500</mtu><status>ok</status></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>\
|
||||
<cedv><edv>edv</edv></cedv><cdv><dv>dv</dv></cdv>\
|
||||
</interfaces></data></rpc-reply>" ""
|
||||
|
||||
new "Pagination"
|
||||
|
|
@ -424,6 +449,7 @@ expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" \
|
|||
<interface><name>eth1</name><mtu wd:default=\"true\">1500</mtu></interface>\
|
||||
<interface><name>eth2</name><mtu>9000</mtu></interface>\
|
||||
<interface><name>eth3</name><mtu wd:default=\"true\">1500</mtu></interface>\
|
||||
<cedv><edv wd:default=\"true\">edv</edv></cedv><cdv><dv wd:default=\"true\">dv</dv></cdv>\
|
||||
</interfaces></data></rpc-reply>"
|
||||
|
||||
|
||||
|
|
@ -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" \
|
||||
'<interfaces xmlns="http://example.com/ns/interfaces"><interface><name>eth0</name><mtu>8192</mtu><status>ok</status></interface><interface><name>eth1</name><mtu>1500</mtu><status>ok</status></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>'
|
||||
'<interfaces xmlns="http://example.com/ns/interfaces"><interface><name>eth0</name><mtu>8192</mtu><status>ok</status></interface><interface><name>eth1</name><mtu>1500</mtu><status>ok</status></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><cedv><edv>edv</edv></cedv><cdv><dv>dv</dv></cdv></interfaces>'
|
||||
|
||||
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)" \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue