mbj4668 / pyang

An extensible YANG validator and converter in python
ISC License
528 stars 342 forks source link

Is submodule containers not placed correctly? #880

Closed hyberdk closed 8 months ago

hyberdk commented 8 months ago

Hi @mbj4668,

Sorry about yet another issue I would like your comment on..

When I parse the Cisco-IOS-XE-native.yang module, I would expect that the containers would be

/ios:native/ios:interface/ios:AppNav-Compress etc.

The only root container in the model is /native (https://github.com/hyberdk/yang_models_ios_xe/blob/2d9e4fe5d7324fd964a5d1a0e60c99fddde7cb01/ios-xe_17.6.5/Cisco-IOS-XE-native.yang#L320) This model is yang v1.1 ;-)

however its showing /ios:/interface/* in the root also..

The Cisco-IOS-XE-interfaces.yang submodule implements the /ios:native/ios:interface/* tree here: https://github.com/hyberdk/yang_models_ios_xe/blob/2d9e4fe5d7324fd964a5d1a0e60c99fddde7cb01/ios-xe_17.6.5/Cisco-IOS-XE-native.yang#L2532C36-L2532C36

Im not sure its related to the latest commits as the problem both exist in v2.5.3 and v2.6.0

could there be another bug here?

here is my output from pyang:

(venv) eslau@N503476:~/repos-wsl/ydk-gen/profiles/bundles/cisco/xe/output$ pip install pyang==2.6.0
Collecting pyang==2.6.0
  Using cached pyang-2.6.0-py2.py3-none-any.whl (594 kB)
Requirement already satisfied: lxml in /home/eslau/repos-wsl/yang_models_ios-xe/venv/lib/python3.10/site-packages (from pyang==2.6.0) (4.9.3)
Installing collected packages: pyang
  Attempting uninstall: pyang
    Found existing installation: pyang 2.5.0
    Uninstalling pyang-2.5.0:
      Successfully uninstalled pyang-2.5.0
Successfully installed pyang-2.6.0
(venv) eslau@N503476:~/repos-wsl/ydk-gen/profiles/bundles/cisco/xe/output$ pyang -f tree Cisco-IOS-XE-native.yang |more
Cisco-IOS-XE-interfaces.yang:373 (at Cisco-IOS-XE-interfaces.yang:609): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-native"
Cisco-IOS-XE-interfaces.yang:373 (at Cisco-IOS-XE-interfaces.yang:1585): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-native"
Cisco-IOS-XE-interfaces.yang:373 (at Cisco-IOS-XE-interfaces.yang:1588): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-native"
Cisco-IOS-XE-interfaces.yang:373 (at Cisco-IOS-XE-interfaces.yang:1600): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-native"
Cisco-IOS-XE-interfaces.yang:373 (at Cisco-IOS-XE-interfaces.yang:1747): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-native"
Cisco-IOS-XE-interfaces.yang:373 (at Cisco-IOS-XE-interfaces.yang:1750): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-native"
Cisco-IOS-XE-interfaces.yang:373 (at Cisco-IOS-XE-interfaces.yang:1924): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-native"
Cisco-IOS-XE-interfaces.yang:373 (at Cisco-IOS-XE-interfaces.yang:2246): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-native"
Cisco-IOS-XE-interfaces.yang:373 (at Cisco-IOS-XE-interfaces.yang:3948): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-native"
Cisco-IOS-XE-interfaces.yang:373 (at Cisco-IOS-XE-interfaces.yang:4035): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-native"
Cisco-IOS-XE-interfaces.yang:373 (at Cisco-IOS-XE-interfaces.yang:4159): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-native"
Cisco-IOS-XE-interfaces.yang:373 (at Cisco-IOS-XE-interfaces.yang:4453): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-native"
Cisco-IOS-XE-interfaces.yang:373 (at Cisco-IOS-XE-interfaces.yang:5560): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-native"
Cisco-IOS-XE-interfaces.yang:373 (at Cisco-IOS-XE-interfaces.yang:5563): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-native"
Cisco-IOS-XE-interfaces.yang:373 (at Cisco-IOS-XE-interfaces.yang:5576): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-native"
Cisco-IOS-XE-interfaces.yang:373 (at Cisco-IOS-XE-interfaces.yang:5755): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-native"
Cisco-IOS-XE-interfaces.yang:373 (at Cisco-IOS-XE-interfaces.yang:5758): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-native"
Cisco-IOS-XE-interfaces.yang:373 (at Cisco-IOS-XE-interfaces.yang:5945): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-native"
Cisco-IOS-XE-interfaces.yang:373 (at Cisco-IOS-XE-interfaces.yang:6314): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-native"
module: Cisco-IOS-XE-native
  +--rw interface
  |  +--rw AppNav-Compress* [name]
  |  |  +--rw name                        uint16
  |  |  +--rw description?                string
  |  |  +--rw switchport-conf
  |  |  |  +--rw switchport?   boolean
  |  |  +--rw switchport-config
  |  |  |  +--rw switchport {ios-features:switching-platform}?
  |  |  x--rw switchport {ios-features:switching-platform}?
  |  |  +--rw stackwise-virtual
  |  |  |  +--rw link?                    uint8
  |  |  |  +--rw dual-active-detection?   empty
  |  |  +--rw mac-address?                string
  |  |  +--rw shutdown?                   empty
  |  |  +--rw arp
  |  |  |  +--rw timeout?           uint32
  |  |  |  +--rw snap?              empty
  |  |  |  +--rw authorized?        empty
  |  |  |  +--rw log
  |  |  |  |  +--rw threshold
  |  |  |  |     +--rw entries?   uint32
  |  |  |  +--rw entries
  |  |  |  |  +--rw interface-limit
  |  |  |  |     +--rw entry-count?   uint32
  |  |  |  |     +--rw log?           uint32
  |  |  |  +--rw packet-priority
  |  |  |     +--rw enable?   empty
  |  |  +--rw backup
  |  |  |  +--rw delay

if I look at the children in the code, it does infact look like its seing two i_children.

image

but looking at the substmts, it looks like its parsing the native module just fine..

image

Am I missing something?

Esben

mbj4668 commented 8 months ago

I don't know which version of these models are the most recent, but when I test with the models in YangModels/yang/vendor/cisco/xe/17121 it seems to work correctly.

In your example, there are warnings: Cisco-IOS-XE-interfaces.yang:373 (at Cisco-IOS-XE-interfaces.yang:609): warning: node "Cisco-IOS-XE-native::native" is not found in module "Cisco-IOS-XE-native"

So something is going on...

hyberdk commented 8 months ago

the models for for the IOS-XE 17.6.5 versions (downloaded from my router), I use these versions as they do not 100% match the official ones on yangmodels/yang/vendor/cisco/xe/1761

the warnings are some must statements that is not working. I think its a side effect from the "interface" container being place wrongly.

just to be safe I commented them out in this commit (I need to read up on the must syntax to fix them): hyberdk/yang_models_ios_xe@01e8a4647ba215ea856b42fe0aad7ae1a5ad1bb1

now it runs with out errors or warnings, but the "interface" container is still placed wrong.. from the looks of it, the 17.12.1 models that you tested are implementing the /native/interface container exactly the same way.. So it is really stange that it works there and not in my models..

(venv) eslau@N503476:~/repos-wsl/yang_models_ios-xe/ios-xe_17.6.5$ pyang -f flatten Cisco-IOS-XE-native.yang |more
xpath
/Cisco-IOS-XE-interfaces:interface
/Cisco-IOS-XE-interfaces:interface/ATM
/Cisco-IOS-XE-interfaces:interface/ATM/access-session
/Cisco-IOS-XE-interfaces:interface/ATM/access-session/closed
/Cisco-IOS-XE-interfaces:interface/ATM/access-session/control-direction
/Cisco-IOS-XE-interfaces:interface/ATM/access-session/control-direction/in
/Cisco-IOS-XE-interfaces:interface/ATM/access-session/control-direction-config
/Cisco-IOS-XE-interfaces:interface/ATM/access-session/host-mode
/Cisco-IOS-XE-interfaces:interface/ATM/access-session/inherit
/Cisco-IOS-XE-interfaces:interface/ATM/access-session/inherit/disable
/Cisco-IOS-XE-interfaces:interface/ATM/access-session/inherit/disable/autoconf

I guess it could be that its not a pyang issue, but can you see whats going on here? Its really weird..

Esben

hyberdk commented 8 months ago

nevermind, found the problem.. it was a leftover from some of my testing that sneaked into git

https://github.com/hyberdk/yang_models_ios_xe/blame/pyang-test/ios-xe_17.6.5/Cisco-IOS-XE-interfaces.yang#L373

it works just fine.. thanks again for your help!

Esben