Closed shmuelnatan closed 2 years ago
After some investigation, it turns out this occurs also for other leafs, not just keys in the autocli, and was introduced in Clixon 5.4. This means it worked in 5.3 but is broken in 5.4 and 5.5 See also https://github.com/clicon/cligen/issues/73 with the same problem for included tree references
I checked it in our systems and the auto cli works but for some reason when I commit anything with the list that contains the union with the enumeration, the clixon doesn't show it to me in a show command
Yes, I see I can set it once, but not a second time, from test_cli_union.sh:
olof@alarik /> set tablekey parkey u1 <?>
<cr>
value
olof@alarik /> set tablekey parkey u1 <cr>
olof@alarik /> set tablekey parkey u1 <?>
<cr>
# <--- No value option
also at commit
New fixes. Can you please verify again?
I checked it in our systems and the auto cli works but for some reason when I commit anything with the list that contains the union with the enumeration, the clixon doesn't show it to me in a show command
I still have the same problem. I'll give an example with the example in the bug
cli> set modules module enum-foo1 content boo
cli> commit
cli> show modules module
cli>
I'm expecting to see the saved value but it doesn't appear in the database after a commit
I cannot recreate it. See testcase : https://github.com/clicon/clixon/blob/4631b02e0065c7e3aadaccd6a88219d70c26732d/test/test_cli_union.sh#L150 where a union key is set and committed and shows up in show config. Can you please check the testcase and see how your example is diffferent?
I cannot recreate it. See testcase :
where a union key is set and committed and shows up in show config. Can you please check the testcase and see how your example is diffferent?
There are two problems I noticed with your fix:
config false
). Setting this field does nothing but nevertheless, this field shouldn't appear in autocompletion.uses ModuleB:foo
and foo is a list (I checked this by lists). When one tries to set foo
the cli thinks that foo has the namespace of ModuleA which results in an error since foo isn't described in ModuleB.
- In autocompletion with a set command you can get a field that is in state data (i.e., config false). Setting this field does nothing but nevertheless, this field shouldn't appear in autocompletion.
I cannot recreate. I tried with eg:
container tablekey{
list parkey{
description "key is union type";
key name;
leaf name{
type uniontype;
}
leaf value{
type string;
}
leaf stat{
config false;
type int32;
}
}
but no state variable
olof@alarik /> set tablekey parkey u2 ?
<cr>
value
olof@alarik /> set tablekey parkey u2
Please provide an example where this happens, eg, what does the the yang look like and in what way is the state completion shown?
- A problem I encountered is when we have two modules each one with a different namespace. Module A has uses ModuleB:foo and foo is a list (I checked this by lists). When one tries to set foo the cli thinks that foo has the namespace of ModuleA which results in an error since foo isn't described in ModuleB.
This sounds like a separate issue? There is an issue with same symbols in different namespaces since prefixes have not been introduced in the auto-cli yet. Some preparations have been made though. Can you please make this issue as a concrete usecase and file a separate issue?
Regarding the state data, it seems like it's connected to the previous namespace issue. Here are examples of the two modules.
module A {
namespace "http://A";
grouping GroupA {
container ContainerA{
config false;
list ListA{
key name;
leaf name{
type string;
}
leaf value{
type string;
}
}
}
}
}
module B {
namespace "http://B";
import A {
prefix "MA";
}
container ContainerB1{
leaf foo {
type string;
}
container ContainerB2{
config false;
uses MA:GroupA;
}
}
The auto cli allows to write the following command
cli> set ContainerB1 ContainerB2 ContainerA ListA boo value boo
I know that this behavior did not happen in the 5.2 version
I take it #2 is moved to https://github.com/clicon/clixon/issues/309? (Plz remove it from here.) Is #1 still an issue?
Regarding the initial bug https://github.com/clicon/clixon/issues/301#issue-1127635911, I noticed that with your fix (i.e., cligen 5.6.0) I get an error when I want to set a module that is not an enumeration.
typedef union-type {
type union {
type enumeration {
enum enum-foo1 {
}
}
type string {
}
}
}
list modules {
leaf "module" {
type union-type;
}
key "module";
leaf content{
type string;
}
}
cli> set modules enum-foo1 content foo1
cli> commit
cli> set modules boo content boo
cli> commit
Mar 15 00:00:02: Commit failed. Edit and try again or discard changes: application operation-failed Module boo is unknown
CLI command error
But since the key of the list is a union, then it should allow other values that are not enumerations.
Cannot recreate:
olof@alarik> clixon_cli -f /usr/local/etc/example.xml
olof@alarik /> set modules enum-foo1 content foo1
olof@alarik /> commit
olof@alarik /> set modules boo content boo
olof@alarik /> commit
olof@alarik /> show configuration xml
<modules xmlns="urn:example:clixon">
<module>boo</module>
<content>boo</content>
</modules>
<modules xmlns="urn:example:clixon">
<module>enum-foo1</module>
<content>foo1</content>
</modules>
olof@alarik />
Cannot recreate, please reopen and add new info if you still consider it an issue
I noticed the following behavior. Let's say I have the following union that contains an enum and some other type (in this case a string), and the union is used as key in a list.
Then I set a node in the list with an enum key (and commit I it)
set modules module enum-foo1 content foo
I then try to change the value ofcontent
but the autocompletion ofcontent
disappears. It only returns if I delete the node using enum-foo1 as the key and reset it.This phenomenon only happens to enumerations in unions that are used as keys.