Passing deviation files to ydk-cpp in the bundle
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2021 08:58 PM
Dear community,
I am using the ydk-cpp (generate.py -cpp) with --bundle option to generate the CPP files from yang. I have a few deviation files that need to be passed for different yang files. Is there a way to pass this information as part of the bundle json file?
I want to have the capability to pass multiple deviation yang files for a specific target yang file.
It would be of great help if any links to documentation or the steps involved to achieve the above are provided.
Thank you
- Labels:
-
YANG Development Kit (YDK)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2021 03:23 PM
The deviation files provide only certain and limited alterations for the YANG modules and therefore they do not affect model API. The deviation files listed in capabilities are loaded by YDK in runtime when corresponding modules are loaded to memory (performed by libyang).
YDK Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2021 08:33 PM
Thanks Yan for your reply - We have a scenario where one configuration node is deviated as "not-supported" using a deviation like below.
deviation /system:system/card:attributes/card:label { deviate not-supported; }
But, in the generated .hpp file we still have the YLeaf present.
ydk::YLeaf label; //type: uint32
We want to know if the deviation files could be used while generating the header files and source files to remove the 'not-supported' attributes, since pyang can take deviation files as input for a particular module and apply the deviations.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2021 10:24 AM - edited 08-13-2021 08:53 AM
Hi @akpramod
In the early YDK development days (<=0.5.5) the deviation files were considered while generating model API. But since 0.6.0 the deviation files are not included to bundle profiles for two reasons:
1. The module files considered to be more stable than their deviations. For example IETF or openconfig standard models are used in multiple vendors applications, while some features in particular implementations might not be supported or slightly changed (ex.: value restrictions).
2. Since 0.6.0 the YANG model processing is implemented in libyang library code. When deviations applied, the corresponding files are loaded and corresponding changes applied accordingly.
In your case the leaf label is present in the model API. But if application developer tries to use it in the presence of deviation, which states that it is not supported, then the libyang will reject it and return an error indicating that this leaf is deprecated.
YDK Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2021 10:57 PM
we are using following json file to generate the cpp files. Please find the attached sample yang files
{ "name": "test", "version": "1.0.0", "core_version": "1.0.0", "author": "Auto Generated", "copyright": "XYZ", "description": "Profile generated test", "models": { "file": [ "yang/test.yang", "yang/aug_test.yang", "yang/dev_test.yang" ] } }
> generate.py -cpp --output-directory /out --bundle test.json
YDK version : YDK-0.8.4
we are still seeing the leaf label and aug_label in the generated cpp files.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2021 09:12 AM - edited 08-13-2021 09:13 AM
Hi John and @akpramod
Sorry for misleading you, I have corrected my previous post. This is correct YDK behavior by design. As stated previously, all deviation statements are ignored during bundle generation. The deviations applied to the YANG models during runtime when corresponding files are loaded into libyang memory. If user then tries to use the deviated node in other way than it is defined in the deviation statement, the YDK will develop a YModelError exception.
YDK Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2021 12:05 AM
Thanks Yan for the clarification ,
statements.add_validation_fun('reference_3', ['deviation'], self._add_d_info)
statements.add_validation_fun('reference_3', ['deviate'], self._remove_d_info)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2021 08:51 AM
Hi John
YDK is open source project under the Apache License, Version 2.0. That mean you can create your own fork and make any changes in the source code. If the above code changes work for you, then please go ahead. If you are going to publish the changes, then you need to make a contribution comment notes in all the affected files.
YDK Solutions
