CiscoDevNet / ydk-gen

Generate model-driven APIs from YANG models
http://ciscodevnet.github.io/ydk-gen/
Apache License 2.0
135 stars 74 forks source link

Invalid keyword "+" - fails to use get_config #1093

Closed hyberdk closed 10 months ago

hyberdk commented 10 months ago

Issue tracker is ONLY used for reporting bugs. Please use the YDK Community for any support issues.

Hi @ygorelik,

When trying to do a get_config using the NetconfServiceProvider it fails with a Invalid keyword "+"

It looks like its even before any request are sent to the device. From the debig logs it almost looks like its trying to use a wrong yang path. it says something like this:

Creating root data node with path '/Cisco-IOS-XE-native:native' which obviously is wrong.. I wonder if some of the changes in mbj4668/pyang@dc9755382194d59484f439b557b6110b138a3bd0 is causing the models to be generated incorrectly??

The other times I have had issues it was able to generate the XML RPC, but it does not now..

Expected Behavior

That it sends a XML request using the filter and returns the XML data and parses that.

Current Behavior

it fails with

2023-11-05 15:39:20,933 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Invalid keyword "+".
2023-11-05 15:39:20,934 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Module "Cisco-IOS-XE-native" parsing failed.
2023-11-05 15:39:21,003 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Invalid keyword "+".
2023-11-05 15:39:21,004 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Module "Cisco-IOS-XE-native" parsing failed.
2023-11-05 15:39:21,024 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Importing "Cisco-IOS-XE-native" module into "Cisco-IOS-XE-cts-routing-deviation" failed.
2023-11-05 15:39:21,024 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Module "Cisco-IOS-XE-cts-routing-deviation" parsing failed.
2023-11-05 15:39:21,074 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Invalid keyword "+".
2023-11-05 15:39:21,074 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Module "Cisco-IOS-XE-native" parsing failed.
2023-11-05 15:39:21,096 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Importing "Cisco-IOS-XE-native" module into "Cisco-IOS-XE-dialer-deviation" failed.
2023-11-05 15:39:21,097 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Module "Cisco-IOS-XE-dialer-deviation" parsing failed.
2023-11-05 15:39:21,147 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Invalid keyword "+".
2023-11-05 15:39:21,148 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Module "Cisco-IOS-XE-native" parsing failed.
2023-11-05 15:39:21,167 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Importing "Cisco-IOS-XE-native" module into "Cisco-IOS-XE-ethernet-deviation" failed.
2023-11-05 15:39:21,167 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Module "Cisco-IOS-XE-ethernet-deviation" parsing failed.
2023-11-05 15:39:21,217 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Invalid keyword "+".
2023-11-05 15:39:21,218 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Module "Cisco-IOS-XE-native" parsing failed.
2023-11-05 15:39:21,241 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Importing "Cisco-IOS-XE-native" module into "Cisco-IOS-XE-lisp-deviation" failed.
2023-11-05 15:39:21,242 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Module "Cisco-IOS-XE-lisp-deviation" parsing failed.
2023-11-05 15:39:21,298 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Invalid keyword "+".
2023-11-05 15:39:21,299 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Module "Cisco-IOS-XE-native" parsing failed.
2023-11-05 15:39:21,322 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Importing "Cisco-IOS-XE-native" module into "Cisco-IOS-XE-nd-deviation" failed.
2023-11-05 15:39:21,322 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Module "Cisco-IOS-XE-nd-deviation" parsing failed.
2023-11-05 15:39:21,372 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Invalid keyword "+".
2023-11-05 15:39:21,373 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Module "Cisco-IOS-XE-native" parsing failed.
2023-11-05 15:39:21,391 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Importing "Cisco-IOS-XE-native" module into "Cisco-IOS-XE-ospfv3-deviation" failed.
2023-11-05 15:39:21,391 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Module "Cisco-IOS-XE-ospfv3-deviation" parsing failed.
2023-11-05 15:39:21,440 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Invalid keyword "+".
2023-11-05 15:39:21,441 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Module "Cisco-IOS-XE-native" parsing failed.
2023-11-05 15:39:21,458 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Importing "Cisco-IOS-XE-native" module into "Cisco-IOS-XE-policy-deviation" failed.
2023-11-05 15:39:21,459 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Module "Cisco-IOS-XE-policy-deviation" parsing failed.
2023-11-05 15:39:21,507 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Invalid keyword "+".
2023-11-05 15:39:21,508 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Module "Cisco-IOS-XE-native" parsing failed.
2023-11-05 15:39:21,526 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Importing "Cisco-IOS-XE-native" module into "Cisco-IOS-XE-port-channel-deviation" failed.
2023-11-05 15:39:21,526 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Module "Cisco-IOS-XE-port-channel-deviation" parsing failed.
2023-11-05 15:39:21,577 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Invalid keyword "+".
2023-11-05 15:39:21,578 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Module "Cisco-IOS-XE-native" parsing failed.
2023-11-05 15:39:21,597 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Importing "Cisco-IOS-XE-native" module into "Cisco-IOS-XE-power-deviation" failed.
2023-11-05 15:39:21,598 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Module "Cisco-IOS-XE-power-deviation" parsing failed.
2023-11-05 15:39:21,646 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Invalid keyword "+".
2023-11-05 15:39:21,647 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Module "Cisco-IOS-XE-native" parsing failed.
2023-11-05 15:39:21,665 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Importing "Cisco-IOS-XE-native" module into "Cisco-IOS-XE-sanet-deviation" failed.
2023-11-05 15:39:21,666 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Module "Cisco-IOS-XE-sanet-deviation" parsing failed.
2023-11-05 15:39:21,715 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Invalid keyword "+".
2023-11-05 15:39:21,716 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Module "Cisco-IOS-XE-native" parsing failed.
2023-11-05 15:39:21,783 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Invalid keyword "+".
2023-11-05 15:39:21,784 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Module "Cisco-IOS-XE-native" parsing failed.
2023-11-05 15:39:21,805 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Importing "Cisco-IOS-XE-native" module into "Cisco-IOS-XE-cts-routing-deviation" failed.
2023-11-05 15:39:21,805 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Module "Cisco-IOS-XE-cts-routing-deviation" parsing failed.
2023-11-05 15:39:21,869 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Invalid keyword "+".
2023-11-05 15:39:21,870 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Module "Cisco-IOS-XE-native" parsing failed.
2023-11-05 15:39:21,900 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Importing "Cisco-IOS-XE-native" module into "Cisco-IOS-XE-dialer-deviation" failed.
2023-11-05 15:39:21,901 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Module "Cisco-IOS-XE-dialer-deviation" parsing failed.
2023-11-05 15:39:21,964 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Invalid keyword "+".
2023-11-05 15:39:21,965 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Module "Cisco-IOS-XE-native" parsing failed.
2023-11-05 15:39:21,984 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Importing "Cisco-IOS-XE-native" module into "Cisco-IOS-XE-ethernet-deviation" failed.
2023-11-05 15:39:21,984 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Module "Cisco-IOS-XE-ethernet-deviation" parsing failed.
2023-11-05 15:39:22,030 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Invalid keyword "+".
2023-11-05 15:39:22,031 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Module "Cisco-IOS-XE-native" parsing failed.
2023-11-05 15:39:22,050 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Importing "Cisco-IOS-XE-native" module into "Cisco-IOS-XE-lisp-deviation" failed.
2023-11-05 15:39:22,050 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Module "Cisco-IOS-XE-lisp-deviation" parsing failed.
2023-11-05 15:39:22,100 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Invalid keyword "+".
2023-11-05 15:39:22,100 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Module "Cisco-IOS-XE-native" parsing failed.
2023-11-05 15:39:22,119 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Importing "Cisco-IOS-XE-native" module into "Cisco-IOS-XE-nd-deviation" failed.
2023-11-05 15:39:22,119 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Module "Cisco-IOS-XE-nd-deviation" parsing failed.
2023-11-05 15:39:22,169 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Invalid keyword "+".
2023-11-05 15:39:22,170 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Module "Cisco-IOS-XE-native" parsing failed.
2023-11-05 15:39:22,190 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Importing "Cisco-IOS-XE-native" module into "Cisco-IOS-XE-ospfv3-deviation" failed.
2023-11-05 15:39:22,190 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Module "Cisco-IOS-XE-ospfv3-deviation" parsing failed.
2023-11-05 15:39:22,239 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Invalid keyword "+".
2023-11-05 15:39:22,240 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Module "Cisco-IOS-XE-native" parsing failed.
2023-11-05 15:39:22,258 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Importing "Cisco-IOS-XE-native" module into "Cisco-IOS-XE-policy-deviation" failed.
2023-11-05 15:39:22,259 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Module "Cisco-IOS-XE-policy-deviation" parsing failed.
2023-11-05 15:39:22,309 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Invalid keyword "+".
2023-11-05 15:39:22,309 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Module "Cisco-IOS-XE-native" parsing failed.
2023-11-05 15:39:22,327 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Importing "Cisco-IOS-XE-native" module into "Cisco-IOS-XE-port-channel-deviation" failed.
2023-11-05 15:39:22,328 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Module "Cisco-IOS-XE-port-channel-deviation" parsing failed.
2023-11-05 15:39:22,376 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Invalid keyword "+".
2023-11-05 15:39:22,377 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Module "Cisco-IOS-XE-native" parsing failed.
2023-11-05 15:39:22,396 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Importing "Cisco-IOS-XE-native" module into "Cisco-IOS-XE-power-deviation" failed.
2023-11-05 15:39:22,396 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Module "Cisco-IOS-XE-power-deviation" parsing failed.
2023-11-05 15:39:22,454 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Invalid keyword "+".
2023-11-05 15:39:22,455 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Module "Cisco-IOS-XE-native" parsing failed.
2023-11-05 15:39:22,477 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Importing "Cisco-IOS-XE-native" module into "Cisco-IOS-XE-sanet-deviation" failed.
2023-11-05 15:39:22,478 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Module "Cisco-IOS-XE-sanet-deviation" parsing failed.
2023-11-05 15:39:22,478 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Module not found. Path: '/Cisco-IOS-XE-native'
2023-11-05 15:39:22,478 - ydk - ERROR - Path 'Cisco-IOS-XE-native:native' is invalid

Steps to Reproduce

  1. make sure that you have pyang version 2.6.0 installed (there are several fixes in that we need)
  2. install ydk-gen
  3. clone https://github.com/hyberdk/yang_models_ios_xe into the ydk-gen folder
  4. run python generate.py --python --bundle yang_models_ios-xe/cisco-ios-xe_17.6.5-local.json to generate the models
  5. install the newly complied models
  6. run the script below

Your Script

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()

Logs

Enable logging and post the logs below

debug logs are attached here: ydk-gen_debug.txt

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
ygorelik commented 10 months ago

This is duplicate of #1083. Please check the workaround in the last comment.