cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1259
Views
5
Helpful
5
Replies

Help needed debugging API compilation errors from ydk-gen

stevesmith31
Level 1
Level 1

Hi all,

After many trials and tribulations I finally managed to install YDK on my Mac, but I haven't yet been able to successfully generate an API with ydk-gen. Depending on the bundle file I use, and which bits I take out of it, I will get different error outputs, but the ultimate outcome is the same in each case. My latest attempt was to work with the bundle from CiscoDevNet on github (https://raw.githubusercontent.com/CiscoDevNet/ydk-gen/master/profiles/bundles/cisco-ios-xe_16_5_1.json) using this command:

sudo ~/ydk-gen/generate.py --python --bundle ios-xe_16_5_1.json -v


Firstly, I get this error, which I think I can ignore because compilations seems to proceed OK (for info, the variable is set anyway):


YDKGEN_HOME not set. Assuming current directory is working directory.


Information - this is the variable declaration: declare -x YDKGEN_HOME="/Users/stevesmith/ydk-gen/"


So the output from the command continues with a bunch of warnings (mainly about double quotes being unsafe), so all looks promising until it gets to this point:


Traceback (most recent call last):

  File "/Users/stevesmith/ydk-gen/generate.py", line 369, in <module>

    options.one_class_per_module).generate(options.bundle))

  File "/Users/stevesmith/ydk-gen/ydkgen/__init__.py", line 91, in generate

    return self._generate_bundle(description_file)

  File "/Users/stevesmith/ydk-gen/ydkgen/__init__.py", line 117, in _generate_bundle

    packages = self._get_packages(curr_bundle.resolved_models_dir)

  File "/Users/stevesmith/ydk-gen/ydkgen/__init__.py", line 163, in _get_packages

    packages = ApiModelBuilder(self.iskeyword, self.language).generate(modules)

  File "/Users/stevesmith/ydk-gen/ydkgen/builder/_api_model_builder.py", line 70, in generate

    self._resolve_expanded_cross_references(package)

  File "/Users/stevesmith/ydk-gen/ydkgen/builder/_api_model_builder.py", line 147, in _resolve_expanded_cross_references

    self._resolve_expanded_cross_references(owned_element)

  File "/Users/stevesmith/ydk-gen/ydkgen/builder/_api_model_builder.py", line 147, in _resolve_expanded_cross_references

    self._resolve_expanded_cross_references(owned_element)

  File "/Users/stevesmith/ydk-gen/ydkgen/builder/_api_model_builder.py", line 147, in _resolve_expanded_cross_references

    self._resolve_expanded_cross_references(owned_element)

  File "/Users/stevesmith/ydk-gen/ydkgen/builder/_api_model_builder.py", line 147, in _resolve_expanded_cross_references

    self._resolve_expanded_cross_references(owned_element)

  File "/Users/stevesmith/ydk-gen/ydkgen/builder/_api_model_builder.py", line 147, in _resolve_expanded_cross_references

    self._resolve_expanded_cross_references(owned_element)

  File "/Users/stevesmith/ydk-gen/ydkgen/builder/_api_model_builder.py", line 147, in _resolve_expanded_cross_references

    self._resolve_expanded_cross_references(owned_element)

  File "/Users/stevesmith/ydk-gen/ydkgen/builder/_api_model_builder.py", line 147, in _resolve_expanded_cross_references

    self._resolve_expanded_cross_references(owned_element)

  File "/Users/stevesmith/ydk-gen/ydkgen/builder/_api_model_builder.py", line 147, in _resolve_expanded_cross_references

    self._resolve_expanded_cross_references(owned_element)

  File "/Users/stevesmith/ydk-gen/ydkgen/builder/_api_model_builder.py", line 131, in _resolve_expanded_cross_references

    if not hasattr(identity_ref_type.i_type_spec.base.i_identity, 'i_class'):

AttributeError: 'NoneType' object has no attribute 'i_identity'


I have no idea where to start to debug this. As with all of the other errors that get thrown when I attempt an API build using various forms of bundle file, the error messages don't offer much in the way of helpful hints, so I presume only a developer would be able to get to the bottom of them.

A bit more background. The only successful compilation I've managed so far is using a simplified bundle file, with ned.yang explicitly removed from the commits list. I assume an issue with ned, but I haven't found a workaround.

Would appreciate any clues on how to move forward!

Steve

5 Replies 5

abhirame
Cisco Employee
Cisco Employee

Hi Steve,

Sorry you are facing this issue.

If you’d like to use a pre-generated bundle for XR, you can try using the package already released on PyPi: https://pypi.python.org/pypi/ydk-models-cisco-ios-xe. ‘pip install ydk-models-cisco-ios-xe’ will install all the packages you need. This way you won’t need to use ydk-gen to generate a bundle.

To fix the issue with ydk-gen you are seeing, it appears you have pyang 1.7 installed. ‘pip list|grep pyang’ will tell you the version. However, ydk-gen requires pyang to be exactly 1.6 as specified in requirements.txt (https://github.com/CiscoDevNet/ydk-gen/blob/master/requirements.txt). So if you try the below, this issue should be fixed:

pip uninstall pyang –y

pip install pyang==1.6

Hi abhirame,

Thanks for taking the time to look into this. I greatly appreciate your contribution. On the use of the pre-generated bundle, I actually already have that installed, but I am just trying to work through the steps in the tutorial at networkop.co.uk/blog/2017/02/22/odl-ydk and the step I'm up to is to run ydk-gen to build an API. So I try and do as I'm told:-)

I did find that pyang 1.7 was installed as you suspected (how did you know that by the way?), so I uninstalled it and tried the install of 1.6, but I was told that requirements was already satisfied (pyang==1.6 in /Library/Python/2.7/site-packages). pip list also confirms pyang (1.6), yet when I run ydk-gen , now I am seeing "no module named yang". Google search for this error didn't reveal much that seemed relevant. Sorry to have to ask again, but can you provide any clues on how to fix this? Or maybe I can skip this step in the tutorial altogether using the pre-generated bundle, but if I try to jump to the next step (from ydk.models.cisco_ios_xe.ned import Native) I get  "import error: no module named ned", which I assume is an artefact of my inability to generate the API. But I could be on the wrong track altogether I guess...

Once again, thanks. Hope you can assist further.

Steve

Hi Steve,

No problem. I had seen the same error you are seeing previously, so I guessed you may have the pyang 1.7 installed. ☺

It would help if you could post the full command line output of these errors.

For the first error, I’m guessing the reason could be there could some issue with the paths to the yang models defined in your .json profile file.

For the second error, with the latest cisco-ios-xe bundle (16.6.1) the name of the python module has actually changed because the corresponding yang models have changed. The documentation for this is here: http://ydk.cisco.com/py/docs/gen_doc_2d1e68f0c4b51b62e2aa90c4760e6900f62a66af.html.

So, you’d need to change the import path to:

from ydk.models.cisco_ios_xe.Cisco_IOS_XE_native import Native

Hi abhirame,

Once again thanks for your tips. In the case of the pyang error, I finally figured out that "pip install pyang==1.6" had created the pyang and pyang-1.6.dist-info directories under /private/var/root/Library/Python/2.7/lib/python/site-packages. So I copied these directories to /Library/Python/2.7/site-packages. This fixed the missing dependency issue and I have since been able to compile the API based on the bundle json file.

FYI, the original import error output was:

steves-MacBook-Air:ydk-gen stevesmith$ sudo ~/ydk-gen/generate.py --python --bundle ios-xe-16-5-bundle.json -v

Traceback (most recent call last):

  File "/Users/stevesmith/ydk-gen/generate.py", line 33, in <module>

    from ydkgen import YdkGenerator

  File "/Users/stevesmith/ydk-gen/ydkgen/__init__.py", line 31, in <module>

    from .common import YdkGenException, iscppkeyword, ispythonkeyword

  File "/Users/stevesmith/ydk-gen/ydkgen/common.py", line 21, in <module>

    from pyang import types as ptypes

ImportError: No module named pyang

So overcoming this problem allows me to move on to the Configuring BGP step in the tutorial, but of course just as you think you’ve cleared the final hurdle you find you’ve landed in a blackberry bush surrounded by an electric fence on the other side. So I move on to solving the next issue:

>>> from ydk.models.cisco_ios_xe.Cisco_IOS_XE_native import Native

Traceback (most recent call last):

  File "<stdin>", line 1, in <module>

  File "/Library/Python/2.7/site-packages/ydk/models/cisco_ios_xe/Cisco_IOS_XE_native.py", line 8, in <module>

    from ydk.types import Entity, EntityPath, Identity, Enum, YType, YLeaf, YLeafList, YList, LeafDataList, Bits, Empty, Decimal64

  File "/Library/Python/2.7/site-packages/ydk/types/__init__.py", line 17, in <module>

    from .py_types import Entity, YList, YLeafList

  File "/Library/Python/2.7/site-packages/ydk/types/py_types.py", line 24, in <module>

    from ydk_ import is_set

ImportError: dlopen(/Library/Python/2.7/site-packages/ydk_.so, 2): Library not loaded: /usr/local/opt/libxslt/lib/libxslt.1.dylib

  Referenced from: /Library/Python/2.7/site-packages/ydk_.so

  Reason: image not found

>>> import /usr/local/opt/libxslt/lib/libxslt.1.dylib

  File "<stdin>", line 1

    import /usr/local/opt/libxslt/lib/libxslt.1.dylib

I’ll beaver away on this one for a while, but if you have any clues, feel free to share!

Steve

Hi Steve,

The error indicates libxslt could be missing. Can you make sure you have installed all the system dependencies as documented here < https://github.com/CiscoDevNet/ydk-py#macos >?