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

Passing deviation files to ydk-cpp in the bundle

akpramod
Beginner
Beginner

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

7 Replies 7

yangorelik
Spotlight
Spotlight

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

Yan Gorelik
YDK Solutions

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.

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.

Yan Gorelik
YDK Solutions

 

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.

 

 

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.

Yan Gorelik
YDK Solutions

Thanks Yan for the clarification , 

If we are using the YDK only for generation of CPP header/source files and not at run time, could we comment the following lines so that the deviation file changes are reflected in the generated model files?
ydkgen/builder/_pyang_model_builder.py (line no: 50, 51, 52    under "def parse_and_return_modules(self):")
    statements.add_validation_fun('reference_3', ['deviation'], self._add_i_deviation)
    statements.add_validation_fun('reference_3', ['deviation'], self._add_d_info)
    statements.add_validation_fun('reference_3', ['deviate'], self._remove_d_info)
 
 
 

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.

Yan Gorelik
YDK Solutions
Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: