Fixed [Wrong yang-generated cli code for typeref identityref combination #88](https://github.com/clicon/clixon/issues/88)

This commit is contained in:
Olof hagsand 2019-06-20 19:00:22 +02:00
parent fe35e181fd
commit d12644a5ef
3 changed files with 21 additions and 4 deletions

View file

@ -251,6 +251,7 @@
### Corrected Bugs ### Corrected Bugs
* Fixed [Wrong yang-generated cli code for typeref identityref combination #88](https://github.com/clicon/clixon/issues/88)
* Fixed [identityref validation fails when using typedef #87](https://github.com/clicon/clixon/issues/87) * Fixed [identityref validation fails when using typedef #87](https://github.com/clicon/clixon/issues/87)
* Fixed a problem with some netconf error messages caused restconf daemon to exit due to no XML encoding * Fixed a problem with some netconf error messages caused restconf daemon to exit due to no XML encoding
* Check cligen tab mode, dont start if CLICON_CLI_TAB_MODE is undefined * Check cligen tab mode, dont start if CLICON_CLI_TAB_MODE is undefined

View file

@ -185,14 +185,15 @@ yang2cli_var_identityref(yang_stmt *ys,
char *name; char *name;
char *id; char *id;
int i; int i;
int len;
/* Add a wildchar string first -let validate take it for default prefix */
cprintf(cb, ">");
if (helptext)
cprintf(cb, "(\"%s\")", helptext);
if ((ybaseref = yang_find(ytype, Y_BASE, NULL)) != NULL && if ((ybaseref = yang_find(ytype, Y_BASE, NULL)) != NULL &&
(ybaseid = yang_find_identity(ys, yang_argument_get(ybaseref))) != NULL){ (ybaseid = yang_find_identity(ys, yang_argument_get(ybaseref))) != NULL){
if (cvec_len(yang_cvec_get(ybaseid)) > 0){ if (cvec_len(yang_cvec_get(ybaseid)) > 0){
/* Add a wildchar string first -let validate take it for default prefix */
cprintf(cb, ">");
if (helptext)
cprintf(cb, "(\"%s\")", helptext);
cprintf(cb, "|<%s:%s choice:", yang_argument_get(ys), cvtypestr); cprintf(cb, "|<%s:%s choice:", yang_argument_get(ys), cvtypestr);
i = 0; i = 0;
while ((cv = cvec_each(yang_cvec_get(ybaseid), cv)) != NULL){ while ((cv = cvec_each(yang_cvec_get(ybaseid), cv)) != NULL){

View file

@ -130,6 +130,12 @@ cat <<EOF > $fyang
} }
} }
} }
identity empty; /* some errors with an empty identity set */
leaf e {
type identityref {
base mc:empty;
}
}
} }
EOF EOF
@ -237,6 +243,15 @@ expectfn "$clixon_cli -1 -f $cfg -l o set acls acl x type undefined" 0 "^$"
new "cli validate" new "cli validate"
expectfn "$clixon_cli -1 -f $cfg -l o validate" 255 "Identityref validation failed" expectfn "$clixon_cli -1 -f $cfg -l o validate" 255 "Identityref validation failed"
# test empty identityref list
new "cli set empty"
expectfn "$clixon_cli -1 -f $cfg -l o set e undefined" 0 "^$"
new "cli validate"
expectfn "$clixon_cli -1 -f $cfg -l o validate" 255 "Identityref validation failed"
new "netconf discard-changes"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc><discard-changes/></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
if [ $BE -eq 0 ]; then if [ $BE -eq 0 ]; then
exit # BE exit # BE