Skip to content
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

libyang python APIs #10

Merged
merged 5 commits into from
Dec 2, 2019
Merged

Conversation

li-pingmao
Copy link
Collaborator

  • libyang python wrapper: class sonic_yang
  • setup.py to build sonic_yang_mgmt-1.0-py2-none-any.whl
  • pytest for the libyang python class: sonic_yang

- What I did

libyang python APIs for handling Yang model schema and data trees

- How I did it
build libyang python debian packages
privode a set of python APIs to handle Yang model schema and data trees:
load yang module files

load yang data files

Yang schema tree
. get yang model object from model name or xpath etc
. get schema tree in xml, json or tree format
. print schema tree
. schema node parent xpath
. schema node xpath

Yang data tree
. load yang data file
. find data node from xpath
. get/set data node value
. add/delete data node
. merge two data trees
. find data dependencies

- How to verify it

  • build requirement:
    build libyang1.0.73 if not exist
  • install packages:
    sudo dpkg -i target/debs/stretch/libyang_1.0.73_amd64.deb
    sudo dpkg -i target/debs/stretch/libyang-cpp_1.0.73_amd64.deb
    sudo dpkg -i target/debs/stretch/python2-yang_1.0.73_amd64.deb

sudo pip install target/python-wheels/sonic_yang_mgmt-1.0-py2-none-any.whl

pytest:

  • a set of test functions to test all the APIs
  • a test data file contains all the tests to run

py tests will be run at build time and can be manually run:
$ py.test src/sonic-yang-mgmt/tests/libyang-python-tests/test_sonic_yang.py
========================================================================= test session starts ==========================================================================
platform linux2 -- Python 2.7.13, pytest-3.0.6, py-1.4.32, pluggy-0.4.0
rootdir: /sonic/src/sonic-yang-mgmt, inifile:
plugins: cov-2.4.0
collected 13 items

src/sonic-yang-mgmt/tests/libyang-python-tests/test_sonic_yang.py .............

====================================================================== 13 passed in 0.08 seconds =======================================================================

- Description for the changelog

- A picture of a cute animal (not mandatory but encouraged)

- libyang python wrapper: class sonic_yang
- setup.py to build sonic_yang_mgmt-1.0-py2-none-any.whl
- pytest for the libyang python class: sonic_yang
Copy link
Collaborator

@praveen-li praveen-li left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

..

src/sonic-yang-mgmt/sonic_yang.py Show resolved Hide resolved
src/sonic-yang-mgmt/sonic_yang.py Outdated Show resolved Hide resolved
src/sonic-yang-mgmt/sonic_yang.py Outdated Show resolved Hide resolved
src/sonic-yang-mgmt/sonic_yang.py Show resolved Hide resolved
src/sonic-yang-mgmt/sonic_yang.py Show resolved Hide resolved
src/sonic-yang-mgmt/sonic_yang.py Outdated Show resolved Hide resolved
src/sonic-yang-mgmt/sonic_yang.py Show resolved Hide resolved
src/sonic-yang-mgmt/sonic_yang.py Show resolved Hide resolved
src/sonic-yang-mgmt/sonic_yang.py Outdated Show resolved Hide resolved
src/sonic-yang-mgmt/sonic_yang.py Outdated Show resolved Hide resolved
src/sonic-yang-mgmt/sonic_yang.py Show resolved Hide resolved
- Add exceptions
- specify data_xpath and schema_xpath
- Add more test cases
1
@praveen-li praveen-li self-requested a review November 27, 2019 17:54

# important reuirements parameters
build_requirements = ['../../target/debs/stretch/libyang_1.0.73_amd64.deb',
'../../target/debs/stretch/libyang-cpp_1.0.73_amd64.deb',
'../../target/debs/stretch/python2-yang_1.0.73_amd64.deb']
'../../target/debs/stretch/libyang-cpp_1.0.73_amd64.deb',
Copy link
Owner

@zhenggen-xu zhenggen-xu Nov 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use the libyang deb package names defined in makefile? You can address this later

@zhenggen-xu zhenggen-xu merged commit 51d1830 into zhenggen-xu:sonic-cfg-mgmt Dec 2, 2019
zhenggen-xu pushed a commit that referenced this pull request Jan 10, 2020
* libyang python APIs
- libyang python wrapper: class sonic_yang
- setup.py to build sonic_yang_mgmt-1.0-py2-none-any.whl
- pytest for the libyang python class: sonic_yang

* Add python wheel package dependency on debs/stretch targets in slave.mk

* Add sonic-yang-mgmt debian package to sonic-broadcom.bin and install libyang python 2 and sonic-yang-mgmt on switch

* Python APIs for libyang
- Add exceptions
- specify data_xpath and schema_xpath
- Add more test cases

* Add error messges for libyang Python APIs
praveen-li pushed a commit to praveen-li/sonic-buildimage that referenced this pull request Feb 9, 2021
* src/sonic-platform-common b553dba...ada0fae (3):
  > Initial add of Sensor Base package file
  > [sonic_eeprom] If reading from what appears to be a corrupt cache file, delete file and read directly from EEPROM (zhenggen-xu#10)
  > [sfputilbase.py] Fix bug where 'title' list always gets overwritten with empty list (zhenggen-xu#8)
praveen-li pushed a commit to praveen-li/sonic-buildimage that referenced this pull request Feb 9, 2021
* [submodule] update sonic-linux-kernel (sonic-net#2985)
* Fix many version strings
* Update minor version
* Update arista-drivers submodule (zhenggen-xu#9)
* Rebuild SDK on new kernel (zhenggen-xu#10)
li-pingmao pushed a commit to li-pingmao/sonic-buildimage that referenced this pull request Feb 23, 2022
* [BFN] Updated platform APIs impl

Signed-off-by: Andriy Kokhan <andriyx.kokhan@intel.com>

* Extended BFN platform SFP APIs implementation

* Update sfp.py

* [BFN] Extended SFP platform plugin implementation

Signed-off-by: Andriy Kokhan <andriyx.kokhan@intel.com>

* [BFN] Extended Fans platform plugin implementation

* [BFN] divided classes Fan and  FanDrawer into 2 files

* Signed-off-by: Vadym Yashchenko <vadymx.yashchenko@intel.com>

What I did
	Add get_model() function
	Add get_low_critical_threshold() function
	Change __get(...) function.
How I did it
	Differnece from previous implementation of __get(...) function is return real value or -9999.9 if value is not provided by thrift API

* Add get_presence() function and revised __get() function

Signed-off-by: Vadym Yashchenko <vadymx.yashchenko@intel.com>

* [BFN] Updated PSU platform APIs impl

Signed-off-by: Dmytro Lytvynenko <dmytrox.lytvynenko@intel.com>

* Added BFN PSU cache (zhenggen-xu#9)

Signed-off-by: Andriy Kokhan <andriyx.kokhan@intel.com>

* [BFN]  Fans and Fantray platform APIs update (zhenggen-xu#7)

* [BFN] Updated SFP platform APIs (zhenggen-xu#10)

Signed-off-by: Volodymyr Boyko <volodymyrx.boiko@intel.com>

* [BFN] Updated platform API for thermal (zhenggen-xu#8)

* Signed-off-by: Vadym Yashchenko <vadymx.yashchenko@intel.com>

* Revert "[BFN]  Fans and Fantray platform APIs update (zhenggen-xu#7)" (zhenggen-xu#11)

This reverts commit c62a733.

* Add support health monitor system (zhenggen-xu#15)

Signed-off-by: Petro Bratash <petrox.bratash@intel.com>

* Update chassis.py

* [BFN] Updated FANs and FAN Tray platform API (zhenggen-xu#14)

* Fix fix_alignment (zhenggen-xu#17)

Signed-off-by: Petro Bratash <petrox.bratash@intel.com>

* [BFN] Improvement show environment (zhenggen-xu#16)

* Added PSU temperature skip into platform.json (zhenggen-xu#18)

Signed-off-by: Andriy Kokhan <andriyx.kokhan@intel.com>

* Do not skip psud on Newport

Signed-off-by: Andriy Kokhan <andriyx.kokhan@intel.com>

* [BFN] fix fan status from Not OK to Ok (zhenggen-xu#19)

* [BFN] Updated SFP platform plugin (zhenggen-xu#13)

Signed-off-by: Volodymyr Boyko <volodymyrx.boiko@intel.com>

* [DPB] Fix typo for Ethernet0 2x200G[100G,40G] breakout mode (zhenggen-xu#21)

Signed-off-by: Mykola Gerasymenko <mykolax.gerasymenko@intel.com>

* [barefoot] Tmp fix vendor_rev (zhenggen-xu#22)

Signed-off-by: Volodymyr Boyko <volodymyrx.boiko@intel.com>

* Fixed python issues in sonic_platform/fan_drawer.py

Signed-off-by: Andriy Kokhan <andriyx.kokhan@intel.com>

* Updated fan_drawer.py

* Fixing trailing white spaces in fan_drawer.py

* [BFN] Fix thrift for SFPs API

Signed-off-by: Volodymyr Boyko <volodymyrx.boiko@intel.com>

* In platform.json, replaced 'false' with '0' to workaround ast.literal_eval() issue

Signed-off-by: Andriy Kokhan <andriyx.kokhan@intel.com>

* [Newport] Thermal manager  (zhenggen-xu#23)

* Signed-off-by: Vadym Yashchenko <vadymx.yashchenko@intel.com>

* Revert "In platform.json, replaced 'false' with '0' to workaround ast.literal_eval() issue"

This reverts commit 1e73127.

* Removed 'controllable' options from platform.json to fix factory default config generation

Signed-off-by: Andriy Kokhan <andriyx.kokhan@intel.com>

* Update thermal_manager.py

* Migrated SFP plugin to sonic_xcvr API (zhenggen-xu#30)

Signed-off-by: Andriy Kokhan <andriyx.kokhan@intel.com>

Co-authored-by: KostiantynYarovyiBf <kostiantynx.yarovyi@intel.com>
Co-authored-by: Vadym Yashchenko <vadymx.yashchenko@intel.com>
Co-authored-by: Dmytro Lytvynenko <dmytrox.lytvynenko@intel.com>
Co-authored-by: Volodymyr Boiko <volodymyrx.boiko@intel.com>
Co-authored-by: Petro Bratash <petrox.bratash@intel.com>
Co-authored-by: Mykola Gerasymenko <mykolax.gerasymenko@intel.com>
praveen-li pushed a commit to praveen-li/sonic-buildimage that referenced this pull request Aug 9, 2022
* Upgrade new DellEMC platforms to Bullseye

* Update s5212f kernel module
praveen-li pushed a commit to praveen-li/sonic-buildimage that referenced this pull request Oct 27, 2022
#### Why I did it
Update sonic-host-services submodule to include below commits:
```
bc8698d Merge pull request zhenggen-xu#21 from abdosi/feature
557a110 Fix the issue where if dest port is not specified in ACL rule than for multi-asic where we create NAT rule to forward traffic from Namespace to host fail with exception.
6e45acc (master) Merge pull request zhenggen-xu#14 from abdosi/feature
4d6cad7 Merge remote-tracking branch 'upstream/master' into feature
bceb13e Install libyang to azure pipeline (zhenggen-xu#20)
82299f5 Merge pull request zhenggen-xu#13 from SuvarnaMeenakshi/cacl_fabricns
15d3bf4 Merge branch 'master' into cacl_fabricns
de54082 Merge pull request zhenggen-xu#16 from ZhaohuiS/feature/caclmgrd_external_client_warning_log
b4b368d Add warning log if destination port is not defined
d4bb96d Merge branch 'master' into cacl_fabricns
35c76cb Add unit-test and fix typo.
17d44c2 Made Changes to be Python 3.7 compatible
978afb5 Aligning Code
1fbf8fb Merge remote-tracking branch 'upstream/master' into feature
7b8c7d1 Added UT for the changes
91c4c42 Merge pull request zhenggen-xu#9 from ZhaohuiS/feature/caclmgrd_external_client
7c0b56a Add 4 test cases for external_client_acl, including single port and port range for ipv4 and ipv6
b71e507 Merge remote-tracking branch 'origin/master' into HEAD
d992dc0 Merge branch 'master' into feature/caclmgrd_external_client
bd7b172 DST_PORT is configuralbe in json config file for EXTERNAL_CLIENT_ACL
f9af7ae [CLI] Move hostname, mgmt interface/vrf config to hostcfgd (zhenggen-xu#2)
70ce6a3 Merge pull request zhenggen-xu#10 from sujinmkang/cold_reset
29be8d2 Added Support to render Feature Table using Device running metadata. Also added support to render 'has_asic_scope' field of Feature Table.
3437e35 [caclmgrd][chassis]: Add ip tables rules to accept internal docker traffic from fabric asic namespaces.
8720561 Fix and add hardware reboot cause determination tests
0dcc7fe remove the empty bracket if no hardware reboot cause minor
e47d831 fix the wrong expected result comparision
ef86b53 Fix startswith Attribute error
8a630bb fix mock patch
8543ddf update the reboot cause logic and update the unit test
53ad7cd fix the mock patch function
7c8003d fix the reboot-cause regix for test
1ba611f fix typo
25379d3 Add unit test case
a56133b Add hardware reboot cause as actual reboot cause for soft reboot failed
c7d3833 Support Restapi/gnmi control plane acls
f6ea036 caclmgrd: Don't block traffic to mgmt by default
a712fc4 Update test cases
adc058b caclmgrd: Don't block traffic to mgmt by default
06ff918 Merge pull request zhenggen-xu#7 from bluecmd/patch-1
e3e23bc ci: Rename sonic-buildimage repository
e83a858 Merge pull request zhenggen-xu#4 from kamelnetworks/acl-ip2me-test
f5a2e50 [caclmgrd]: Tests for IP2ME rules generation
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants