expand_dbvar usage in clispec
Opened this issue · 1 comments
Hello team,
Have some issue with expand_dbvar usage in clispec file.
Does it support nested expansion when one list is located inside another?
If so what is the correct syntax for the path?
let's say we have the following simple yang
container C1 {
list L1 {
key name;
leaf name {
type string;
}
container C2{
list L2 {
key name;
leaf name {
type string;
}
}
}
}
}
And in the cli I'd like to get the second list name expansion and completion to work.
I've tried the following spec:
show {
container {
(<list1:string>("Show list1 name.")|<list1:string> expand_dbvar("running","/C1/L1=%s/name)>){
(<list2:string>("Show list2 name.")|<list2:string> expand_dbvar("running","/C1/L1[name='%s']/C2/L2=%s/name)>), some_callbak();
}
}
}
Also tried the following paths:
(<list2:string>("Show list2 name.")|<list2:string> expand_dbvar("running","/C1/L1=%s/name/C2/L2=%s/name)>)
and
(<list2:string>("Show list2 name.")|<list2:string> expand_dbvar("running","/C1/L1=%k/name/C2/L2=%s/name)>)
but no luck.
Why dont you use the autocli where these rules are already generated?
I put your YANG in clixon-example.yang, installed and started a backend and cli
# sudo clixon_backend -f /usr/local/etc/clixon/example.xml
# clixon_cli -f /usr/local/etc/clixon/example.xml
cli/> set C1 L1 a C2 L2 b
cli/> show auto C1 L1 ?
<cr>
a
<name>
cli/> show auto C1 L1 a C2 L2 ?
<cr>
b
<name>
cli />
If you want your own callback, you can add that in the clispec declaration:
show container {
@datamodelshow, some_callback();
}
where some_callback()
needs to have the following argument list:
* @param[in] h Clixon handle
* @param[in] cvv Vector of variables from CLIgen command-line
* @param[in] argv String vector of show options, format:
* <api_path_fmt> Generated API PATH (this is added implicitly, not actually given in argv)
* [<mt-point>] Optional YANG path-arg/xpath from mount-point
If you really want to make manual rules, you can look at the generated rule with the -G
option:
# clixon_cli -G1 -f /usr/local/etc/clixon/example.xml
C1,overwrite_me("/clixon-example:C1"), act-container;{
L1,overwrite_me("/clixon-example:C1/L1=%s"),act-list;
{
(<name:string>|<name:string expand_dbvar("candidate","/clixon-example:C1/L1=%s/name")>),overwrite_me("/clixon-example:C1/L1=%s/"), act-lastkey;{
C2,overwrite_me("/clixon-example:C1/L1=%s/C2"), act-container;{
L2,overwrite_me("/clixon-example:C1/L1=%s/C2/L2=%s"),act-list;{
(<name:string>|<name:string expand_dbvar("candidate","/clixon-example:C1/L1=%s/C2/L2=%s/name")>),overwrite_me("/clixon-example:C1/L1=%s/C2/L2=%s/"), act-lastkey;{
}
}
}
}
}
}
Then edit that to something you like, eg:
show container {
(<name:string>|<name:string expand_dbvar("candidate","/clixon-example:C1/L1=%s/name")>),cli_show_auto("/clixon-example:C1/L1=%s/", "running", "default", true, false, "report-all"){
(<name:string>|<name:string expand_dbvar("candidate","/clixon-example:C1/L1=%s/C2/L2=%s/name")>),overwrite_me("/clixon-example:C1/L1=%s/C2/L2=%s/"),cli_show_auto("/clixon-example:C1/L1=%s/", "running", "default", true, false, "report-all");
}
}