Subject: [netmod] tree diagrams - prefixes

From: Radek Krejčí <[email-masked]>
Date: Tue, 21 Mar 2017 14:32:52 +0100

Hi,

I have another note regarding the standardization of tree diagrams - the <prefix> is not clearly defined. pyang --tree-help says:

   <name> is the name of the node
    (<name>) means that the node is a choice node
   :(<name>) means that the node is a case node

   If the node is augmented into the tree from another module, its
   name is printed as <prefix>:<name>.

pyang uses the prefix value from the import statement in the module being printed. This approach can result in confusing output when e.g. module and its submodule import a) same module with different prefixes or b) different modules with a same prefix. However, not even use of the prefix defined in the module itself solve the issue. YANG has no requirement for the module prefixes, so they can repeat in different modules.

The solution I see here, and which is actually already used in JSON encoding of YANG modeled data, is using module names as prefixes. This approach is also implemented in yanglint (there was no standardization of the tree format, so as developers we have decided to slightly modify the format in comparison to what is printed by pyang). The price for the exactness is the width of the output - prefixes used to be shorter than the full module names.

Regards,
Radek

---

From: Robert Wilton <[email-masked]>
Date: Tue, 21 Mar 2017 13:52:46 +0000

Hi Radek,

I think that using the full module name might make the lines too long.

Perhaps the tree output could separately list the prefix to module 
mapping, and ensure that the prefix names are unique in the diagram 
(e.g. adding a number to the prefix name if it clashes).

Prefix to module map:
if -> ietf-interfaces
ip -> ietf-ip
ip2 -> ietf-ip @ 2017-03-21
...

where, if no revision number is specified then the import is for any 
revision.

Thanks,
Rob

On 21/03/2017 13:32, Radek Krejčí wrote:
> _______________________________________________
> netmod mailing list
> [email-masked]
> https://www.ietf.org/mailman/listinfo/netmod
> .
>