Fixed: [cl:autocli-op hide has no effect in yang submodule](https://github.com/clicon/clixon/issues/282)

This commit is contained in:
Olof hagsand 2021-11-04 16:22:27 +01:00
parent d335a72659
commit 5297ebe3cb
4 changed files with 73 additions and 4 deletions

View file

@ -82,6 +82,7 @@ Developers may need to change their code
### Corrected Bugs
* [cl:autocli-op hide has no effect in yang submodule](https://github.com/clicon/clixon/issues/282)
* [Doxygen - Typo in Input #275](https://github.com/clicon/clixon/issues/275)
## 5.3.0

View file

@ -2355,6 +2355,14 @@ ys_populate_unique(clicon_handle h,
* RFC 7950 Sec 7.19:
* If no "argument" statement is present, the keyword expects no argument when
* it is used.
* Note there is some complexity in different yang modules with unknown-statements.
* y0) The location of the extension definition. E.g. extension autocli-op
* y1) The location of the unknown-statement (ys). This is for example: cl:autocli-op hide.
* Lookup of "cl" is lexically scoped in this context (to find (y0)).
* y2) The unknown statement may be used by uses/grouping of (y1). But "cl" is declared
* in y1 context. This is fixed by setting ys_mymodule to y1 which is then used in
* lookups such as in yang_extension_value().
* @see yang_extension_value Called on expanded YANG, eg in context of (y2)
*/
static int
ys_populate_unknown(clicon_handle h,
@ -2376,6 +2384,8 @@ ys_populate_unknown(clicon_handle h,
clicon_err(OE_YANG, ENOENT, "Extension \"%s:%s\", module not found", prefix, id);
goto done;
}
/* To find right binding eg after grouping/uses */
ys->ys_mymodule = ys_module(ys);
if ((yext = yang_find(ymod, Y_EXTENSION, id)) == NULL){
clicon_err(OE_YANG, ENOENT, "Extension \"%s:%s\" not found", prefix, id);
goto done;
@ -3572,6 +3582,7 @@ yang_anydata_add(yang_stmt *yp,
* // use extension value
* }
* @endcode
* @see ys_populate_unknown Called when parsing YANGo
*/
int
yang_extension_value(yang_stmt *ys,

View file

@ -71,9 +71,13 @@ struct yang_stmt{
char *ys_argument; /* String / argument depending on keyword */
uint16_t ys_flags; /* Flags according to YANG_FLAG_MARK and others */
yang_stmt *ys_mymodule; /* Shortcut to "my" module. Augmented
nodes can belong to other
modules than the ancestor module */
yang_stmt *ys_mymodule; /* Shortcut to "my" module. Used by:
1) Augmented nodes "belong" to the module where the
augment is declared, which may be differnt from
the direct ancestor module
2) Unknown nodes "belong" to where the extension is
declared
*/
cg_var *ys_cv; /* cligen variable. See ys_populate()
Following stmts have cv:s:
leaf: for default value

View file

@ -136,7 +136,6 @@ wait_backend
function testparam()
{
# Try hidden parameter list
new "query table parameter hidden"
expectpart "$(echo "set table ?" | $clixon_cli -f $cfg 2>&1)" 0 "set table" "<cr>" --not-- "parameter"
@ -282,6 +281,60 @@ EOF
new "Test hidden parameter in table/param/value augment"
testvalue
# Example using imported module where clixon-lib is NOT declared in main module
# see discussion in ys_populate_unknown (y1 vs y2) and
# https://github.com/clicon/clixon/issues/282
cat <<EOF > $fyang
module example {
yang-version 1.1;
namespace "urn:example:clixon";
prefix ex;
import example-augment{
prefix aug;
}
container table{
list parameter{
key name;
leaf name{
type string;
}
uses aug:pg;
}
}
}
EOF
# Use this as grouping (not annotate)
cat <<EOF > $fyang2
module example-augment {
namespace "urn:example:augment";
prefix aug;
import clixon-lib{
prefix cl;
}
grouping pg {
cl:autocli-op hide; /* This is the extension */
leaf value{
description "a value";
type string;
}
list index{
key i;
leaf i{
type string;
}
leaf iv{
type string;
}
}
}
}
EOF
new "Test hidden parameter in imported module"
testparam
new "Kill backend"
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)