cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
334
Views
1
Helpful
1
Replies

Is YDK capable of parsing all YANG models within a folder, and parse out attributes of every XPath?

remcampb
Cisco Employee
Cisco Employee

Hi all, I'm looking at YDK as a potential solution to parsing custom attributes for all XPaths within models/modules. My current approach is based on pyang (exploratory code, but effectively the same), but doesn't account for errors, etc. very well - nor deviations or other complexities that frankly I am not familiar with. With YDK, would it be relatively trivial or possible to parse all YANG models in a folder, and then iterate through every XPath of every parsed model to output something akin to this structure?

1 Reply 1

abhirame
Cisco Employee
Cisco Employee

Hi Remington,

The ydk-gen generator tool parses the fully expanded yang tree and prints out this data as python files, including the paths for each of the containers/lists. You can see this by generating a bundle, for example, with the below commands

git clone https://github.com/CiscoDevNet/ydk-gen.git
cd ydk-gen
pip install -r requirements.txt
./generate.py --python --bundle profiles/bundles/ietf_0_1_4.json
ls gen-api/python/ietf-bundle/ydk/models/ietf
vi gen-api/python/ietf-bundle/ydk/models/ietf/ietf_interfaces.py

You may be interested in the below attributes of the generated classes:

self._segment_path = ..
self._absolute_path  = ..

The python code for the generator including the parsing and printers is here. However, note that deviations are not considered above, but this could also be included with a few small code changes