Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clixon CLI issue: when I try to print the value of the leaf node nothing appeared #345

Closed
vvsosed opened this issue Jul 21, 2022 · 11 comments

Comments

@vvsosed
Copy link
Contributor

vvsosed commented Jul 21, 2022

I used command CLI command "show system name" . "name" is the nested leaf value in the "system" container node. The right output should be in my case
MH-T280@00000000>show system name
name 00000000;
MH-T280@00000000>
but I got nothing.

If I try to print the whole container it did fine:
MH-T280@00000000>show system
radio-bridge-tg-system:system {
name 00000000;
reboot-needed false;
control {
soft-watchdog-enabled true;
}
state {
product MH-T280;
<.... other output>

I also enabled detailed logs in clixon_backend app and found log strings that can be considered RPC i/o between CLI client and clixon_backend:

clicon_msg_decode <nc:filter nc:type="xpath" nc:select="/rb-tg-sys:system/rb-tg-sys:name" xmlns:rb-tg-sys="http://siklu.com/yang/tg/system"/>
<..... a lot of other output>
from_client_msg cbret:00000000](http://siklu.com/yang/tg/system%22%3E%3Cname%3E00000000%3C/name%3E%3C/system%3E%3C/data%3E%3C/rpc-reply%3E)

Based on this I supposes that maybe CLI client receives valid RPC response but not display it properly.

Also, I've found that this issue appeared after Changed C-API for xml translation/print the internal cxobj tree data structure to other formats commit.

@olofhagsand
Copy link
Member

Cannot recreate it, need some more info.

  1. please try and see if the issue remains after the fix of "autocli:hide-show" extension cause bug in xmldb_put method #343 ? Since that fix changed the print C-API slightly.
  2. Otherwise, can you provide the sub-part of the YANG of system/name as well as the CLI command with which you print system/name?

@vvsosed
Copy link
Contributor Author

vvsosed commented Jul 25, 2022

  1. The Issue still remains after the autocli:hide-show fix
  2. This is the YANG datamodel example at which I can observe the problem

module issue-example {
yang-version "1";

// namespace
namespace 'http://example.com/ns/issue';

revision 2022-07-25 {
    description
      "Initial revision";
    reference
      "TBD";
}

grouping system-group {
    container system {
        leaf name {
            type string;
        }
        leaf location {
            type string;
        }
    }
}

uses system-group;

}

so when I type in cli console "show system" I see output like

name SomeName
location SomeLocation

but when I type command "show system name" I don't see any output

@vvsosed
Copy link
Contributor Author

vvsosed commented Jul 26, 2022

I was able to fix the issue by editing if (clixon_txt2file(stdout, xp, 0, cligen_output, 1, 1) < 0). When I define skiptop = 0 instead of 1 in the call (i.e. if (clixon_txt2file(stdout, xp, 0, cligen_output, 0, 1)), the issue dissapears.

@olofhagsand
Copy link
Member

Ok, in which file/function? Is this a patch that should be committed?

@vvsosed vvsosed closed this as completed Jul 26, 2022
@vvsosed vvsosed reopened this Jul 26, 2022
@olofhagsand
Copy link
Member

I am still curious on some details on this.
In my system using cli_show_auto() I get:

olof@alarik /> show auto system     
<system xmlns="urn:example:clixon">
   <name>foo</name>
   <location>hej</location>
</system>
olof@alarik /> show auto system name 
CLI syntax error: "show auto system name": Incomplete command
olof@alarik /> show auto system name foo 
<name>foo</name>

If I interpret your issue report correctly, you want to do:

olof@alarik /> show auto system name 
   <name>foo</name>
olof@alarik /> 

is that correct?
I suspect you have some other autocli setting, I remember this requirement from you earlier.

@olofhagsand
Copy link
Member

I see you probably use show @datamodelshow as defined in
https://clixon-docs.readthedocs.io/en/latest/cli.html#tree-expansion

@olofhagsand
Copy link
Member

OK, recreated it with @datamodelshow and text format.
Patch submitted, also for JSON output.
Please verify patch.

@vvsosed
Copy link
Contributor Author

vvsosed commented Jul 26, 2022

Thanks a lot for the patch. I have verified - the issue was fixed.

In our *.cli file, we are using @datamodelstate. As I am understanding this is the same as @datamodelshow but with the state. So, your assumption was right.

I also have yet one question. I typed "show system" to print "system" container and received the output

MH-T280@qwweerty>show system
radio-bridge-tg-system:system {
name qwweerty;
reboot-needed false;
location MyLocation;
...
}
MH-T280@qwweerty>

Here "radio-bridge-tg-system" is the module name. The problem is that our current CLI, that based on the old version of the clixon library, returns a value without a module name prefix. So my question is which variant right? Is it possible to enable or disable the appearance of the "prefix" by a configuration for consistency with previous behaviour?

@olofhagsand
Copy link
Member

OK, I can add a compile-time option TEXT_SYNTAX_NOPREFIX for backward compatible.

@olofhagsand
Copy link
Member

Problem is it may not be parseable.
The reason for adding the prefix was to make it parseable for top-levels and augments.
I assume this is OK for you since you only use it for showing syntax?
BTW, this is a separate issue, it would be great if you could close this issue if verified and continue this discussion in a separate issue thread, or slack.

olofhagsand added a commit that referenced this issue Jul 26, 2022
…compile-time option `TEXT_SYNTAX_NOPREFIX`

See #345
@olofhagsand
Copy link
Member

See patch regarding backward-compatible text format output

@vvsosed vvsosed closed this as completed Jul 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants