02-02-2024 02:07 AM - edited 02-02-2024 03:30 AM
I have a container and inside there is one action leaf which has 3 enums.
container container_name {
leaf action {
type enumeration {
enum key1;
enum key2;
enum key3;
}
default key2;
}
leaf leaf_name {
when "../action = 'key1'";
default 10;
}
In nso cli, after writing
container_name key1 ?
it shows
Possible completions:
key2
key3
<cr>
I want to disable possible combinations after i put container_name key1 10 and nothing should be followed after this cli
which is wrong , it should only accept one enum at the same time. Is it possible to modify behavior of this autocompletion from my yang models?
02-02-2024 02:19 AM
An example
leaf my-enum{ type enumeration { enum single{value 1;} enum dual{value 2;} } }
02-02-2024 03:28 AM - edited 02-02-2024 03:30 AM
I get error: unterminated statement for keyword "value"
I dont think it is what i want. I want to disable possible combinations after i put container_name key1 10 and nothing should be followed after this cli
02-02-2024 05:02 AM
That yang snippet you show do render the commands as you show. Where does the action token go in your illustration? Does it have a drop-node-name extension in module?
What you show in the yang module render the commands as:
# container_name ?
Possible completions:
action
# container_name action ?
Possible completions:
key1 key2 key3
# container_name action key1 ?
Possible completions:
leaf_name <cr>
# container_name action key1 leaf_name ?
Possible completions:
<int>[10]
Maybe you simplified the yang snippet when you shared it? Anyhow I don't think the commands that you are illustrating is consistent with the yang snippet.
If you describe how you want each token to render and also show what you expect to see on "show running-config.." for this config i can probably suggest you a way on how the model needs look like.
02-07-2024 02:34 AM
Hi,
As it was said by others, your ask is not really clear. What you may be looking for is adding a must statement which would limit the possible completions in the second leaf like this example (you can use any Xpath1.0 expression). There are other NSO features like validation callbacks and policies that could be applied too.
leaf action {
type enumeration {
enum key1;
enum key2;
}
default key2;
}
leaf leaf_name {
when "../action = 'key1'";
type uint16;
default 10;
must "(../action='key1' and current()<20) or (../action='key2' and current()>8)";
}
which ends up with a result solution:
admin@ncs% set action key1
[ok][2024-02-07 11:29:48]
[edit]
admin@ncs% set leaf_name 14
[ok][2024-02-07 11:29:56]
[edit]
admin@ncs% validate
Validation complete
[ok][2024-02-07 11:29:58]
[edit]
admin@ncs% set leaf_name 35
[ok][2024-02-07 11:30:01]
[edit]
admin@ncs% validate
Failed: 'leaf_name' (value "35"): the 'must' expression "(../action='key1' and current()<20) or (../action='key2' and current()>8)" failed
[error][2024-02-07 11:30:04]
[edit]
admin@ncs%
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide