-
Notifications
You must be signed in to change notification settings - Fork 1.8k
[sonic-yang-mgmt]: sonic-yang-mgmt package for configuration validation. #3861
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
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
310bff8
[sonic-yang-mgmt]: Basic build infra for sonic-yang-mgmt package.
fbfa732
[sonic-yang-mgmt/setup.py]: Change Python tag from Py2 to Py.
de86133
[sonic_yang.py]: Dev Code for Python Config Validation Librabry.
15a471c
[libyang-python-tests]: Bring in test code for Python Library.
ae53c36
[sonic-yang-mgmt-py2.mk]: Falling back to PY2.
c46dbd5
[sonic-yang-mgmt]: Resolving LGTM.
a3a8109
[_sonic_yang_ext.py]: Stores modules irrespective of top-level-contai…
6debe61
[_sonic_yang_ext.py]: Process container and leaves in container.
7596515
[_sonic_yang_ext.py]: Test Code for Process container and leaves in c…
334e528
[sonic_yang_ext.py]: Rename _sonic_yang_ext.py as sonic_yang_ext.py.
524b5cd
[setup.py]: Add IMAGE_DISTRO_DEBS_PATH after recent master branch cha…
49c46a6
Address feedback from pull request Azure#3874.
li-pingmao fb66b2c
[libyang-python-tests/test_sonic_yang.py]: Allow extra tables in conf…
57db247
[sonic-yang-mgmt-py2.dep]: DEP files for sonic-yang-mgmt-py2 PKG
f82637a
[tests/libyang-python-tests]: Changing yang models to generic and rem…
977df0a
[sonic_yang_ext.py]: Store Tables without YANG models seperately for …
97c266e
[sonic-yang-mgmt]: Test for Store Tables without YANG models seperate…
84beafb
[sonic_yang.py]: Categories public and private functions.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
|
|
||
| SPATH := $($(SONIC_YANG_MGMT_PY)_SRC_PATH) | ||
| DEP_FILES := $(SONIC_COMMON_FILES_LIST) rules/sonic-yang-mgmt-py2.mk rules/sonic-yang-mgmt-py2.dep | ||
| DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST) | ||
| DEP_FILES += $(shell git ls-files $(SPATH)) | ||
|
|
||
| $(SONIC_YANG_MGMT_PY)_CACHE_MODE := GIT_CONTENT_SHA | ||
| $(SONIC_YANG_MGMT_PY)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST) | ||
| $(SONIC_YANG_MGMT_PY)_DEP_FILES := $(DEP_FILES) | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # sonic-yang-mgmt python2 wheel | ||
|
|
||
| SONIC_YANG_MGMT_PY = sonic_yang_mgmt-1.0-py2-none-any.whl | ||
| $(SONIC_YANG_MGMT_PY)_SRC_PATH = $(SRC_PATH)/sonic-yang-mgmt | ||
| $(SONIC_YANG_MGMT_PY)_PYTHON_VERSION = 2 | ||
| $(SONIC_YANG_MGMT_PY)_DEBS_DEPENDS = $(LIBYANG) | ||
| $(SONIC_YANG_MGMT_PY)_DEPENDS = $(SONIC_YANG_MODELS_PY3) | ||
|
|
||
| SONIC_PYTHON_WHEELS += $(SONIC_YANG_MGMT_PY) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| ======= | ||
| Credits | ||
| ======= | ||
|
|
||
| Development Lead | ||
| ---------------- | ||
|
|
||
| LNOS-CODERS <lnos-coders@linkedin.com> | ||
| MSFT-LINUX-DEV <linuxnetdev@microsoft.com> | ||
|
|
||
| Contributors | ||
| ------------ | ||
|
|
||
| Praveen Chaudhary <pchaudhary@linkedin.com> | ||
| Ping Mao <pmao@linkedin.com> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| Copyright 2019 Microsoft, Inc | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| " | ||
| This package includes python yang libraries which will be used with sonic utilities | ||
| pacakge to validate the config. This python libraries are written on top of libyang | ||
| and also provides functionality to translate the config from SONiC ConfigDB to SONiC | ||
| YANG and vice-versa. | ||
| " |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| #!/usr/bin/env python | ||
praveen-li marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| # -*- coding: utf-8 -*- | ||
|
|
||
| """The setup script.""" | ||
|
|
||
| from setuptools import setup, find_packages | ||
| from setuptools.command.build_py import build_py | ||
| from os import system, environ | ||
| from sys import exit | ||
| import pytest | ||
|
|
||
| # find path of pkgs from os environment vars | ||
| prefix = '../../'; debs = environ["IMAGE_DISTRO_DEBS_PATH"] | ||
| wheels = environ["PYTHON_WHEELS_PATH"] | ||
| wheels_path = '{}/{}'.format(prefix, wheels) | ||
| deps_path = '{}/{}'.format(prefix, debs) | ||
| # dependencies | ||
| libyang = '{}/{}'.format(deps_path, environ["LIBYANG"]) | ||
praveen-li marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| libyangCpp = '{}/{}'.format(deps_path, environ["LIBYANG_CPP"]) | ||
| libyangPy2 = '{}/{}'.format(deps_path, environ["LIBYANG_PY2"]) | ||
| libyangPy3 = '{}/{}'.format(deps_path, environ["LIBYANG_PY3"]) | ||
| sonicYangModels = '{}/{}'.format(wheels_path, environ["SONIC_YANG_MODELS_PY3"]) | ||
|
|
||
| # important reuirements parameters | ||
| build_requirements = [libyang, libyangCpp, libyangPy2, libyangPy3, sonicYangModels,] | ||
|
|
||
| setup_requirements = ['pytest-runner'] | ||
|
|
||
| test_requirements = ['pytest>=3'] | ||
|
|
||
| # read me | ||
| with open('README.rst') as readme_file: | ||
| readme = readme_file.read() | ||
|
|
||
| # class for prerequisites to build this package | ||
| class pkgBuild(build_py): | ||
| """Custom Build PLY""" | ||
|
|
||
| def run (self): | ||
praveen-li marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| # install libyang and sonic_yang_models | ||
| for req in build_requirements: | ||
| if '.deb' in req: | ||
| pkg_install_cmd = "sudo dpkg -i {}".format(req) | ||
| if (system(pkg_install_cmd)): | ||
| print("{} installation failed".format(req)) | ||
| exit(1) | ||
| else: | ||
| print("{} installed".format(req)) | ||
| elif '.whl' in req: | ||
| pkg_install_cmd = "pip3 install {}".format(req) | ||
| if (system(pkg_install_cmd)): | ||
| print("{} installation failed".format(req)) | ||
| exit(1) | ||
| else: | ||
| print("{} installed".format(req)) | ||
|
|
||
praveen-li marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| # run pytest for libyang python APIs | ||
| self.pytest_args = [] | ||
| errno = pytest.main(self.pytest_args) | ||
| if (errno): | ||
| exit(errno) | ||
|
|
||
| # Continue usual build steps | ||
| build_py.run(self) | ||
|
|
||
| setup( | ||
| cmdclass={ | ||
| 'build_py': pkgBuild, | ||
| }, | ||
| author="lnos-coders", | ||
| author_email='lnos-coders@linkedin.com', | ||
| python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*', | ||
| classifiers=[ | ||
| 'Development Status :: 2 - Pre-Alpha', | ||
| 'Intended Audience :: Developers', | ||
| 'License :: OSI Approved :: GNU General Public License v3 (GPLv3)', | ||
| 'Natural Language :: English', | ||
| "Programming Language :: Python :: 2", | ||
| 'Programming Language :: Python :: 2.7', | ||
| 'Programming Language :: Python :: 3', | ||
| 'Programming Language :: Python :: 3.5', | ||
| 'Programming Language :: Python :: 3.6', | ||
| 'Programming Language :: Python :: 3.7', | ||
| 'Programming Language :: Python :: 3.8', | ||
| ], | ||
| description="Package contains Python Library for YANG for sonic.", | ||
| tests_require = test_requirements, | ||
| license="GNU General Public License v3", | ||
| long_description=readme + '\n\n', | ||
| include_package_data=True, | ||
| keywords='sonic_yang_mgmt', | ||
| name='sonic_yang_mgmt', | ||
| py_modules=['sonic_yang', 'sonic_yang_ext'], | ||
| packages=find_packages(), | ||
| setup_requires=setup_requirements, | ||
| version='1.0', | ||
| zip_safe=False, | ||
| ) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.