ydk-gen
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)
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
Thanks. Related to #334
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,
Yes. It is in the roadmap. It may take some time
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!
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,
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,
Is this issue seen while generating for python api as well?
It's been an year. Any status on this issue is appreciated.
This is still on the TODO list. So far, other tasks had higher priority than this and had to be done first.
+1. looking forward to support for yang 1.1 in ydk.
- Could you please elaborate in what environment (platform, version, server, protocol etc.) you are trying to use YDK?
- What specific Yang 1.1 features are exposed in your server?
- What is the project that you would like to apply this new feature?
Hi @ydk-admin, is there any update for the use of Yang 1.1 with YDK 0.8.4. Thanks!
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.
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...
Not an issue for release 0.9.0.1.