-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[_sonic_yang_ext.py]: Extend sonic yang class to support cropping, transalation, reverse translation of Config DB. #3891
Conversation
This Package will contain YANG models for sonic which are written with guidelines mentioned in https://github.com/Azure/SONiC/blob/master/doc/mgmt/SONiC_YANG_Model_Guidelines.md. This package will include python yang libraries which will be used with sonic utilities pacakge to validate the config.
- python APIs based on libyang - functions to load/merge yang models and data files - add/set/delete node in schema and data trees - find dependencies
…, PortChannel and ACL. [Sonic Yang Tree]: YANG models as per Guidelines. Guideline doc: https://github.com/Azure/SONiC/blob/master/doc/mgmt/SONiC_YANG_Model_Guidelines.md [yang-model-tests]: YANG model test code and JSON input for testing. [setup.py]: Add testing for yang models. [sonic-slave-stretch]: Add a package ijson for sonic_yang_mgmt build.
…ansalation, reverse translation of config DB. This PR includes: -- Cropping input config based on Yang Model. -- Translate input config based on Yang Model. -- rev Translate input config based on Yang Model. -- Find xpath of port, portleaf and a yang list. -- Find if node is key of a list while deletion if yes, then delete the parent.
Curious! Having two different modules doing the same would be hard to maintain. Have you looked in-depth the committed code (from Broadcom) that does this translation ? |
@renukamanavalan Thanks |
@renukamanavalan |
This PR is merged in PR 3861. |
…config DB.
This PR changes are added in PR 3861 now.
From the json format of yang models, a map is created from config DB tables
to container in yang model. Input Config is cropped on based of this map.
Input Config is also translated based of this map.
Similarly from yang data tree, output is reverse translated to config DB.
This PR also includes:
-- Find xpath of port, portleaf and a yang list.
-- Find if node is key of a list while deletion if yes, then delete the parent.
- What I did
-- Cropping input config based on Yang Model.
-- Translate input config based on Yang Model.
-- rev Translate input config based on Yang Model.
-- Find xpath of port, portleaf and a yang list.
-- Find if node is key of a list while deletion if yes, then delete the parent.
- How I did it
Yang model can be represented in JSON as below:
This is used to create a map between Config DB Table and YANG Model Container.
Note: As per guideline https://github.com/Azure/SONiC/blob/master/doc/mgmt/SONiC_YANG_Model_Guidelines.md. Table maps to only container in YANG.
Map and json format of yang model is used to:
-- Cropping input config based on Yang Model.
-- Translate input config based on Yang Model.
-- rev Translate input config based on Yang Model.
-- Find xpath of port, portleaf and a yang list.
-- Find if node is key of a list while deletion if yes, then delete the parent.
- How to verify it
Added PyTest:
Below are sample config and cropped config files.
Cropped Config