CESNET / libyang

YANG data modeling language library
BSD 3-Clause "New" or "Revised" License
368 stars 291 forks source link

yanglint print tree of augment-module does NOT work #24

Closed classcwnd closed 8 years ago

classcwnd commented 8 years ago

I added some modules and found the model tree of augment module can not be printed out. Is this normal? I am afraid that the augment models are not added successfully. The models.tar was uploaded in #22
Following are the log of my steps. ietf-interfaces & ericsson-contexts-ipos are main models, and ericsson-context-ipos & ericsson-interfaces-ext-ipos are augment models.

(gdb) r
Starting program: /project/swbuild82/eyyuppg/libnetconf/integration/new4/netopeer/libyang/build/yanglint 
[Thread debugging using libthread_db enabled]
> add ietf-interfaces@2014-05-08.yin
> add iana-if-type.yin
> add ericsson-contexts-ipos@2015-12-07.yin
> add ericsson-context-ipos@2015-12-07.yin
> add ericsson-interfaces-ext-ipos@2015-12-07.yin
> print -f tree ericsson-contexts-ipos
module: ericsson-contexts-ipos
   +--rw contexts
   |  +--rw service
   |  |  +--rw multiple-contexts?       boolean <true>
   |  |  +--rw inter-context-routing?   empty
   |  |  +--rw load-balance
   |  |     +--rw ip
   |  |     |  +--rw (ip)?
   |  |     |     +--:(layer-3)
   |  |     |     |  +--rw layer-3?       empty
   |  |     |     +--:(layer-4)
   |  |     |     |  +--rw layer-4?       empty
   |  |     |     +--:(source-only)
   |  |     |        +--rw source-only?   empty
   |  |     +--rw link-group
   |  |        +--rw (link-group)?
   |  |           +--:(layer-3)
   |  |           |  +--rw layer-3?       empty
   |  |           +--:(layer-4)
   |  |           |  +--rw layer-4?       empty
   |  |           +--:(source-only)
   |  |              +--rw source-only?   empty
   |  +--rw system!
   |  |  +--rw lacp
   |  |     +--rw priority?   uint16
   |  |     +--rw mac-addr?   ietf-yang-types:mac-address
   |  +--rw ctxipos:context* [context-name]
   |  |  +--rw ctxipos:context-name     string
   |  |  +--rw ctxipos:vpn-rd?          string
   |  |  +--rw ctxipos:ippm!
   |  |  |  +--rw ctxipos:twamp-light
   |  |  +--rw ctxipos:description?     string
   |  |  +--rw ctxipos:subscriber
   |  |  |  +--rw ctxipos:name* [name]
   |  |  |  |  +--rw ctxipos:name              string
   |  |  |  |  +--rw ctxipos:ipv6!
   |  |  |  |  |  +--rw ctxipos:nd-profile    string
   |  |  |  |  +--rw ctxipos:forward-policy!
   |  |  |  |     +--rw ctxipos:pol-name    string
   |  |  |  |     +--rw ctxipos:in          empty
   |  |  |  +--rw ctxipos:profile* [profile]
   |  |  |     +--rw ctxipos:profile           string
   |  |  |     +--rw ctxipos:ipv6!
   |  |  |     |  +--rw ctxipos:nd-profile    string
   |  |  |     +--rw ctxipos:forward-policy!
   |  |  |        +--rw ctxipos:pol-name    string
   |  |  |        +--rw ctxipos:in          empty
   |  |  +--rw ctxipos:route-map* [route-map]
   |  |  |  +--rw ctxipos:route-map      string
   |  |  |  +--rw ctxipos:description?   string
   |  |  +--rw ctxipos:router
   |  |  |  +--rw ctxipos:msdp?              empty
   |  |  +--rw ctxipos:ospf3-maximum!
   |  |  |  +--rw (ctxipos:ospf3-maximum)?
   |  |  |     +--:(ctxipos:paths)
   |  |  |     |  +--rw ctxipos:paths?               uint8
   |  |  |     +--:(ctxipos:neighbor-exchange)
   |  |  |        +--rw ctxipos:neighbor-exchange?   uint32
   |  |  +--rw ctxipos:ip
   |  |  +--rw ctxipos:ipv6
   |  +--rw ctxipos:dot1q* [profile]
   |     +--rw ctxipos:profile        string
   |     +--rw ctxipos:description?   string
   +--ro contexts-state
> print -f tree ericsson-context-ipos
module: ericsson-context-ipos
> 
> 
> 
> 
> 
> print -f tree ericsson-interfaces-ext-ipos
module: ericsson-interfaces-ext-ipos
> print -f tree ericsson-context
ericsson-contexts-ipos  ericsson-context-ipos 
rkrejci commented 8 years ago

Augments should be correct in the internal structures, but I see some issues with the tree printer: 1) augments are printed only in the target module, not in the module where they are defined 2) in the target module, the augments data are printed with the prefix of the module where they are defined. pyang does it this way, but we print module names as prefix (in your output, see type of /contexts/system/lacp/mac-addr)

classcwnd commented 8 years ago

hi

I found the fixed version still uses module name as the prefix not using defined prefix.

rkrejci commented 8 years ago

That's correct. The defined prefixes are not necessarily unique (in contrast to module names), so, as I wrote, we want to use module names as prefixes in tree output - they are longer, but it is much more clear from which module data comes.

Unfortunatelly, this differs libyang's tree output from pyang, but it is intended.

classcwnd commented 8 years ago

Ok, I see. :)