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

(CLI) the description of a used grouping is shown instead of the encapsulating container #124

Closed
itzik-solomon opened this issue Aug 5, 2020 · 5 comments
Labels

Comments

@itzik-solomon
Copy link

itzik-solomon commented Aug 5, 2020

CLI takes the description of a grouping even though the container has its own description.
example:

container a{
 uses group1;
 description "container desc";
}
grouping group1{
 description "group desc";
}

in this example, the description shown for container a should be "container desc", but instead "group desc" is shown.

also, swapping the lines inside the container will change the description shown to the expected "container desc".

@olofhagsand olofhagsand added the bug label Aug 5, 2020
@olofhagsand
Copy link
Member

Yes, I see this issue for the autocli. RFC 7950 is not explicit in this subject (see 5.5/7.12/7.13) and maybe the autocli is not really in scope of the RFC, ie how to genera CLI statements from YANG.
The only hints I see are in 7.12:

The effect of a "uses" reference to a grouping is that the nodes defined by the grouping are copied into the current schema tree,...

This is what the code does, it copies the nodes in the grouping into the uses statement. The effect for the autocli is that there are two descriptions, and their order determines which is shown (the two cases above).

The second hint the error in 7.13.4:

   leaf ip {          // illegal - same identifier "ip" used twice

which seems to indicate that you cannot have two identical nodes eg "leaf ip", in the two cases.

The easy way out here would therefore be to point at 7.13.4 and say that this is not allowed (and maybe add an error in the uses expansion code).

But I could see there being a benefit to have specialized descriptions for comments. In that case I assume that the principle of least surprise would be that you would use the more specialized description (if it exists), and to use the generalized description if there is no specific description.
For the example in the issue that would mean that "container desc" should be used in this case.

How does that sound?

@itzik-solomon
Copy link
Author

Totally agree, especially considering that one might have more than one grouping in a container and that all groupings and containers are advised to all have a description (RFC 8407 at 4.14).
also, 7950 RFC (section 6.4) says "The data tree has no concept of document order" which implies that the order of elements (like groupings) in a container should not have an effect. so assuming we allow for multiple descriptions, their order shouldn't affect the behavior.

@itzik-solomon
Copy link
Author

itzik-solomon commented Aug 16, 2020

regarding the case that a container doesn't have a description and there are multiple nested groupings with descriptions:
taking the first/last/random description out of multiple groupings' descriptions might have a counterproductive effect, so I think we should either display all of the descriptions or non at all.
So I think the only well-defined behaviors are the following:

  • no description at all
  • display all groupings' descriptions.
  • take a grouping's description only if it is the only description.

personally I am not a fan of taking a grouping's description as a description of a container unless the container only encapsulates a single grouping without any other node (e.g. no other leaves). As I see it, a grouping's description is meant to only describe the structure of that grouping.

@olofhagsand
Copy link
Member

olofhagsand commented Aug 19, 2020

That makes sense:

a grouping's description is meant to only describe the structure of that grouping.

Its also a simple solution, I will go with that, ie ignore the groupings description, do not copy it into the "uses" instance.

olofhagsand added a commit that referenced this issue Aug 19, 2020
@olofhagsand
Copy link
Member

Fixed:
Uses/group and augments only copies schemanodes. This means reference/description/.. etc are not copied, the original is kept. Also, as a side-effect of the bugfix, a final cardinality sanity check is now made after all yang modifications, not only at the time the file is loaded.
Please verify.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants