ydk-gen icon indicating copy to clipboard operation
ydk-gen copied to clipboard

ydk-gen cannot generate cpp api if the yang version is 1.1 (for which pyang 1.7.5 is needed)

Open vhuertas opened this issue 6 years ago • 14 comments

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

Expected Behavior

I was expecting to be able to generate new apis using updated ietfs models which uses yang v1.1.

Current Behavior

supporting v1.1 of yang models forces me to update pyang to the 1.7.5 version which provokes this failure.

Steps to Reproduce

./generate.py --cpp --bundle profiles/bundles/ietf_0_1_5.json 

Logs

Enable logging and post the logs below

./generate.py --cpp --bundle profiles/bundles/ietf_0_1_5.json 
Traceback (most recent call last):
  File "./generate.py", line 468, in <module>
    output_directory = (generator.generate(options.bundle))
  File "/home/cuda1/git/ydk-gen/ydkgen/__init__.py", line 89, in generate
    return self._generate_bundle(description_file)
  File "/home/cuda1/git/ydk-gen/ydkgen/__init__.py", line 115, in _generate_bundle
    packages = self._get_packages(curr_bundle)
  File "/home/cuda1/git/ydk-gen/ydkgen/__init__.py", line 161, in _get_packages
    packages = ApiModelBuilder(self.iskeyword, self.language, bundle.name).generate(modules)
  File "/home/cuda1/git/ydk-gen/ydkgen/builder/_api_model_builder.py", line 77, in generate
    self._resolve_expanded_cross_references(package)
  File "/home/cuda1/git/ydk-gen/ydkgen/builder/_api_model_builder.py", line 154, in _resolve_expanded_cross_references
    self._resolve_expanded_cross_references(owned_element)
  File "/home/cuda1/git/ydk-gen/ydkgen/builder/_api_model_builder.py", line 154, in _resolve_expanded_cross_references
    self._resolve_expanded_cross_references(owned_element)
  File "/home/cuda1/git/ydk-gen/ydkgen/builder/_api_model_builder.py", line 154, in _resolve_expanded_cross_references
    self._resolve_expanded_cross_references(owned_element)
  File "/home/cuda1/git/ydk-gen/ydkgen/builder/_api_model_builder.py", line 138, 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'

System Information

pyang 1.7.5 python v3.4 Linux openSuse 42.3 Leap

vhuertas avatar Jun 15 '18 10:06 vhuertas

Thanks. Related to #334

ghost avatar Jun 15 '18 16:06 ghost

Hi,

Regarding the yang 1.1 support in order to generate cpp code, is it planned in the roadmap? I am asking this because I would like to integrate the data structure of the ietf-interfaces yang models (and future new ones), which are only implemented in v1.1.

That's why I have to change to openconfig (all of them is 1.0) however these models are giving me lots of problems while using repository handling tools such as sysrepo.

Regards,

vhuertas avatar Jul 11 '18 08:07 vhuertas

Yes. It is in the roadmap. It may take some time

ghost avatar Jul 11 '18 22:07 ghost

Just stumbled upon the same problem... It seems most IETF models are using YANG 1.1. Looking forward to see YDK supporting YANG 1.1!

rwestphal avatar Aug 26 '18 02:08 rwestphal

Copying issue #808 as it is a duplicate:

I would like to use ietf yang modems for interface configuration. However, there is no way to specify subinterfaces or the vlan tag associated to an interface. The IETF yang models implemented doesn't seem to include it.

I would like to avoid openconfig models for several reasons and I want to use the cpp api of the IETF bundle. As I said, no vlan subinterfaces are supported.

Is there some workaround in order to specify vlan tag? The only one that comes to mind is to take advantage of the interface name. For example, eth0.30 would mean that the eth0 has a subinterface with vlan tag 30. As the name is not the "elegant" way to specify subinterfaces I wanted to know if there would be some other means to do using ietf bundle.

The other option is to support experimental yang models from ietf which are implemented in yang version 1.1. But this is upto the roadmap of the API and you guys are the only ones who can answer this question.

Thanks.

Regards,

ghost avatar Sep 10 '18 21:09 ghost

Thank for putting this enhancement as "To Do". I just hope that it doesn't take too long to be implemented because I am now in a phase of the project where I have to dessign a future software where I want to use YDK-GEN to generate cpp libs and I found myself on the same issue. IETF yang models (now it is the turn for ietf-routing.yang) that would save me a lot of time are all v1.1.

If this enhancement is not pushed up in the priority list for near future developments I will have to dedicate a lot of time to "augment" the ietf-routing and ietf-ipv4-unicast-routing.yang in v1.0 so that I can use ydk-gen.

This will cause that I will have to make again some work that it has been already done in v1.1 and it will cause unecessary ad-hoc implementations in my software which will be hard to maintain. This makes me think whether ydk-gen can fulfill my current requirements at this moment or not because of this. And I think that it is a pitty as I really think that you are doing a nice and useful job with this library.

So I strongly recommend to put this enhancement as a the top one in the priority list. Otherwise ydk-gen lib will not save time and effort for future developers as yang 1.1 becomes the norm in new ietf and non-ietf releases.

Thanks again for your attention,

vhuertas avatar Sep 17 '18 08:09 vhuertas

Is this issue seen while generating for python api as well?

maheshnayak1 avatar Jan 04 '19 23:01 maheshnayak1

It's been an year. Any status on this issue is appreciated.

maheshnayak1 avatar Apr 11 '19 16:04 maheshnayak1

This is still on the TODO list. So far, other tasks had higher priority than this and had to be done first.

ydk-admin avatar Apr 11 '19 17:04 ydk-admin

+1. looking forward to support for yang 1.1 in ydk.

p-sherratt avatar Aug 30 '19 11:08 p-sherratt

  1. Could you please elaborate in what environment (platform, version, server, protocol etc.) you are trying to use YDK?
  2. What specific Yang 1.1 features are exposed in your server?
  3. What is the project that you would like to apply this new feature?

ygorelik avatar Aug 30 '19 17:08 ygorelik

Hi @ydk-admin, is there any update for the use of Yang 1.1 with YDK 0.8.4. Thanks!

ankit7gup avatar Feb 24 '20 07:02 ankit7gup

It would be great to increase priority of this, internally in Cisco we're planning use of YDK for testing purposes. If you need details please contact me on webex.

valeriodigregorio avatar Jul 08 '20 16:07 valeriodigregorio

I added a try: except: to _api_model_builder.py and, for whatever reason, the exception does not bubble up to generator.py and I was able to successfully compile a yang model using pyang 2.2.1.

_api_model_builder.py updated with:

# Line 138
 try:
    if not hasattr(identity_ref_type.i_type_spec.base.i_identity, 'i_class'):
        raise YdkGenException(
            'Cross resolution of identity class failed for ' + element.fqn())
    element.property_type = identity_ref_type.i_type_spec.base.i_identity.i_class
except:
    YdkGenException(
        'Cross resolution of identity class failed for ' + element.fqn())

Your mileage may vary...

MitchellMahan avatar Aug 20 '20 19:08 MitchellMahan

Not an issue for release 0.9.0.1.

ygorelik avatar Sep 07 '23 18:09 ygorelik