Fixed a cornercase of RFC 7950 Sec 7.9, a choice witout case with sub-containers
This commit is contained in:
parent
5bd64712c7
commit
3a336838f7
3 changed files with 52 additions and 7 deletions
|
|
@ -17,6 +17,6 @@ Clixon has a master branch continuously tested with CI, but releases are made ca
|
||||||
|
|
||||||
Clixon interaction is best done posting issues, pull requests, or joining the
|
Clixon interaction is best done posting issues, pull requests, or joining the
|
||||||
[slack channel](https://clixondev.slack.com).
|
[slack channel](https://clixondev.slack.com).
|
||||||
[Slack invite](https://join.slack.com/t/clixondev/shared_invite/zt-14apfsdlt-U8y5TX_VX7oP99wKKvTScQ)(updated 23/2 2022)
|
[Slack invite](https://join.slack.com/t/clixondev/shared_invite/zt-191czm376-kWvI3tyDdqDU86DlfbLRxg)(updated 16/5 2022)
|
||||||
|
|
||||||
Clixon is sponsored by [Rubicon Communications LLC(Netgate)](https://www.netgate.com/)
|
Clixon is sponsored by [Rubicon Communications LLC(Netgate)](https://www.netgate.com/)
|
||||||
|
|
|
||||||
|
|
@ -297,6 +297,7 @@ check_delete_existing_case(cxobj *x0,
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
yang_stmt *yp;
|
yang_stmt *yp;
|
||||||
|
yang_stmt *y0p;
|
||||||
yang_stmt *y0case;
|
yang_stmt *y0case;
|
||||||
yang_stmt *y1case;
|
yang_stmt *y1case;
|
||||||
yang_stmt *y0choice;
|
yang_stmt *y0choice;
|
||||||
|
|
@ -317,28 +318,30 @@ check_delete_existing_case(cxobj *x0,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
goto ok;
|
goto ok;
|
||||||
|
/* Now traverse existing tree and compare with choice yang structure of added tree */
|
||||||
x0prev = NULL;
|
x0prev = NULL;
|
||||||
x0c = NULL;
|
x0c = NULL;
|
||||||
while ((x0c = xml_child_each(x0, x0c, CX_ELMNT)) != NULL) {
|
while ((x0c = xml_child_each(x0, x0c, CX_ELMNT)) != NULL) {
|
||||||
if ((y0c = xml_spec(x0c)) == NULL ||
|
if ((y0c = xml_spec(x0c)) == NULL ||
|
||||||
(yp = yang_parent_get(y0c)) == NULL){
|
yang_parent_get(y0c) == NULL){
|
||||||
x0prev = x0c;
|
x0prev = x0c;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (yang_keyword_get(yp) == Y_CASE){
|
y0p = yang_parent_get(y0c);
|
||||||
y0case = yp;
|
if (yang_keyword_get(y0p) == Y_CASE){
|
||||||
|
y0case = y0p;
|
||||||
y0choice = yang_parent_get(y0case);
|
y0choice = yang_parent_get(y0case);
|
||||||
}
|
}
|
||||||
else if (yang_keyword_get(yp) == Y_CHOICE){
|
else if (yang_keyword_get(y0p) == Y_CHOICE){
|
||||||
y0case = NULL;
|
y0case = NULL;
|
||||||
y0choice = yp;
|
y0choice = y0p;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
x0prev = x0c;
|
x0prev = x0c;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (y0choice == y1choice){
|
if (y0choice == y1choice){
|
||||||
if (y0case == NULL ||
|
if ((y0case == NULL && y0c != y1c) ||
|
||||||
y0case != y1case){
|
y0case != y1case){
|
||||||
if (xml_purge(x0c) < 0)
|
if (xml_purge(x0c) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
|
||||||
|
|
@ -106,6 +106,25 @@ module system{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* Choice shorthand with sub-container */
|
||||||
|
container choice-subcontainer {
|
||||||
|
presence true;
|
||||||
|
choice name {
|
||||||
|
container udp {
|
||||||
|
leaf udp1{
|
||||||
|
type string;
|
||||||
|
}
|
||||||
|
leaf udp2{
|
||||||
|
type string;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
container tcp {
|
||||||
|
leaf tcp1{
|
||||||
|
type string;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
@ -335,6 +354,29 @@ expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS>
|
||||||
new "netconf validate ok"
|
new "netconf validate ok"
|
||||||
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><validate><source><candidate/></source></validate></rpc>" "" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>"
|
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><validate><source><candidate/></source></validate></rpc>" "" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>"
|
||||||
|
|
||||||
|
new "netconf discard-changes"
|
||||||
|
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><discard-changes/></rpc>" "" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>"
|
||||||
|
|
||||||
|
# Merge in choice-subcontainer
|
||||||
|
new "netconf choice sub-container 1st leaf"
|
||||||
|
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config><system xmlns=\"urn:example:config\" nc:operation=\"replace\" xmlns:nc=\"$BASENS\">
|
||||||
|
<choice-subcontainer><udp><udp1>42</udp1></udp></choice-subcontainer>
|
||||||
|
</system></config></edit-config></rpc>" "" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>"
|
||||||
|
|
||||||
|
new "netconf choice sub-container 2nd leaf (dont remove 1st)"
|
||||||
|
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config><system xmlns=\"urn:example:config\" xmlns:nc=\"$BASENS\">
|
||||||
|
<choice-subcontainer><udp><udp2 nc:operation=\"replace\">99</udp2></udp></choice-subcontainer>
|
||||||
|
</system></config></edit-config></rpc>" "" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>"
|
||||||
|
|
||||||
|
new "netconf get both items"
|
||||||
|
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><get-config><source><candidate/></source></get-config></rpc>" "<rpc-reply $DEFAULTNS><data><system xmlns=\"urn:example:config\"><choice-subcontainer><udp><udp1>42</udp1><udp2>99</udp2></udp></choice-subcontainer></system></data></rpc-reply>" ""
|
||||||
|
|
||||||
|
new "netconf validate ok"
|
||||||
|
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><validate><source><candidate/></source></validate></rpc>" "" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>"
|
||||||
|
|
||||||
|
new "netconf discard-changes"
|
||||||
|
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><discard-changes/></rpc>" "" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>"
|
||||||
|
|
||||||
if [ $RC -ne 0 ]; then
|
if [ $RC -ne 0 ]; then
|
||||||
new "Kill restconf daemon"
|
new "Kill restconf daemon"
|
||||||
stop_restconf
|
stop_restconf
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue