Skip to content

Incorrect loading of submodules into YANG repository #1094

@hyberdk

Description

@hyberdk

When YDK-GEN downloads the models and put them into the repository (I guess by default in ~/.ydk/<ip>/ it seems like sub-modules are named using the model@revision.yang notation. I guess this should be fine, excepts that the versions seems to be wrong.

Expected Behavior

The revision of the sub-module are versioned with the latest revision in the sub-module, or not versioned at all.

Current Behavior

From the looks of it, it seems like the revision of the sub-module are coming from the parent (belongs-to) module. These revisions are not always the same, just an example here:

https://github.com/YangModels/yang/blob/43f84815fdbf4b374ec58e7a424610bea8c492f1/vendor/cisco/xe/1771/Cisco-IOS-XE-native.yang#L45
vs.
https://github.com/YangModels/yang/blob/43f84815fdbf4b374ec58e7a424610bea8c492f1/vendor/cisco/xe/1771/Cisco-IOS-XE-parser.yang#L27C11-L27C22

there are also different revisions on the devices itself which are not in the public yang repo on github.

Steps to Reproduce

this is just an example, it does actually not need a working model to see it, but Im usng this code.

from ydk.services import NetconfService, Datastore
from ydk.providers import NetconfServiceProvider
from ydk.models.cisco_ios_xe import (
    Cisco_IOS_XE_native as xe_native
    )
from ydk.filters import YFilter

import logging

if __name__ == "__main__":
    logger = logging.getLogger("ydk")
    logger.setLevel(logging.DEBUG)
    handler = logging.StreamHandler()
    file_handler = logging.FileHandler("ydk.log")
    formatter = logging.Formatter(("%(asctime)s - %(name)s - "
                                    "%(levelname)s - %(message)s"))
    handler.setFormatter(formatter)
    logger.addHandler(handler)
    logger.addHandler(file_handler)

    provider = NetconfServiceProvider(address="<ip>",
                                      port=830,
                                      username="<username>",
                                      password="<password>",
                                      protocol="ssh")
    netconf = NetconfService()
    native = xe_native.Native()
    native.ip.access_list.yfilter = YFilter.read
    native.object_group.yfilter = YFilter.read

    result = netconf.get_config(provider, Datastore.running, read_filter=native)  # read running config
    exit()

once that has run, go to the repo folder and do a yanglint Cisco-IOS-XE-native.yang and observe that it complains about version mismatch. Or simply look at the revisions in the models :-)

here is an example for my ISR1K router running 17.6.5

eslau@N503476:~/.ydk/10.12.35.56$ cat Cisco-IOS-XE-native.yang |grep revision | head -1
  revision 2021-08-10 {
eslau@N503476:~/.ydk/10.12.35.56$ cat Cisco-IOS-XE-ip@2021-08-10.yang |grep revision | head -1
  revision 2021-07-10 {

System Information

(venv) eslau@N503476:~/repos-wsl/ydk_poc$ python --version
Python 3.10.12
(venv) eslau@N503476:~/repos-wsl/ydk_poc$ uname -a
Linux N503476 5.15.90.1-microsoft-standard-WSL2 #1 SMP Fri Jan 27 02:56:13 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
(venv) eslau@N503476:~/repos-wsl/ydk_poc$ 
(venv) eslau@N503476:~/repos-wsl/ydk_poc$ pip list
Package                       Version
----------------------------- -----------
alabaster                     0.7.13
Babel                         2.13.1
certifi                       2023.7.22
charset-normalizer            3.3.2
docutils                      0.18.1
gitdb                         4.0.11
GitPython                     3.1.40
idna                          3.4
imagesize                     1.4.1
Jinja2                        3.1.2
lxml                          4.9.3
MarkupSafe                    2.1.3
packaging                     23.2
pip                           22.0.2
pyang                         2.6.0
pybind11                      2.6.2
Pygments                      2.16.1
requests                      2.31.0
rstr                          3.2.2
setuptools                    59.6.0
smmap                         5.0.1
snowballstemmer               2.2.0
Sphinx                        7.2.6
sphinx-rtd-theme              1.3.0
sphinxcontrib-applehelp       1.0.7
sphinxcontrib-devhelp         1.0.5
sphinxcontrib-htmlhelp        2.0.4
sphinxcontrib-jquery          4.1
sphinxcontrib-jsmath          1.0.1
sphinxcontrib-qthelp          1.0.6
sphinxcontrib-serializinghtml 1.1.9
urllib3                       2.0.7
wheel                         0.41.3
ydk                           0.8.6.5
ydk-models-cisco-ios-xe       17.6.5.dev3

Metadata

Metadata

Assignees

Labels

C++workaroundThe issue has a workaround

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions