12-02-2019 05:21 AM
Hello.
I'm trying to create a model bundle for Juniper device using YANG models stored in Juniper Git repo.
I've created a profile:
{ "name": "junos-19.2", "version": "0.1.0", "ydk_version": "0.8.4", "author": "horseinthesky", "copyright": "horseinthesky", "description": "JunOS 19.2 Yang Model", "models": { "git": [ { "url": "https://github.com/Juniper/yang.git", "dir": [ "19.2/19.2R1/junos/conf", "19.2/19.2R1/junos/conf-with-extensions" ] } ] } }
But executing generate.py against it runs in exception:
python3 generate.py --python --bundle ~/test/junos-19.2.json Traceback (most recent call last): File "generate.py", line 492, in <module> output_directory = (generator.generate(options.bundle)) File "/home/horseinthesky/ydk-gen/ydkgen/__init__.py", line 93, in generate return self._generate_bundle(description_file) File "/home/horseinthesky/ydk-gen/ydkgen/__init__.py", line 120, in _generate_bundle bundle_translator.translate(profile_file, tmp_file, self.ydk_root) File "/home/horseinthesky/ydk-gen/ydkgen/resolver/bundle_translator.py", line 198, in translate modules.extend(globals()[get_fun](data['models'][source],ydk_root)) File "/home/horseinthesky/ydk-gen/ydkgen/resolver/bundle_translator.py", line 151, in get_git_attrs for c in g['commits']: KeyError: 'commits'
Solved! Go to Solution.
12-02-2019 05:25 PM
There are couple of errors in your profile:
With these changes the profile looks like this:
{
"name": "junos-19.2",
"version": "0.1.0",
"ydk_version": "0.8.4",
"author": "horseinthesky",
"copyright": "horseinthesky",
"description": "JunOS 19.2 Yang Model",
"models": {
"git": [
{
"url": "https://github.com/Juniper/yang.git",
"commits": [
{
"dir": [
"19.2/19.2R1/common",
"19.2/19.2R1/junos/conf",
"19.2/19.2R1/junos/conf-with-extensions"
]
}
]
}
]
}
}
I tested model bundle generation with this profile and it worked fine. You need to make sure that you have enough RAM and disk space on your system in order to generate API for these models.
12-02-2019 05:25 PM
There are couple of errors in your profile:
With these changes the profile looks like this:
{
"name": "junos-19.2",
"version": "0.1.0",
"ydk_version": "0.8.4",
"author": "horseinthesky",
"copyright": "horseinthesky",
"description": "JunOS 19.2 Yang Model",
"models": {
"git": [
{
"url": "https://github.com/Juniper/yang.git",
"commits": [
{
"dir": [
"19.2/19.2R1/common",
"19.2/19.2R1/junos/conf",
"19.2/19.2R1/junos/conf-with-extensions"
]
}
]
}
]
}
}
I tested model bundle generation with this profile and it worked fine. You need to make sure that you have enough RAM and disk space on your system in order to generate API for these models.
12-03-2019 12:29 AM
This works. Couldn't find the right structure https://github.com/CiscoDevNet/ydk-gen#build-model-bundle-profile
Thank you.
12-03-2019 09:03 AM
01-05-2021 09:58 AM
How much RAM did you need to install the package with pip? In my case it keeps crushing, the max RAM u could allocate is 32G.
12-03-2019 02:30 AM
Ok. How can I start discovering the package?
It is 14 million lines so it's just undiscoverable.
Any time i do:
In [1]: from ydk.models.junos_19_2.junos_conf_root import Configuration In [2]: c = Configuration() In [4]: c.
and press <Tab> my interpreter session just freezes forever.
12-03-2019 09:25 AM
12-03-2019 09:53 AM
I mean is there a way to correlate what YANG object turned into while Python module creation?
It really hard to understand how all these YANG things work and the lack of documentation makes it even more difficult. (I'm looking at https://community.cisco.com/t5/yang-development-kit-ydk/sample-apps-for-encoding-acl-using-openconfig/m-p/3880235/highlight/false#M1226)
12-03-2019 04:19 PM
There is definitive correlation between YANG model and generated API. The rules are multiple and quite complicated; they are implemented in the API generator code. The simple way is just follow YANG model and compare it with generated Python API. You also might consider generating documentation for your core and bundles. You can get example of generated documentation on ydk.cisco.com.
In order to generate documentation for YDK core and bundles, generate the bundles first, then run this command:
./generate.py --core --generate-doc
Based on the volume of your model, please be prepared to wait for few hours for this command to finish. It also eats up lots of disk space. I would suggest to run it overnight. Once ready the documentation is located at ./gen-apy/python/ydk/docs_expanded.
Locally you can open documentation by running:
firefox gen-apy/python/ydk/docs_expanded/index.html &
You also can publish the documentation on the web for your peers access.
The big plus of having documentation is web based, easy to browse and follow API description.
12-04-2019 12:15 AM
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide